noah_sdk/api/
balances.rs

1//! Balances API
2
3use crate::client::NoahClient;
4use crate::error::Result;
5use crate::models::balances::GetBalancesResponse;
6
7impl NoahClient {
8    /// Get balances (async)
9    #[cfg(feature = "async")]
10    pub async fn get_balances(
11        &self,
12        page_size: Option<u32>,
13        page_token: Option<&str>,
14    ) -> Result<GetBalancesResponse> {
15        let mut path = "/balances".to_string();
16        let mut query_params = Vec::new();
17
18        if let Some(size) = page_size {
19            query_params.push(format!("PageSize={size}"));
20        }
21        if let Some(token) = page_token {
22            query_params.push(format!("PageToken={token}"));
23        }
24
25        if !query_params.is_empty() {
26            path.push('?');
27            path.push_str(&query_params.join("&"));
28        }
29
30        self.get(&path).await
31    }
32
33    /// Get balances (blocking)
34    #[cfg(feature = "sync")]
35    pub fn get_balances_blocking(
36        &self,
37        page_size: Option<u32>,
38        page_token: Option<&str>,
39    ) -> Result<GetBalancesResponse> {
40        let mut path = "/balances".to_string();
41        let mut query_params = Vec::new();
42
43        if let Some(size) = page_size {
44            query_params.push(format!("PageSize={size}"));
45        }
46        if let Some(token) = page_token {
47            query_params.push(format!("PageToken={token}"));
48        }
49
50        if !query_params.is_empty() {
51            path.push('?');
52            path.push_str(&query_params.join("&"));
53        }
54
55        self.get_blocking(&path)
56    }
57}