Skip to content

Commit a1dd5ab

Browse files
committed
Revert "Rename get_latest_prices() to get_prices()"
This reverts commit 72f42b3.
1 parent 72f42b3 commit a1dd5ab

3 files changed

Lines changed: 6 additions & 72 deletions

File tree

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ mod tls;
66

77
pub use client::{SpiceClient as Client};
88
pub use flight::{SqlFlightClient};
9-
pub use client::new_spice_client;
109

1110
// Further public exports and integrations

src/prices.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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));

tests/price_test.rs

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)