binance/subaccount/apis/
account_management_api.rs

1/*
2 * Binance Sub Account API
3 *
4 * OpenAPI specification for Binance exchange - Subaccount 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::subaccount::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`subaccount_create_sub_account_blvt_enable_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct SubaccountCreateSubAccountBlvtEnableV1Params {
20    pub email: String,
21    pub enable_blvt: bool,
22    pub timestamp: i64,
23    pub recv_window: Option<i64>
24}
25
26/// struct for passing parameters to the method [`subaccount_create_sub_account_eoptions_enable_v1`]
27#[derive(Clone, Debug, Default)]
28pub struct SubaccountCreateSubAccountEoptionsEnableV1Params {
29    pub email: String,
30    pub timestamp: i64,
31    pub recv_window: Option<i64>
32}
33
34/// struct for passing parameters to the method [`subaccount_create_sub_account_futures_enable_v1`]
35#[derive(Clone, Debug, Default)]
36pub struct SubaccountCreateSubAccountFuturesEnableV1Params {
37    pub email: String,
38    pub timestamp: i64,
39    pub recv_window: Option<i64>
40}
41
42/// struct for passing parameters to the method [`subaccount_create_sub_account_margin_enable_v1`]
43#[derive(Clone, Debug, Default)]
44pub struct SubaccountCreateSubAccountMarginEnableV1Params {
45    pub email: String,
46    pub timestamp: i64,
47    pub recv_window: Option<i64>
48}
49
50/// struct for passing parameters to the method [`subaccount_create_sub_account_virtual_sub_account_v1`]
51#[derive(Clone, Debug, Default)]
52pub struct SubaccountCreateSubAccountVirtualSubAccountV1Params {
53    pub sub_account_string: String,
54    pub timestamp: i64,
55    pub recv_window: Option<i64>
56}
57
58/// struct for passing parameters to the method [`subaccount_get_sub_account_futures_position_risk_v1`]
59#[derive(Clone, Debug, Default)]
60pub struct SubaccountGetSubAccountFuturesPositionRiskV1Params {
61    /// <a href=\"/docs/sub_account/account-management/Get-Futures-Position-Risk-of-Sub-account#email-address\">Sub-account email</a>
62    pub email: String,
63    pub timestamp: i64,
64    pub recv_window: Option<i64>
65}
66
67/// struct for passing parameters to the method [`subaccount_get_sub_account_futures_position_risk_v2`]
68#[derive(Clone, Debug, Default)]
69pub struct SubaccountGetSubAccountFuturesPositionRiskV2Params {
70    /// <a href=\"/docs/sub_account/account-management/Get-Futures-Position-Risk-of-Sub-account-V2#email-address\">Sub-account email</a>
71    pub email: String,
72    /// 1:USDT Margined Futures, 2:COIN Margined Futures
73    pub futures_type: i32,
74    pub timestamp: i64,
75    pub recv_window: Option<i64>
76}
77
78/// struct for passing parameters to the method [`subaccount_get_sub_account_list_v1`]
79#[derive(Clone, Debug, Default)]
80pub struct SubaccountGetSubAccountListV1Params {
81    pub timestamp: i64,
82    /// <a href=\"/docs/sub_account/account-management/Query-Sub-account-List#email-address\">Sub-account email</a>
83    pub email: Option<String>,
84    /// true or false
85    pub is_freeze: Option<String>,
86    /// Default value: 1
87    pub page: Option<i32>,
88    /// Default value: 1, Max value: 200
89    pub limit: Option<i32>,
90    pub recv_window: Option<i64>
91}
92
93/// struct for passing parameters to the method [`subaccount_get_sub_account_status_v1`]
94#[derive(Clone, Debug, Default)]
95pub struct SubaccountGetSubAccountStatusV1Params {
96    pub timestamp: i64,
97    /// <a href=\"/docs/sub_account/account-management/Get-Sub-accounts-Status-on-Margin-Or-Futures#email-address\">Sub-account email</a>
98    pub email: Option<String>,
99    pub recv_window: Option<i64>
100}
101
102/// struct for passing parameters to the method [`subaccount_get_sub_account_transaction_statistics_v1`]
103#[derive(Clone, Debug, Default)]
104pub struct SubaccountGetSubAccountTransactionStatisticsV1Params {
105    /// Sub user email
106    pub email: String,
107    pub timestamp: i64,
108    pub recv_window: Option<i64>
109}
110
111
112/// struct for typed errors of method [`subaccount_create_sub_account_blvt_enable_v1`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum SubaccountCreateSubAccountBlvtEnableV1Error {
116    Status4XX(models::ApiError),
117    Status5XX(models::ApiError),
118    UnknownValue(serde_json::Value),
119}
120
121/// struct for typed errors of method [`subaccount_create_sub_account_eoptions_enable_v1`]
122#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum SubaccountCreateSubAccountEoptionsEnableV1Error {
125    Status4XX(models::ApiError),
126    Status5XX(models::ApiError),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`subaccount_create_sub_account_futures_enable_v1`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum SubaccountCreateSubAccountFuturesEnableV1Error {
134    Status4XX(models::ApiError),
135    Status5XX(models::ApiError),
136    UnknownValue(serde_json::Value),
137}
138
139/// struct for typed errors of method [`subaccount_create_sub_account_margin_enable_v1`]
140#[derive(Debug, Clone, Serialize, Deserialize)]
141#[serde(untagged)]
142pub enum SubaccountCreateSubAccountMarginEnableV1Error {
143    Status4XX(models::ApiError),
144    Status5XX(models::ApiError),
145    UnknownValue(serde_json::Value),
146}
147
148/// struct for typed errors of method [`subaccount_create_sub_account_virtual_sub_account_v1`]
149#[derive(Debug, Clone, Serialize, Deserialize)]
150#[serde(untagged)]
151pub enum SubaccountCreateSubAccountVirtualSubAccountV1Error {
152    Status4XX(models::ApiError),
153    Status5XX(models::ApiError),
154    UnknownValue(serde_json::Value),
155}
156
157/// struct for typed errors of method [`subaccount_get_sub_account_futures_position_risk_v1`]
158#[derive(Debug, Clone, Serialize, Deserialize)]
159#[serde(untagged)]
160pub enum SubaccountGetSubAccountFuturesPositionRiskV1Error {
161    Status4XX(models::ApiError),
162    Status5XX(models::ApiError),
163    UnknownValue(serde_json::Value),
164}
165
166/// struct for typed errors of method [`subaccount_get_sub_account_futures_position_risk_v2`]
167#[derive(Debug, Clone, Serialize, Deserialize)]
168#[serde(untagged)]
169pub enum SubaccountGetSubAccountFuturesPositionRiskV2Error {
170    Status4XX(models::ApiError),
171    Status5XX(models::ApiError),
172    UnknownValue(serde_json::Value),
173}
174
175/// struct for typed errors of method [`subaccount_get_sub_account_list_v1`]
176#[derive(Debug, Clone, Serialize, Deserialize)]
177#[serde(untagged)]
178pub enum SubaccountGetSubAccountListV1Error {
179    Status4XX(models::ApiError),
180    Status5XX(models::ApiError),
181    UnknownValue(serde_json::Value),
182}
183
184/// struct for typed errors of method [`subaccount_get_sub_account_status_v1`]
185#[derive(Debug, Clone, Serialize, Deserialize)]
186#[serde(untagged)]
187pub enum SubaccountGetSubAccountStatusV1Error {
188    Status4XX(models::ApiError),
189    Status5XX(models::ApiError),
190    UnknownValue(serde_json::Value),
191}
192
193/// struct for typed errors of method [`subaccount_get_sub_account_transaction_statistics_v1`]
194#[derive(Debug, Clone, Serialize, Deserialize)]
195#[serde(untagged)]
196pub enum SubaccountGetSubAccountTransactionStatisticsV1Error {
197    Status4XX(models::ApiError),
198    Status5XX(models::ApiError),
199    UnknownValue(serde_json::Value),
200}
201
202
203/// Enable Leverage Token for Sub-account
204pub async fn subaccount_create_sub_account_blvt_enable_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountBlvtEnableV1Params) -> Result<models::SubaccountCreateSubAccountBlvtEnableV1Resp, Error<SubaccountCreateSubAccountBlvtEnableV1Error>> {
205
206    let uri_str = format!("{}/sapi/v1/sub-account/blvt/enable", configuration.base_path);
207    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
208
209    // Create a mutable vector for query parameters
210    let mut query_params: Vec<(String, String)> = Vec::new();
211
212
213    // Create header parameters collection
214    let mut header_params = std::collections::HashMap::new();
215
216    // Handle Binance Auth first if configured
217    if let Some(ref binance_auth) = configuration.binance_auth {
218        // Add API key to headers
219        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
220        
221        // Generate request body for signing (if any)
222        let body_string: Option<Vec<u8>> = None;
223        
224        // Sign the request
225        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
226            Ok(sig) => sig,
227            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
228        };
229        
230        // Add signature to query params
231        query_params.push(("signature".to_string(), signature));
232    }
233
234    // Apply all query parameters
235    if !query_params.is_empty() {
236        req_builder = req_builder.query(&query_params);
237    }
238
239
240    // Add user agent if configured
241    if let Some(ref user_agent) = configuration.user_agent {
242        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
243    }
244
245    // Apply all header parameters
246    for (header_name, header_value) in header_params {
247        req_builder = req_builder.header(&header_name, &header_value);
248    }
249
250    let mut multipart_form_params = std::collections::HashMap::new();
251    multipart_form_params.insert("email", params.email.to_string());
252    multipart_form_params.insert("enableBlvt", params.enable_blvt.to_string());
253    if let Some(param_value) = params.recv_window {
254        multipart_form_params.insert("recvWindow", param_value.to_string());
255    }
256    multipart_form_params.insert("timestamp", params.timestamp.to_string());
257    req_builder = req_builder.form(&multipart_form_params);
258
259    let req = req_builder.build()?;
260    let resp = configuration.client.execute(req).await?;
261
262    let status = resp.status();
263    let content_type = resp
264        .headers()
265        .get("content-type")
266        .and_then(|v| v.to_str().ok())
267        .unwrap_or("application/octet-stream");
268    let content_type = super::ContentType::from(content_type);
269
270    if !status.is_client_error() && !status.is_server_error() {
271        let content = resp.text().await?;
272        match content_type {
273            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
274            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountBlvtEnableV1Resp`"))),
275            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::SubaccountCreateSubAccountBlvtEnableV1Resp`")))),
276        }
277    } else {
278        let content = resp.text().await?;
279        let entity: Option<SubaccountCreateSubAccountBlvtEnableV1Error> = serde_json::from_str(&content).ok();
280        Err(Error::ResponseError(ResponseContent { status, content, entity }))
281    }
282}
283
284/// Enable Options for Sub-account (For Master Account).
285pub async fn subaccount_create_sub_account_eoptions_enable_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountEoptionsEnableV1Params) -> Result<models::SubaccountCreateSubAccountEoptionsEnableV1Resp, Error<SubaccountCreateSubAccountEoptionsEnableV1Error>> {
286
287    let uri_str = format!("{}/sapi/v1/sub-account/eoptions/enable", configuration.base_path);
288    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
289
290    // Create a mutable vector for query parameters
291    let mut query_params: Vec<(String, String)> = Vec::new();
292
293
294    // Create header parameters collection
295    let mut header_params = std::collections::HashMap::new();
296
297    // Handle Binance Auth first if configured
298    if let Some(ref binance_auth) = configuration.binance_auth {
299        // Add API key to headers
300        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
301        
302        // Generate request body for signing (if any)
303        let body_string: Option<Vec<u8>> = None;
304        
305        // Sign the request
306        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
307            Ok(sig) => sig,
308            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
309        };
310        
311        // Add signature to query params
312        query_params.push(("signature".to_string(), signature));
313    }
314
315    // Apply all query parameters
316    if !query_params.is_empty() {
317        req_builder = req_builder.query(&query_params);
318    }
319
320
321    // Add user agent if configured
322    if let Some(ref user_agent) = configuration.user_agent {
323        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
324    }
325
326    // Apply all header parameters
327    for (header_name, header_value) in header_params {
328        req_builder = req_builder.header(&header_name, &header_value);
329    }
330
331    let mut multipart_form_params = std::collections::HashMap::new();
332    multipart_form_params.insert("email", params.email.to_string());
333    if let Some(param_value) = params.recv_window {
334        multipart_form_params.insert("recvWindow", param_value.to_string());
335    }
336    multipart_form_params.insert("timestamp", params.timestamp.to_string());
337    req_builder = req_builder.form(&multipart_form_params);
338
339    let req = req_builder.build()?;
340    let resp = configuration.client.execute(req).await?;
341
342    let status = resp.status();
343    let content_type = resp
344        .headers()
345        .get("content-type")
346        .and_then(|v| v.to_str().ok())
347        .unwrap_or("application/octet-stream");
348    let content_type = super::ContentType::from(content_type);
349
350    if !status.is_client_error() && !status.is_server_error() {
351        let content = resp.text().await?;
352        match content_type {
353            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
354            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountEoptionsEnableV1Resp`"))),
355            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::SubaccountCreateSubAccountEoptionsEnableV1Resp`")))),
356        }
357    } else {
358        let content = resp.text().await?;
359        let entity: Option<SubaccountCreateSubAccountEoptionsEnableV1Error> = serde_json::from_str(&content).ok();
360        Err(Error::ResponseError(ResponseContent { status, content, entity }))
361    }
362}
363
364/// Enable Futures for Sub-account for Master Account
365pub async fn subaccount_create_sub_account_futures_enable_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountFuturesEnableV1Params) -> Result<models::SubaccountCreateSubAccountFuturesEnableV1Resp, Error<SubaccountCreateSubAccountFuturesEnableV1Error>> {
366
367    let uri_str = format!("{}/sapi/v1/sub-account/futures/enable", configuration.base_path);
368    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
369
370    // Create a mutable vector for query parameters
371    let mut query_params: Vec<(String, String)> = Vec::new();
372
373
374    // Create header parameters collection
375    let mut header_params = std::collections::HashMap::new();
376
377    // Handle Binance Auth first if configured
378    if let Some(ref binance_auth) = configuration.binance_auth {
379        // Add API key to headers
380        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
381        
382        // Generate request body for signing (if any)
383        let body_string: Option<Vec<u8>> = None;
384        
385        // Sign the request
386        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
387            Ok(sig) => sig,
388            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
389        };
390        
391        // Add signature to query params
392        query_params.push(("signature".to_string(), signature));
393    }
394
395    // Apply all query parameters
396    if !query_params.is_empty() {
397        req_builder = req_builder.query(&query_params);
398    }
399
400
401    // Add user agent if configured
402    if let Some(ref user_agent) = configuration.user_agent {
403        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
404    }
405
406    // Apply all header parameters
407    for (header_name, header_value) in header_params {
408        req_builder = req_builder.header(&header_name, &header_value);
409    }
410
411    let mut multipart_form_params = std::collections::HashMap::new();
412    multipart_form_params.insert("email", params.email.to_string());
413    if let Some(param_value) = params.recv_window {
414        multipart_form_params.insert("recvWindow", param_value.to_string());
415    }
416    multipart_form_params.insert("timestamp", params.timestamp.to_string());
417    req_builder = req_builder.form(&multipart_form_params);
418
419    let req = req_builder.build()?;
420    let resp = configuration.client.execute(req).await?;
421
422    let status = resp.status();
423    let content_type = resp
424        .headers()
425        .get("content-type")
426        .and_then(|v| v.to_str().ok())
427        .unwrap_or("application/octet-stream");
428    let content_type = super::ContentType::from(content_type);
429
430    if !status.is_client_error() && !status.is_server_error() {
431        let content = resp.text().await?;
432        match content_type {
433            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
434            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountFuturesEnableV1Resp`"))),
435            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::SubaccountCreateSubAccountFuturesEnableV1Resp`")))),
436        }
437    } else {
438        let content = resp.text().await?;
439        let entity: Option<SubaccountCreateSubAccountFuturesEnableV1Error> = serde_json::from_str(&content).ok();
440        Err(Error::ResponseError(ResponseContent { status, content, entity }))
441    }
442}
443
444/// Enable Margin for Sub-account
445pub async fn subaccount_create_sub_account_margin_enable_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountMarginEnableV1Params) -> Result<models::SubaccountCreateSubAccountMarginEnableV1Resp, Error<SubaccountCreateSubAccountMarginEnableV1Error>> {
446
447    let uri_str = format!("{}/sapi/v1/sub-account/margin/enable", configuration.base_path);
448    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
449
450    // Create a mutable vector for query parameters
451    let mut query_params: Vec<(String, String)> = Vec::new();
452
453
454    // Create header parameters collection
455    let mut header_params = std::collections::HashMap::new();
456
457    // Handle Binance Auth first if configured
458    if let Some(ref binance_auth) = configuration.binance_auth {
459        // Add API key to headers
460        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
461        
462        // Generate request body for signing (if any)
463        let body_string: Option<Vec<u8>> = None;
464        
465        // Sign the request
466        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
467            Ok(sig) => sig,
468            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
469        };
470        
471        // Add signature to query params
472        query_params.push(("signature".to_string(), signature));
473    }
474
475    // Apply all query parameters
476    if !query_params.is_empty() {
477        req_builder = req_builder.query(&query_params);
478    }
479
480
481    // Add user agent if configured
482    if let Some(ref user_agent) = configuration.user_agent {
483        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
484    }
485
486    // Apply all header parameters
487    for (header_name, header_value) in header_params {
488        req_builder = req_builder.header(&header_name, &header_value);
489    }
490
491    let mut multipart_form_params = std::collections::HashMap::new();
492    multipart_form_params.insert("email", params.email.to_string());
493    if let Some(param_value) = params.recv_window {
494        multipart_form_params.insert("recvWindow", param_value.to_string());
495    }
496    multipart_form_params.insert("timestamp", params.timestamp.to_string());
497    req_builder = req_builder.form(&multipart_form_params);
498
499    let req = req_builder.build()?;
500    let resp = configuration.client.execute(req).await?;
501
502    let status = resp.status();
503    let content_type = resp
504        .headers()
505        .get("content-type")
506        .and_then(|v| v.to_str().ok())
507        .unwrap_or("application/octet-stream");
508    let content_type = super::ContentType::from(content_type);
509
510    if !status.is_client_error() && !status.is_server_error() {
511        let content = resp.text().await?;
512        match content_type {
513            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
514            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountMarginEnableV1Resp`"))),
515            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::SubaccountCreateSubAccountMarginEnableV1Resp`")))),
516        }
517    } else {
518        let content = resp.text().await?;
519        let entity: Option<SubaccountCreateSubAccountMarginEnableV1Error> = serde_json::from_str(&content).ok();
520        Err(Error::ResponseError(ResponseContent { status, content, entity }))
521    }
522}
523
524/// Create a Virtual Sub-account
525pub async fn subaccount_create_sub_account_virtual_sub_account_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountVirtualSubAccountV1Params) -> Result<models::SubaccountCreateSubAccountVirtualSubAccountV1Resp, Error<SubaccountCreateSubAccountVirtualSubAccountV1Error>> {
526
527    let uri_str = format!("{}/sapi/v1/sub-account/virtualSubAccount", configuration.base_path);
528    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
529
530    // Create a mutable vector for query parameters
531    let mut query_params: Vec<(String, String)> = Vec::new();
532
533
534    // Create header parameters collection
535    let mut header_params = std::collections::HashMap::new();
536
537    // Handle Binance Auth first if configured
538    if let Some(ref binance_auth) = configuration.binance_auth {
539        // Add API key to headers
540        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
541        
542        // Generate request body for signing (if any)
543        let body_string: Option<Vec<u8>> = None;
544        
545        // Sign the request
546        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
547            Ok(sig) => sig,
548            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
549        };
550        
551        // Add signature to query params
552        query_params.push(("signature".to_string(), signature));
553    }
554
555    // Apply all query parameters
556    if !query_params.is_empty() {
557        req_builder = req_builder.query(&query_params);
558    }
559
560
561    // Add user agent if configured
562    if let Some(ref user_agent) = configuration.user_agent {
563        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
564    }
565
566    // Apply all header parameters
567    for (header_name, header_value) in header_params {
568        req_builder = req_builder.header(&header_name, &header_value);
569    }
570
571    let mut multipart_form_params = std::collections::HashMap::new();
572    if let Some(param_value) = params.recv_window {
573        multipart_form_params.insert("recvWindow", param_value.to_string());
574    }
575    multipart_form_params.insert("subAccountString", params.sub_account_string.to_string());
576    multipart_form_params.insert("timestamp", params.timestamp.to_string());
577    req_builder = req_builder.form(&multipart_form_params);
578
579    let req = req_builder.build()?;
580    let resp = configuration.client.execute(req).await?;
581
582    let status = resp.status();
583    let content_type = resp
584        .headers()
585        .get("content-type")
586        .and_then(|v| v.to_str().ok())
587        .unwrap_or("application/octet-stream");
588    let content_type = super::ContentType::from(content_type);
589
590    if !status.is_client_error() && !status.is_server_error() {
591        let content = resp.text().await?;
592        match content_type {
593            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
594            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountVirtualSubAccountV1Resp`"))),
595            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::SubaccountCreateSubAccountVirtualSubAccountV1Resp`")))),
596        }
597    } else {
598        let content = resp.text().await?;
599        let entity: Option<SubaccountCreateSubAccountVirtualSubAccountV1Error> = serde_json::from_str(&content).ok();
600        Err(Error::ResponseError(ResponseContent { status, content, entity }))
601    }
602}
603
604/// Get Futures Position-Risk of Sub-account
605pub async fn subaccount_get_sub_account_futures_position_risk_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesPositionRiskV1Params) -> Result<Vec<models::SubaccountGetSubAccountFuturesPositionRiskV1RespItem>, Error<SubaccountGetSubAccountFuturesPositionRiskV1Error>> {
606
607    let uri_str = format!("{}/sapi/v1/sub-account/futures/positionRisk", configuration.base_path);
608    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
609
610    // Create a mutable vector for query parameters
611    let mut query_params: Vec<(String, String)> = Vec::new();
612
613    query_params.push(("email".to_string(), params.email.to_string()));
614    if let Some(ref param_value) = params.recv_window {
615        query_params.push(("recvWindow".to_string(), param_value.to_string()));
616    }
617    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
618
619    // Create header parameters collection
620    let mut header_params = std::collections::HashMap::new();
621
622    // Handle Binance Auth first if configured
623    if let Some(ref binance_auth) = configuration.binance_auth {
624        // Add API key to headers
625        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
626        
627        // Generate request body for signing (if any)
628        let body_string: Option<Vec<u8>> = None;
629        
630        // Sign the request
631        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
632            Ok(sig) => sig,
633            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
634        };
635        
636        // Add signature to query params
637        query_params.push(("signature".to_string(), signature));
638    }
639
640    // Apply all query parameters
641    if !query_params.is_empty() {
642        req_builder = req_builder.query(&query_params);
643    }
644
645
646    // Add user agent if configured
647    if let Some(ref user_agent) = configuration.user_agent {
648        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
649    }
650
651    // Apply all header parameters
652    for (header_name, header_value) in header_params {
653        req_builder = req_builder.header(&header_name, &header_value);
654    }
655
656
657    let req = req_builder.build()?;
658    let resp = configuration.client.execute(req).await?;
659
660    let status = resp.status();
661    let content_type = resp
662        .headers()
663        .get("content-type")
664        .and_then(|v| v.to_str().ok())
665        .unwrap_or("application/octet-stream");
666    let content_type = super::ContentType::from(content_type);
667
668    if !status.is_client_error() && !status.is_server_error() {
669        let content = resp.text().await?;
670        match content_type {
671            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
672            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SubaccountGetSubAccountFuturesPositionRiskV1RespItem&gt;`"))),
673            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::SubaccountGetSubAccountFuturesPositionRiskV1RespItem&gt;`")))),
674        }
675    } else {
676        let content = resp.text().await?;
677        let entity: Option<SubaccountGetSubAccountFuturesPositionRiskV1Error> = serde_json::from_str(&content).ok();
678        Err(Error::ResponseError(ResponseContent { status, content, entity }))
679    }
680}
681
682/// Get Futures Position-Risk of Sub-account V2
683pub async fn subaccount_get_sub_account_futures_position_risk_v2(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesPositionRiskV2Params) -> Result<models::SubaccountGetSubAccountFuturesPositionRiskV2Resp, Error<SubaccountGetSubAccountFuturesPositionRiskV2Error>> {
684
685    let uri_str = format!("{}/sapi/v2/sub-account/futures/positionRisk", configuration.base_path);
686    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
687
688    // Create a mutable vector for query parameters
689    let mut query_params: Vec<(String, String)> = Vec::new();
690
691    query_params.push(("email".to_string(), params.email.to_string()));
692    query_params.push(("futuresType".to_string(), params.futures_type.to_string()));
693    if let Some(ref param_value) = params.recv_window {
694        query_params.push(("recvWindow".to_string(), param_value.to_string()));
695    }
696    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
697
698    // Create header parameters collection
699    let mut header_params = std::collections::HashMap::new();
700
701    // Handle Binance Auth first if configured
702    if let Some(ref binance_auth) = configuration.binance_auth {
703        // Add API key to headers
704        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
705        
706        // Generate request body for signing (if any)
707        let body_string: Option<Vec<u8>> = None;
708        
709        // Sign the request
710        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
711            Ok(sig) => sig,
712            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
713        };
714        
715        // Add signature to query params
716        query_params.push(("signature".to_string(), signature));
717    }
718
719    // Apply all query parameters
720    if !query_params.is_empty() {
721        req_builder = req_builder.query(&query_params);
722    }
723
724
725    // Add user agent if configured
726    if let Some(ref user_agent) = configuration.user_agent {
727        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
728    }
729
730    // Apply all header parameters
731    for (header_name, header_value) in header_params {
732        req_builder = req_builder.header(&header_name, &header_value);
733    }
734
735
736    let req = req_builder.build()?;
737    let resp = configuration.client.execute(req).await?;
738
739    let status = resp.status();
740    let content_type = resp
741        .headers()
742        .get("content-type")
743        .and_then(|v| v.to_str().ok())
744        .unwrap_or("application/octet-stream");
745    let content_type = super::ContentType::from(content_type);
746
747    if !status.is_client_error() && !status.is_server_error() {
748        let content = resp.text().await?;
749        match content_type {
750            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
751            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountFuturesPositionRiskV2Resp`"))),
752            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::SubaccountGetSubAccountFuturesPositionRiskV2Resp`")))),
753        }
754    } else {
755        let content = resp.text().await?;
756        let entity: Option<SubaccountGetSubAccountFuturesPositionRiskV2Error> = serde_json::from_str(&content).ok();
757        Err(Error::ResponseError(ResponseContent { status, content, entity }))
758    }
759}
760
761/// Query Sub-account List
762pub async fn subaccount_get_sub_account_list_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountListV1Params) -> Result<models::SubaccountGetSubAccountListV1Resp, Error<SubaccountGetSubAccountListV1Error>> {
763
764    let uri_str = format!("{}/sapi/v1/sub-account/list", configuration.base_path);
765    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
766
767    // Create a mutable vector for query parameters
768    let mut query_params: Vec<(String, String)> = Vec::new();
769
770    if let Some(ref param_value) = params.email {
771        query_params.push(("email".to_string(), param_value.to_string()));
772    }
773    if let Some(ref param_value) = params.is_freeze {
774        query_params.push(("isFreeze".to_string(), param_value.to_string()));
775    }
776    if let Some(ref param_value) = params.page {
777        query_params.push(("page".to_string(), param_value.to_string()));
778    }
779    if let Some(ref param_value) = params.limit {
780        query_params.push(("limit".to_string(), param_value.to_string()));
781    }
782    if let Some(ref param_value) = params.recv_window {
783        query_params.push(("recvWindow".to_string(), param_value.to_string()));
784    }
785    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
786
787    // Create header parameters collection
788    let mut header_params = std::collections::HashMap::new();
789
790    // Handle Binance Auth first if configured
791    if let Some(ref binance_auth) = configuration.binance_auth {
792        // Add API key to headers
793        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
794        
795        // Generate request body for signing (if any)
796        let body_string: Option<Vec<u8>> = None;
797        
798        // Sign the request
799        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
800            Ok(sig) => sig,
801            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
802        };
803        
804        // Add signature to query params
805        query_params.push(("signature".to_string(), signature));
806    }
807
808    // Apply all query parameters
809    if !query_params.is_empty() {
810        req_builder = req_builder.query(&query_params);
811    }
812
813
814    // Add user agent if configured
815    if let Some(ref user_agent) = configuration.user_agent {
816        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
817    }
818
819    // Apply all header parameters
820    for (header_name, header_value) in header_params {
821        req_builder = req_builder.header(&header_name, &header_value);
822    }
823
824
825    let req = req_builder.build()?;
826    let resp = configuration.client.execute(req).await?;
827
828    let status = resp.status();
829    let content_type = resp
830        .headers()
831        .get("content-type")
832        .and_then(|v| v.to_str().ok())
833        .unwrap_or("application/octet-stream");
834    let content_type = super::ContentType::from(content_type);
835
836    if !status.is_client_error() && !status.is_server_error() {
837        let content = resp.text().await?;
838        match content_type {
839            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
840            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountListV1Resp`"))),
841            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::SubaccountGetSubAccountListV1Resp`")))),
842        }
843    } else {
844        let content = resp.text().await?;
845        let entity: Option<SubaccountGetSubAccountListV1Error> = serde_json::from_str(&content).ok();
846        Err(Error::ResponseError(ResponseContent { status, content, entity }))
847    }
848}
849
850/// Get Sub-account's Status on Margin Or Futures
851pub async fn subaccount_get_sub_account_status_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountStatusV1Params) -> Result<Vec<models::SubaccountGetSubAccountStatusV1RespItem>, Error<SubaccountGetSubAccountStatusV1Error>> {
852
853    let uri_str = format!("{}/sapi/v1/sub-account/status", configuration.base_path);
854    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
855
856    // Create a mutable vector for query parameters
857    let mut query_params: Vec<(String, String)> = Vec::new();
858
859    if let Some(ref param_value) = params.email {
860        query_params.push(("email".to_string(), param_value.to_string()));
861    }
862    if let Some(ref param_value) = params.recv_window {
863        query_params.push(("recvWindow".to_string(), param_value.to_string()));
864    }
865    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
866
867    // Create header parameters collection
868    let mut header_params = std::collections::HashMap::new();
869
870    // Handle Binance Auth first if configured
871    if let Some(ref binance_auth) = configuration.binance_auth {
872        // Add API key to headers
873        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
874        
875        // Generate request body for signing (if any)
876        let body_string: Option<Vec<u8>> = None;
877        
878        // Sign the request
879        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
880            Ok(sig) => sig,
881            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
882        };
883        
884        // Add signature to query params
885        query_params.push(("signature".to_string(), signature));
886    }
887
888    // Apply all query parameters
889    if !query_params.is_empty() {
890        req_builder = req_builder.query(&query_params);
891    }
892
893
894    // Add user agent if configured
895    if let Some(ref user_agent) = configuration.user_agent {
896        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
897    }
898
899    // Apply all header parameters
900    for (header_name, header_value) in header_params {
901        req_builder = req_builder.header(&header_name, &header_value);
902    }
903
904
905    let req = req_builder.build()?;
906    let resp = configuration.client.execute(req).await?;
907
908    let status = resp.status();
909    let content_type = resp
910        .headers()
911        .get("content-type")
912        .and_then(|v| v.to_str().ok())
913        .unwrap_or("application/octet-stream");
914    let content_type = super::ContentType::from(content_type);
915
916    if !status.is_client_error() && !status.is_server_error() {
917        let content = resp.text().await?;
918        match content_type {
919            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
920            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SubaccountGetSubAccountStatusV1RespItem&gt;`"))),
921            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::SubaccountGetSubAccountStatusV1RespItem&gt;`")))),
922        }
923    } else {
924        let content = resp.text().await?;
925        let entity: Option<SubaccountGetSubAccountStatusV1Error> = serde_json::from_str(&content).ok();
926        Err(Error::ResponseError(ResponseContent { status, content, entity }))
927    }
928}
929
930/// Query Sub-account Transaction statistics (For Master Account).
931pub async fn subaccount_get_sub_account_transaction_statistics_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountTransactionStatisticsV1Params) -> Result<models::SubaccountGetSubAccountTransactionStatisticsV1Resp, Error<SubaccountGetSubAccountTransactionStatisticsV1Error>> {
932
933    let uri_str = format!("{}/sapi/v1/sub-account/transaction-statistics", configuration.base_path);
934    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
935
936    // Create a mutable vector for query parameters
937    let mut query_params: Vec<(String, String)> = Vec::new();
938
939    query_params.push(("email".to_string(), params.email.to_string()));
940    if let Some(ref param_value) = params.recv_window {
941        query_params.push(("recvWindow".to_string(), param_value.to_string()));
942    }
943    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
944
945    // Create header parameters collection
946    let mut header_params = std::collections::HashMap::new();
947
948    // Handle Binance Auth first if configured
949    if let Some(ref binance_auth) = configuration.binance_auth {
950        // Add API key to headers
951        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
952        
953        // Generate request body for signing (if any)
954        let body_string: Option<Vec<u8>> = None;
955        
956        // Sign the request
957        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
958            Ok(sig) => sig,
959            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
960        };
961        
962        // Add signature to query params
963        query_params.push(("signature".to_string(), signature));
964    }
965
966    // Apply all query parameters
967    if !query_params.is_empty() {
968        req_builder = req_builder.query(&query_params);
969    }
970
971
972    // Add user agent if configured
973    if let Some(ref user_agent) = configuration.user_agent {
974        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
975    }
976
977    // Apply all header parameters
978    for (header_name, header_value) in header_params {
979        req_builder = req_builder.header(&header_name, &header_value);
980    }
981
982
983    let req = req_builder.build()?;
984    let resp = configuration.client.execute(req).await?;
985
986    let status = resp.status();
987    let content_type = resp
988        .headers()
989        .get("content-type")
990        .and_then(|v| v.to_str().ok())
991        .unwrap_or("application/octet-stream");
992    let content_type = super::ContentType::from(content_type);
993
994    if !status.is_client_error() && !status.is_server_error() {
995        let content = resp.text().await?;
996        match content_type {
997            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
998            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountTransactionStatisticsV1Resp`"))),
999            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::SubaccountGetSubAccountTransactionStatisticsV1Resp`")))),
1000        }
1001    } else {
1002        let content = resp.text().await?;
1003        let entity: Option<SubaccountGetSubAccountTransactionStatisticsV1Error> = serde_json::from_str(&content).ok();
1004        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1005    }
1006}
1007