Skip to content

Commit b59caa6

Browse files
committed
Allow optional timestamp when getting historical price
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
1 parent a98d36f commit b59caa6

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/client.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,18 @@ impl MempoolClient {
139139
pub async fn historical_price(
140140
&self,
141141
currency: Currency,
142-
timestamp: u64,
142+
timestamp: Option<u64>,
143143
) -> Result<HistoricalPrice, Error> {
144144
let mut url: Url = self.url.join("/api/v1/historical-price")?;
145145

146-
// Set query string
147-
let query: String = format!("currency={}&timestamp={timestamp}", currency.as_str());
146+
let mut query: String = format!("currency={}", currency.as_str());
147+
148+
if let Some(timestamp) = timestamp {
149+
query.push_str(&format!("&timestamp={timestamp}"));
150+
}
151+
148152
url.set_query(Some(&query));
149153

150-
// Get response
151154
self.get_response(url).await
152155
}
153156

0 commit comments

Comments
 (0)