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 SubaccountCreateSubAccountFuturesInternalTransferV1Params {
20 pub amount: String,
21 pub asset: String,
22 pub from_email: String,
23 pub futures_type: i64,
24 pub timestamp: i64,
25 pub to_email: String,
26 pub recv_window: Option<i64>
27}
28
29#[derive(Clone, Debug, Default)]
31pub struct SubaccountCreateSubAccountFuturesMovePositionV1Params {
32 pub from_user_email: String,
33 pub order_args: Vec<serde_json::Value>,
34 pub product_type: String,
35 pub timestamp: i64,
36 pub to_user_email: String,
37 pub recv_window: Option<i64>
38}
39
40#[derive(Clone, Debug, Default)]
42pub struct SubaccountCreateSubAccountFuturesTransferV1Params {
43 pub amount: String,
44 pub asset: String,
45 pub email: String,
46 pub timestamp: i64,
47 pub r#type: i32,
48 pub recv_window: Option<i64>
49}
50
51#[derive(Clone, Debug, Default)]
53pub struct SubaccountCreateSubAccountMarginTransferV1Params {
54 pub amount: String,
55 pub asset: String,
56 pub email: String,
57 pub timestamp: i64,
58 pub r#type: i32,
59 pub recv_window: Option<i64>
60}
61
62#[derive(Clone, Debug, Default)]
64pub struct SubaccountCreateSubAccountTransferSubToMasterV1Params {
65 pub amount: String,
66 pub asset: String,
67 pub timestamp: i64,
68 pub recv_window: Option<i64>
69}
70
71#[derive(Clone, Debug, Default)]
73pub struct SubaccountCreateSubAccountTransferSubToSubV1Params {
74 pub amount: String,
75 pub asset: String,
76 pub timestamp: i64,
77 pub to_email: String,
78 pub recv_window: Option<i64>
79}
80
81#[derive(Clone, Debug, Default)]
83pub struct SubaccountCreateSubAccountUniversalTransferV1Params {
84 pub amount: String,
85 pub asset: String,
86 pub from_account_type: String,
87 pub timestamp: i64,
88 pub to_account_type: String,
89 pub client_tran_id: Option<String>,
90 pub from_email: Option<String>,
91 pub recv_window: Option<i64>,
92 pub symbol: Option<String>,
93 pub to_email: Option<String>
94}
95
96#[derive(Clone, Debug, Default)]
98pub struct SubaccountGetCapitalDepositSubAddressV1Params {
99 pub email: String,
101 pub coin: String,
102 pub timestamp: i64,
103 pub network: Option<String>,
104 pub amount: Option<String>,
105 pub recv_window: Option<i64>
106}
107
108#[derive(Clone, Debug, Default)]
110pub struct SubaccountGetCapitalDepositSubHisrecV1Params {
111 pub email: String,
113 pub timestamp: i64,
114 pub coin: Option<String>,
115 pub status: Option<i32>,
117 pub start_time: Option<i64>,
118 pub end_time: Option<i64>,
119 pub limit: Option<i32>,
120 pub offset: Option<i32>,
122 pub recv_window: Option<i64>,
123 pub tx_id: Option<String>
124}
125
126#[derive(Clone, Debug, Default)]
128pub struct SubaccountGetSubAccountAssetsV3Params {
129 pub email: String,
131 pub timestamp: i64,
132 pub recv_window: Option<i64>
133}
134
135#[derive(Clone, Debug, Default)]
137pub struct SubaccountGetSubAccountAssetsV4Params {
138 pub email: String,
140 pub timestamp: i64,
141 pub recv_window: Option<i64>
142}
143
144#[derive(Clone, Debug, Default)]
146pub struct SubaccountGetSubAccountFuturesAccountSummaryV1Params {
147 pub timestamp: i64,
148 pub recv_window: Option<i64>
149}
150
151#[derive(Clone, Debug, Default)]
153pub struct SubaccountGetSubAccountFuturesAccountSummaryV2Params {
154 pub futures_type: i32,
156 pub timestamp: i64,
157 pub page: Option<i32>,
159 pub limit: Option<i32>,
161 pub recv_window: Option<i64>
162}
163
164#[derive(Clone, Debug, Default)]
166pub struct SubaccountGetSubAccountFuturesAccountV1Params {
167 pub email: String,
169 pub timestamp: i64,
170 pub recv_window: Option<i64>
171}
172
173#[derive(Clone, Debug, Default)]
175pub struct SubaccountGetSubAccountFuturesAccountV2Params {
176 pub email: String,
178 pub futures_type: i32,
180 pub timestamp: i64,
181 pub recv_window: Option<i64>
182}
183
184#[derive(Clone, Debug, Default)]
186pub struct SubaccountGetSubAccountFuturesInternalTransferV1Params {
187 pub email: String,
189 pub futures_type: i64,
191 pub timestamp: i64,
192 pub start_time: Option<i64>,
194 pub end_time: Option<i64>,
195 pub page: Option<i32>,
197 pub limit: Option<i32>,
199 pub recv_window: Option<i64>
200}
201
202#[derive(Clone, Debug, Default)]
204pub struct SubaccountGetSubAccountFuturesMovePositionV1Params {
205 pub symbol: String,
206 pub page: i32,
207 pub row: i32,
208 pub timestamp: i64,
209 pub start_time: Option<i64>,
210 pub end_time: Option<i64>,
211 pub recv_window: Option<i64>
212}
213
214#[derive(Clone, Debug, Default)]
216pub struct SubaccountGetSubAccountMarginAccountSummaryV1Params {
217 pub timestamp: i64,
218 pub recv_window: Option<i64>
219}
220
221#[derive(Clone, Debug, Default)]
223pub struct SubaccountGetSubAccountMarginAccountV1Params {
224 pub email: String,
226 pub timestamp: i64,
227 pub recv_window: Option<i64>
228}
229
230#[derive(Clone, Debug, Default)]
232pub struct SubaccountGetSubAccountSpotSummaryV1Params {
233 pub timestamp: i64,
234 pub email: Option<String>,
236 pub page: Option<i64>,
238 pub size: Option<i64>,
240 pub recv_window: Option<i64>
241}
242
243#[derive(Clone, Debug, Default)]
245pub struct SubaccountGetSubAccountSubTransferHistoryV1Params {
246 pub timestamp: i64,
247 pub from_email: Option<String>,
248 pub to_email: Option<String>,
249 pub start_time: Option<i64>,
250 pub end_time: Option<i64>,
251 pub page: Option<i32>,
253 pub limit: Option<i32>,
255 pub recv_window: Option<i64>
256}
257
258#[derive(Clone, Debug, Default)]
260pub struct SubaccountGetSubAccountTransferSubUserHistoryV1Params {
261 pub timestamp: i64,
262 pub asset: Option<String>,
264 pub r#type: Option<i32>,
266 pub start_time: Option<i64>,
267 pub end_time: Option<i64>,
268 pub limit: Option<i32>,
270 pub return_fail_history: Option<bool>,
272 pub recv_window: Option<i64>
273}
274
275#[derive(Clone, Debug, Default)]
277pub struct SubaccountGetSubAccountUniversalTransferV1Params {
278 pub timestamp: i64,
279 pub from_email: Option<String>,
280 pub to_email: Option<String>,
281 pub client_tran_id: Option<String>,
282 pub start_time: Option<i64>,
283 pub end_time: Option<i64>,
284 pub page: Option<i32>,
286 pub limit: Option<i32>,
288 pub recv_window: Option<i64>
289}
290
291
292#[derive(Debug, Clone, Serialize, Deserialize)]
294#[serde(untagged)]
295pub enum SubaccountCreateSubAccountFuturesInternalTransferV1Error {
296 Status4XX(models::ApiError),
297 Status5XX(models::ApiError),
298 UnknownValue(serde_json::Value),
299}
300
301#[derive(Debug, Clone, Serialize, Deserialize)]
303#[serde(untagged)]
304pub enum SubaccountCreateSubAccountFuturesMovePositionV1Error {
305 Status4XX(models::ApiError),
306 Status5XX(models::ApiError),
307 UnknownValue(serde_json::Value),
308}
309
310#[derive(Debug, Clone, Serialize, Deserialize)]
312#[serde(untagged)]
313pub enum SubaccountCreateSubAccountFuturesTransferV1Error {
314 Status4XX(models::ApiError),
315 Status5XX(models::ApiError),
316 UnknownValue(serde_json::Value),
317}
318
319#[derive(Debug, Clone, Serialize, Deserialize)]
321#[serde(untagged)]
322pub enum SubaccountCreateSubAccountMarginTransferV1Error {
323 Status4XX(models::ApiError),
324 Status5XX(models::ApiError),
325 UnknownValue(serde_json::Value),
326}
327
328#[derive(Debug, Clone, Serialize, Deserialize)]
330#[serde(untagged)]
331pub enum SubaccountCreateSubAccountTransferSubToMasterV1Error {
332 Status4XX(models::ApiError),
333 Status5XX(models::ApiError),
334 UnknownValue(serde_json::Value),
335}
336
337#[derive(Debug, Clone, Serialize, Deserialize)]
339#[serde(untagged)]
340pub enum SubaccountCreateSubAccountTransferSubToSubV1Error {
341 Status4XX(models::ApiError),
342 Status5XX(models::ApiError),
343 UnknownValue(serde_json::Value),
344}
345
346#[derive(Debug, Clone, Serialize, Deserialize)]
348#[serde(untagged)]
349pub enum SubaccountCreateSubAccountUniversalTransferV1Error {
350 Status4XX(models::ApiError),
351 Status5XX(models::ApiError),
352 UnknownValue(serde_json::Value),
353}
354
355#[derive(Debug, Clone, Serialize, Deserialize)]
357#[serde(untagged)]
358pub enum SubaccountGetCapitalDepositSubAddressV1Error {
359 Status4XX(models::ApiError),
360 Status5XX(models::ApiError),
361 UnknownValue(serde_json::Value),
362}
363
364#[derive(Debug, Clone, Serialize, Deserialize)]
366#[serde(untagged)]
367pub enum SubaccountGetCapitalDepositSubHisrecV1Error {
368 Status4XX(models::ApiError),
369 Status5XX(models::ApiError),
370 UnknownValue(serde_json::Value),
371}
372
373#[derive(Debug, Clone, Serialize, Deserialize)]
375#[serde(untagged)]
376pub enum SubaccountGetSubAccountAssetsV3Error {
377 Status4XX(models::ApiError),
378 Status5XX(models::ApiError),
379 UnknownValue(serde_json::Value),
380}
381
382#[derive(Debug, Clone, Serialize, Deserialize)]
384#[serde(untagged)]
385pub enum SubaccountGetSubAccountAssetsV4Error {
386 Status4XX(models::ApiError),
387 Status5XX(models::ApiError),
388 UnknownValue(serde_json::Value),
389}
390
391#[derive(Debug, Clone, Serialize, Deserialize)]
393#[serde(untagged)]
394pub enum SubaccountGetSubAccountFuturesAccountSummaryV1Error {
395 Status4XX(models::ApiError),
396 Status5XX(models::ApiError),
397 UnknownValue(serde_json::Value),
398}
399
400#[derive(Debug, Clone, Serialize, Deserialize)]
402#[serde(untagged)]
403pub enum SubaccountGetSubAccountFuturesAccountSummaryV2Error {
404 Status4XX(models::ApiError),
405 Status5XX(models::ApiError),
406 UnknownValue(serde_json::Value),
407}
408
409#[derive(Debug, Clone, Serialize, Deserialize)]
411#[serde(untagged)]
412pub enum SubaccountGetSubAccountFuturesAccountV1Error {
413 Status4XX(models::ApiError),
414 Status5XX(models::ApiError),
415 UnknownValue(serde_json::Value),
416}
417
418#[derive(Debug, Clone, Serialize, Deserialize)]
420#[serde(untagged)]
421pub enum SubaccountGetSubAccountFuturesAccountV2Error {
422 Status4XX(models::ApiError),
423 Status5XX(models::ApiError),
424 UnknownValue(serde_json::Value),
425}
426
427#[derive(Debug, Clone, Serialize, Deserialize)]
429#[serde(untagged)]
430pub enum SubaccountGetSubAccountFuturesInternalTransferV1Error {
431 Status4XX(models::ApiError),
432 Status5XX(models::ApiError),
433 UnknownValue(serde_json::Value),
434}
435
436#[derive(Debug, Clone, Serialize, Deserialize)]
438#[serde(untagged)]
439pub enum SubaccountGetSubAccountFuturesMovePositionV1Error {
440 Status4XX(models::ApiError),
441 Status5XX(models::ApiError),
442 UnknownValue(serde_json::Value),
443}
444
445#[derive(Debug, Clone, Serialize, Deserialize)]
447#[serde(untagged)]
448pub enum SubaccountGetSubAccountMarginAccountSummaryV1Error {
449 Status4XX(models::ApiError),
450 Status5XX(models::ApiError),
451 UnknownValue(serde_json::Value),
452}
453
454#[derive(Debug, Clone, Serialize, Deserialize)]
456#[serde(untagged)]
457pub enum SubaccountGetSubAccountMarginAccountV1Error {
458 Status4XX(models::ApiError),
459 Status5XX(models::ApiError),
460 UnknownValue(serde_json::Value),
461}
462
463#[derive(Debug, Clone, Serialize, Deserialize)]
465#[serde(untagged)]
466pub enum SubaccountGetSubAccountSpotSummaryV1Error {
467 Status4XX(models::ApiError),
468 Status5XX(models::ApiError),
469 UnknownValue(serde_json::Value),
470}
471
472#[derive(Debug, Clone, Serialize, Deserialize)]
474#[serde(untagged)]
475pub enum SubaccountGetSubAccountSubTransferHistoryV1Error {
476 Status4XX(models::ApiError),
477 Status5XX(models::ApiError),
478 UnknownValue(serde_json::Value),
479}
480
481#[derive(Debug, Clone, Serialize, Deserialize)]
483#[serde(untagged)]
484pub enum SubaccountGetSubAccountTransferSubUserHistoryV1Error {
485 Status4XX(models::ApiError),
486 Status5XX(models::ApiError),
487 UnknownValue(serde_json::Value),
488}
489
490#[derive(Debug, Clone, Serialize, Deserialize)]
492#[serde(untagged)]
493pub enum SubaccountGetSubAccountUniversalTransferV1Error {
494 Status4XX(models::ApiError),
495 Status5XX(models::ApiError),
496 UnknownValue(serde_json::Value),
497}
498
499
500pub async fn subaccount_create_sub_account_futures_internal_transfer_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountFuturesInternalTransferV1Params) -> Result<models::SubaccountCreateSubAccountFuturesInternalTransferV1Resp, Error<SubaccountCreateSubAccountFuturesInternalTransferV1Error>> {
502
503 let uri_str = format!("{}/sapi/v1/sub-account/futures/internalTransfer", configuration.base_path);
504 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
505
506 let mut query_params: Vec<(String, String)> = Vec::new();
508
509
510 let mut header_params = std::collections::HashMap::new();
512
513 if let Some(ref binance_auth) = configuration.binance_auth {
515 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
517
518 let body_string: Option<Vec<u8>> = None;
520
521 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
523 Ok(sig) => sig,
524 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
525 };
526
527 query_params.push(("signature".to_string(), signature));
529 }
530
531 if !query_params.is_empty() {
533 req_builder = req_builder.query(&query_params);
534 }
535
536
537 if let Some(ref user_agent) = configuration.user_agent {
539 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
540 }
541
542 for (header_name, header_value) in header_params {
544 req_builder = req_builder.header(&header_name, &header_value);
545 }
546
547 let mut multipart_form_params = std::collections::HashMap::new();
548 multipart_form_params.insert("amount", params.amount.to_string());
549 multipart_form_params.insert("asset", params.asset.to_string());
550 multipart_form_params.insert("fromEmail", params.from_email.to_string());
551 multipart_form_params.insert("futuresType", params.futures_type.to_string());
552 if let Some(param_value) = params.recv_window {
553 multipart_form_params.insert("recvWindow", param_value.to_string());
554 }
555 multipart_form_params.insert("timestamp", params.timestamp.to_string());
556 multipart_form_params.insert("toEmail", params.to_email.to_string());
557 req_builder = req_builder.form(&multipart_form_params);
558
559 let req = req_builder.build()?;
560 let resp = configuration.client.execute(req).await?;
561
562 let status = resp.status();
563 let content_type = resp
564 .headers()
565 .get("content-type")
566 .and_then(|v| v.to_str().ok())
567 .unwrap_or("application/octet-stream");
568 let content_type = super::ContentType::from(content_type);
569
570 if !status.is_client_error() && !status.is_server_error() {
571 let content = resp.text().await?;
572 match content_type {
573 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
574 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountFuturesInternalTransferV1Resp`"))),
575 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::SubaccountCreateSubAccountFuturesInternalTransferV1Resp`")))),
576 }
577 } else {
578 let content = resp.text().await?;
579 let entity: Option<SubaccountCreateSubAccountFuturesInternalTransferV1Error> = serde_json::from_str(&content).ok();
580 Err(Error::ResponseError(ResponseContent { status, content, entity }))
581 }
582}
583
584pub async fn subaccount_create_sub_account_futures_move_position_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountFuturesMovePositionV1Params) -> Result<models::SubaccountCreateSubAccountFuturesMovePositionV1Resp, Error<SubaccountCreateSubAccountFuturesMovePositionV1Error>> {
586
587 let uri_str = format!("{}/sapi/v1/sub-account/futures/move-position", configuration.base_path);
588 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
589
590 let mut query_params: Vec<(String, String)> = Vec::new();
592
593
594 let mut header_params = std::collections::HashMap::new();
596
597 if let Some(ref binance_auth) = configuration.binance_auth {
599 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
601
602 let body_string: Option<Vec<u8>> = None;
604
605 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
607 Ok(sig) => sig,
608 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
609 };
610
611 query_params.push(("signature".to_string(), signature));
613 }
614
615 if !query_params.is_empty() {
617 req_builder = req_builder.query(&query_params);
618 }
619
620
621 if let Some(ref user_agent) = configuration.user_agent {
623 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
624 }
625
626 for (header_name, header_value) in header_params {
628 req_builder = req_builder.header(&header_name, &header_value);
629 }
630
631 let mut multipart_form_params = std::collections::HashMap::new();
632 multipart_form_params.insert("fromUserEmail", params.from_user_email.to_string());
633 multipart_form_params.insert("orderArgs", params.order_args.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
634 multipart_form_params.insert("productType", params.product_type.to_string());
635 if let Some(param_value) = params.recv_window {
636 multipart_form_params.insert("recvWindow", param_value.to_string());
637 }
638 multipart_form_params.insert("timestamp", params.timestamp.to_string());
639 multipart_form_params.insert("toUserEmail", params.to_user_email.to_string());
640 req_builder = req_builder.form(&multipart_form_params);
641
642 let req = req_builder.build()?;
643 let resp = configuration.client.execute(req).await?;
644
645 let status = resp.status();
646 let content_type = resp
647 .headers()
648 .get("content-type")
649 .and_then(|v| v.to_str().ok())
650 .unwrap_or("application/octet-stream");
651 let content_type = super::ContentType::from(content_type);
652
653 if !status.is_client_error() && !status.is_server_error() {
654 let content = resp.text().await?;
655 match content_type {
656 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
657 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountFuturesMovePositionV1Resp`"))),
658 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::SubaccountCreateSubAccountFuturesMovePositionV1Resp`")))),
659 }
660 } else {
661 let content = resp.text().await?;
662 let entity: Option<SubaccountCreateSubAccountFuturesMovePositionV1Error> = serde_json::from_str(&content).ok();
663 Err(Error::ResponseError(ResponseContent { status, content, entity }))
664 }
665}
666
667pub async fn subaccount_create_sub_account_futures_transfer_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountFuturesTransferV1Params) -> Result<models::SubaccountCreateSubAccountFuturesTransferV1Resp, Error<SubaccountCreateSubAccountFuturesTransferV1Error>> {
669
670 let uri_str = format!("{}/sapi/v1/sub-account/futures/transfer", configuration.base_path);
671 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
672
673 let mut query_params: Vec<(String, String)> = Vec::new();
675
676
677 let mut header_params = std::collections::HashMap::new();
679
680 if let Some(ref binance_auth) = configuration.binance_auth {
682 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
684
685 let body_string: Option<Vec<u8>> = None;
687
688 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
690 Ok(sig) => sig,
691 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
692 };
693
694 query_params.push(("signature".to_string(), signature));
696 }
697
698 if !query_params.is_empty() {
700 req_builder = req_builder.query(&query_params);
701 }
702
703
704 if let Some(ref user_agent) = configuration.user_agent {
706 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
707 }
708
709 for (header_name, header_value) in header_params {
711 req_builder = req_builder.header(&header_name, &header_value);
712 }
713
714 let mut multipart_form_params = std::collections::HashMap::new();
715 multipart_form_params.insert("amount", params.amount.to_string());
716 multipart_form_params.insert("asset", params.asset.to_string());
717 multipart_form_params.insert("email", params.email.to_string());
718 if let Some(param_value) = params.recv_window {
719 multipart_form_params.insert("recvWindow", param_value.to_string());
720 }
721 multipart_form_params.insert("timestamp", params.timestamp.to_string());
722 multipart_form_params.insert("type", params.r#type.to_string());
723 req_builder = req_builder.form(&multipart_form_params);
724
725 let req = req_builder.build()?;
726 let resp = configuration.client.execute(req).await?;
727
728 let status = resp.status();
729 let content_type = resp
730 .headers()
731 .get("content-type")
732 .and_then(|v| v.to_str().ok())
733 .unwrap_or("application/octet-stream");
734 let content_type = super::ContentType::from(content_type);
735
736 if !status.is_client_error() && !status.is_server_error() {
737 let content = resp.text().await?;
738 match content_type {
739 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
740 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountFuturesTransferV1Resp`"))),
741 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::SubaccountCreateSubAccountFuturesTransferV1Resp`")))),
742 }
743 } else {
744 let content = resp.text().await?;
745 let entity: Option<SubaccountCreateSubAccountFuturesTransferV1Error> = serde_json::from_str(&content).ok();
746 Err(Error::ResponseError(ResponseContent { status, content, entity }))
747 }
748}
749
750pub async fn subaccount_create_sub_account_margin_transfer_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountMarginTransferV1Params) -> Result<models::SubaccountCreateSubAccountMarginTransferV1Resp, Error<SubaccountCreateSubAccountMarginTransferV1Error>> {
752
753 let uri_str = format!("{}/sapi/v1/sub-account/margin/transfer", configuration.base_path);
754 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
755
756 let mut query_params: Vec<(String, String)> = Vec::new();
758
759
760 let mut header_params = std::collections::HashMap::new();
762
763 if let Some(ref binance_auth) = configuration.binance_auth {
765 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
767
768 let body_string: Option<Vec<u8>> = None;
770
771 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
773 Ok(sig) => sig,
774 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
775 };
776
777 query_params.push(("signature".to_string(), signature));
779 }
780
781 if !query_params.is_empty() {
783 req_builder = req_builder.query(&query_params);
784 }
785
786
787 if let Some(ref user_agent) = configuration.user_agent {
789 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
790 }
791
792 for (header_name, header_value) in header_params {
794 req_builder = req_builder.header(&header_name, &header_value);
795 }
796
797 let mut multipart_form_params = std::collections::HashMap::new();
798 multipart_form_params.insert("amount", params.amount.to_string());
799 multipart_form_params.insert("asset", params.asset.to_string());
800 multipart_form_params.insert("email", params.email.to_string());
801 if let Some(param_value) = params.recv_window {
802 multipart_form_params.insert("recvWindow", param_value.to_string());
803 }
804 multipart_form_params.insert("timestamp", params.timestamp.to_string());
805 multipart_form_params.insert("type", params.r#type.to_string());
806 req_builder = req_builder.form(&multipart_form_params);
807
808 let req = req_builder.build()?;
809 let resp = configuration.client.execute(req).await?;
810
811 let status = resp.status();
812 let content_type = resp
813 .headers()
814 .get("content-type")
815 .and_then(|v| v.to_str().ok())
816 .unwrap_or("application/octet-stream");
817 let content_type = super::ContentType::from(content_type);
818
819 if !status.is_client_error() && !status.is_server_error() {
820 let content = resp.text().await?;
821 match content_type {
822 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
823 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountMarginTransferV1Resp`"))),
824 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::SubaccountCreateSubAccountMarginTransferV1Resp`")))),
825 }
826 } else {
827 let content = resp.text().await?;
828 let entity: Option<SubaccountCreateSubAccountMarginTransferV1Error> = serde_json::from_str(&content).ok();
829 Err(Error::ResponseError(ResponseContent { status, content, entity }))
830 }
831}
832
833pub async fn subaccount_create_sub_account_transfer_sub_to_master_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountTransferSubToMasterV1Params) -> Result<models::SubaccountCreateSubAccountTransferSubToMasterV1Resp, Error<SubaccountCreateSubAccountTransferSubToMasterV1Error>> {
835
836 let uri_str = format!("{}/sapi/v1/sub-account/transfer/subToMaster", configuration.base_path);
837 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
838
839 let mut query_params: Vec<(String, String)> = Vec::new();
841
842
843 let mut header_params = std::collections::HashMap::new();
845
846 if let Some(ref binance_auth) = configuration.binance_auth {
848 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
850
851 let body_string: Option<Vec<u8>> = None;
853
854 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
856 Ok(sig) => sig,
857 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
858 };
859
860 query_params.push(("signature".to_string(), signature));
862 }
863
864 if !query_params.is_empty() {
866 req_builder = req_builder.query(&query_params);
867 }
868
869
870 if let Some(ref user_agent) = configuration.user_agent {
872 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
873 }
874
875 for (header_name, header_value) in header_params {
877 req_builder = req_builder.header(&header_name, &header_value);
878 }
879
880 let mut multipart_form_params = std::collections::HashMap::new();
881 multipart_form_params.insert("amount", params.amount.to_string());
882 multipart_form_params.insert("asset", params.asset.to_string());
883 if let Some(param_value) = params.recv_window {
884 multipart_form_params.insert("recvWindow", param_value.to_string());
885 }
886 multipart_form_params.insert("timestamp", params.timestamp.to_string());
887 req_builder = req_builder.form(&multipart_form_params);
888
889 let req = req_builder.build()?;
890 let resp = configuration.client.execute(req).await?;
891
892 let status = resp.status();
893 let content_type = resp
894 .headers()
895 .get("content-type")
896 .and_then(|v| v.to_str().ok())
897 .unwrap_or("application/octet-stream");
898 let content_type = super::ContentType::from(content_type);
899
900 if !status.is_client_error() && !status.is_server_error() {
901 let content = resp.text().await?;
902 match content_type {
903 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
904 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountTransferSubToMasterV1Resp`"))),
905 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::SubaccountCreateSubAccountTransferSubToMasterV1Resp`")))),
906 }
907 } else {
908 let content = resp.text().await?;
909 let entity: Option<SubaccountCreateSubAccountTransferSubToMasterV1Error> = serde_json::from_str(&content).ok();
910 Err(Error::ResponseError(ResponseContent { status, content, entity }))
911 }
912}
913
914pub async fn subaccount_create_sub_account_transfer_sub_to_sub_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountTransferSubToSubV1Params) -> Result<models::SubaccountCreateSubAccountTransferSubToSubV1Resp, Error<SubaccountCreateSubAccountTransferSubToSubV1Error>> {
916
917 let uri_str = format!("{}/sapi/v1/sub-account/transfer/subToSub", configuration.base_path);
918 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
919
920 let mut query_params: Vec<(String, String)> = Vec::new();
922
923
924 let mut header_params = std::collections::HashMap::new();
926
927 if let Some(ref binance_auth) = configuration.binance_auth {
929 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
931
932 let body_string: Option<Vec<u8>> = None;
934
935 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
937 Ok(sig) => sig,
938 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
939 };
940
941 query_params.push(("signature".to_string(), signature));
943 }
944
945 if !query_params.is_empty() {
947 req_builder = req_builder.query(&query_params);
948 }
949
950
951 if let Some(ref user_agent) = configuration.user_agent {
953 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
954 }
955
956 for (header_name, header_value) in header_params {
958 req_builder = req_builder.header(&header_name, &header_value);
959 }
960
961 let mut multipart_form_params = std::collections::HashMap::new();
962 multipart_form_params.insert("amount", params.amount.to_string());
963 multipart_form_params.insert("asset", params.asset.to_string());
964 if let Some(param_value) = params.recv_window {
965 multipart_form_params.insert("recvWindow", param_value.to_string());
966 }
967 multipart_form_params.insert("timestamp", params.timestamp.to_string());
968 multipart_form_params.insert("toEmail", params.to_email.to_string());
969 req_builder = req_builder.form(&multipart_form_params);
970
971 let req = req_builder.build()?;
972 let resp = configuration.client.execute(req).await?;
973
974 let status = resp.status();
975 let content_type = resp
976 .headers()
977 .get("content-type")
978 .and_then(|v| v.to_str().ok())
979 .unwrap_or("application/octet-stream");
980 let content_type = super::ContentType::from(content_type);
981
982 if !status.is_client_error() && !status.is_server_error() {
983 let content = resp.text().await?;
984 match content_type {
985 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
986 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountTransferSubToSubV1Resp`"))),
987 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::SubaccountCreateSubAccountTransferSubToSubV1Resp`")))),
988 }
989 } else {
990 let content = resp.text().await?;
991 let entity: Option<SubaccountCreateSubAccountTransferSubToSubV1Error> = serde_json::from_str(&content).ok();
992 Err(Error::ResponseError(ResponseContent { status, content, entity }))
993 }
994}
995
996pub async fn subaccount_create_sub_account_universal_transfer_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountUniversalTransferV1Params) -> Result<models::SubaccountCreateSubAccountUniversalTransferV1Resp, Error<SubaccountCreateSubAccountUniversalTransferV1Error>> {
998
999 let uri_str = format!("{}/sapi/v1/sub-account/universalTransfer", configuration.base_path);
1000 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1001
1002 let mut query_params: Vec<(String, String)> = Vec::new();
1004
1005
1006 let mut header_params = std::collections::HashMap::new();
1008
1009 if let Some(ref binance_auth) = configuration.binance_auth {
1011 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1013
1014 let body_string: Option<Vec<u8>> = None;
1016
1017 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1019 Ok(sig) => sig,
1020 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1021 };
1022
1023 query_params.push(("signature".to_string(), signature));
1025 }
1026
1027 if !query_params.is_empty() {
1029 req_builder = req_builder.query(&query_params);
1030 }
1031
1032
1033 if let Some(ref user_agent) = configuration.user_agent {
1035 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1036 }
1037
1038 for (header_name, header_value) in header_params {
1040 req_builder = req_builder.header(&header_name, &header_value);
1041 }
1042
1043 let mut multipart_form_params = std::collections::HashMap::new();
1044 multipart_form_params.insert("amount", params.amount.to_string());
1045 multipart_form_params.insert("asset", params.asset.to_string());
1046 if let Some(param_value) = params.client_tran_id {
1047 multipart_form_params.insert("clientTranId", param_value.to_string());
1048 }
1049 multipart_form_params.insert("fromAccountType", params.from_account_type.to_string());
1050 if let Some(param_value) = params.from_email {
1051 multipart_form_params.insert("fromEmail", param_value.to_string());
1052 }
1053 if let Some(param_value) = params.recv_window {
1054 multipart_form_params.insert("recvWindow", param_value.to_string());
1055 }
1056 if let Some(param_value) = params.symbol {
1057 multipart_form_params.insert("symbol", param_value.to_string());
1058 }
1059 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1060 multipart_form_params.insert("toAccountType", params.to_account_type.to_string());
1061 if let Some(param_value) = params.to_email {
1062 multipart_form_params.insert("toEmail", param_value.to_string());
1063 }
1064 req_builder = req_builder.form(&multipart_form_params);
1065
1066 let req = req_builder.build()?;
1067 let resp = configuration.client.execute(req).await?;
1068
1069 let status = resp.status();
1070 let content_type = resp
1071 .headers()
1072 .get("content-type")
1073 .and_then(|v| v.to_str().ok())
1074 .unwrap_or("application/octet-stream");
1075 let content_type = super::ContentType::from(content_type);
1076
1077 if !status.is_client_error() && !status.is_server_error() {
1078 let content = resp.text().await?;
1079 match content_type {
1080 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1081 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountCreateSubAccountUniversalTransferV1Resp`"))),
1082 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::SubaccountCreateSubAccountUniversalTransferV1Resp`")))),
1083 }
1084 } else {
1085 let content = resp.text().await?;
1086 let entity: Option<SubaccountCreateSubAccountUniversalTransferV1Error> = serde_json::from_str(&content).ok();
1087 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1088 }
1089}
1090
1091pub async fn subaccount_get_capital_deposit_sub_address_v1(configuration: &configuration::Configuration, params: SubaccountGetCapitalDepositSubAddressV1Params) -> Result<models::SubaccountGetCapitalDepositSubAddressV1Resp, Error<SubaccountGetCapitalDepositSubAddressV1Error>> {
1093
1094 let uri_str = format!("{}/sapi/v1/capital/deposit/subAddress", configuration.base_path);
1095 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1096
1097 let mut query_params: Vec<(String, String)> = Vec::new();
1099
1100 query_params.push(("email".to_string(), params.email.to_string()));
1101 query_params.push(("coin".to_string(), params.coin.to_string()));
1102 if let Some(ref param_value) = params.network {
1103 query_params.push(("network".to_string(), param_value.to_string()));
1104 }
1105 if let Some(ref param_value) = params.amount {
1106 query_params.push(("amount".to_string(), param_value.to_string()));
1107 }
1108 if let Some(ref param_value) = params.recv_window {
1109 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1110 }
1111 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1112
1113 let mut header_params = std::collections::HashMap::new();
1115
1116 if let Some(ref binance_auth) = configuration.binance_auth {
1118 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1120
1121 let body_string: Option<Vec<u8>> = None;
1123
1124 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1126 Ok(sig) => sig,
1127 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1128 };
1129
1130 query_params.push(("signature".to_string(), signature));
1132 }
1133
1134 if !query_params.is_empty() {
1136 req_builder = req_builder.query(&query_params);
1137 }
1138
1139
1140 if let Some(ref user_agent) = configuration.user_agent {
1142 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1143 }
1144
1145 for (header_name, header_value) in header_params {
1147 req_builder = req_builder.header(&header_name, &header_value);
1148 }
1149
1150
1151 let req = req_builder.build()?;
1152 let resp = configuration.client.execute(req).await?;
1153
1154 let status = resp.status();
1155 let content_type = resp
1156 .headers()
1157 .get("content-type")
1158 .and_then(|v| v.to_str().ok())
1159 .unwrap_or("application/octet-stream");
1160 let content_type = super::ContentType::from(content_type);
1161
1162 if !status.is_client_error() && !status.is_server_error() {
1163 let content = resp.text().await?;
1164 match content_type {
1165 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1166 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetCapitalDepositSubAddressV1Resp`"))),
1167 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::SubaccountGetCapitalDepositSubAddressV1Resp`")))),
1168 }
1169 } else {
1170 let content = resp.text().await?;
1171 let entity: Option<SubaccountGetCapitalDepositSubAddressV1Error> = serde_json::from_str(&content).ok();
1172 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1173 }
1174}
1175
1176pub async fn subaccount_get_capital_deposit_sub_hisrec_v1(configuration: &configuration::Configuration, params: SubaccountGetCapitalDepositSubHisrecV1Params) -> Result<Vec<models::SubaccountGetCapitalDepositSubHisrecV1RespItem>, Error<SubaccountGetCapitalDepositSubHisrecV1Error>> {
1178
1179 let uri_str = format!("{}/sapi/v1/capital/deposit/subHisrec", configuration.base_path);
1180 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1181
1182 let mut query_params: Vec<(String, String)> = Vec::new();
1184
1185 query_params.push(("email".to_string(), params.email.to_string()));
1186 if let Some(ref param_value) = params.coin {
1187 query_params.push(("coin".to_string(), param_value.to_string()));
1188 }
1189 if let Some(ref param_value) = params.status {
1190 query_params.push(("status".to_string(), param_value.to_string()));
1191 }
1192 if let Some(ref param_value) = params.start_time {
1193 query_params.push(("startTime".to_string(), param_value.to_string()));
1194 }
1195 if let Some(ref param_value) = params.end_time {
1196 query_params.push(("endTime".to_string(), param_value.to_string()));
1197 }
1198 if let Some(ref param_value) = params.limit {
1199 query_params.push(("limit".to_string(), param_value.to_string()));
1200 }
1201 if let Some(ref param_value) = params.offset {
1202 query_params.push(("offset".to_string(), param_value.to_string()));
1203 }
1204 if let Some(ref param_value) = params.recv_window {
1205 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1206 }
1207 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1208 if let Some(ref param_value) = params.tx_id {
1209 query_params.push(("txId".to_string(), param_value.to_string()));
1210 }
1211
1212 let mut header_params = std::collections::HashMap::new();
1214
1215 if let Some(ref binance_auth) = configuration.binance_auth {
1217 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1219
1220 let body_string: Option<Vec<u8>> = None;
1222
1223 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1225 Ok(sig) => sig,
1226 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1227 };
1228
1229 query_params.push(("signature".to_string(), signature));
1231 }
1232
1233 if !query_params.is_empty() {
1235 req_builder = req_builder.query(&query_params);
1236 }
1237
1238
1239 if let Some(ref user_agent) = configuration.user_agent {
1241 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1242 }
1243
1244 for (header_name, header_value) in header_params {
1246 req_builder = req_builder.header(&header_name, &header_value);
1247 }
1248
1249
1250 let req = req_builder.build()?;
1251 let resp = configuration.client.execute(req).await?;
1252
1253 let status = resp.status();
1254 let content_type = resp
1255 .headers()
1256 .get("content-type")
1257 .and_then(|v| v.to_str().ok())
1258 .unwrap_or("application/octet-stream");
1259 let content_type = super::ContentType::from(content_type);
1260
1261 if !status.is_client_error() && !status.is_server_error() {
1262 let content = resp.text().await?;
1263 match content_type {
1264 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1265 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SubaccountGetCapitalDepositSubHisrecV1RespItem>`"))),
1266 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::SubaccountGetCapitalDepositSubHisrecV1RespItem>`")))),
1267 }
1268 } else {
1269 let content = resp.text().await?;
1270 let entity: Option<SubaccountGetCapitalDepositSubHisrecV1Error> = serde_json::from_str(&content).ok();
1271 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1272 }
1273}
1274
1275pub async fn subaccount_get_sub_account_assets_v3(configuration: &configuration::Configuration, params: SubaccountGetSubAccountAssetsV3Params) -> Result<models::SubaccountGetSubAccountAssetsV3Resp, Error<SubaccountGetSubAccountAssetsV3Error>> {
1277
1278 let uri_str = format!("{}/sapi/v3/sub-account/assets", configuration.base_path);
1279 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1280
1281 let mut query_params: Vec<(String, String)> = Vec::new();
1283
1284 query_params.push(("email".to_string(), params.email.to_string()));
1285 if let Some(ref param_value) = params.recv_window {
1286 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1287 }
1288 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1289
1290 let mut header_params = std::collections::HashMap::new();
1292
1293 if let Some(ref binance_auth) = configuration.binance_auth {
1295 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1297
1298 let body_string: Option<Vec<u8>> = None;
1300
1301 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1303 Ok(sig) => sig,
1304 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1305 };
1306
1307 query_params.push(("signature".to_string(), signature));
1309 }
1310
1311 if !query_params.is_empty() {
1313 req_builder = req_builder.query(&query_params);
1314 }
1315
1316
1317 if let Some(ref user_agent) = configuration.user_agent {
1319 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1320 }
1321
1322 for (header_name, header_value) in header_params {
1324 req_builder = req_builder.header(&header_name, &header_value);
1325 }
1326
1327
1328 let req = req_builder.build()?;
1329 let resp = configuration.client.execute(req).await?;
1330
1331 let status = resp.status();
1332 let content_type = resp
1333 .headers()
1334 .get("content-type")
1335 .and_then(|v| v.to_str().ok())
1336 .unwrap_or("application/octet-stream");
1337 let content_type = super::ContentType::from(content_type);
1338
1339 if !status.is_client_error() && !status.is_server_error() {
1340 let content = resp.text().await?;
1341 match content_type {
1342 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1343 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountAssetsV3Resp`"))),
1344 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::SubaccountGetSubAccountAssetsV3Resp`")))),
1345 }
1346 } else {
1347 let content = resp.text().await?;
1348 let entity: Option<SubaccountGetSubAccountAssetsV3Error> = serde_json::from_str(&content).ok();
1349 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1350 }
1351}
1352
1353pub async fn subaccount_get_sub_account_assets_v4(configuration: &configuration::Configuration, params: SubaccountGetSubAccountAssetsV4Params) -> Result<models::SubaccountGetSubAccountAssetsV4Resp, Error<SubaccountGetSubAccountAssetsV4Error>> {
1355
1356 let uri_str = format!("{}/sapi/v4/sub-account/assets", configuration.base_path);
1357 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1358
1359 let mut query_params: Vec<(String, String)> = Vec::new();
1361
1362 query_params.push(("email".to_string(), params.email.to_string()));
1363 if let Some(ref param_value) = params.recv_window {
1364 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1365 }
1366 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1367
1368 let mut header_params = std::collections::HashMap::new();
1370
1371 if let Some(ref binance_auth) = configuration.binance_auth {
1373 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1375
1376 let body_string: Option<Vec<u8>> = None;
1378
1379 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1381 Ok(sig) => sig,
1382 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1383 };
1384
1385 query_params.push(("signature".to_string(), signature));
1387 }
1388
1389 if !query_params.is_empty() {
1391 req_builder = req_builder.query(&query_params);
1392 }
1393
1394
1395 if let Some(ref user_agent) = configuration.user_agent {
1397 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1398 }
1399
1400 for (header_name, header_value) in header_params {
1402 req_builder = req_builder.header(&header_name, &header_value);
1403 }
1404
1405
1406 let req = req_builder.build()?;
1407 let resp = configuration.client.execute(req).await?;
1408
1409 let status = resp.status();
1410 let content_type = resp
1411 .headers()
1412 .get("content-type")
1413 .and_then(|v| v.to_str().ok())
1414 .unwrap_or("application/octet-stream");
1415 let content_type = super::ContentType::from(content_type);
1416
1417 if !status.is_client_error() && !status.is_server_error() {
1418 let content = resp.text().await?;
1419 match content_type {
1420 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1421 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountAssetsV4Resp`"))),
1422 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::SubaccountGetSubAccountAssetsV4Resp`")))),
1423 }
1424 } else {
1425 let content = resp.text().await?;
1426 let entity: Option<SubaccountGetSubAccountAssetsV4Error> = serde_json::from_str(&content).ok();
1427 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1428 }
1429}
1430
1431pub async fn subaccount_get_sub_account_futures_account_summary_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesAccountSummaryV1Params) -> Result<models::SubaccountGetSubAccountFuturesAccountSummaryV1Resp, Error<SubaccountGetSubAccountFuturesAccountSummaryV1Error>> {
1433
1434 let uri_str = format!("{}/sapi/v1/sub-account/futures/accountSummary", configuration.base_path);
1435 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1436
1437 let mut query_params: Vec<(String, String)> = Vec::new();
1439
1440 if let Some(ref param_value) = params.recv_window {
1441 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1442 }
1443 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1444
1445 let mut header_params = std::collections::HashMap::new();
1447
1448 if let Some(ref binance_auth) = configuration.binance_auth {
1450 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1452
1453 let body_string: Option<Vec<u8>> = None;
1455
1456 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1458 Ok(sig) => sig,
1459 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1460 };
1461
1462 query_params.push(("signature".to_string(), signature));
1464 }
1465
1466 if !query_params.is_empty() {
1468 req_builder = req_builder.query(&query_params);
1469 }
1470
1471
1472 if let Some(ref user_agent) = configuration.user_agent {
1474 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1475 }
1476
1477 for (header_name, header_value) in header_params {
1479 req_builder = req_builder.header(&header_name, &header_value);
1480 }
1481
1482
1483 let req = req_builder.build()?;
1484 let resp = configuration.client.execute(req).await?;
1485
1486 let status = resp.status();
1487 let content_type = resp
1488 .headers()
1489 .get("content-type")
1490 .and_then(|v| v.to_str().ok())
1491 .unwrap_or("application/octet-stream");
1492 let content_type = super::ContentType::from(content_type);
1493
1494 if !status.is_client_error() && !status.is_server_error() {
1495 let content = resp.text().await?;
1496 match content_type {
1497 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1498 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountFuturesAccountSummaryV1Resp`"))),
1499 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::SubaccountGetSubAccountFuturesAccountSummaryV1Resp`")))),
1500 }
1501 } else {
1502 let content = resp.text().await?;
1503 let entity: Option<SubaccountGetSubAccountFuturesAccountSummaryV1Error> = serde_json::from_str(&content).ok();
1504 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1505 }
1506}
1507
1508pub async fn subaccount_get_sub_account_futures_account_summary_v2(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesAccountSummaryV2Params) -> Result<models::SubaccountGetSubAccountFuturesAccountSummaryV2Resp, Error<SubaccountGetSubAccountFuturesAccountSummaryV2Error>> {
1510
1511 let uri_str = format!("{}/sapi/v2/sub-account/futures/accountSummary", configuration.base_path);
1512 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1513
1514 let mut query_params: Vec<(String, String)> = Vec::new();
1516
1517 query_params.push(("futuresType".to_string(), params.futures_type.to_string()));
1518 if let Some(ref param_value) = params.page {
1519 query_params.push(("page".to_string(), param_value.to_string()));
1520 }
1521 if let Some(ref param_value) = params.limit {
1522 query_params.push(("limit".to_string(), param_value.to_string()));
1523 }
1524 if let Some(ref param_value) = params.recv_window {
1525 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1526 }
1527 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1528
1529 let mut header_params = std::collections::HashMap::new();
1531
1532 if let Some(ref binance_auth) = configuration.binance_auth {
1534 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1536
1537 let body_string: Option<Vec<u8>> = None;
1539
1540 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1542 Ok(sig) => sig,
1543 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1544 };
1545
1546 query_params.push(("signature".to_string(), signature));
1548 }
1549
1550 if !query_params.is_empty() {
1552 req_builder = req_builder.query(&query_params);
1553 }
1554
1555
1556 if let Some(ref user_agent) = configuration.user_agent {
1558 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1559 }
1560
1561 for (header_name, header_value) in header_params {
1563 req_builder = req_builder.header(&header_name, &header_value);
1564 }
1565
1566
1567 let req = req_builder.build()?;
1568 let resp = configuration.client.execute(req).await?;
1569
1570 let status = resp.status();
1571 let content_type = resp
1572 .headers()
1573 .get("content-type")
1574 .and_then(|v| v.to_str().ok())
1575 .unwrap_or("application/octet-stream");
1576 let content_type = super::ContentType::from(content_type);
1577
1578 if !status.is_client_error() && !status.is_server_error() {
1579 let content = resp.text().await?;
1580 match content_type {
1581 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1582 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountFuturesAccountSummaryV2Resp`"))),
1583 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::SubaccountGetSubAccountFuturesAccountSummaryV2Resp`")))),
1584 }
1585 } else {
1586 let content = resp.text().await?;
1587 let entity: Option<SubaccountGetSubAccountFuturesAccountSummaryV2Error> = serde_json::from_str(&content).ok();
1588 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1589 }
1590}
1591
1592pub async fn subaccount_get_sub_account_futures_account_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesAccountV1Params) -> Result<models::SubaccountGetSubAccountFuturesAccountV1Resp, Error<SubaccountGetSubAccountFuturesAccountV1Error>> {
1594
1595 let uri_str = format!("{}/sapi/v1/sub-account/futures/account", configuration.base_path);
1596 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1597
1598 let mut query_params: Vec<(String, String)> = Vec::new();
1600
1601 query_params.push(("email".to_string(), params.email.to_string()));
1602 if let Some(ref param_value) = params.recv_window {
1603 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1604 }
1605 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1606
1607 let mut header_params = std::collections::HashMap::new();
1609
1610 if let Some(ref binance_auth) = configuration.binance_auth {
1612 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1614
1615 let body_string: Option<Vec<u8>> = None;
1617
1618 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1620 Ok(sig) => sig,
1621 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1622 };
1623
1624 query_params.push(("signature".to_string(), signature));
1626 }
1627
1628 if !query_params.is_empty() {
1630 req_builder = req_builder.query(&query_params);
1631 }
1632
1633
1634 if let Some(ref user_agent) = configuration.user_agent {
1636 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1637 }
1638
1639 for (header_name, header_value) in header_params {
1641 req_builder = req_builder.header(&header_name, &header_value);
1642 }
1643
1644
1645 let req = req_builder.build()?;
1646 let resp = configuration.client.execute(req).await?;
1647
1648 let status = resp.status();
1649 let content_type = resp
1650 .headers()
1651 .get("content-type")
1652 .and_then(|v| v.to_str().ok())
1653 .unwrap_or("application/octet-stream");
1654 let content_type = super::ContentType::from(content_type);
1655
1656 if !status.is_client_error() && !status.is_server_error() {
1657 let content = resp.text().await?;
1658 match content_type {
1659 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1660 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountFuturesAccountV1Resp`"))),
1661 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::SubaccountGetSubAccountFuturesAccountV1Resp`")))),
1662 }
1663 } else {
1664 let content = resp.text().await?;
1665 let entity: Option<SubaccountGetSubAccountFuturesAccountV1Error> = serde_json::from_str(&content).ok();
1666 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1667 }
1668}
1669
1670pub async fn subaccount_get_sub_account_futures_account_v2(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesAccountV2Params) -> Result<models::SubaccountGetSubAccountFuturesAccountV2Resp, Error<SubaccountGetSubAccountFuturesAccountV2Error>> {
1672
1673 let uri_str = format!("{}/sapi/v2/sub-account/futures/account", configuration.base_path);
1674 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1675
1676 let mut query_params: Vec<(String, String)> = Vec::new();
1678
1679 query_params.push(("email".to_string(), params.email.to_string()));
1680 query_params.push(("futuresType".to_string(), params.futures_type.to_string()));
1681 if let Some(ref param_value) = params.recv_window {
1682 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1683 }
1684 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1685
1686 let mut header_params = std::collections::HashMap::new();
1688
1689 if let Some(ref binance_auth) = configuration.binance_auth {
1691 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1693
1694 let body_string: Option<Vec<u8>> = None;
1696
1697 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1699 Ok(sig) => sig,
1700 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1701 };
1702
1703 query_params.push(("signature".to_string(), signature));
1705 }
1706
1707 if !query_params.is_empty() {
1709 req_builder = req_builder.query(&query_params);
1710 }
1711
1712
1713 if let Some(ref user_agent) = configuration.user_agent {
1715 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1716 }
1717
1718 for (header_name, header_value) in header_params {
1720 req_builder = req_builder.header(&header_name, &header_value);
1721 }
1722
1723
1724 let req = req_builder.build()?;
1725 let resp = configuration.client.execute(req).await?;
1726
1727 let status = resp.status();
1728 let content_type = resp
1729 .headers()
1730 .get("content-type")
1731 .and_then(|v| v.to_str().ok())
1732 .unwrap_or("application/octet-stream");
1733 let content_type = super::ContentType::from(content_type);
1734
1735 if !status.is_client_error() && !status.is_server_error() {
1736 let content = resp.text().await?;
1737 match content_type {
1738 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1739 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountFuturesAccountV2Resp`"))),
1740 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::SubaccountGetSubAccountFuturesAccountV2Resp`")))),
1741 }
1742 } else {
1743 let content = resp.text().await?;
1744 let entity: Option<SubaccountGetSubAccountFuturesAccountV2Error> = serde_json::from_str(&content).ok();
1745 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1746 }
1747}
1748
1749pub async fn subaccount_get_sub_account_futures_internal_transfer_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesInternalTransferV1Params) -> Result<models::SubaccountGetSubAccountFuturesInternalTransferV1Resp, Error<SubaccountGetSubAccountFuturesInternalTransferV1Error>> {
1751
1752 let uri_str = format!("{}/sapi/v1/sub-account/futures/internalTransfer", configuration.base_path);
1753 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1754
1755 let mut query_params: Vec<(String, String)> = Vec::new();
1757
1758 query_params.push(("email".to_string(), params.email.to_string()));
1759 query_params.push(("futuresType".to_string(), params.futures_type.to_string()));
1760 if let Some(ref param_value) = params.start_time {
1761 query_params.push(("startTime".to_string(), param_value.to_string()));
1762 }
1763 if let Some(ref param_value) = params.end_time {
1764 query_params.push(("endTime".to_string(), param_value.to_string()));
1765 }
1766 if let Some(ref param_value) = params.page {
1767 query_params.push(("page".to_string(), param_value.to_string()));
1768 }
1769 if let Some(ref param_value) = params.limit {
1770 query_params.push(("limit".to_string(), param_value.to_string()));
1771 }
1772 if let Some(ref param_value) = params.recv_window {
1773 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1774 }
1775 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1776
1777 let mut header_params = std::collections::HashMap::new();
1779
1780 if let Some(ref binance_auth) = configuration.binance_auth {
1782 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1784
1785 let body_string: Option<Vec<u8>> = None;
1787
1788 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1790 Ok(sig) => sig,
1791 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1792 };
1793
1794 query_params.push(("signature".to_string(), signature));
1796 }
1797
1798 if !query_params.is_empty() {
1800 req_builder = req_builder.query(&query_params);
1801 }
1802
1803
1804 if let Some(ref user_agent) = configuration.user_agent {
1806 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1807 }
1808
1809 for (header_name, header_value) in header_params {
1811 req_builder = req_builder.header(&header_name, &header_value);
1812 }
1813
1814
1815 let req = req_builder.build()?;
1816 let resp = configuration.client.execute(req).await?;
1817
1818 let status = resp.status();
1819 let content_type = resp
1820 .headers()
1821 .get("content-type")
1822 .and_then(|v| v.to_str().ok())
1823 .unwrap_or("application/octet-stream");
1824 let content_type = super::ContentType::from(content_type);
1825
1826 if !status.is_client_error() && !status.is_server_error() {
1827 let content = resp.text().await?;
1828 match content_type {
1829 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1830 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountFuturesInternalTransferV1Resp`"))),
1831 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::SubaccountGetSubAccountFuturesInternalTransferV1Resp`")))),
1832 }
1833 } else {
1834 let content = resp.text().await?;
1835 let entity: Option<SubaccountGetSubAccountFuturesInternalTransferV1Error> = serde_json::from_str(&content).ok();
1836 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1837 }
1838}
1839
1840pub async fn subaccount_get_sub_account_futures_move_position_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesMovePositionV1Params) -> Result<models::SubaccountGetSubAccountFuturesMovePositionV1Resp, Error<SubaccountGetSubAccountFuturesMovePositionV1Error>> {
1842
1843 let uri_str = format!("{}/sapi/v1/sub-account/futures/move-position", configuration.base_path);
1844 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1845
1846 let mut query_params: Vec<(String, String)> = Vec::new();
1848
1849 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1850 if let Some(ref param_value) = params.start_time {
1851 query_params.push(("startTime".to_string(), param_value.to_string()));
1852 }
1853 if let Some(ref param_value) = params.end_time {
1854 query_params.push(("endTime".to_string(), param_value.to_string()));
1855 }
1856 query_params.push(("page".to_string(), params.page.to_string()));
1857 query_params.push(("row".to_string(), params.row.to_string()));
1858 if let Some(ref param_value) = params.recv_window {
1859 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1860 }
1861 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1862
1863 let mut header_params = std::collections::HashMap::new();
1865
1866 if let Some(ref binance_auth) = configuration.binance_auth {
1868 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1870
1871 let body_string: Option<Vec<u8>> = None;
1873
1874 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1876 Ok(sig) => sig,
1877 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1878 };
1879
1880 query_params.push(("signature".to_string(), signature));
1882 }
1883
1884 if !query_params.is_empty() {
1886 req_builder = req_builder.query(&query_params);
1887 }
1888
1889
1890 if let Some(ref user_agent) = configuration.user_agent {
1892 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1893 }
1894
1895 for (header_name, header_value) in header_params {
1897 req_builder = req_builder.header(&header_name, &header_value);
1898 }
1899
1900
1901 let req = req_builder.build()?;
1902 let resp = configuration.client.execute(req).await?;
1903
1904 let status = resp.status();
1905 let content_type = resp
1906 .headers()
1907 .get("content-type")
1908 .and_then(|v| v.to_str().ok())
1909 .unwrap_or("application/octet-stream");
1910 let content_type = super::ContentType::from(content_type);
1911
1912 if !status.is_client_error() && !status.is_server_error() {
1913 let content = resp.text().await?;
1914 match content_type {
1915 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1916 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountFuturesMovePositionV1Resp`"))),
1917 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::SubaccountGetSubAccountFuturesMovePositionV1Resp`")))),
1918 }
1919 } else {
1920 let content = resp.text().await?;
1921 let entity: Option<SubaccountGetSubAccountFuturesMovePositionV1Error> = serde_json::from_str(&content).ok();
1922 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1923 }
1924}
1925
1926pub async fn subaccount_get_sub_account_margin_account_summary_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountMarginAccountSummaryV1Params) -> Result<models::SubaccountGetSubAccountMarginAccountSummaryV1Resp, Error<SubaccountGetSubAccountMarginAccountSummaryV1Error>> {
1928
1929 let uri_str = format!("{}/sapi/v1/sub-account/margin/accountSummary", configuration.base_path);
1930 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1931
1932 let mut query_params: Vec<(String, String)> = Vec::new();
1934
1935 if let Some(ref param_value) = params.recv_window {
1936 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1937 }
1938 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1939
1940 let mut header_params = std::collections::HashMap::new();
1942
1943 if let Some(ref binance_auth) = configuration.binance_auth {
1945 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1947
1948 let body_string: Option<Vec<u8>> = None;
1950
1951 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1953 Ok(sig) => sig,
1954 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1955 };
1956
1957 query_params.push(("signature".to_string(), signature));
1959 }
1960
1961 if !query_params.is_empty() {
1963 req_builder = req_builder.query(&query_params);
1964 }
1965
1966
1967 if let Some(ref user_agent) = configuration.user_agent {
1969 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1970 }
1971
1972 for (header_name, header_value) in header_params {
1974 req_builder = req_builder.header(&header_name, &header_value);
1975 }
1976
1977
1978 let req = req_builder.build()?;
1979 let resp = configuration.client.execute(req).await?;
1980
1981 let status = resp.status();
1982 let content_type = resp
1983 .headers()
1984 .get("content-type")
1985 .and_then(|v| v.to_str().ok())
1986 .unwrap_or("application/octet-stream");
1987 let content_type = super::ContentType::from(content_type);
1988
1989 if !status.is_client_error() && !status.is_server_error() {
1990 let content = resp.text().await?;
1991 match content_type {
1992 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1993 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountMarginAccountSummaryV1Resp`"))),
1994 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::SubaccountGetSubAccountMarginAccountSummaryV1Resp`")))),
1995 }
1996 } else {
1997 let content = resp.text().await?;
1998 let entity: Option<SubaccountGetSubAccountMarginAccountSummaryV1Error> = serde_json::from_str(&content).ok();
1999 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2000 }
2001}
2002
2003pub async fn subaccount_get_sub_account_margin_account_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountMarginAccountV1Params) -> Result<models::SubaccountGetSubAccountMarginAccountV1Resp, Error<SubaccountGetSubAccountMarginAccountV1Error>> {
2005
2006 let uri_str = format!("{}/sapi/v1/sub-account/margin/account", configuration.base_path);
2007 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2008
2009 let mut query_params: Vec<(String, String)> = Vec::new();
2011
2012 query_params.push(("email".to_string(), params.email.to_string()));
2013 if let Some(ref param_value) = params.recv_window {
2014 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2015 }
2016 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2017
2018 let mut header_params = std::collections::HashMap::new();
2020
2021 if let Some(ref binance_auth) = configuration.binance_auth {
2023 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2025
2026 let body_string: Option<Vec<u8>> = None;
2028
2029 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2031 Ok(sig) => sig,
2032 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2033 };
2034
2035 query_params.push(("signature".to_string(), signature));
2037 }
2038
2039 if !query_params.is_empty() {
2041 req_builder = req_builder.query(&query_params);
2042 }
2043
2044
2045 if let Some(ref user_agent) = configuration.user_agent {
2047 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2048 }
2049
2050 for (header_name, header_value) in header_params {
2052 req_builder = req_builder.header(&header_name, &header_value);
2053 }
2054
2055
2056 let req = req_builder.build()?;
2057 let resp = configuration.client.execute(req).await?;
2058
2059 let status = resp.status();
2060 let content_type = resp
2061 .headers()
2062 .get("content-type")
2063 .and_then(|v| v.to_str().ok())
2064 .unwrap_or("application/octet-stream");
2065 let content_type = super::ContentType::from(content_type);
2066
2067 if !status.is_client_error() && !status.is_server_error() {
2068 let content = resp.text().await?;
2069 match content_type {
2070 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2071 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountMarginAccountV1Resp`"))),
2072 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::SubaccountGetSubAccountMarginAccountV1Resp`")))),
2073 }
2074 } else {
2075 let content = resp.text().await?;
2076 let entity: Option<SubaccountGetSubAccountMarginAccountV1Error> = serde_json::from_str(&content).ok();
2077 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2078 }
2079}
2080
2081pub async fn subaccount_get_sub_account_spot_summary_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountSpotSummaryV1Params) -> Result<models::SubaccountGetSubAccountSpotSummaryV1Resp, Error<SubaccountGetSubAccountSpotSummaryV1Error>> {
2083
2084 let uri_str = format!("{}/sapi/v1/sub-account/spotSummary", configuration.base_path);
2085 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2086
2087 let mut query_params: Vec<(String, String)> = Vec::new();
2089
2090 if let Some(ref param_value) = params.email {
2091 query_params.push(("email".to_string(), param_value.to_string()));
2092 }
2093 if let Some(ref param_value) = params.page {
2094 query_params.push(("page".to_string(), param_value.to_string()));
2095 }
2096 if let Some(ref param_value) = params.size {
2097 query_params.push(("size".to_string(), param_value.to_string()));
2098 }
2099 if let Some(ref param_value) = params.recv_window {
2100 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2101 }
2102 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2103
2104 let mut header_params = std::collections::HashMap::new();
2106
2107 if let Some(ref binance_auth) = configuration.binance_auth {
2109 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2111
2112 let body_string: Option<Vec<u8>> = None;
2114
2115 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2117 Ok(sig) => sig,
2118 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2119 };
2120
2121 query_params.push(("signature".to_string(), signature));
2123 }
2124
2125 if !query_params.is_empty() {
2127 req_builder = req_builder.query(&query_params);
2128 }
2129
2130
2131 if let Some(ref user_agent) = configuration.user_agent {
2133 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2134 }
2135
2136 for (header_name, header_value) in header_params {
2138 req_builder = req_builder.header(&header_name, &header_value);
2139 }
2140
2141
2142 let req = req_builder.build()?;
2143 let resp = configuration.client.execute(req).await?;
2144
2145 let status = resp.status();
2146 let content_type = resp
2147 .headers()
2148 .get("content-type")
2149 .and_then(|v| v.to_str().ok())
2150 .unwrap_or("application/octet-stream");
2151 let content_type = super::ContentType::from(content_type);
2152
2153 if !status.is_client_error() && !status.is_server_error() {
2154 let content = resp.text().await?;
2155 match content_type {
2156 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2157 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountSpotSummaryV1Resp`"))),
2158 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::SubaccountGetSubAccountSpotSummaryV1Resp`")))),
2159 }
2160 } else {
2161 let content = resp.text().await?;
2162 let entity: Option<SubaccountGetSubAccountSpotSummaryV1Error> = serde_json::from_str(&content).ok();
2163 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2164 }
2165}
2166
2167pub async fn subaccount_get_sub_account_sub_transfer_history_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountSubTransferHistoryV1Params) -> Result<Vec<models::SubaccountGetSubAccountSubTransferHistoryV1RespItem>, Error<SubaccountGetSubAccountSubTransferHistoryV1Error>> {
2169
2170 let uri_str = format!("{}/sapi/v1/sub-account/sub/transfer/history", configuration.base_path);
2171 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2172
2173 let mut query_params: Vec<(String, String)> = Vec::new();
2175
2176 if let Some(ref param_value) = params.from_email {
2177 query_params.push(("fromEmail".to_string(), param_value.to_string()));
2178 }
2179 if let Some(ref param_value) = params.to_email {
2180 query_params.push(("toEmail".to_string(), param_value.to_string()));
2181 }
2182 if let Some(ref param_value) = params.start_time {
2183 query_params.push(("startTime".to_string(), param_value.to_string()));
2184 }
2185 if let Some(ref param_value) = params.end_time {
2186 query_params.push(("endTime".to_string(), param_value.to_string()));
2187 }
2188 if let Some(ref param_value) = params.page {
2189 query_params.push(("page".to_string(), param_value.to_string()));
2190 }
2191 if let Some(ref param_value) = params.limit {
2192 query_params.push(("limit".to_string(), param_value.to_string()));
2193 }
2194 if let Some(ref param_value) = params.recv_window {
2195 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2196 }
2197 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2198
2199 let mut header_params = std::collections::HashMap::new();
2201
2202 if let Some(ref binance_auth) = configuration.binance_auth {
2204 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2206
2207 let body_string: Option<Vec<u8>> = None;
2209
2210 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2212 Ok(sig) => sig,
2213 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2214 };
2215
2216 query_params.push(("signature".to_string(), signature));
2218 }
2219
2220 if !query_params.is_empty() {
2222 req_builder = req_builder.query(&query_params);
2223 }
2224
2225
2226 if let Some(ref user_agent) = configuration.user_agent {
2228 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2229 }
2230
2231 for (header_name, header_value) in header_params {
2233 req_builder = req_builder.header(&header_name, &header_value);
2234 }
2235
2236
2237 let req = req_builder.build()?;
2238 let resp = configuration.client.execute(req).await?;
2239
2240 let status = resp.status();
2241 let content_type = resp
2242 .headers()
2243 .get("content-type")
2244 .and_then(|v| v.to_str().ok())
2245 .unwrap_or("application/octet-stream");
2246 let content_type = super::ContentType::from(content_type);
2247
2248 if !status.is_client_error() && !status.is_server_error() {
2249 let content = resp.text().await?;
2250 match content_type {
2251 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2252 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SubaccountGetSubAccountSubTransferHistoryV1RespItem>`"))),
2253 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::SubaccountGetSubAccountSubTransferHistoryV1RespItem>`")))),
2254 }
2255 } else {
2256 let content = resp.text().await?;
2257 let entity: Option<SubaccountGetSubAccountSubTransferHistoryV1Error> = serde_json::from_str(&content).ok();
2258 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2259 }
2260}
2261
2262pub async fn subaccount_get_sub_account_transfer_sub_user_history_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountTransferSubUserHistoryV1Params) -> Result<Vec<models::SubaccountGetSubAccountTransferSubUserHistoryV1RespItem>, Error<SubaccountGetSubAccountTransferSubUserHistoryV1Error>> {
2264
2265 let uri_str = format!("{}/sapi/v1/sub-account/transfer/subUserHistory", configuration.base_path);
2266 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2267
2268 let mut query_params: Vec<(String, String)> = Vec::new();
2270
2271 if let Some(ref param_value) = params.asset {
2272 query_params.push(("asset".to_string(), param_value.to_string()));
2273 }
2274 if let Some(ref param_value) = params.r#type {
2275 query_params.push(("type".to_string(), param_value.to_string()));
2276 }
2277 if let Some(ref param_value) = params.start_time {
2278 query_params.push(("startTime".to_string(), param_value.to_string()));
2279 }
2280 if let Some(ref param_value) = params.end_time {
2281 query_params.push(("endTime".to_string(), param_value.to_string()));
2282 }
2283 if let Some(ref param_value) = params.limit {
2284 query_params.push(("limit".to_string(), param_value.to_string()));
2285 }
2286 if let Some(ref param_value) = params.return_fail_history {
2287 query_params.push(("returnFailHistory".to_string(), param_value.to_string()));
2288 }
2289 if let Some(ref param_value) = params.recv_window {
2290 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2291 }
2292 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2293
2294 let mut header_params = std::collections::HashMap::new();
2296
2297 if let Some(ref binance_auth) = configuration.binance_auth {
2299 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2301
2302 let body_string: Option<Vec<u8>> = None;
2304
2305 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2307 Ok(sig) => sig,
2308 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2309 };
2310
2311 query_params.push(("signature".to_string(), signature));
2313 }
2314
2315 if !query_params.is_empty() {
2317 req_builder = req_builder.query(&query_params);
2318 }
2319
2320
2321 if let Some(ref user_agent) = configuration.user_agent {
2323 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2324 }
2325
2326 for (header_name, header_value) in header_params {
2328 req_builder = req_builder.header(&header_name, &header_value);
2329 }
2330
2331
2332 let req = req_builder.build()?;
2333 let resp = configuration.client.execute(req).await?;
2334
2335 let status = resp.status();
2336 let content_type = resp
2337 .headers()
2338 .get("content-type")
2339 .and_then(|v| v.to_str().ok())
2340 .unwrap_or("application/octet-stream");
2341 let content_type = super::ContentType::from(content_type);
2342
2343 if !status.is_client_error() && !status.is_server_error() {
2344 let content = resp.text().await?;
2345 match content_type {
2346 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2347 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SubaccountGetSubAccountTransferSubUserHistoryV1RespItem>`"))),
2348 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::SubaccountGetSubAccountTransferSubUserHistoryV1RespItem>`")))),
2349 }
2350 } else {
2351 let content = resp.text().await?;
2352 let entity: Option<SubaccountGetSubAccountTransferSubUserHistoryV1Error> = serde_json::from_str(&content).ok();
2353 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2354 }
2355}
2356
2357pub async fn subaccount_get_sub_account_universal_transfer_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountUniversalTransferV1Params) -> Result<models::SubaccountGetSubAccountUniversalTransferV1Resp, Error<SubaccountGetSubAccountUniversalTransferV1Error>> {
2359
2360 let uri_str = format!("{}/sapi/v1/sub-account/universalTransfer", configuration.base_path);
2361 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2362
2363 let mut query_params: Vec<(String, String)> = Vec::new();
2365
2366 if let Some(ref param_value) = params.from_email {
2367 query_params.push(("fromEmail".to_string(), param_value.to_string()));
2368 }
2369 if let Some(ref param_value) = params.to_email {
2370 query_params.push(("toEmail".to_string(), param_value.to_string()));
2371 }
2372 if let Some(ref param_value) = params.client_tran_id {
2373 query_params.push(("clientTranId".to_string(), param_value.to_string()));
2374 }
2375 if let Some(ref param_value) = params.start_time {
2376 query_params.push(("startTime".to_string(), param_value.to_string()));
2377 }
2378 if let Some(ref param_value) = params.end_time {
2379 query_params.push(("endTime".to_string(), param_value.to_string()));
2380 }
2381 if let Some(ref param_value) = params.page {
2382 query_params.push(("page".to_string(), param_value.to_string()));
2383 }
2384 if let Some(ref param_value) = params.limit {
2385 query_params.push(("limit".to_string(), param_value.to_string()));
2386 }
2387 if let Some(ref param_value) = params.recv_window {
2388 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2389 }
2390 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2391
2392 let mut header_params = std::collections::HashMap::new();
2394
2395 if let Some(ref binance_auth) = configuration.binance_auth {
2397 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2399
2400 let body_string: Option<Vec<u8>> = None;
2402
2403 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2405 Ok(sig) => sig,
2406 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2407 };
2408
2409 query_params.push(("signature".to_string(), signature));
2411 }
2412
2413 if !query_params.is_empty() {
2415 req_builder = req_builder.query(&query_params);
2416 }
2417
2418
2419 if let Some(ref user_agent) = configuration.user_agent {
2421 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2422 }
2423
2424 for (header_name, header_value) in header_params {
2426 req_builder = req_builder.header(&header_name, &header_value);
2427 }
2428
2429
2430 let req = req_builder.build()?;
2431 let resp = configuration.client.execute(req).await?;
2432
2433 let status = resp.status();
2434 let content_type = resp
2435 .headers()
2436 .get("content-type")
2437 .and_then(|v| v.to_str().ok())
2438 .unwrap_or("application/octet-stream");
2439 let content_type = super::ContentType::from(content_type);
2440
2441 if !status.is_client_error() && !status.is_server_error() {
2442 let content = resp.text().await?;
2443 match content_type {
2444 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2445 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubaccountGetSubAccountUniversalTransferV1Resp`"))),
2446 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::SubaccountGetSubAccountUniversalTransferV1Resp`")))),
2447 }
2448 } else {
2449 let content = resp.text().await?;
2450 let entity: Option<SubaccountGetSubAccountUniversalTransferV1Error> = serde_json::from_str(&content).ok();
2451 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2452 }
2453}
2454