diff --git a/src/trello/client.rs b/src/trello/client.rs index 34a4984..bbe4ecc 100644 --- a/src/trello/client.rs +++ b/src/trello/client.rs @@ -35,19 +35,14 @@ impl<'ctx> TrelloClient<'ctx> { let api_secret = &self.ctx.cfg.trello.api_secret; HashMap::from([( s!("Authorization"), - f!(r#"OAuth oauth_consumer_key="{api_key}", oauth_token="{api_secret}""#,), + f!(r#"OAuth oauth_consumer_key="{api_key}", oauth_token="{api_secret}""#), )]) } + fn common_headers(&self) -> HashMap { - let api_key = &self.ctx.cfg.trello.api_key; - let api_secret = &self.ctx.cfg.trello.api_secret; HashMap::from([ - (s!("accept"), s!("application/json")), (s!("content-type"), s!("application/json")), - ( - s!("Authorization"), - f!(r#"OAuth oauth_consumer_key="{api_key}", oauth_token="{api_secret}""#,), - ), + (s!("accept"), s!("application/json")), ]) } @@ -61,6 +56,7 @@ impl<'ctx> TrelloClient<'ctx> { with_exponential_backoff!( &self.ctx, custom(&self.ctx.net, self.url(url.clone())) + .headers(self.auth_headers()) .headers(self.common_headers()) .send() .await @@ -90,6 +86,7 @@ impl<'ctx> TrelloClient<'ctx> { .net .get(url.clone()) .headers(self.auth_headers()) + .header("content-type", "application/json") .header("accept", "application/octet") .send() .await @@ -123,14 +120,18 @@ impl<'ctx> TrelloClient<'ctx> { impl<'ctx> TrelloClient<'ctx> { // https://developer.atlassian.com/cloud/trello/rest/api-group-members/#api-members-id-boards-get pub(crate) async fn boards(&self) -> APIResult> { - self.request("/members/me/boards?lists=open", |net, url| net.get(url)) - .await + self.request("/members/me/boards", |net, url| { + net.get(url).query("lists", "open") + }) + .await } // https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-get pub(crate) async fn board(&self, board_id: &TrelloBoardId) -> APIResult { - self.request(f!("/boards/{board_id}?lists=open"), |net, url| net.get(url)) - .await + self.request(f!("/boards/{board_id}"), |net, url| { + net.get(url).query("lists", "open") + }) + .await } // https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-cards-get