1
0
mirror of https://github.com/payden/libwsclient synced 2025-06-13 12:53:52 +00:00
payden_libwsclient/api/parsec.rs

26 lines
661 B
Rust
Raw Normal View History

2025-05-16 06:09:24 +00:00
pub struct ParsecApi {
pub api_key: String,
pub api_url: String,
}
impl ParsecApi {
pub fn new(api_key: String, api_url: String) -> Self {
ParsecApi {
api_key,
api_url,
}
}
pub async fn get_token_prices(&self) -> Result<HashMap<String, f64>, reqwest::Error> {
let url = format!("{}/prices", self.api_url);
let client = reqwest::Client::new();
let response = client
.get(&url)
.header("Authorization", &self.api_key)
.send()
.await?;
let prices: HashMap<String, f64> = response.json().await?;
Ok(prices)
}
}