use super::responses::orderbooks::BinanceDepthSnapshot;
#[derive(Clone)]
pub struct BinanceRestClient {
base_url: String,
http: reqwest::Client,
}
impl BinanceRestClient {
pub fn new(base_url: impl Into<String>) -> Self {
Self {
base_url: base_url.into(),
http: reqwest::Client::new(),
}
}
pub async fn fetch_depth(
&self,
symbol: &str,
limit: u32,
) -> anyhow::Result<BinanceDepthSnapshot> {
let url = format!(
"{}/api/v3/depth?symbol={}&limit={}",
self.base_url, symbol, limit,
);
let resp = self.http.get(&url).send().await?.error_for_status()?;
let snapshot: BinanceDepthSnapshot = resp.json().await?;
Ok(snapshot)
}
}