From ee7c0f230c9d8c6c0a9c248d6cba92a06c281b66 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 23 Dec 2024 09:44:02 +0000 Subject: [PATCH] refactor: nextcloud client: request takes Bytes --- src/nextcloud/client.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/nextcloud/client.rs b/src/nextcloud/client.rs index eca89a9..479e579 100644 --- a/src/nextcloud/client.rs +++ b/src/nextcloud/client.rs @@ -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 serde::Deserialize<'a>>( &self, url: impl Into, - body: impl Into, + body: Value, custom: fn(&Net, String) -> ReqBuilder, ) -> APIResult { 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