1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::subaccount::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[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#[derive(Clone, Debug, Default)]
28pub struct SubaccountCreateSubAccountEoptionsEnableV1Params {
29 pub email: String,
30 pub timestamp: i64,
31 pub recv_window: Option<i64>
32}
33
34#[derive(Clone, Debug, Default)]
36pub struct SubaccountCreateSubAccountFuturesEnableV1Params {
37 pub email: String,
38 pub timestamp: i64,
39 pub recv_window: Option<i64>
40}
41
42#[derive(Clone, Debug, Default)]
44pub struct SubaccountCreateSubAccountMarginEnableV1Params {
45 pub email: String,
46 pub timestamp: i64,
47 pub recv_window: Option<i64>
48}
49
50#[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#[derive(Clone, Debug, Default)]
60pub struct SubaccountGetSubAccountFuturesPositionRiskV1Params {
61 pub email: String,
63 pub timestamp: i64,
64 pub recv_window: Option<i64>
65}
66
67#[derive(Clone, Debug, Default)]
69pub struct SubaccountGetSubAccountFuturesPositionRiskV2Params {
70 pub email: String,
72 pub futures_type: i32,
74 pub timestamp: i64,
75 pub recv_window: Option<i64>
76}
77
78#[derive(Clone, Debug, Default)]
80pub struct SubaccountGetSubAccountListV1Params {
81 pub timestamp: i64,
82 pub email: Option<String>,
84 pub is_freeze: Option<String>,
86 pub page: Option<i32>,
88 pub limit: Option<i32>,
90 pub recv_window: Option<i64>
91}
92
93#[derive(Clone, Debug, Default)]
95pub struct SubaccountGetSubAccountStatusV1Params {
96 pub timestamp: i64,
97 pub email: Option<String>,
99 pub recv_window: Option<i64>
100}
101
102#[derive(Clone, Debug, Default)]
104pub struct SubaccountGetSubAccountTransactionStatisticsV1Params {
105 pub email: String,
107 pub timestamp: i64,
108 pub recv_window: Option<i64>
109}
110
111
112#[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#[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#[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#[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#[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#[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#[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#[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#[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#[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
203pub 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 let mut query_params: Vec<(String, String)> = Vec::new();
211
212
213 let mut header_params = std::collections::HashMap::new();
215
216 if let Some(ref binance_auth) = configuration.binance_auth {
218 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
220
221 let body_string: Option<Vec<u8>> = None;
223
224 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 query_params.push(("signature".to_string(), signature));
232 }
233
234 if !query_params.is_empty() {
236 req_builder = req_builder.query(&query_params);
237 }
238
239
240 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 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
284pub 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 let mut query_params: Vec<(String, String)> = Vec::new();
292
293
294 let mut header_params = std::collections::HashMap::new();
296
297 if let Some(ref binance_auth) = configuration.binance_auth {
299 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
301
302 let body_string: Option<Vec<u8>> = None;
304
305 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 query_params.push(("signature".to_string(), signature));
313 }
314
315 if !query_params.is_empty() {
317 req_builder = req_builder.query(&query_params);
318 }
319
320
321 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 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
364pub 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 let mut query_params: Vec<(String, String)> = Vec::new();
372
373
374 let mut header_params = std::collections::HashMap::new();
376
377 if let Some(ref binance_auth) = configuration.binance_auth {
379 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
381
382 let body_string: Option<Vec<u8>> = None;
384
385 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 query_params.push(("signature".to_string(), signature));
393 }
394
395 if !query_params.is_empty() {
397 req_builder = req_builder.query(&query_params);
398 }
399
400
401 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 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
444pub 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 let mut query_params: Vec<(String, String)> = Vec::new();
452
453
454 let mut header_params = std::collections::HashMap::new();
456
457 if let Some(ref binance_auth) = configuration.binance_auth {
459 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
461
462 let body_string: Option<Vec<u8>> = None;
464
465 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 query_params.push(("signature".to_string(), signature));
473 }
474
475 if !query_params.is_empty() {
477 req_builder = req_builder.query(&query_params);
478 }
479
480
481 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 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
524pub 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 let mut query_params: Vec<(String, String)> = Vec::new();
532
533
534 let mut header_params = std::collections::HashMap::new();
536
537 if let Some(ref binance_auth) = configuration.binance_auth {
539 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
541
542 let body_string: Option<Vec<u8>> = None;
544
545 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 query_params.push(("signature".to_string(), signature));
553 }
554
555 if !query_params.is_empty() {
557 req_builder = req_builder.query(&query_params);
558 }
559
560
561 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 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
604pub 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 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 let mut header_params = std::collections::HashMap::new();
621
622 if let Some(ref binance_auth) = configuration.binance_auth {
624 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
626
627 let body_string: Option<Vec<u8>> = None;
629
630 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 query_params.push(("signature".to_string(), signature));
638 }
639
640 if !query_params.is_empty() {
642 req_builder = req_builder.query(&query_params);
643 }
644
645
646 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 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<models::SubaccountGetSubAccountFuturesPositionRiskV1RespItem>`"))),
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<models::SubaccountGetSubAccountFuturesPositionRiskV1RespItem>`")))),
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
682pub 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 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 let mut header_params = std::collections::HashMap::new();
700
701 if let Some(ref binance_auth) = configuration.binance_auth {
703 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
705
706 let body_string: Option<Vec<u8>> = None;
708
709 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 query_params.push(("signature".to_string(), signature));
717 }
718
719 if !query_params.is_empty() {
721 req_builder = req_builder.query(&query_params);
722 }
723
724
725 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 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
761pub 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 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 let mut header_params = std::collections::HashMap::new();
789
790 if let Some(ref binance_auth) = configuration.binance_auth {
792 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
794
795 let body_string: Option<Vec<u8>> = None;
797
798 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 query_params.push(("signature".to_string(), signature));
806 }
807
808 if !query_params.is_empty() {
810 req_builder = req_builder.query(&query_params);
811 }
812
813
814 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 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
850pub 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 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 let mut header_params = std::collections::HashMap::new();
869
870 if let Some(ref binance_auth) = configuration.binance_auth {
872 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
874
875 let body_string: Option<Vec<u8>> = None;
877
878 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 query_params.push(("signature".to_string(), signature));
886 }
887
888 if !query_params.is_empty() {
890 req_builder = req_builder.query(&query_params);
891 }
892
893
894 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 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<models::SubaccountGetSubAccountStatusV1RespItem>`"))),
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<models::SubaccountGetSubAccountStatusV1RespItem>`")))),
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
930pub 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 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 let mut header_params = std::collections::HashMap::new();
947
948 if let Some(ref binance_auth) = configuration.binance_auth {
950 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
952
953 let body_string: Option<Vec<u8>> = None;
955
956 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 query_params.push(("signature".to_string(), signature));
964 }
965
966 if !query_params.is_empty() {
968 req_builder = req_builder.query(&query_params);
969 }
970
971
972 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 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