polyoxide_data/api/
open_interest.rs1use polyoxide_core::{HttpClient, QueryBuilder, Request};
2
3use crate::{error::DataApiError, types::OpenInterest};
4
5#[derive(Clone)]
7pub struct OpenInterestApi {
8 pub(crate) http_client: HttpClient,
9}
10
11impl OpenInterestApi {
12 pub fn get(&self) -> GetOpenInterest {
14 GetOpenInterest {
15 request: Request::new(self.http_client.clone(), "/oi"),
16 }
17 }
18}
19
20pub struct GetOpenInterest {
22 request: Request<Vec<OpenInterest>, DataApiError>,
23}
24
25impl GetOpenInterest {
26 pub fn market(mut self, condition_ids: impl IntoIterator<Item = impl ToString>) -> Self {
28 let ids: Vec<String> = condition_ids.into_iter().map(|s| s.to_string()).collect();
29 if !ids.is_empty() {
30 self.request = self.request.query("market", ids.join(","));
31 }
32 self
33 }
34
35 pub async fn send(self) -> Result<Vec<OpenInterest>, DataApiError> {
37 self.request.send().await
38 }
39}