@@ -117,10 +117,13 @@ impl PricesClient {
117117 Ok ( response)
118118 }
119119
120- pub async fn get_latest_prices ( & self , pairs : & [ & str ] ) -> Result < LatestPricesResponse , Box < dyn Error > > {
121- let url = format ! ( "{}/v1/prices/latest?pair={}" , self . base_url, pairs. join( "," ) ) ;
122- let request = self . client . get ( & url) ;
123- let resp = self . add_headers ( request) . send ( ) . await ?;
120+ pub async fn get_prices (
121+ & self ,
122+ pair : & str ,
123+ ) -> Result < LatestPricesResponse , Box < dyn Error > > {
124+ let mut url = format ! ( "{}/v1/prices?pairs={}" , self . base_url, pair) ;
125+
126+ let resp = self . add_headers ( self . client . get ( & url) ) . send ( ) . await ?;
124127 match resp. status ( ) {
125128 reqwest:: StatusCode :: OK => {
126129 let response: LatestPricesResponse = resp. json ( ) . await ?;
@@ -130,7 +133,7 @@ impl PricesClient {
130133 reqwest:: StatusCode :: TOO_MANY_REQUESTS => Err ( Box :: new ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , "Rate limit exceeded, slow down" ) ) ) ,
131134 reqwest:: StatusCode :: INTERNAL_SERVER_ERROR => Err ( Box :: new ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , "Internal server error" ) ) ) ,
132135 _ => Err ( Box :: new ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , format ! ( "Unexpected response status: {}" , resp. status( ) ) ) ) ) ,
133- }
136+ }
134137 }
135138
136139 pub async fn get_historical_prices (
@@ -140,7 +143,7 @@ impl PricesClient {
140143 end : Option < i64 > ,
141144 granularity : Option < & str >
142145 ) -> Result < HashMap < String , Vec < HistoricalPriceData > > , Box < dyn Error > > {
143- let mut url = format ! ( "{}/v1/prices?pair ={}" , self . base_url, pairs. join( "," ) ) ;
146+ let mut url = format ! ( "{}/v1/prices/historical?pairs ={}" , self . base_url, pairs. join( "," ) ) ;
144147
145148 if let Some ( start_time) = start {
146149 url. push_str ( & format ! ( "&start={}" , start_time) ) ;
0 commit comments