refactor: nextcloud client: request takes Bytes
This commit is contained in:
parent
ea73db714c
commit
ee7c0f230c
1 changed files with 8 additions and 10 deletions
|
@ -5,7 +5,7 @@ use kxio::{
|
|||
net::{Net, ReqBuilder},
|
||||
};
|
||||
use reqwest::multipart;
|
||||
use serde_json::json;
|
||||
use serde_json::{json, Value};
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::nextcloud::model::NextcloudOrder;
|
||||
|
@ -74,11 +74,12 @@ impl<'ctx> DeckClient<'ctx> {
|
|||
async fn request_with_body<T: for<'a> serde::Deserialize<'a>>(
|
||||
&self,
|
||||
url: impl Into<String>,
|
||||
body: impl Into<Bytes>,
|
||||
body: Value,
|
||||
custom: fn(&Net, String) -> ReqBuilder,
|
||||
) -> APIResult<T> {
|
||||
let url = self.url(url.into());
|
||||
let body = body.into();
|
||||
tracing::trace!(?url, %body);
|
||||
let body: Bytes = body.to_string().into();
|
||||
APIResult::new(
|
||||
with_exponential_backoff!(
|
||||
&self.ctx,
|
||||
|
@ -136,8 +137,7 @@ impl<'ctx> DeckClient<'ctx> {
|
|||
json!({
|
||||
"title": stack_title,
|
||||
"order": stack_order,
|
||||
})
|
||||
.to_string(),
|
||||
}),
|
||||
|net, url| net.post(url),
|
||||
)
|
||||
.await
|
||||
|
@ -161,7 +161,7 @@ impl<'ctx> DeckClient<'ctx> {
|
|||
|
||||
self.request_with_body(
|
||||
f!("boards/{board_id}/stacks/{stack_id}/cards"),
|
||||
body.to_string(),
|
||||
body,
|
||||
|net, url| net.post(url),
|
||||
)
|
||||
.await
|
||||
|
@ -179,8 +179,7 @@ impl<'ctx> DeckClient<'ctx> {
|
|||
json!({
|
||||
"title": name,
|
||||
"color": colour,
|
||||
})
|
||||
.to_string(),
|
||||
}),
|
||||
|net, url| net.post(url),
|
||||
)
|
||||
.await
|
||||
|
@ -212,8 +211,7 @@ impl<'ctx> DeckClient<'ctx> {
|
|||
f!("boards/{board_id}/stacks/{stack_id}/cards/{card_id}/assignLabel"),
|
||||
json!({
|
||||
"labelId": label_id
|
||||
})
|
||||
.to_string(),
|
||||
}),
|
||||
|net, url| net.put(url),
|
||||
)
|
||||
.await
|
||||
|
|
Loading…
Reference in a new issue