refactor: trello client: clean up headers
Some checks failed
Test / build (map[name:nightly]) (push) Successful in 3m42s
Test / build (map[name:stable]) (push) Successful in 4m18s
Release Please / Release-plz (push) Failing after 43s

This commit is contained in:
Paul Campbell 2024-12-23 09:44:02 +00:00
parent 090e4a4345
commit 022bb697fb

View file

@ -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<String, String> {
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<Vec<TrelloBoard>> {
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<TrelloBoard> {
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