@@ -117,13 +117,10 @@ impl PricesClient {
117117 Ok ( response)
118118 }
119119
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 ?;
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 ?;
127124 match resp. status ( ) {
128125 reqwest:: StatusCode :: OK => {
129126 let response: LatestPricesResponse = resp. json ( ) . await ?;
@@ -133,7 +130,7 @@ impl PricesClient {
133130 reqwest:: StatusCode :: TOO_MANY_REQUESTS => Err ( Box :: new ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , "Rate limit exceeded, slow down" ) ) ) ,
134131 reqwest:: StatusCode :: INTERNAL_SERVER_ERROR => Err ( Box :: new ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , "Internal server error" ) ) ) ,
135132 _ => Err ( Box :: new ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , format ! ( "Unexpected response status: {}" , resp. status( ) ) ) ) ) ,
136- }
133+ }
137134 }
138135
139136 pub async fn get_historical_prices (
@@ -143,7 +140,7 @@ impl PricesClient {
143140 end : Option < i64 > ,
144141 granularity : Option < & str >
145142 ) -> Result < HashMap < String , Vec < HistoricalPriceData > > , Box < dyn Error > > {
146- let mut url = format ! ( "{}/v1/prices/historical?pairs ={}" , self . base_url, pairs. join( "," ) ) ;
143+ let mut url = format ! ( "{}/v1/prices?pair ={}" , self . base_url, pairs. join( "," ) ) ;
147144
148145 if let Some ( start_time) = start {
149146 url. push_str ( & format ! ( "&start={}" , start_time) ) ;
0 commit comments