refactor: nextcloud client: request takes Bytes
Some checks failed
Test / build (map[name:nightly]) (push) Successful in 4m22s
Test / build (map[name:stable]) (push) Successful in 4m34s
Release Please / Release-plz (push) Failing after 31s

This commit is contained in:
Paul Campbell 2024-12-23 09:44:02 +00:00
parent ea73db714c
commit ee7c0f230c

View file

@ -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