@@ -10,6 +10,7 @@ use walkdir::WalkDir;
1010
1111use std:: io;
1212use std:: sync:: LazyLock ;
13+
1314pub struct ZenodoClient {
1415 http_client : reqwest:: Client ,
1516 base_url : Url ,
@@ -38,15 +39,15 @@ pub enum Error {
3839impl ZenodoClient {
3940 pub fn new ( token : String ) -> ZenodoClient {
4041 let http_client = reqwest:: Client :: new ( ) ;
41- return ZenodoClient {
42+ ZenodoClient {
4243 http_client,
4344 base_url : BASE_URL . clone ( ) ,
4445 token,
45- } ;
46+ }
4647 }
4748
4849 fn make_url ( & self , path : & str ) -> Result < Url , Error > {
49- return self . base_url . join ( path) . context ( UrlParseSnafu ) ;
50+ self . base_url . join ( path) . context ( UrlParseSnafu )
5051 }
5152
5253 pub async fn get_deposition < R : DeserializeOwned > (
@@ -57,11 +58,12 @@ impl ZenodoClient {
5758 let res = self
5859 . http_client
5960 . get ( endpoint)
61+ . bearer_auth ( & self . token )
6062 . send ( )
6163 . await
6264 . context ( ReqwestSnafu ) ?;
6365 // res.error_for_status().context(ReqwestSnafu)?;
64- return res. json :: < R > ( ) . await . context ( DeserializeRespSnafu ) ;
66+ res. json :: < R > ( ) . await . context ( DeserializeRespSnafu )
6567 }
6668
6769 pub async fn upload_files ( & self , deposition_id : & str , source_path : & Path ) -> Result < ( ) , Error > {
@@ -77,11 +79,11 @@ impl ZenodoClient {
7779 let res = self
7880 . http_client
7981 . get ( endpoint)
82+ . bearer_auth ( & self . token )
8083 . send ( )
8184 . await
8285 . context ( ReqwestSnafu ) ?;
83- // res.error_for_status().context(ReqwestSnafu)?;
84- return res. json :: < R > ( ) . await . context ( DeserializeRespSnafu ) ;
86+ res. json :: < R > ( ) . await . context ( DeserializeRespSnafu )
8587 }
8688
8789 async fn upload_file < R : DeserializeOwned > (
@@ -114,11 +116,11 @@ impl ZenodoClient {
114116 let res = self
115117 . http_client
116118 . post ( endpoint)
119+ . bearer_auth ( & self . token )
117120 . multipart ( form)
118121 . send ( )
119122 . await
120123 . context ( ReqwestSnafu ) ?;
121- // res.error_for_status().context(ReqwestSnafu)?;
122- return res. json :: < R > ( ) . await . context ( DeserializeRespSnafu ) ;
124+ res. json :: < R > ( ) . await . context ( DeserializeRespSnafu )
123125 }
124126}
0 commit comments