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