binance/wallet/apis/
capital_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_capital_deposit_credit_apply_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct WalletCreateCapitalDepositCreditApplyV1Params {
20    pub deposit_id: Option<i64>,
21    pub sub_account_id: Option<i64>,
22    pub sub_user_id: Option<i64>,
23    pub tx_id: Option<String>
24}
25
26/// struct for passing parameters to the method [`wallet_create_capital_withdraw_apply_v1`]
27#[derive(Clone, Debug, Default)]
28pub struct WalletCreateCapitalWithdrawApplyV1Params {
29    pub address: String,
30    pub amount: String,
31    pub coin: String,
32    pub timestamp: i64,
33    pub address_tag: Option<String>,
34    pub name: Option<String>,
35    pub network: Option<String>,
36    pub recv_window: Option<i64>,
37    pub transaction_fee_flag: Option<bool>,
38    pub wallet_type: Option<i32>,
39    pub withdraw_order_id: Option<String>
40}
41
42/// struct for passing parameters to the method [`wallet_get_capital_config_getall_v1`]
43#[derive(Clone, Debug, Default)]
44pub struct WalletGetCapitalConfigGetallV1Params {
45    pub timestamp: i64,
46    pub recv_window: Option<i64>
47}
48
49/// struct for passing parameters to the method [`wallet_get_capital_deposit_address_list_v1`]
50#[derive(Clone, Debug, Default)]
51pub struct WalletGetCapitalDepositAddressListV1Params {
52    /// `coin` refers to the parent network address format that the address is using
53    pub coin: String,
54    pub timestamp: i64,
55    pub network: Option<String>
56}
57
58/// struct for passing parameters to the method [`wallet_get_capital_deposit_address_v1`]
59#[derive(Clone, Debug, Default)]
60pub struct WalletGetCapitalDepositAddressV1Params {
61    pub coin: String,
62    pub timestamp: i64,
63    pub network: Option<String>,
64    pub amount: Option<String>,
65    pub recv_window: Option<i64>
66}
67
68/// struct for passing parameters to the method [`wallet_get_capital_deposit_hisrec_v1`]
69#[derive(Clone, Debug, Default)]
70pub struct WalletGetCapitalDepositHisrecV1Params {
71    pub timestamp: i64,
72    /// Default: `false`, return `sourceAddress`field when set to `true`
73    pub include_source: Option<bool>,
74    pub coin: Option<String>,
75    /// 0(0:pending, 6:credited but cannot withdraw, 7:Wrong Deposit, 8:Waiting User confirm, 1:success, 2:rejected)
76    pub status: Option<i32>,
77    /// Default: 90 days from current timestamp
78    pub start_time: Option<i64>,
79    /// Default: present timestamp
80    pub end_time: Option<i64>,
81    /// Default:0
82    pub offset: Option<i32>,
83    /// Default:1000, Max:1000
84    pub limit: Option<i32>,
85    pub recv_window: Option<i64>,
86    pub tx_id: Option<String>
87}
88
89/// struct for passing parameters to the method [`wallet_get_capital_withdraw_history_v1`]
90#[derive(Clone, Debug, Default)]
91pub struct WalletGetCapitalWithdrawHistoryV1Params {
92    pub timestamp: i64,
93    pub coin: Option<String>,
94    pub withdraw_order_id: Option<String>,
95    /// 0(0:Email Sent, 2:Awaiting Approval 3:Rejected 4:Processing 6:Completed)
96    pub status: Option<i32>,
97    pub offset: Option<i32>,
98    /// Default: 1000, Max: 1000
99    pub limit: Option<i32>,
100    /// id list returned in the response of POST `/sapi/v1/capital/withdraw/apply`, separated by `,`
101    pub id_list: Option<String>,
102    /// Default: 90 days from current timestamp
103    pub start_time: Option<i64>,
104    /// Default: present timestamp
105    pub end_time: Option<i64>,
106    pub recv_window: Option<i64>
107}
108
109
110/// struct for typed errors of method [`wallet_create_capital_deposit_credit_apply_v1`]
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum WalletCreateCapitalDepositCreditApplyV1Error {
114    Status4XX(models::ApiError),
115    Status5XX(models::ApiError),
116    UnknownValue(serde_json::Value),
117}
118
119/// struct for typed errors of method [`wallet_create_capital_withdraw_apply_v1`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum WalletCreateCapitalWithdrawApplyV1Error {
123    Status4XX(models::ApiError),
124    Status5XX(models::ApiError),
125    UnknownValue(serde_json::Value),
126}
127
128/// struct for typed errors of method [`wallet_get_capital_config_getall_v1`]
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum WalletGetCapitalConfigGetallV1Error {
132    Status4XX(models::ApiError),
133    Status5XX(models::ApiError),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`wallet_get_capital_deposit_address_list_v1`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum WalletGetCapitalDepositAddressListV1Error {
141    Status4XX(models::ApiError),
142    Status5XX(models::ApiError),
143    UnknownValue(serde_json::Value),
144}
145
146/// struct for typed errors of method [`wallet_get_capital_deposit_address_v1`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum WalletGetCapitalDepositAddressV1Error {
150    Status4XX(models::ApiError),
151    Status5XX(models::ApiError),
152    UnknownValue(serde_json::Value),
153}
154
155/// struct for typed errors of method [`wallet_get_capital_deposit_hisrec_v1`]
156#[derive(Debug, Clone, Serialize, Deserialize)]
157#[serde(untagged)]
158pub enum WalletGetCapitalDepositHisrecV1Error {
159    Status4XX(models::ApiError),
160    Status5XX(models::ApiError),
161    UnknownValue(serde_json::Value),
162}
163
164/// struct for typed errors of method [`wallet_get_capital_withdraw_address_list_v1`]
165#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum WalletGetCapitalWithdrawAddressListV1Error {
168    Status4XX(models::ApiError),
169    Status5XX(models::ApiError),
170    UnknownValue(serde_json::Value),
171}
172
173/// struct for typed errors of method [`wallet_get_capital_withdraw_history_v1`]
174#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(untagged)]
176pub enum WalletGetCapitalWithdrawHistoryV1Error {
177    Status4XX(models::ApiError),
178    Status5XX(models::ApiError),
179    UnknownValue(serde_json::Value),
180}
181
182
183/// Apply deposit credit for expired address (One click arrival)
184pub async fn wallet_create_capital_deposit_credit_apply_v1(configuration: &configuration::Configuration, params: WalletCreateCapitalDepositCreditApplyV1Params) -> Result<models::WalletCreateCapitalDepositCreditApplyV1Resp, Error<WalletCreateCapitalDepositCreditApplyV1Error>> {
185
186    let uri_str = format!("{}/sapi/v1/capital/deposit/credit-apply", configuration.base_path);
187    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
188
189    // Create a mutable vector for query parameters
190    let mut query_params: Vec<(String, String)> = Vec::new();
191
192
193    // Create header parameters collection
194    let mut header_params = std::collections::HashMap::new();
195
196    // Handle Binance Auth first if configured
197    if let Some(ref binance_auth) = configuration.binance_auth {
198        // Add API key to headers
199        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
200        
201        // Generate request body for signing (if any)
202        let body_string: Option<Vec<u8>> = None;
203        
204        // Sign the request
205        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
206            Ok(sig) => sig,
207            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
208        };
209        
210        // Add signature to query params
211        query_params.push(("signature".to_string(), signature));
212    }
213
214    // Apply all query parameters
215    if !query_params.is_empty() {
216        req_builder = req_builder.query(&query_params);
217    }
218
219
220    // Add user agent if configured
221    if let Some(ref user_agent) = configuration.user_agent {
222        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
223    }
224
225    // Apply all header parameters
226    for (header_name, header_value) in header_params {
227        req_builder = req_builder.header(&header_name, &header_value);
228    }
229
230    let mut multipart_form_params = std::collections::HashMap::new();
231    if let Some(param_value) = params.deposit_id {
232        multipart_form_params.insert("depositId", param_value.to_string());
233    }
234    if let Some(param_value) = params.sub_account_id {
235        multipart_form_params.insert("subAccountId", param_value.to_string());
236    }
237    if let Some(param_value) = params.sub_user_id {
238        multipart_form_params.insert("subUserId", param_value.to_string());
239    }
240    if let Some(param_value) = params.tx_id {
241        multipart_form_params.insert("txId", param_value.to_string());
242    }
243    req_builder = req_builder.form(&multipart_form_params);
244
245    let req = req_builder.build()?;
246    let resp = configuration.client.execute(req).await?;
247
248    let status = resp.status();
249    let content_type = resp
250        .headers()
251        .get("content-type")
252        .and_then(|v| v.to_str().ok())
253        .unwrap_or("application/octet-stream");
254    let content_type = super::ContentType::from(content_type);
255
256    if !status.is_client_error() && !status.is_server_error() {
257        let content = resp.text().await?;
258        match content_type {
259            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
260            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletCreateCapitalDepositCreditApplyV1Resp`"))),
261            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::WalletCreateCapitalDepositCreditApplyV1Resp`")))),
262        }
263    } else {
264        let content = resp.text().await?;
265        let entity: Option<WalletCreateCapitalDepositCreditApplyV1Error> = serde_json::from_str(&content).ok();
266        Err(Error::ResponseError(ResponseContent { status, content, entity }))
267    }
268}
269
270/// Submit a withdraw request.
271pub async fn wallet_create_capital_withdraw_apply_v1(configuration: &configuration::Configuration, params: WalletCreateCapitalWithdrawApplyV1Params) -> Result<models::WalletCreateCapitalWithdrawApplyV1Resp, Error<WalletCreateCapitalWithdrawApplyV1Error>> {
272
273    let uri_str = format!("{}/sapi/v1/capital/withdraw/apply", configuration.base_path);
274    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
275
276    // Create a mutable vector for query parameters
277    let mut query_params: Vec<(String, String)> = Vec::new();
278
279
280    // Create header parameters collection
281    let mut header_params = std::collections::HashMap::new();
282
283    // Handle Binance Auth first if configured
284    if let Some(ref binance_auth) = configuration.binance_auth {
285        // Add API key to headers
286        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
287        
288        // Generate request body for signing (if any)
289        let body_string: Option<Vec<u8>> = None;
290        
291        // Sign the request
292        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
293            Ok(sig) => sig,
294            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
295        };
296        
297        // Add signature to query params
298        query_params.push(("signature".to_string(), signature));
299    }
300
301    // Apply all query parameters
302    if !query_params.is_empty() {
303        req_builder = req_builder.query(&query_params);
304    }
305
306
307    // Add user agent if configured
308    if let Some(ref user_agent) = configuration.user_agent {
309        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
310    }
311
312    // Apply all header parameters
313    for (header_name, header_value) in header_params {
314        req_builder = req_builder.header(&header_name, &header_value);
315    }
316
317    let mut multipart_form_params = std::collections::HashMap::new();
318    multipart_form_params.insert("address", params.address.to_string());
319    if let Some(param_value) = params.address_tag {
320        multipart_form_params.insert("addressTag", param_value.to_string());
321    }
322    multipart_form_params.insert("amount", params.amount.to_string());
323    multipart_form_params.insert("coin", params.coin.to_string());
324    if let Some(param_value) = params.name {
325        multipart_form_params.insert("name", param_value.to_string());
326    }
327    if let Some(param_value) = params.network {
328        multipart_form_params.insert("network", param_value.to_string());
329    }
330    if let Some(param_value) = params.recv_window {
331        multipart_form_params.insert("recvWindow", param_value.to_string());
332    }
333    multipart_form_params.insert("timestamp", params.timestamp.to_string());
334    if let Some(param_value) = params.transaction_fee_flag {
335        multipart_form_params.insert("transactionFeeFlag", param_value.to_string());
336    }
337    if let Some(param_value) = params.wallet_type {
338        multipart_form_params.insert("walletType", param_value.to_string());
339    }
340    if let Some(param_value) = params.withdraw_order_id {
341        multipart_form_params.insert("withdrawOrderId", param_value.to_string());
342    }
343    req_builder = req_builder.form(&multipart_form_params);
344
345    let req = req_builder.build()?;
346    let resp = configuration.client.execute(req).await?;
347
348    let status = resp.status();
349    let content_type = resp
350        .headers()
351        .get("content-type")
352        .and_then(|v| v.to_str().ok())
353        .unwrap_or("application/octet-stream");
354    let content_type = super::ContentType::from(content_type);
355
356    if !status.is_client_error() && !status.is_server_error() {
357        let content = resp.text().await?;
358        match content_type {
359            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
360            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletCreateCapitalWithdrawApplyV1Resp`"))),
361            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::WalletCreateCapitalWithdrawApplyV1Resp`")))),
362        }
363    } else {
364        let content = resp.text().await?;
365        let entity: Option<WalletCreateCapitalWithdrawApplyV1Error> = serde_json::from_str(&content).ok();
366        Err(Error::ResponseError(ResponseContent { status, content, entity }))
367    }
368}
369
370/// Get information of coins (available for deposit and withdraw) for user.
371pub async fn wallet_get_capital_config_getall_v1(configuration: &configuration::Configuration, params: WalletGetCapitalConfigGetallV1Params) -> Result<Vec<models::WalletGetCapitalConfigGetallV1RespItem>, Error<WalletGetCapitalConfigGetallV1Error>> {
372
373    let uri_str = format!("{}/sapi/v1/capital/config/getall", configuration.base_path);
374    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
375
376    // Create a mutable vector for query parameters
377    let mut query_params: Vec<(String, String)> = Vec::new();
378
379    if let Some(ref param_value) = params.recv_window {
380        query_params.push(("recvWindow".to_string(), param_value.to_string()));
381    }
382    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
383
384    // Create header parameters collection
385    let mut header_params = std::collections::HashMap::new();
386
387    // Handle Binance Auth first if configured
388    if let Some(ref binance_auth) = configuration.binance_auth {
389        // Add API key to headers
390        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
391        
392        // Generate request body for signing (if any)
393        let body_string: Option<Vec<u8>> = None;
394        
395        // Sign the request
396        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
397            Ok(sig) => sig,
398            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
399        };
400        
401        // Add signature to query params
402        query_params.push(("signature".to_string(), signature));
403    }
404
405    // Apply all query parameters
406    if !query_params.is_empty() {
407        req_builder = req_builder.query(&query_params);
408    }
409
410
411    // Add user agent if configured
412    if let Some(ref user_agent) = configuration.user_agent {
413        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
414    }
415
416    // Apply all header parameters
417    for (header_name, header_value) in header_params {
418        req_builder = req_builder.header(&header_name, &header_value);
419    }
420
421
422    let req = req_builder.build()?;
423    let resp = configuration.client.execute(req).await?;
424
425    let status = resp.status();
426    let content_type = resp
427        .headers()
428        .get("content-type")
429        .and_then(|v| v.to_str().ok())
430        .unwrap_or("application/octet-stream");
431    let content_type = super::ContentType::from(content_type);
432
433    if !status.is_client_error() && !status.is_server_error() {
434        let content = resp.text().await?;
435        match content_type {
436            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
437            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::WalletGetCapitalConfigGetallV1RespItem&gt;`"))),
438            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::WalletGetCapitalConfigGetallV1RespItem&gt;`")))),
439        }
440    } else {
441        let content = resp.text().await?;
442        let entity: Option<WalletGetCapitalConfigGetallV1Error> = serde_json::from_str(&content).ok();
443        Err(Error::ResponseError(ResponseContent { status, content, entity }))
444    }
445}
446
447/// Fetch deposit address list with network.
448pub async fn wallet_get_capital_deposit_address_list_v1(configuration: &configuration::Configuration, params: WalletGetCapitalDepositAddressListV1Params) -> Result<Vec<models::WalletGetCapitalDepositAddressListV1RespItem>, Error<WalletGetCapitalDepositAddressListV1Error>> {
449
450    let uri_str = format!("{}/sapi/v1/capital/deposit/address/list", configuration.base_path);
451    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
452
453    // Create a mutable vector for query parameters
454    let mut query_params: Vec<(String, String)> = Vec::new();
455
456    query_params.push(("coin".to_string(), params.coin.to_string()));
457    if let Some(ref param_value) = params.network {
458        query_params.push(("network".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 `Vec&lt;models::WalletGetCapitalDepositAddressListV1RespItem&gt;`"))),
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 `Vec&lt;models::WalletGetCapitalDepositAddressListV1RespItem&gt;`")))),
517        }
518    } else {
519        let content = resp.text().await?;
520        let entity: Option<WalletGetCapitalDepositAddressListV1Error> = serde_json::from_str(&content).ok();
521        Err(Error::ResponseError(ResponseContent { status, content, entity }))
522    }
523}
524
525/// Fetch deposit address with network.
526pub async fn wallet_get_capital_deposit_address_v1(configuration: &configuration::Configuration, params: WalletGetCapitalDepositAddressV1Params) -> Result<models::WalletGetCapitalDepositAddressV1Resp, Error<WalletGetCapitalDepositAddressV1Error>> {
527
528    let uri_str = format!("{}/sapi/v1/capital/deposit/address", 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(("coin".to_string(), params.coin.to_string()));
535    if let Some(ref param_value) = params.network {
536        query_params.push(("network".to_string(), param_value.to_string()));
537    }
538    if let Some(ref param_value) = params.amount {
539        query_params.push(("amount".to_string(), param_value.to_string()));
540    }
541    if let Some(ref param_value) = params.recv_window {
542        query_params.push(("recvWindow".to_string(), param_value.to_string()));
543    }
544    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
545
546    // Create header parameters collection
547    let mut header_params = std::collections::HashMap::new();
548
549    // Handle Binance Auth first if configured
550    if let Some(ref binance_auth) = configuration.binance_auth {
551        // Add API key to headers
552        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
553        
554        // Generate request body for signing (if any)
555        let body_string: Option<Vec<u8>> = None;
556        
557        // Sign the request
558        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
559            Ok(sig) => sig,
560            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
561        };
562        
563        // Add signature to query params
564        query_params.push(("signature".to_string(), signature));
565    }
566
567    // Apply all query parameters
568    if !query_params.is_empty() {
569        req_builder = req_builder.query(&query_params);
570    }
571
572
573    // Add user agent if configured
574    if let Some(ref user_agent) = configuration.user_agent {
575        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
576    }
577
578    // Apply all header parameters
579    for (header_name, header_value) in header_params {
580        req_builder = req_builder.header(&header_name, &header_value);
581    }
582
583
584    let req = req_builder.build()?;
585    let resp = configuration.client.execute(req).await?;
586
587    let status = resp.status();
588    let content_type = resp
589        .headers()
590        .get("content-type")
591        .and_then(|v| v.to_str().ok())
592        .unwrap_or("application/octet-stream");
593    let content_type = super::ContentType::from(content_type);
594
595    if !status.is_client_error() && !status.is_server_error() {
596        let content = resp.text().await?;
597        match content_type {
598            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
599            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetCapitalDepositAddressV1Resp`"))),
600            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::WalletGetCapitalDepositAddressV1Resp`")))),
601        }
602    } else {
603        let content = resp.text().await?;
604        let entity: Option<WalletGetCapitalDepositAddressV1Error> = serde_json::from_str(&content).ok();
605        Err(Error::ResponseError(ResponseContent { status, content, entity }))
606    }
607}
608
609/// Fetch deposit history.
610pub async fn wallet_get_capital_deposit_hisrec_v1(configuration: &configuration::Configuration, params: WalletGetCapitalDepositHisrecV1Params) -> Result<Vec<models::WalletGetCapitalDepositHisrecV1RespItem>, Error<WalletGetCapitalDepositHisrecV1Error>> {
611
612    let uri_str = format!("{}/sapi/v1/capital/deposit/hisrec", configuration.base_path);
613    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
614
615    // Create a mutable vector for query parameters
616    let mut query_params: Vec<(String, String)> = Vec::new();
617
618    if let Some(ref param_value) = params.include_source {
619        query_params.push(("includeSource".to_string(), param_value.to_string()));
620    }
621    if let Some(ref param_value) = params.coin {
622        query_params.push(("coin".to_string(), param_value.to_string()));
623    }
624    if let Some(ref param_value) = params.status {
625        query_params.push(("status".to_string(), param_value.to_string()));
626    }
627    if let Some(ref param_value) = params.start_time {
628        query_params.push(("startTime".to_string(), param_value.to_string()));
629    }
630    if let Some(ref param_value) = params.end_time {
631        query_params.push(("endTime".to_string(), param_value.to_string()));
632    }
633    if let Some(ref param_value) = params.offset {
634        query_params.push(("offset".to_string(), param_value.to_string()));
635    }
636    if let Some(ref param_value) = params.limit {
637        query_params.push(("limit".to_string(), param_value.to_string()));
638    }
639    if let Some(ref param_value) = params.recv_window {
640        query_params.push(("recvWindow".to_string(), param_value.to_string()));
641    }
642    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
643    if let Some(ref param_value) = params.tx_id {
644        query_params.push(("txId".to_string(), param_value.to_string()));
645    }
646
647    // Create header parameters collection
648    let mut header_params = std::collections::HashMap::new();
649
650    // Handle Binance Auth first if configured
651    if let Some(ref binance_auth) = configuration.binance_auth {
652        // Add API key to headers
653        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
654        
655        // Generate request body for signing (if any)
656        let body_string: Option<Vec<u8>> = None;
657        
658        // Sign the request
659        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
660            Ok(sig) => sig,
661            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
662        };
663        
664        // Add signature to query params
665        query_params.push(("signature".to_string(), signature));
666    }
667
668    // Apply all query parameters
669    if !query_params.is_empty() {
670        req_builder = req_builder.query(&query_params);
671    }
672
673
674    // Add user agent if configured
675    if let Some(ref user_agent) = configuration.user_agent {
676        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
677    }
678
679    // Apply all header parameters
680    for (header_name, header_value) in header_params {
681        req_builder = req_builder.header(&header_name, &header_value);
682    }
683
684
685    let req = req_builder.build()?;
686    let resp = configuration.client.execute(req).await?;
687
688    let status = resp.status();
689    let content_type = resp
690        .headers()
691        .get("content-type")
692        .and_then(|v| v.to_str().ok())
693        .unwrap_or("application/octet-stream");
694    let content_type = super::ContentType::from(content_type);
695
696    if !status.is_client_error() && !status.is_server_error() {
697        let content = resp.text().await?;
698        match content_type {
699            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
700            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::WalletGetCapitalDepositHisrecV1RespItem&gt;`"))),
701            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::WalletGetCapitalDepositHisrecV1RespItem&gt;`")))),
702        }
703    } else {
704        let content = resp.text().await?;
705        let entity: Option<WalletGetCapitalDepositHisrecV1Error> = serde_json::from_str(&content).ok();
706        Err(Error::ResponseError(ResponseContent { status, content, entity }))
707    }
708}
709
710/// Fetch withdraw address list
711pub async fn wallet_get_capital_withdraw_address_list_v1(configuration: &configuration::Configuration) -> Result<Vec<models::WalletGetCapitalWithdrawAddressListV1RespItem>, Error<WalletGetCapitalWithdrawAddressListV1Error>> {
712
713    let uri_str = format!("{}/sapi/v1/capital/withdraw/address/list", configuration.base_path);
714    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
715
716    // Create a mutable vector for query parameters
717    let mut query_params: Vec<(String, String)> = Vec::new();
718
719
720    // Create header parameters collection
721    let mut header_params = std::collections::HashMap::new();
722
723    // Handle Binance Auth first if configured
724    if let Some(ref binance_auth) = configuration.binance_auth {
725        // Add API key to headers
726        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
727        
728        // Generate request body for signing (if any)
729        let body_string: Option<Vec<u8>> = None;
730        
731        // Sign the request
732        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
733            Ok(sig) => sig,
734            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
735        };
736        
737        // Add signature to query params
738        query_params.push(("signature".to_string(), signature));
739    }
740
741    // Apply all query parameters
742    if !query_params.is_empty() {
743        req_builder = req_builder.query(&query_params);
744    }
745
746
747    // Add user agent if configured
748    if let Some(ref user_agent) = configuration.user_agent {
749        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
750    }
751
752    // Apply all header parameters
753    for (header_name, header_value) in header_params {
754        req_builder = req_builder.header(&header_name, &header_value);
755    }
756
757
758    let req = req_builder.build()?;
759    let resp = configuration.client.execute(req).await?;
760
761    let status = resp.status();
762    let content_type = resp
763        .headers()
764        .get("content-type")
765        .and_then(|v| v.to_str().ok())
766        .unwrap_or("application/octet-stream");
767    let content_type = super::ContentType::from(content_type);
768
769    if !status.is_client_error() && !status.is_server_error() {
770        let content = resp.text().await?;
771        match content_type {
772            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
773            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::WalletGetCapitalWithdrawAddressListV1RespItem&gt;`"))),
774            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::WalletGetCapitalWithdrawAddressListV1RespItem&gt;`")))),
775        }
776    } else {
777        let content = resp.text().await?;
778        let entity: Option<WalletGetCapitalWithdrawAddressListV1Error> = serde_json::from_str(&content).ok();
779        Err(Error::ResponseError(ResponseContent { status, content, entity }))
780    }
781}
782
783/// Fetch withdraw history.
784pub async fn wallet_get_capital_withdraw_history_v1(configuration: &configuration::Configuration, params: WalletGetCapitalWithdrawHistoryV1Params) -> Result<Vec<models::WalletGetCapitalWithdrawHistoryV1RespItem>, Error<WalletGetCapitalWithdrawHistoryV1Error>> {
785
786    let uri_str = format!("{}/sapi/v1/capital/withdraw/history", configuration.base_path);
787    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
788
789    // Create a mutable vector for query parameters
790    let mut query_params: Vec<(String, String)> = Vec::new();
791
792    if let Some(ref param_value) = params.coin {
793        query_params.push(("coin".to_string(), param_value.to_string()));
794    }
795    if let Some(ref param_value) = params.withdraw_order_id {
796        query_params.push(("withdrawOrderId".to_string(), param_value.to_string()));
797    }
798    if let Some(ref param_value) = params.status {
799        query_params.push(("status".to_string(), param_value.to_string()));
800    }
801    if let Some(ref param_value) = params.offset {
802        query_params.push(("offset".to_string(), param_value.to_string()));
803    }
804    if let Some(ref param_value) = params.limit {
805        query_params.push(("limit".to_string(), param_value.to_string()));
806    }
807    if let Some(ref param_value) = params.id_list {
808        query_params.push(("idList".to_string(), param_value.to_string()));
809    }
810    if let Some(ref param_value) = params.start_time {
811        query_params.push(("startTime".to_string(), param_value.to_string()));
812    }
813    if let Some(ref param_value) = params.end_time {
814        query_params.push(("endTime".to_string(), param_value.to_string()));
815    }
816    if let Some(ref param_value) = params.recv_window {
817        query_params.push(("recvWindow".to_string(), param_value.to_string()));
818    }
819    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
820
821    // Create header parameters collection
822    let mut header_params = std::collections::HashMap::new();
823
824    // Handle Binance Auth first if configured
825    if let Some(ref binance_auth) = configuration.binance_auth {
826        // Add API key to headers
827        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
828        
829        // Generate request body for signing (if any)
830        let body_string: Option<Vec<u8>> = None;
831        
832        // Sign the request
833        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
834            Ok(sig) => sig,
835            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
836        };
837        
838        // Add signature to query params
839        query_params.push(("signature".to_string(), signature));
840    }
841
842    // Apply all query parameters
843    if !query_params.is_empty() {
844        req_builder = req_builder.query(&query_params);
845    }
846
847
848    // Add user agent if configured
849    if let Some(ref user_agent) = configuration.user_agent {
850        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
851    }
852
853    // Apply all header parameters
854    for (header_name, header_value) in header_params {
855        req_builder = req_builder.header(&header_name, &header_value);
856    }
857
858
859    let req = req_builder.build()?;
860    let resp = configuration.client.execute(req).await?;
861
862    let status = resp.status();
863    let content_type = resp
864        .headers()
865        .get("content-type")
866        .and_then(|v| v.to_str().ok())
867        .unwrap_or("application/octet-stream");
868    let content_type = super::ContentType::from(content_type);
869
870    if !status.is_client_error() && !status.is_server_error() {
871        let content = resp.text().await?;
872        match content_type {
873            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
874            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::WalletGetCapitalWithdrawHistoryV1RespItem&gt;`"))),
875            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::WalletGetCapitalWithdrawHistoryV1RespItem&gt;`")))),
876        }
877    } else {
878        let content = resp.text().await?;
879        let entity: Option<WalletGetCapitalWithdrawHistoryV1Error> = serde_json::from_str(&content).ok();
880        Err(Error::ResponseError(ResponseContent { status, content, entity }))
881    }
882}
883