binance/wallet/apis/
account_api.rs

1/*
2 * Binance Wallet API
3 *
4 * OpenAPI specification for Binance exchange - Wallet API
5 *
6 * The version of the OpenAPI document: 0.1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::wallet::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`wallet_create_account_disable_fast_withdraw_switch_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct WalletCreateAccountDisableFastWithdrawSwitchV1Params {
20    pub timestamp: i64,
21    pub recv_window: Option<i64>
22}
23
24/// struct for passing parameters to the method [`wallet_create_account_enable_fast_withdraw_switch_v1`]
25#[derive(Clone, Debug, Default)]
26pub struct WalletCreateAccountEnableFastWithdrawSwitchV1Params {
27    pub timestamp: i64,
28    pub recv_window: Option<i64>
29}
30
31/// struct for passing parameters to the method [`wallet_get_account_api_restrictions_v1`]
32#[derive(Clone, Debug, Default)]
33pub struct WalletGetAccountApiRestrictionsV1Params {
34    pub timestamp: i64,
35    pub recv_window: Option<i64>
36}
37
38/// struct for passing parameters to the method [`wallet_get_account_api_trading_status_v1`]
39#[derive(Clone, Debug, Default)]
40pub struct WalletGetAccountApiTradingStatusV1Params {
41    pub timestamp: i64,
42    pub recv_window: Option<i64>
43}
44
45/// struct for passing parameters to the method [`wallet_get_account_info_v1`]
46#[derive(Clone, Debug, Default)]
47pub struct WalletGetAccountInfoV1Params {
48    pub timestamp: i64,
49    pub recv_window: Option<i64>
50}
51
52/// struct for passing parameters to the method [`wallet_get_account_snapshot_v1`]
53#[derive(Clone, Debug, Default)]
54pub struct WalletGetAccountSnapshotV1Params {
55    /// &#34;SPOT&#34;, &#34;MARGIN&#34;, &#34;FUTURES&#34;
56    pub r#type: String,
57    pub timestamp: i64,
58    pub start_time: Option<i64>,
59    pub end_time: Option<i64>,
60    /// min 7, max 30, default 7
61    pub limit: Option<i32>,
62    pub recv_window: Option<i64>
63}
64
65/// struct for passing parameters to the method [`wallet_get_account_status_v1`]
66#[derive(Clone, Debug, Default)]
67pub struct WalletGetAccountStatusV1Params {
68    pub timestamp: i64,
69    pub recv_window: Option<i64>
70}
71
72
73/// struct for typed errors of method [`wallet_create_account_disable_fast_withdraw_switch_v1`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum WalletCreateAccountDisableFastWithdrawSwitchV1Error {
77    Status4XX(models::ApiError),
78    Status5XX(models::ApiError),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`wallet_create_account_enable_fast_withdraw_switch_v1`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum WalletCreateAccountEnableFastWithdrawSwitchV1Error {
86    Status4XX(models::ApiError),
87    Status5XX(models::ApiError),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`wallet_get_account_api_restrictions_v1`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum WalletGetAccountApiRestrictionsV1Error {
95    Status4XX(models::ApiError),
96    Status5XX(models::ApiError),
97    UnknownValue(serde_json::Value),
98}
99
100/// struct for typed errors of method [`wallet_get_account_api_trading_status_v1`]
101#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum WalletGetAccountApiTradingStatusV1Error {
104    Status4XX(models::ApiError),
105    Status5XX(models::ApiError),
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`wallet_get_account_info_v1`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum WalletGetAccountInfoV1Error {
113    Status4XX(models::ApiError),
114    Status5XX(models::ApiError),
115    UnknownValue(serde_json::Value),
116}
117
118/// struct for typed errors of method [`wallet_get_account_snapshot_v1`]
119#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum WalletGetAccountSnapshotV1Error {
122    Status4XX(models::ApiError),
123    Status5XX(models::ApiError),
124    UnknownValue(serde_json::Value),
125}
126
127/// struct for typed errors of method [`wallet_get_account_status_v1`]
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum WalletGetAccountStatusV1Error {
131    Status4XX(models::ApiError),
132    Status5XX(models::ApiError),
133    UnknownValue(serde_json::Value),
134}
135
136
137pub async fn wallet_create_account_disable_fast_withdraw_switch_v1(configuration: &configuration::Configuration, params: WalletCreateAccountDisableFastWithdrawSwitchV1Params) -> Result<serde_json::Value, Error<WalletCreateAccountDisableFastWithdrawSwitchV1Error>> {
138
139    let uri_str = format!("{}/sapi/v1/account/disableFastWithdrawSwitch", configuration.base_path);
140    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
141
142    // Create a mutable vector for query parameters
143    let mut query_params: Vec<(String, String)> = Vec::new();
144
145
146    // Create header parameters collection
147    let mut header_params = std::collections::HashMap::new();
148
149    // Handle Binance Auth first if configured
150    if let Some(ref binance_auth) = configuration.binance_auth {
151        // Add API key to headers
152        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
153        
154        // Generate request body for signing (if any)
155        let body_string: Option<Vec<u8>> = None;
156        
157        // Sign the request
158        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
159            Ok(sig) => sig,
160            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
161        };
162        
163        // Add signature to query params
164        query_params.push(("signature".to_string(), signature));
165    }
166
167    // Apply all query parameters
168    if !query_params.is_empty() {
169        req_builder = req_builder.query(&query_params);
170    }
171
172
173    // Add user agent if configured
174    if let Some(ref user_agent) = configuration.user_agent {
175        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
176    }
177
178    // Apply all header parameters
179    for (header_name, header_value) in header_params {
180        req_builder = req_builder.header(&header_name, &header_value);
181    }
182
183    let mut multipart_form_params = std::collections::HashMap::new();
184    if let Some(param_value) = params.recv_window {
185        multipart_form_params.insert("recvWindow", param_value.to_string());
186    }
187    multipart_form_params.insert("timestamp", params.timestamp.to_string());
188    req_builder = req_builder.form(&multipart_form_params);
189
190    let req = req_builder.build()?;
191    let resp = configuration.client.execute(req).await?;
192
193    let status = resp.status();
194    let content_type = resp
195        .headers()
196        .get("content-type")
197        .and_then(|v| v.to_str().ok())
198        .unwrap_or("application/octet-stream");
199    let content_type = super::ContentType::from(content_type);
200
201    if !status.is_client_error() && !status.is_server_error() {
202        let content = resp.text().await?;
203        match content_type {
204            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
205            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
206            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
207        }
208    } else {
209        let content = resp.text().await?;
210        let entity: Option<WalletCreateAccountDisableFastWithdrawSwitchV1Error> = serde_json::from_str(&content).ok();
211        Err(Error::ResponseError(ResponseContent { status, content, entity }))
212    }
213}
214
215/// Enable Fast Withdraw Switch (USER_DATA)
216pub async fn wallet_create_account_enable_fast_withdraw_switch_v1(configuration: &configuration::Configuration, params: WalletCreateAccountEnableFastWithdrawSwitchV1Params) -> Result<serde_json::Value, Error<WalletCreateAccountEnableFastWithdrawSwitchV1Error>> {
217
218    let uri_str = format!("{}/sapi/v1/account/enableFastWithdrawSwitch", configuration.base_path);
219    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
220
221    // Create a mutable vector for query parameters
222    let mut query_params: Vec<(String, String)> = Vec::new();
223
224
225    // Create header parameters collection
226    let mut header_params = std::collections::HashMap::new();
227
228    // Handle Binance Auth first if configured
229    if let Some(ref binance_auth) = configuration.binance_auth {
230        // Add API key to headers
231        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
232        
233        // Generate request body for signing (if any)
234        let body_string: Option<Vec<u8>> = None;
235        
236        // Sign the request
237        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
238            Ok(sig) => sig,
239            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
240        };
241        
242        // Add signature to query params
243        query_params.push(("signature".to_string(), signature));
244    }
245
246    // Apply all query parameters
247    if !query_params.is_empty() {
248        req_builder = req_builder.query(&query_params);
249    }
250
251
252    // Add user agent if configured
253    if let Some(ref user_agent) = configuration.user_agent {
254        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255    }
256
257    // Apply all header parameters
258    for (header_name, header_value) in header_params {
259        req_builder = req_builder.header(&header_name, &header_value);
260    }
261
262    let mut multipart_form_params = std::collections::HashMap::new();
263    if let Some(param_value) = params.recv_window {
264        multipart_form_params.insert("recvWindow", param_value.to_string());
265    }
266    multipart_form_params.insert("timestamp", params.timestamp.to_string());
267    req_builder = req_builder.form(&multipart_form_params);
268
269    let req = req_builder.build()?;
270    let resp = configuration.client.execute(req).await?;
271
272    let status = resp.status();
273    let content_type = resp
274        .headers()
275        .get("content-type")
276        .and_then(|v| v.to_str().ok())
277        .unwrap_or("application/octet-stream");
278    let content_type = super::ContentType::from(content_type);
279
280    if !status.is_client_error() && !status.is_server_error() {
281        let content = resp.text().await?;
282        match content_type {
283            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
284            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
285            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
286        }
287    } else {
288        let content = resp.text().await?;
289        let entity: Option<WalletCreateAccountEnableFastWithdrawSwitchV1Error> = serde_json::from_str(&content).ok();
290        Err(Error::ResponseError(ResponseContent { status, content, entity }))
291    }
292}
293
294/// Get API Key Permission
295pub async fn wallet_get_account_api_restrictions_v1(configuration: &configuration::Configuration, params: WalletGetAccountApiRestrictionsV1Params) -> Result<models::WalletGetAccountApiRestrictionsV1Resp, Error<WalletGetAccountApiRestrictionsV1Error>> {
296
297    let uri_str = format!("{}/sapi/v1/account/apiRestrictions", configuration.base_path);
298    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
299
300    // Create a mutable vector for query parameters
301    let mut query_params: Vec<(String, String)> = Vec::new();
302
303    if let Some(ref param_value) = params.recv_window {
304        query_params.push(("recvWindow".to_string(), param_value.to_string()));
305    }
306    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
307
308    // Create header parameters collection
309    let mut header_params = std::collections::HashMap::new();
310
311    // Handle Binance Auth first if configured
312    if let Some(ref binance_auth) = configuration.binance_auth {
313        // Add API key to headers
314        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
315        
316        // Generate request body for signing (if any)
317        let body_string: Option<Vec<u8>> = None;
318        
319        // Sign the request
320        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
321            Ok(sig) => sig,
322            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
323        };
324        
325        // Add signature to query params
326        query_params.push(("signature".to_string(), signature));
327    }
328
329    // Apply all query parameters
330    if !query_params.is_empty() {
331        req_builder = req_builder.query(&query_params);
332    }
333
334
335    // Add user agent if configured
336    if let Some(ref user_agent) = configuration.user_agent {
337        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
338    }
339
340    // Apply all header parameters
341    for (header_name, header_value) in header_params {
342        req_builder = req_builder.header(&header_name, &header_value);
343    }
344
345
346    let req = req_builder.build()?;
347    let resp = configuration.client.execute(req).await?;
348
349    let status = resp.status();
350    let content_type = resp
351        .headers()
352        .get("content-type")
353        .and_then(|v| v.to_str().ok())
354        .unwrap_or("application/octet-stream");
355    let content_type = super::ContentType::from(content_type);
356
357    if !status.is_client_error() && !status.is_server_error() {
358        let content = resp.text().await?;
359        match content_type {
360            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
361            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountApiRestrictionsV1Resp`"))),
362            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WalletGetAccountApiRestrictionsV1Resp`")))),
363        }
364    } else {
365        let content = resp.text().await?;
366        let entity: Option<WalletGetAccountApiRestrictionsV1Error> = serde_json::from_str(&content).ok();
367        Err(Error::ResponseError(ResponseContent { status, content, entity }))
368    }
369}
370
371/// Fetch account api trading status detail.
372pub async fn wallet_get_account_api_trading_status_v1(configuration: &configuration::Configuration, params: WalletGetAccountApiTradingStatusV1Params) -> Result<models::WalletGetAccountApiTradingStatusV1Resp, Error<WalletGetAccountApiTradingStatusV1Error>> {
373
374    let uri_str = format!("{}/sapi/v1/account/apiTradingStatus", configuration.base_path);
375    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
376
377    // Create a mutable vector for query parameters
378    let mut query_params: Vec<(String, String)> = Vec::new();
379
380    if let Some(ref param_value) = params.recv_window {
381        query_params.push(("recvWindow".to_string(), param_value.to_string()));
382    }
383    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
384
385    // Create header parameters collection
386    let mut header_params = std::collections::HashMap::new();
387
388    // Handle Binance Auth first if configured
389    if let Some(ref binance_auth) = configuration.binance_auth {
390        // Add API key to headers
391        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
392        
393        // Generate request body for signing (if any)
394        let body_string: Option<Vec<u8>> = None;
395        
396        // Sign the request
397        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
398            Ok(sig) => sig,
399            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
400        };
401        
402        // Add signature to query params
403        query_params.push(("signature".to_string(), signature));
404    }
405
406    // Apply all query parameters
407    if !query_params.is_empty() {
408        req_builder = req_builder.query(&query_params);
409    }
410
411
412    // Add user agent if configured
413    if let Some(ref user_agent) = configuration.user_agent {
414        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
415    }
416
417    // Apply all header parameters
418    for (header_name, header_value) in header_params {
419        req_builder = req_builder.header(&header_name, &header_value);
420    }
421
422
423    let req = req_builder.build()?;
424    let resp = configuration.client.execute(req).await?;
425
426    let status = resp.status();
427    let content_type = resp
428        .headers()
429        .get("content-type")
430        .and_then(|v| v.to_str().ok())
431        .unwrap_or("application/octet-stream");
432    let content_type = super::ContentType::from(content_type);
433
434    if !status.is_client_error() && !status.is_server_error() {
435        let content = resp.text().await?;
436        match content_type {
437            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
438            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountApiTradingStatusV1Resp`"))),
439            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WalletGetAccountApiTradingStatusV1Resp`")))),
440        }
441    } else {
442        let content = resp.text().await?;
443        let entity: Option<WalletGetAccountApiTradingStatusV1Error> = serde_json::from_str(&content).ok();
444        Err(Error::ResponseError(ResponseContent { status, content, entity }))
445    }
446}
447
448/// Fetch account info detail.
449pub async fn wallet_get_account_info_v1(configuration: &configuration::Configuration, params: WalletGetAccountInfoV1Params) -> Result<models::WalletGetAccountInfoV1Resp, Error<WalletGetAccountInfoV1Error>> {
450
451    let uri_str = format!("{}/sapi/v1/account/info", configuration.base_path);
452    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
453
454    // Create a mutable vector for query parameters
455    let mut query_params: Vec<(String, String)> = Vec::new();
456
457    if let Some(ref param_value) = params.recv_window {
458        query_params.push(("recvWindow".to_string(), param_value.to_string()));
459    }
460    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
461
462    // Create header parameters collection
463    let mut header_params = std::collections::HashMap::new();
464
465    // Handle Binance Auth first if configured
466    if let Some(ref binance_auth) = configuration.binance_auth {
467        // Add API key to headers
468        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
469        
470        // Generate request body for signing (if any)
471        let body_string: Option<Vec<u8>> = None;
472        
473        // Sign the request
474        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
475            Ok(sig) => sig,
476            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
477        };
478        
479        // Add signature to query params
480        query_params.push(("signature".to_string(), signature));
481    }
482
483    // Apply all query parameters
484    if !query_params.is_empty() {
485        req_builder = req_builder.query(&query_params);
486    }
487
488
489    // Add user agent if configured
490    if let Some(ref user_agent) = configuration.user_agent {
491        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
492    }
493
494    // Apply all header parameters
495    for (header_name, header_value) in header_params {
496        req_builder = req_builder.header(&header_name, &header_value);
497    }
498
499
500    let req = req_builder.build()?;
501    let resp = configuration.client.execute(req).await?;
502
503    let status = resp.status();
504    let content_type = resp
505        .headers()
506        .get("content-type")
507        .and_then(|v| v.to_str().ok())
508        .unwrap_or("application/octet-stream");
509    let content_type = super::ContentType::from(content_type);
510
511    if !status.is_client_error() && !status.is_server_error() {
512        let content = resp.text().await?;
513        match content_type {
514            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
515            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountInfoV1Resp`"))),
516            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WalletGetAccountInfoV1Resp`")))),
517        }
518    } else {
519        let content = resp.text().await?;
520        let entity: Option<WalletGetAccountInfoV1Error> = serde_json::from_str(&content).ok();
521        Err(Error::ResponseError(ResponseContent { status, content, entity }))
522    }
523}
524
525/// Daily account snapshot
526pub async fn wallet_get_account_snapshot_v1(configuration: &configuration::Configuration, params: WalletGetAccountSnapshotV1Params) -> Result<models::WalletGetAccountSnapshotV1Resp, Error<WalletGetAccountSnapshotV1Error>> {
527
528    let uri_str = format!("{}/sapi/v1/accountSnapshot", configuration.base_path);
529    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
530
531    // Create a mutable vector for query parameters
532    let mut query_params: Vec<(String, String)> = Vec::new();
533
534    query_params.push(("type".to_string(), params.r#type.to_string()));
535    if let Some(ref param_value) = params.start_time {
536        query_params.push(("startTime".to_string(), param_value.to_string()));
537    }
538    if let Some(ref param_value) = params.end_time {
539        query_params.push(("endTime".to_string(), param_value.to_string()));
540    }
541    if let Some(ref param_value) = params.limit {
542        query_params.push(("limit".to_string(), param_value.to_string()));
543    }
544    if let Some(ref param_value) = params.recv_window {
545        query_params.push(("recvWindow".to_string(), param_value.to_string()));
546    }
547    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
548
549    // Create header parameters collection
550    let mut header_params = std::collections::HashMap::new();
551
552    // Handle Binance Auth first if configured
553    if let Some(ref binance_auth) = configuration.binance_auth {
554        // Add API key to headers
555        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
556        
557        // Generate request body for signing (if any)
558        let body_string: Option<Vec<u8>> = None;
559        
560        // Sign the request
561        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
562            Ok(sig) => sig,
563            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
564        };
565        
566        // Add signature to query params
567        query_params.push(("signature".to_string(), signature));
568    }
569
570    // Apply all query parameters
571    if !query_params.is_empty() {
572        req_builder = req_builder.query(&query_params);
573    }
574
575
576    // Add user agent if configured
577    if let Some(ref user_agent) = configuration.user_agent {
578        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
579    }
580
581    // Apply all header parameters
582    for (header_name, header_value) in header_params {
583        req_builder = req_builder.header(&header_name, &header_value);
584    }
585
586
587    let req = req_builder.build()?;
588    let resp = configuration.client.execute(req).await?;
589
590    let status = resp.status();
591    let content_type = resp
592        .headers()
593        .get("content-type")
594        .and_then(|v| v.to_str().ok())
595        .unwrap_or("application/octet-stream");
596    let content_type = super::ContentType::from(content_type);
597
598    if !status.is_client_error() && !status.is_server_error() {
599        let content = resp.text().await?;
600        match content_type {
601            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
602            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountSnapshotV1Resp`"))),
603            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WalletGetAccountSnapshotV1Resp`")))),
604        }
605    } else {
606        let content = resp.text().await?;
607        let entity: Option<WalletGetAccountSnapshotV1Error> = serde_json::from_str(&content).ok();
608        Err(Error::ResponseError(ResponseContent { status, content, entity }))
609    }
610}
611
612/// Fetch account status detail.
613pub async fn wallet_get_account_status_v1(configuration: &configuration::Configuration, params: WalletGetAccountStatusV1Params) -> Result<models::WalletGetAccountStatusV1Resp, Error<WalletGetAccountStatusV1Error>> {
614
615    let uri_str = format!("{}/sapi/v1/account/status", configuration.base_path);
616    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
617
618    // Create a mutable vector for query parameters
619    let mut query_params: Vec<(String, String)> = Vec::new();
620
621    if let Some(ref param_value) = params.recv_window {
622        query_params.push(("recvWindow".to_string(), param_value.to_string()));
623    }
624    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
625
626    // Create header parameters collection
627    let mut header_params = std::collections::HashMap::new();
628
629    // Handle Binance Auth first if configured
630    if let Some(ref binance_auth) = configuration.binance_auth {
631        // Add API key to headers
632        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
633        
634        // Generate request body for signing (if any)
635        let body_string: Option<Vec<u8>> = None;
636        
637        // Sign the request
638        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
639            Ok(sig) => sig,
640            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
641        };
642        
643        // Add signature to query params
644        query_params.push(("signature".to_string(), signature));
645    }
646
647    // Apply all query parameters
648    if !query_params.is_empty() {
649        req_builder = req_builder.query(&query_params);
650    }
651
652
653    // Add user agent if configured
654    if let Some(ref user_agent) = configuration.user_agent {
655        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
656    }
657
658    // Apply all header parameters
659    for (header_name, header_value) in header_params {
660        req_builder = req_builder.header(&header_name, &header_value);
661    }
662
663
664    let req = req_builder.build()?;
665    let resp = configuration.client.execute(req).await?;
666
667    let status = resp.status();
668    let content_type = resp
669        .headers()
670        .get("content-type")
671        .and_then(|v| v.to_str().ok())
672        .unwrap_or("application/octet-stream");
673    let content_type = super::ContentType::from(content_type);
674
675    if !status.is_client_error() && !status.is_server_error() {
676        let content = resp.text().await?;
677        match content_type {
678            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
679            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountStatusV1Resp`"))),
680            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WalletGetAccountStatusV1Resp`")))),
681        }
682    } else {
683        let content = resp.text().await?;
684        let entity: Option<WalletGetAccountStatusV1Error> = serde_json::from_str(&content).ok();
685        Err(Error::ResponseError(ResponseContent { status, content, entity }))
686    }
687}
688