1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::derivatives::pmargin::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct PmarginCreateAssetCollectionV1Params {
20 pub asset: String,
21 pub timestamp: i64,
22 pub recv_window: Option<i64>
23}
24
25#[derive(Clone, Debug, Default)]
27pub struct PmarginCreateAutoCollectionV1Params {
28 pub timestamp: i64,
29 pub recv_window: Option<i64>
30}
31
32#[derive(Clone, Debug, Default)]
34pub struct PmarginCreateBnbTransferV1Params {
35 pub amount: String,
36 pub timestamp: i64,
37 pub transfer_side: String,
38 pub recv_window: Option<i64>
39}
40
41#[derive(Clone, Debug, Default)]
43pub struct PmarginCreateCmLeverageV1Params {
44 pub leverage: i32,
45 pub symbol: String,
46 pub timestamp: i64,
47 pub recv_window: Option<i64>
48}
49
50#[derive(Clone, Debug, Default)]
52pub struct PmarginCreateCmPositionSideDualV1Params {
53 pub dual_side_position: String,
54 pub timestamp: i64,
55 pub recv_window: Option<i64>
56}
57
58#[derive(Clone, Debug, Default)]
60pub struct PmarginCreateRepayFuturesNegativeBalanceV1Params {
61 pub timestamp: i64,
62 pub recv_window: Option<i64>
63}
64
65#[derive(Clone, Debug, Default)]
67pub struct PmarginCreateRepayFuturesSwitchV1Params {
68 pub auto_repay: String,
69 pub timestamp: i64,
70 pub recv_window: Option<i64>
71}
72
73#[derive(Clone, Debug, Default)]
75pub struct PmarginCreateUmLeverageV1Params {
76 pub leverage: i32,
77 pub symbol: String,
78 pub timestamp: i64,
79 pub recv_window: Option<i64>
80}
81
82#[derive(Clone, Debug, Default)]
84pub struct PmarginCreateUmPositionSideDualV1Params {
85 pub dual_side_position: String,
86 pub timestamp: i64,
87 pub recv_window: Option<i64>
88}
89
90#[derive(Clone, Debug, Default)]
92pub struct PmarginGetAccountV1Params {
93 pub timestamp: i64,
94 pub recv_window: Option<i64>
95}
96
97#[derive(Clone, Debug, Default)]
99pub struct PmarginGetBalanceV1Params {
100 pub timestamp: i64,
101 pub asset: Option<String>,
102 pub recv_window: Option<i64>
103}
104
105#[derive(Clone, Debug, Default)]
107pub struct PmarginGetCmAccountV1Params {
108 pub timestamp: i64,
109 pub recv_window: Option<i64>
110}
111
112#[derive(Clone, Debug, Default)]
114pub struct PmarginGetCmCommissionRateV1Params {
115 pub symbol: String,
116 pub timestamp: i64,
117 pub recv_window: Option<i64>
118}
119
120#[derive(Clone, Debug, Default)]
122pub struct PmarginGetCmIncomeV1Params {
123 pub timestamp: i64,
124 pub symbol: Option<String>,
125 pub income_type: Option<String>,
127 pub start_time: Option<i64>,
129 pub end_time: Option<i64>,
131 pub page: Option<i32>,
132 pub limit: Option<i32>,
134 pub recv_window: Option<i64>
135}
136
137#[derive(Clone, Debug, Default)]
139pub struct PmarginGetCmLeverageBracketV1Params {
140 pub timestamp: i64,
141 pub symbol: Option<String>,
142 pub recv_window: Option<i64>
143}
144
145#[derive(Clone, Debug, Default)]
147pub struct PmarginGetCmPositionRiskV1Params {
148 pub timestamp: i64,
149 pub margin_asset: Option<String>,
150 pub pair: Option<String>,
151 pub recv_window: Option<i64>
152}
153
154#[derive(Clone, Debug, Default)]
156pub struct PmarginGetCmPositionSideDualV1Params {
157 pub timestamp: i64,
158 pub recv_window: Option<i64>
159}
160
161#[derive(Clone, Debug, Default)]
163pub struct PmarginGetMarginMarginInterestHistoryV1Params {
164 pub timestamp: i64,
165 pub asset: Option<String>,
166 pub start_time: Option<i64>,
167 pub end_time: Option<i64>,
168 pub current: Option<i64>,
170 pub size: Option<i64>,
172 pub archived: Option<String>,
174 pub recv_window: Option<i64>
176}
177
178#[derive(Clone, Debug, Default)]
180pub struct PmarginGetMarginMarginLoanV1Params {
181 pub asset: String,
182 pub timestamp: i64,
183 pub tx_id: Option<i64>,
185 pub start_time: Option<i64>,
186 pub end_time: Option<i64>,
187 pub current: Option<i64>,
189 pub size: Option<i64>,
191 pub archived: Option<String>,
193 pub recv_window: Option<i64>
195}
196
197#[derive(Clone, Debug, Default)]
199pub struct PmarginGetMarginMaxBorrowableV1Params {
200 pub asset: String,
201 pub timestamp: i64,
202 pub recv_window: Option<i64>
204}
205
206#[derive(Clone, Debug, Default)]
208pub struct PmarginGetMarginMaxWithdrawV1Params {
209 pub asset: String,
210 pub timestamp: i64,
211 pub recv_window: Option<i64>
213}
214
215#[derive(Clone, Debug, Default)]
217pub struct PmarginGetMarginRepayLoanV1Params {
218 pub asset: String,
219 pub timestamp: i64,
220 pub tx_id: Option<i64>,
222 pub start_time: Option<i64>,
223 pub end_time: Option<i64>,
224 pub current: Option<i64>,
226 pub size: Option<i64>,
228 pub archived: Option<String>,
230 pub recv_window: Option<i64>
232}
233
234#[derive(Clone, Debug, Default)]
236pub struct PmarginGetPortfolioInterestHistoryV1Params {
237 pub timestamp: i64,
238 pub asset: Option<String>,
239 pub start_time: Option<i64>,
240 pub end_time: Option<i64>,
241 pub size: Option<i64>,
243 pub recv_window: Option<i64>
244}
245
246#[derive(Clone, Debug, Default)]
248pub struct PmarginGetPortfolioNegativeBalanceExchangeRecordV1Params {
249 pub start_time: i64,
250 pub end_time: i64,
251 pub timestamp: i64,
252 pub recv_window: Option<i64>
254}
255
256#[derive(Clone, Debug, Default)]
258pub struct PmarginGetRateLimitOrderV1Params {
259 pub timestamp: i64,
260 pub recv_window: Option<i64>
261}
262
263#[derive(Clone, Debug, Default)]
265pub struct PmarginGetRepayFuturesSwitchV1Params {
266 pub timestamp: i64,
267 pub recv_window: Option<i64>
268}
269
270#[derive(Clone, Debug, Default)]
272pub struct PmarginGetUmAccountConfigV1Params {
273 pub timestamp: i64,
274 pub recv_window: Option<i64>
275}
276
277#[derive(Clone, Debug, Default)]
279pub struct PmarginGetUmAccountV1Params {
280 pub timestamp: i64,
281 pub recv_window: Option<i64>
282}
283
284#[derive(Clone, Debug, Default)]
286pub struct PmarginGetUmAccountV2Params {
287 pub timestamp: i64,
288 pub recv_window: Option<i64>
289}
290
291#[derive(Clone, Debug, Default)]
293pub struct PmarginGetUmApiTradingStatusV1Params {
294 pub timestamp: i64,
295 pub symbol: Option<String>,
296 pub recv_window: Option<i64>
297}
298
299#[derive(Clone, Debug, Default)]
301pub struct PmarginGetUmCommissionRateV1Params {
302 pub symbol: String,
303 pub timestamp: i64,
304 pub recv_window: Option<i64>
305}
306
307#[derive(Clone, Debug, Default)]
309pub struct PmarginGetUmIncomeAsynIdV1Params {
310 pub download_id: String,
312 pub timestamp: i64,
313 pub recv_window: Option<i64>
314}
315
316#[derive(Clone, Debug, Default)]
318pub struct PmarginGetUmIncomeAsynV1Params {
319 pub start_time: i64,
321 pub end_time: i64,
323 pub timestamp: i64,
324 pub recv_window: Option<i64>
325}
326
327#[derive(Clone, Debug, Default)]
329pub struct PmarginGetUmIncomeV1Params {
330 pub timestamp: i64,
331 pub symbol: Option<String>,
332 pub income_type: Option<String>,
334 pub start_time: Option<i64>,
336 pub end_time: Option<i64>,
338 pub page: Option<i32>,
339 pub limit: Option<i32>,
341 pub recv_window: Option<i64>
342}
343
344#[derive(Clone, Debug, Default)]
346pub struct PmarginGetUmLeverageBracketV1Params {
347 pub timestamp: i64,
348 pub symbol: Option<String>,
349 pub recv_window: Option<i64>
350}
351
352#[derive(Clone, Debug, Default)]
354pub struct PmarginGetUmOrderAsynIdV1Params {
355 pub download_id: String,
357 pub timestamp: i64,
358 pub recv_window: Option<i64>
359}
360
361#[derive(Clone, Debug, Default)]
363pub struct PmarginGetUmOrderAsynV1Params {
364 pub start_time: i64,
366 pub end_time: i64,
368 pub timestamp: i64,
369 pub recv_window: Option<i64>
370}
371
372#[derive(Clone, Debug, Default)]
374pub struct PmarginGetUmPositionSideDualV1Params {
375 pub timestamp: i64,
376 pub recv_window: Option<i64>
377}
378
379#[derive(Clone, Debug, Default)]
381pub struct PmarginGetUmSymbolConfigV1Params {
382 pub timestamp: i64,
383 pub symbol: Option<String>,
384 pub recv_window: Option<i64>
385}
386
387#[derive(Clone, Debug, Default)]
389pub struct PmarginGetUmTradeAsynIdV1Params {
390 pub download_id: String,
392 pub timestamp: i64,
393 pub recv_window: Option<i64>
394}
395
396#[derive(Clone, Debug, Default)]
398pub struct PmarginGetUmTradeAsynV1Params {
399 pub start_time: i64,
401 pub end_time: i64,
403 pub timestamp: i64,
404 pub recv_window: Option<i64>
405}
406
407
408#[derive(Debug, Clone, Serialize, Deserialize)]
410#[serde(untagged)]
411pub enum PmarginCreateAssetCollectionV1Error {
412 Status4XX(models::ApiError),
413 Status5XX(models::ApiError),
414 UnknownValue(serde_json::Value),
415}
416
417#[derive(Debug, Clone, Serialize, Deserialize)]
419#[serde(untagged)]
420pub enum PmarginCreateAutoCollectionV1Error {
421 Status4XX(models::ApiError),
422 Status5XX(models::ApiError),
423 UnknownValue(serde_json::Value),
424}
425
426#[derive(Debug, Clone, Serialize, Deserialize)]
428#[serde(untagged)]
429pub enum PmarginCreateBnbTransferV1Error {
430 Status4XX(models::ApiError),
431 Status5XX(models::ApiError),
432 UnknownValue(serde_json::Value),
433}
434
435#[derive(Debug, Clone, Serialize, Deserialize)]
437#[serde(untagged)]
438pub enum PmarginCreateCmLeverageV1Error {
439 Status4XX(models::ApiError),
440 Status5XX(models::ApiError),
441 UnknownValue(serde_json::Value),
442}
443
444#[derive(Debug, Clone, Serialize, Deserialize)]
446#[serde(untagged)]
447pub enum PmarginCreateCmPositionSideDualV1Error {
448 Status4XX(models::ApiError),
449 Status5XX(models::ApiError),
450 UnknownValue(serde_json::Value),
451}
452
453#[derive(Debug, Clone, Serialize, Deserialize)]
455#[serde(untagged)]
456pub enum PmarginCreateRepayFuturesNegativeBalanceV1Error {
457 Status4XX(models::ApiError),
458 Status5XX(models::ApiError),
459 UnknownValue(serde_json::Value),
460}
461
462#[derive(Debug, Clone, Serialize, Deserialize)]
464#[serde(untagged)]
465pub enum PmarginCreateRepayFuturesSwitchV1Error {
466 Status4XX(models::ApiError),
467 Status5XX(models::ApiError),
468 UnknownValue(serde_json::Value),
469}
470
471#[derive(Debug, Clone, Serialize, Deserialize)]
473#[serde(untagged)]
474pub enum PmarginCreateUmLeverageV1Error {
475 Status4XX(models::ApiError),
476 Status5XX(models::ApiError),
477 UnknownValue(serde_json::Value),
478}
479
480#[derive(Debug, Clone, Serialize, Deserialize)]
482#[serde(untagged)]
483pub enum PmarginCreateUmPositionSideDualV1Error {
484 Status4XX(models::ApiError),
485 Status5XX(models::ApiError),
486 UnknownValue(serde_json::Value),
487}
488
489#[derive(Debug, Clone, Serialize, Deserialize)]
491#[serde(untagged)]
492pub enum PmarginGetAccountV1Error {
493 Status4XX(models::ApiError),
494 Status5XX(models::ApiError),
495 UnknownValue(serde_json::Value),
496}
497
498#[derive(Debug, Clone, Serialize, Deserialize)]
500#[serde(untagged)]
501pub enum PmarginGetBalanceV1Error {
502 Status4XX(models::ApiError),
503 Status5XX(models::ApiError),
504 UnknownValue(serde_json::Value),
505}
506
507#[derive(Debug, Clone, Serialize, Deserialize)]
509#[serde(untagged)]
510pub enum PmarginGetCmAccountV1Error {
511 Status4XX(models::ApiError),
512 Status5XX(models::ApiError),
513 UnknownValue(serde_json::Value),
514}
515
516#[derive(Debug, Clone, Serialize, Deserialize)]
518#[serde(untagged)]
519pub enum PmarginGetCmCommissionRateV1Error {
520 Status4XX(models::ApiError),
521 Status5XX(models::ApiError),
522 UnknownValue(serde_json::Value),
523}
524
525#[derive(Debug, Clone, Serialize, Deserialize)]
527#[serde(untagged)]
528pub enum PmarginGetCmIncomeV1Error {
529 Status4XX(models::ApiError),
530 Status5XX(models::ApiError),
531 UnknownValue(serde_json::Value),
532}
533
534#[derive(Debug, Clone, Serialize, Deserialize)]
536#[serde(untagged)]
537pub enum PmarginGetCmLeverageBracketV1Error {
538 Status4XX(models::ApiError),
539 Status5XX(models::ApiError),
540 UnknownValue(serde_json::Value),
541}
542
543#[derive(Debug, Clone, Serialize, Deserialize)]
545#[serde(untagged)]
546pub enum PmarginGetCmPositionRiskV1Error {
547 Status4XX(models::ApiError),
548 Status5XX(models::ApiError),
549 UnknownValue(serde_json::Value),
550}
551
552#[derive(Debug, Clone, Serialize, Deserialize)]
554#[serde(untagged)]
555pub enum PmarginGetCmPositionSideDualV1Error {
556 Status4XX(models::ApiError),
557 Status5XX(models::ApiError),
558 UnknownValue(serde_json::Value),
559}
560
561#[derive(Debug, Clone, Serialize, Deserialize)]
563#[serde(untagged)]
564pub enum PmarginGetMarginMarginInterestHistoryV1Error {
565 Status4XX(models::ApiError),
566 Status5XX(models::ApiError),
567 UnknownValue(serde_json::Value),
568}
569
570#[derive(Debug, Clone, Serialize, Deserialize)]
572#[serde(untagged)]
573pub enum PmarginGetMarginMarginLoanV1Error {
574 Status4XX(models::ApiError),
575 Status5XX(models::ApiError),
576 UnknownValue(serde_json::Value),
577}
578
579#[derive(Debug, Clone, Serialize, Deserialize)]
581#[serde(untagged)]
582pub enum PmarginGetMarginMaxBorrowableV1Error {
583 Status4XX(models::ApiError),
584 Status5XX(models::ApiError),
585 UnknownValue(serde_json::Value),
586}
587
588#[derive(Debug, Clone, Serialize, Deserialize)]
590#[serde(untagged)]
591pub enum PmarginGetMarginMaxWithdrawV1Error {
592 Status4XX(models::ApiError),
593 Status5XX(models::ApiError),
594 UnknownValue(serde_json::Value),
595}
596
597#[derive(Debug, Clone, Serialize, Deserialize)]
599#[serde(untagged)]
600pub enum PmarginGetMarginRepayLoanV1Error {
601 Status4XX(models::ApiError),
602 Status5XX(models::ApiError),
603 UnknownValue(serde_json::Value),
604}
605
606#[derive(Debug, Clone, Serialize, Deserialize)]
608#[serde(untagged)]
609pub enum PmarginGetPortfolioInterestHistoryV1Error {
610 Status4XX(models::ApiError),
611 Status5XX(models::ApiError),
612 UnknownValue(serde_json::Value),
613}
614
615#[derive(Debug, Clone, Serialize, Deserialize)]
617#[serde(untagged)]
618pub enum PmarginGetPortfolioNegativeBalanceExchangeRecordV1Error {
619 Status4XX(models::ApiError),
620 Status5XX(models::ApiError),
621 UnknownValue(serde_json::Value),
622}
623
624#[derive(Debug, Clone, Serialize, Deserialize)]
626#[serde(untagged)]
627pub enum PmarginGetRateLimitOrderV1Error {
628 Status4XX(models::ApiError),
629 Status5XX(models::ApiError),
630 UnknownValue(serde_json::Value),
631}
632
633#[derive(Debug, Clone, Serialize, Deserialize)]
635#[serde(untagged)]
636pub enum PmarginGetRepayFuturesSwitchV1Error {
637 Status4XX(models::ApiError),
638 Status5XX(models::ApiError),
639 UnknownValue(serde_json::Value),
640}
641
642#[derive(Debug, Clone, Serialize, Deserialize)]
644#[serde(untagged)]
645pub enum PmarginGetUmAccountConfigV1Error {
646 Status4XX(models::ApiError),
647 Status5XX(models::ApiError),
648 UnknownValue(serde_json::Value),
649}
650
651#[derive(Debug, Clone, Serialize, Deserialize)]
653#[serde(untagged)]
654pub enum PmarginGetUmAccountV1Error {
655 Status4XX(models::ApiError),
656 Status5XX(models::ApiError),
657 UnknownValue(serde_json::Value),
658}
659
660#[derive(Debug, Clone, Serialize, Deserialize)]
662#[serde(untagged)]
663pub enum PmarginGetUmAccountV2Error {
664 Status4XX(models::ApiError),
665 Status5XX(models::ApiError),
666 UnknownValue(serde_json::Value),
667}
668
669#[derive(Debug, Clone, Serialize, Deserialize)]
671#[serde(untagged)]
672pub enum PmarginGetUmApiTradingStatusV1Error {
673 Status4XX(models::ApiError),
674 Status5XX(models::ApiError),
675 UnknownValue(serde_json::Value),
676}
677
678#[derive(Debug, Clone, Serialize, Deserialize)]
680#[serde(untagged)]
681pub enum PmarginGetUmCommissionRateV1Error {
682 Status4XX(models::ApiError),
683 Status5XX(models::ApiError),
684 UnknownValue(serde_json::Value),
685}
686
687#[derive(Debug, Clone, Serialize, Deserialize)]
689#[serde(untagged)]
690pub enum PmarginGetUmIncomeAsynIdV1Error {
691 Status4XX(models::ApiError),
692 Status5XX(models::ApiError),
693 UnknownValue(serde_json::Value),
694}
695
696#[derive(Debug, Clone, Serialize, Deserialize)]
698#[serde(untagged)]
699pub enum PmarginGetUmIncomeAsynV1Error {
700 Status4XX(models::ApiError),
701 Status5XX(models::ApiError),
702 UnknownValue(serde_json::Value),
703}
704
705#[derive(Debug, Clone, Serialize, Deserialize)]
707#[serde(untagged)]
708pub enum PmarginGetUmIncomeV1Error {
709 Status4XX(models::ApiError),
710 Status5XX(models::ApiError),
711 UnknownValue(serde_json::Value),
712}
713
714#[derive(Debug, Clone, Serialize, Deserialize)]
716#[serde(untagged)]
717pub enum PmarginGetUmLeverageBracketV1Error {
718 Status4XX(models::ApiError),
719 Status5XX(models::ApiError),
720 UnknownValue(serde_json::Value),
721}
722
723#[derive(Debug, Clone, Serialize, Deserialize)]
725#[serde(untagged)]
726pub enum PmarginGetUmOrderAsynIdV1Error {
727 Status4XX(models::ApiError),
728 Status5XX(models::ApiError),
729 UnknownValue(serde_json::Value),
730}
731
732#[derive(Debug, Clone, Serialize, Deserialize)]
734#[serde(untagged)]
735pub enum PmarginGetUmOrderAsynV1Error {
736 Status4XX(models::ApiError),
737 Status5XX(models::ApiError),
738 UnknownValue(serde_json::Value),
739}
740
741#[derive(Debug, Clone, Serialize, Deserialize)]
743#[serde(untagged)]
744pub enum PmarginGetUmPositionRiskV1Error {
745 Status4XX(models::ApiError),
746 Status5XX(models::ApiError),
747 UnknownValue(serde_json::Value),
748}
749
750#[derive(Debug, Clone, Serialize, Deserialize)]
752#[serde(untagged)]
753pub enum PmarginGetUmPositionSideDualV1Error {
754 Status4XX(models::ApiError),
755 Status5XX(models::ApiError),
756 UnknownValue(serde_json::Value),
757}
758
759#[derive(Debug, Clone, Serialize, Deserialize)]
761#[serde(untagged)]
762pub enum PmarginGetUmSymbolConfigV1Error {
763 Status4XX(models::ApiError),
764 Status5XX(models::ApiError),
765 UnknownValue(serde_json::Value),
766}
767
768#[derive(Debug, Clone, Serialize, Deserialize)]
770#[serde(untagged)]
771pub enum PmarginGetUmTradeAsynIdV1Error {
772 Status4XX(models::ApiError),
773 Status5XX(models::ApiError),
774 UnknownValue(serde_json::Value),
775}
776
777#[derive(Debug, Clone, Serialize, Deserialize)]
779#[serde(untagged)]
780pub enum PmarginGetUmTradeAsynV1Error {
781 Status4XX(models::ApiError),
782 Status5XX(models::ApiError),
783 UnknownValue(serde_json::Value),
784}
785
786
787pub async fn pmargin_create_asset_collection_v1(configuration: &configuration::Configuration, params: PmarginCreateAssetCollectionV1Params) -> Result<models::PmarginCreateAssetCollectionV1Resp, Error<PmarginCreateAssetCollectionV1Error>> {
789
790 let uri_str = format!("{}/papi/v1/asset-collection", configuration.base_path);
791 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
792
793 let mut query_params: Vec<(String, String)> = Vec::new();
795
796
797 let mut header_params = std::collections::HashMap::new();
799
800 if let Some(ref binance_auth) = configuration.binance_auth {
802 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
804
805 let body_string: Option<Vec<u8>> = None;
807
808 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
810 Ok(sig) => sig,
811 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
812 };
813
814 query_params.push(("signature".to_string(), signature));
816 }
817
818 if !query_params.is_empty() {
820 req_builder = req_builder.query(&query_params);
821 }
822
823
824 if let Some(ref user_agent) = configuration.user_agent {
826 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
827 }
828
829 for (header_name, header_value) in header_params {
831 req_builder = req_builder.header(&header_name, &header_value);
832 }
833
834 let mut multipart_form_params = std::collections::HashMap::new();
835 multipart_form_params.insert("asset", params.asset.to_string());
836 if let Some(param_value) = params.recv_window {
837 multipart_form_params.insert("recvWindow", param_value.to_string());
838 }
839 multipart_form_params.insert("timestamp", params.timestamp.to_string());
840 req_builder = req_builder.form(&multipart_form_params);
841
842 let req = req_builder.build()?;
843 let resp = configuration.client.execute(req).await?;
844
845 let status = resp.status();
846 let content_type = resp
847 .headers()
848 .get("content-type")
849 .and_then(|v| v.to_str().ok())
850 .unwrap_or("application/octet-stream");
851 let content_type = super::ContentType::from(content_type);
852
853 if !status.is_client_error() && !status.is_server_error() {
854 let content = resp.text().await?;
855 match content_type {
856 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
857 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateAssetCollectionV1Resp`"))),
858 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::PmarginCreateAssetCollectionV1Resp`")))),
859 }
860 } else {
861 let content = resp.text().await?;
862 let entity: Option<PmarginCreateAssetCollectionV1Error> = serde_json::from_str(&content).ok();
863 Err(Error::ResponseError(ResponseContent { status, content, entity }))
864 }
865}
866
867pub async fn pmargin_create_auto_collection_v1(configuration: &configuration::Configuration, params: PmarginCreateAutoCollectionV1Params) -> Result<models::PmarginCreateAutoCollectionV1Resp, Error<PmarginCreateAutoCollectionV1Error>> {
869
870 let uri_str = format!("{}/papi/v1/auto-collection", configuration.base_path);
871 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
872
873 let mut query_params: Vec<(String, String)> = Vec::new();
875
876
877 let mut header_params = std::collections::HashMap::new();
879
880 if let Some(ref binance_auth) = configuration.binance_auth {
882 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
884
885 let body_string: Option<Vec<u8>> = None;
887
888 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
890 Ok(sig) => sig,
891 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
892 };
893
894 query_params.push(("signature".to_string(), signature));
896 }
897
898 if !query_params.is_empty() {
900 req_builder = req_builder.query(&query_params);
901 }
902
903
904 if let Some(ref user_agent) = configuration.user_agent {
906 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
907 }
908
909 for (header_name, header_value) in header_params {
911 req_builder = req_builder.header(&header_name, &header_value);
912 }
913
914 let mut multipart_form_params = std::collections::HashMap::new();
915 if let Some(param_value) = params.recv_window {
916 multipart_form_params.insert("recvWindow", param_value.to_string());
917 }
918 multipart_form_params.insert("timestamp", params.timestamp.to_string());
919 req_builder = req_builder.form(&multipart_form_params);
920
921 let req = req_builder.build()?;
922 let resp = configuration.client.execute(req).await?;
923
924 let status = resp.status();
925 let content_type = resp
926 .headers()
927 .get("content-type")
928 .and_then(|v| v.to_str().ok())
929 .unwrap_or("application/octet-stream");
930 let content_type = super::ContentType::from(content_type);
931
932 if !status.is_client_error() && !status.is_server_error() {
933 let content = resp.text().await?;
934 match content_type {
935 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
936 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateAutoCollectionV1Resp`"))),
937 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::PmarginCreateAutoCollectionV1Resp`")))),
938 }
939 } else {
940 let content = resp.text().await?;
941 let entity: Option<PmarginCreateAutoCollectionV1Error> = serde_json::from_str(&content).ok();
942 Err(Error::ResponseError(ResponseContent { status, content, entity }))
943 }
944}
945
946pub async fn pmargin_create_bnb_transfer_v1(configuration: &configuration::Configuration, params: PmarginCreateBnbTransferV1Params) -> Result<models::PmarginCreateBnbTransferV1Resp, Error<PmarginCreateBnbTransferV1Error>> {
948
949 let uri_str = format!("{}/papi/v1/bnb-transfer", configuration.base_path);
950 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
951
952 let mut query_params: Vec<(String, String)> = Vec::new();
954
955
956 let mut header_params = std::collections::HashMap::new();
958
959 if let Some(ref binance_auth) = configuration.binance_auth {
961 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
963
964 let body_string: Option<Vec<u8>> = None;
966
967 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
969 Ok(sig) => sig,
970 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
971 };
972
973 query_params.push(("signature".to_string(), signature));
975 }
976
977 if !query_params.is_empty() {
979 req_builder = req_builder.query(&query_params);
980 }
981
982
983 if let Some(ref user_agent) = configuration.user_agent {
985 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
986 }
987
988 for (header_name, header_value) in header_params {
990 req_builder = req_builder.header(&header_name, &header_value);
991 }
992
993 let mut multipart_form_params = std::collections::HashMap::new();
994 multipart_form_params.insert("amount", params.amount.to_string());
995 if let Some(param_value) = params.recv_window {
996 multipart_form_params.insert("recvWindow", param_value.to_string());
997 }
998 multipart_form_params.insert("timestamp", params.timestamp.to_string());
999 multipart_form_params.insert("transferSide", params.transfer_side.to_string());
1000 req_builder = req_builder.form(&multipart_form_params);
1001
1002 let req = req_builder.build()?;
1003 let resp = configuration.client.execute(req).await?;
1004
1005 let status = resp.status();
1006 let content_type = resp
1007 .headers()
1008 .get("content-type")
1009 .and_then(|v| v.to_str().ok())
1010 .unwrap_or("application/octet-stream");
1011 let content_type = super::ContentType::from(content_type);
1012
1013 if !status.is_client_error() && !status.is_server_error() {
1014 let content = resp.text().await?;
1015 match content_type {
1016 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1017 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateBnbTransferV1Resp`"))),
1018 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::PmarginCreateBnbTransferV1Resp`")))),
1019 }
1020 } else {
1021 let content = resp.text().await?;
1022 let entity: Option<PmarginCreateBnbTransferV1Error> = serde_json::from_str(&content).ok();
1023 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1024 }
1025}
1026
1027pub async fn pmargin_create_cm_leverage_v1(configuration: &configuration::Configuration, params: PmarginCreateCmLeverageV1Params) -> Result<models::PmarginCreateCmLeverageV1Resp, Error<PmarginCreateCmLeverageV1Error>> {
1029
1030 let uri_str = format!("{}/papi/v1/cm/leverage", configuration.base_path);
1031 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1032
1033 let mut query_params: Vec<(String, String)> = Vec::new();
1035
1036
1037 let mut header_params = std::collections::HashMap::new();
1039
1040 if let Some(ref binance_auth) = configuration.binance_auth {
1042 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1044
1045 let body_string: Option<Vec<u8>> = None;
1047
1048 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1050 Ok(sig) => sig,
1051 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1052 };
1053
1054 query_params.push(("signature".to_string(), signature));
1056 }
1057
1058 if !query_params.is_empty() {
1060 req_builder = req_builder.query(&query_params);
1061 }
1062
1063
1064 if let Some(ref user_agent) = configuration.user_agent {
1066 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1067 }
1068
1069 for (header_name, header_value) in header_params {
1071 req_builder = req_builder.header(&header_name, &header_value);
1072 }
1073
1074 let mut multipart_form_params = std::collections::HashMap::new();
1075 multipart_form_params.insert("leverage", params.leverage.to_string());
1076 if let Some(param_value) = params.recv_window {
1077 multipart_form_params.insert("recvWindow", param_value.to_string());
1078 }
1079 multipart_form_params.insert("symbol", params.symbol.to_string());
1080 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1081 req_builder = req_builder.form(&multipart_form_params);
1082
1083 let req = req_builder.build()?;
1084 let resp = configuration.client.execute(req).await?;
1085
1086 let status = resp.status();
1087 let content_type = resp
1088 .headers()
1089 .get("content-type")
1090 .and_then(|v| v.to_str().ok())
1091 .unwrap_or("application/octet-stream");
1092 let content_type = super::ContentType::from(content_type);
1093
1094 if !status.is_client_error() && !status.is_server_error() {
1095 let content = resp.text().await?;
1096 match content_type {
1097 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1098 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateCmLeverageV1Resp`"))),
1099 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::PmarginCreateCmLeverageV1Resp`")))),
1100 }
1101 } else {
1102 let content = resp.text().await?;
1103 let entity: Option<PmarginCreateCmLeverageV1Error> = serde_json::from_str(&content).ok();
1104 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1105 }
1106}
1107
1108pub async fn pmargin_create_cm_position_side_dual_v1(configuration: &configuration::Configuration, params: PmarginCreateCmPositionSideDualV1Params) -> Result<models::PmarginCreateCmPositionSideDualV1Resp, Error<PmarginCreateCmPositionSideDualV1Error>> {
1110
1111 let uri_str = format!("{}/papi/v1/cm/positionSide/dual", configuration.base_path);
1112 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1113
1114 let mut query_params: Vec<(String, String)> = Vec::new();
1116
1117
1118 let mut header_params = std::collections::HashMap::new();
1120
1121 if let Some(ref binance_auth) = configuration.binance_auth {
1123 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1125
1126 let body_string: Option<Vec<u8>> = None;
1128
1129 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1131 Ok(sig) => sig,
1132 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1133 };
1134
1135 query_params.push(("signature".to_string(), signature));
1137 }
1138
1139 if !query_params.is_empty() {
1141 req_builder = req_builder.query(&query_params);
1142 }
1143
1144
1145 if let Some(ref user_agent) = configuration.user_agent {
1147 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1148 }
1149
1150 for (header_name, header_value) in header_params {
1152 req_builder = req_builder.header(&header_name, &header_value);
1153 }
1154
1155 let mut multipart_form_params = std::collections::HashMap::new();
1156 multipart_form_params.insert("dualSidePosition", params.dual_side_position.to_string());
1157 if let Some(param_value) = params.recv_window {
1158 multipart_form_params.insert("recvWindow", param_value.to_string());
1159 }
1160 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1161 req_builder = req_builder.form(&multipart_form_params);
1162
1163 let req = req_builder.build()?;
1164 let resp = configuration.client.execute(req).await?;
1165
1166 let status = resp.status();
1167 let content_type = resp
1168 .headers()
1169 .get("content-type")
1170 .and_then(|v| v.to_str().ok())
1171 .unwrap_or("application/octet-stream");
1172 let content_type = super::ContentType::from(content_type);
1173
1174 if !status.is_client_error() && !status.is_server_error() {
1175 let content = resp.text().await?;
1176 match content_type {
1177 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1178 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateCmPositionSideDualV1Resp`"))),
1179 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::PmarginCreateCmPositionSideDualV1Resp`")))),
1180 }
1181 } else {
1182 let content = resp.text().await?;
1183 let entity: Option<PmarginCreateCmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
1184 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1185 }
1186}
1187
1188pub async fn pmargin_create_repay_futures_negative_balance_v1(configuration: &configuration::Configuration, params: PmarginCreateRepayFuturesNegativeBalanceV1Params) -> Result<models::PmarginCreateRepayFuturesNegativeBalanceV1Resp, Error<PmarginCreateRepayFuturesNegativeBalanceV1Error>> {
1190
1191 let uri_str = format!("{}/papi/v1/repay-futures-negative-balance", configuration.base_path);
1192 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1193
1194 let mut query_params: Vec<(String, String)> = Vec::new();
1196
1197
1198 let mut header_params = std::collections::HashMap::new();
1200
1201 if let Some(ref binance_auth) = configuration.binance_auth {
1203 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1205
1206 let body_string: Option<Vec<u8>> = None;
1208
1209 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1211 Ok(sig) => sig,
1212 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1213 };
1214
1215 query_params.push(("signature".to_string(), signature));
1217 }
1218
1219 if !query_params.is_empty() {
1221 req_builder = req_builder.query(&query_params);
1222 }
1223
1224
1225 if let Some(ref user_agent) = configuration.user_agent {
1227 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1228 }
1229
1230 for (header_name, header_value) in header_params {
1232 req_builder = req_builder.header(&header_name, &header_value);
1233 }
1234
1235 let mut multipart_form_params = std::collections::HashMap::new();
1236 if let Some(param_value) = params.recv_window {
1237 multipart_form_params.insert("recvWindow", param_value.to_string());
1238 }
1239 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1240 req_builder = req_builder.form(&multipart_form_params);
1241
1242 let req = req_builder.build()?;
1243 let resp = configuration.client.execute(req).await?;
1244
1245 let status = resp.status();
1246 let content_type = resp
1247 .headers()
1248 .get("content-type")
1249 .and_then(|v| v.to_str().ok())
1250 .unwrap_or("application/octet-stream");
1251 let content_type = super::ContentType::from(content_type);
1252
1253 if !status.is_client_error() && !status.is_server_error() {
1254 let content = resp.text().await?;
1255 match content_type {
1256 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1257 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateRepayFuturesNegativeBalanceV1Resp`"))),
1258 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::PmarginCreateRepayFuturesNegativeBalanceV1Resp`")))),
1259 }
1260 } else {
1261 let content = resp.text().await?;
1262 let entity: Option<PmarginCreateRepayFuturesNegativeBalanceV1Error> = serde_json::from_str(&content).ok();
1263 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1264 }
1265}
1266
1267pub async fn pmargin_create_repay_futures_switch_v1(configuration: &configuration::Configuration, params: PmarginCreateRepayFuturesSwitchV1Params) -> Result<models::PmarginCreateRepayFuturesSwitchV1Resp, Error<PmarginCreateRepayFuturesSwitchV1Error>> {
1269
1270 let uri_str = format!("{}/papi/v1/repay-futures-switch", configuration.base_path);
1271 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1272
1273 let mut query_params: Vec<(String, String)> = Vec::new();
1275
1276
1277 let mut header_params = std::collections::HashMap::new();
1279
1280 if let Some(ref binance_auth) = configuration.binance_auth {
1282 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1284
1285 let body_string: Option<Vec<u8>> = None;
1287
1288 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1290 Ok(sig) => sig,
1291 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1292 };
1293
1294 query_params.push(("signature".to_string(), signature));
1296 }
1297
1298 if !query_params.is_empty() {
1300 req_builder = req_builder.query(&query_params);
1301 }
1302
1303
1304 if let Some(ref user_agent) = configuration.user_agent {
1306 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1307 }
1308
1309 for (header_name, header_value) in header_params {
1311 req_builder = req_builder.header(&header_name, &header_value);
1312 }
1313
1314 let mut multipart_form_params = std::collections::HashMap::new();
1315 multipart_form_params.insert("autoRepay", params.auto_repay.to_string());
1316 if let Some(param_value) = params.recv_window {
1317 multipart_form_params.insert("recvWindow", param_value.to_string());
1318 }
1319 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1320 req_builder = req_builder.form(&multipart_form_params);
1321
1322 let req = req_builder.build()?;
1323 let resp = configuration.client.execute(req).await?;
1324
1325 let status = resp.status();
1326 let content_type = resp
1327 .headers()
1328 .get("content-type")
1329 .and_then(|v| v.to_str().ok())
1330 .unwrap_or("application/octet-stream");
1331 let content_type = super::ContentType::from(content_type);
1332
1333 if !status.is_client_error() && !status.is_server_error() {
1334 let content = resp.text().await?;
1335 match content_type {
1336 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1337 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateRepayFuturesSwitchV1Resp`"))),
1338 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::PmarginCreateRepayFuturesSwitchV1Resp`")))),
1339 }
1340 } else {
1341 let content = resp.text().await?;
1342 let entity: Option<PmarginCreateRepayFuturesSwitchV1Error> = serde_json::from_str(&content).ok();
1343 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1344 }
1345}
1346
1347pub async fn pmargin_create_um_leverage_v1(configuration: &configuration::Configuration, params: PmarginCreateUmLeverageV1Params) -> Result<models::PmarginCreateUmLeverageV1Resp, Error<PmarginCreateUmLeverageV1Error>> {
1349
1350 let uri_str = format!("{}/papi/v1/um/leverage", configuration.base_path);
1351 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1352
1353 let mut query_params: Vec<(String, String)> = Vec::new();
1355
1356
1357 let mut header_params = std::collections::HashMap::new();
1359
1360 if let Some(ref binance_auth) = configuration.binance_auth {
1362 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1364
1365 let body_string: Option<Vec<u8>> = None;
1367
1368 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1370 Ok(sig) => sig,
1371 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1372 };
1373
1374 query_params.push(("signature".to_string(), signature));
1376 }
1377
1378 if !query_params.is_empty() {
1380 req_builder = req_builder.query(&query_params);
1381 }
1382
1383
1384 if let Some(ref user_agent) = configuration.user_agent {
1386 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1387 }
1388
1389 for (header_name, header_value) in header_params {
1391 req_builder = req_builder.header(&header_name, &header_value);
1392 }
1393
1394 let mut multipart_form_params = std::collections::HashMap::new();
1395 multipart_form_params.insert("leverage", params.leverage.to_string());
1396 if let Some(param_value) = params.recv_window {
1397 multipart_form_params.insert("recvWindow", param_value.to_string());
1398 }
1399 multipart_form_params.insert("symbol", params.symbol.to_string());
1400 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1401 req_builder = req_builder.form(&multipart_form_params);
1402
1403 let req = req_builder.build()?;
1404 let resp = configuration.client.execute(req).await?;
1405
1406 let status = resp.status();
1407 let content_type = resp
1408 .headers()
1409 .get("content-type")
1410 .and_then(|v| v.to_str().ok())
1411 .unwrap_or("application/octet-stream");
1412 let content_type = super::ContentType::from(content_type);
1413
1414 if !status.is_client_error() && !status.is_server_error() {
1415 let content = resp.text().await?;
1416 match content_type {
1417 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1418 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateUmLeverageV1Resp`"))),
1419 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::PmarginCreateUmLeverageV1Resp`")))),
1420 }
1421 } else {
1422 let content = resp.text().await?;
1423 let entity: Option<PmarginCreateUmLeverageV1Error> = serde_json::from_str(&content).ok();
1424 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1425 }
1426}
1427
1428pub async fn pmargin_create_um_position_side_dual_v1(configuration: &configuration::Configuration, params: PmarginCreateUmPositionSideDualV1Params) -> Result<models::PmarginCreateUmPositionSideDualV1Resp, Error<PmarginCreateUmPositionSideDualV1Error>> {
1430
1431 let uri_str = format!("{}/papi/v1/um/positionSide/dual", configuration.base_path);
1432 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1433
1434 let mut query_params: Vec<(String, String)> = Vec::new();
1436
1437
1438 let mut header_params = std::collections::HashMap::new();
1440
1441 if let Some(ref binance_auth) = configuration.binance_auth {
1443 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1445
1446 let body_string: Option<Vec<u8>> = None;
1448
1449 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1451 Ok(sig) => sig,
1452 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1453 };
1454
1455 query_params.push(("signature".to_string(), signature));
1457 }
1458
1459 if !query_params.is_empty() {
1461 req_builder = req_builder.query(&query_params);
1462 }
1463
1464
1465 if let Some(ref user_agent) = configuration.user_agent {
1467 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1468 }
1469
1470 for (header_name, header_value) in header_params {
1472 req_builder = req_builder.header(&header_name, &header_value);
1473 }
1474
1475 let mut multipart_form_params = std::collections::HashMap::new();
1476 multipart_form_params.insert("dualSidePosition", params.dual_side_position.to_string());
1477 if let Some(param_value) = params.recv_window {
1478 multipart_form_params.insert("recvWindow", param_value.to_string());
1479 }
1480 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1481 req_builder = req_builder.form(&multipart_form_params);
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::PmarginCreateUmPositionSideDualV1Resp`"))),
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::PmarginCreateUmPositionSideDualV1Resp`")))),
1500 }
1501 } else {
1502 let content = resp.text().await?;
1503 let entity: Option<PmarginCreateUmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
1504 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1505 }
1506}
1507
1508pub async fn pmargin_get_account_v1(configuration: &configuration::Configuration, params: PmarginGetAccountV1Params) -> Result<models::PmarginGetAccountV1Resp, Error<PmarginGetAccountV1Error>> {
1510
1511 let uri_str = format!("{}/papi/v1/account", 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 if let Some(ref param_value) = params.recv_window {
1518 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1519 }
1520 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1521
1522 let mut header_params = std::collections::HashMap::new();
1524
1525 if let Some(ref binance_auth) = configuration.binance_auth {
1527 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1529
1530 let body_string: Option<Vec<u8>> = None;
1532
1533 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1535 Ok(sig) => sig,
1536 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1537 };
1538
1539 query_params.push(("signature".to_string(), signature));
1541 }
1542
1543 if !query_params.is_empty() {
1545 req_builder = req_builder.query(&query_params);
1546 }
1547
1548
1549 if let Some(ref user_agent) = configuration.user_agent {
1551 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1552 }
1553
1554 for (header_name, header_value) in header_params {
1556 req_builder = req_builder.header(&header_name, &header_value);
1557 }
1558
1559
1560 let req = req_builder.build()?;
1561 let resp = configuration.client.execute(req).await?;
1562
1563 let status = resp.status();
1564 let content_type = resp
1565 .headers()
1566 .get("content-type")
1567 .and_then(|v| v.to_str().ok())
1568 .unwrap_or("application/octet-stream");
1569 let content_type = super::ContentType::from(content_type);
1570
1571 if !status.is_client_error() && !status.is_server_error() {
1572 let content = resp.text().await?;
1573 match content_type {
1574 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1575 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetAccountV1Resp`"))),
1576 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::PmarginGetAccountV1Resp`")))),
1577 }
1578 } else {
1579 let content = resp.text().await?;
1580 let entity: Option<PmarginGetAccountV1Error> = serde_json::from_str(&content).ok();
1581 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1582 }
1583}
1584
1585pub async fn pmargin_get_balance_v1(configuration: &configuration::Configuration, params: PmarginGetBalanceV1Params) -> Result<models::PmarginGetBalanceV1Resp, Error<PmarginGetBalanceV1Error>> {
1587
1588 let uri_str = format!("{}/papi/v1/balance", configuration.base_path);
1589 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1590
1591 let mut query_params: Vec<(String, String)> = Vec::new();
1593
1594 if let Some(ref param_value) = params.asset {
1595 query_params.push(("asset".to_string(), param_value.to_string()));
1596 }
1597 if let Some(ref param_value) = params.recv_window {
1598 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1599 }
1600 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1601
1602 let mut header_params = std::collections::HashMap::new();
1604
1605 if let Some(ref binance_auth) = configuration.binance_auth {
1607 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1609
1610 let body_string: Option<Vec<u8>> = None;
1612
1613 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1615 Ok(sig) => sig,
1616 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1617 };
1618
1619 query_params.push(("signature".to_string(), signature));
1621 }
1622
1623 if !query_params.is_empty() {
1625 req_builder = req_builder.query(&query_params);
1626 }
1627
1628
1629 if let Some(ref user_agent) = configuration.user_agent {
1631 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1632 }
1633
1634 for (header_name, header_value) in header_params {
1636 req_builder = req_builder.header(&header_name, &header_value);
1637 }
1638
1639
1640 let req = req_builder.build()?;
1641 let resp = configuration.client.execute(req).await?;
1642
1643 let status = resp.status();
1644 let content_type = resp
1645 .headers()
1646 .get("content-type")
1647 .and_then(|v| v.to_str().ok())
1648 .unwrap_or("application/octet-stream");
1649 let content_type = super::ContentType::from(content_type);
1650
1651 if !status.is_client_error() && !status.is_server_error() {
1652 let content = resp.text().await?;
1653 match content_type {
1654 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1655 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetBalanceV1Resp`"))),
1656 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::PmarginGetBalanceV1Resp`")))),
1657 }
1658 } else {
1659 let content = resp.text().await?;
1660 let entity: Option<PmarginGetBalanceV1Error> = serde_json::from_str(&content).ok();
1661 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1662 }
1663}
1664
1665pub async fn pmargin_get_cm_account_v1(configuration: &configuration::Configuration, params: PmarginGetCmAccountV1Params) -> Result<models::PmarginGetCmAccountV1Resp, Error<PmarginGetCmAccountV1Error>> {
1667
1668 let uri_str = format!("{}/papi/v1/cm/account", configuration.base_path);
1669 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1670
1671 let mut query_params: Vec<(String, String)> = Vec::new();
1673
1674 if let Some(ref param_value) = params.recv_window {
1675 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1676 }
1677 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1678
1679 let mut header_params = std::collections::HashMap::new();
1681
1682 if let Some(ref binance_auth) = configuration.binance_auth {
1684 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1686
1687 let body_string: Option<Vec<u8>> = None;
1689
1690 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1692 Ok(sig) => sig,
1693 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1694 };
1695
1696 query_params.push(("signature".to_string(), signature));
1698 }
1699
1700 if !query_params.is_empty() {
1702 req_builder = req_builder.query(&query_params);
1703 }
1704
1705
1706 if let Some(ref user_agent) = configuration.user_agent {
1708 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1709 }
1710
1711 for (header_name, header_value) in header_params {
1713 req_builder = req_builder.header(&header_name, &header_value);
1714 }
1715
1716
1717 let req = req_builder.build()?;
1718 let resp = configuration.client.execute(req).await?;
1719
1720 let status = resp.status();
1721 let content_type = resp
1722 .headers()
1723 .get("content-type")
1724 .and_then(|v| v.to_str().ok())
1725 .unwrap_or("application/octet-stream");
1726 let content_type = super::ContentType::from(content_type);
1727
1728 if !status.is_client_error() && !status.is_server_error() {
1729 let content = resp.text().await?;
1730 match content_type {
1731 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1732 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetCmAccountV1Resp`"))),
1733 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::PmarginGetCmAccountV1Resp`")))),
1734 }
1735 } else {
1736 let content = resp.text().await?;
1737 let entity: Option<PmarginGetCmAccountV1Error> = serde_json::from_str(&content).ok();
1738 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1739 }
1740}
1741
1742pub async fn pmargin_get_cm_commission_rate_v1(configuration: &configuration::Configuration, params: PmarginGetCmCommissionRateV1Params) -> Result<models::PmarginGetCmCommissionRateV1Resp, Error<PmarginGetCmCommissionRateV1Error>> {
1744
1745 let uri_str = format!("{}/papi/v1/cm/commissionRate", configuration.base_path);
1746 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1747
1748 let mut query_params: Vec<(String, String)> = Vec::new();
1750
1751 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1752 if let Some(ref param_value) = params.recv_window {
1753 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1754 }
1755 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1756
1757 let mut header_params = std::collections::HashMap::new();
1759
1760 if let Some(ref binance_auth) = configuration.binance_auth {
1762 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1764
1765 let body_string: Option<Vec<u8>> = None;
1767
1768 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1770 Ok(sig) => sig,
1771 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1772 };
1773
1774 query_params.push(("signature".to_string(), signature));
1776 }
1777
1778 if !query_params.is_empty() {
1780 req_builder = req_builder.query(&query_params);
1781 }
1782
1783
1784 if let Some(ref user_agent) = configuration.user_agent {
1786 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1787 }
1788
1789 for (header_name, header_value) in header_params {
1791 req_builder = req_builder.header(&header_name, &header_value);
1792 }
1793
1794
1795 let req = req_builder.build()?;
1796 let resp = configuration.client.execute(req).await?;
1797
1798 let status = resp.status();
1799 let content_type = resp
1800 .headers()
1801 .get("content-type")
1802 .and_then(|v| v.to_str().ok())
1803 .unwrap_or("application/octet-stream");
1804 let content_type = super::ContentType::from(content_type);
1805
1806 if !status.is_client_error() && !status.is_server_error() {
1807 let content = resp.text().await?;
1808 match content_type {
1809 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1810 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetCmCommissionRateV1Resp`"))),
1811 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::PmarginGetCmCommissionRateV1Resp`")))),
1812 }
1813 } else {
1814 let content = resp.text().await?;
1815 let entity: Option<PmarginGetCmCommissionRateV1Error> = serde_json::from_str(&content).ok();
1816 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1817 }
1818}
1819
1820pub async fn pmargin_get_cm_income_v1(configuration: &configuration::Configuration, params: PmarginGetCmIncomeV1Params) -> Result<Vec<models::PmarginGetCmIncomeV1RespItem>, Error<PmarginGetCmIncomeV1Error>> {
1822
1823 let uri_str = format!("{}/papi/v1/cm/income", configuration.base_path);
1824 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1825
1826 let mut query_params: Vec<(String, String)> = Vec::new();
1828
1829 if let Some(ref param_value) = params.symbol {
1830 query_params.push(("symbol".to_string(), param_value.to_string()));
1831 }
1832 if let Some(ref param_value) = params.income_type {
1833 query_params.push(("incomeType".to_string(), param_value.to_string()));
1834 }
1835 if let Some(ref param_value) = params.start_time {
1836 query_params.push(("startTime".to_string(), param_value.to_string()));
1837 }
1838 if let Some(ref param_value) = params.end_time {
1839 query_params.push(("endTime".to_string(), param_value.to_string()));
1840 }
1841 if let Some(ref param_value) = params.page {
1842 query_params.push(("page".to_string(), param_value.to_string()));
1843 }
1844 if let Some(ref param_value) = params.limit {
1845 query_params.push(("limit".to_string(), param_value.to_string()));
1846 }
1847 if let Some(ref param_value) = params.recv_window {
1848 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1849 }
1850 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1851
1852 let mut header_params = std::collections::HashMap::new();
1854
1855 if let Some(ref binance_auth) = configuration.binance_auth {
1857 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1859
1860 let body_string: Option<Vec<u8>> = None;
1862
1863 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1865 Ok(sig) => sig,
1866 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1867 };
1868
1869 query_params.push(("signature".to_string(), signature));
1871 }
1872
1873 if !query_params.is_empty() {
1875 req_builder = req_builder.query(&query_params);
1876 }
1877
1878
1879 if let Some(ref user_agent) = configuration.user_agent {
1881 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1882 }
1883
1884 for (header_name, header_value) in header_params {
1886 req_builder = req_builder.header(&header_name, &header_value);
1887 }
1888
1889
1890 let req = req_builder.build()?;
1891 let resp = configuration.client.execute(req).await?;
1892
1893 let status = resp.status();
1894 let content_type = resp
1895 .headers()
1896 .get("content-type")
1897 .and_then(|v| v.to_str().ok())
1898 .unwrap_or("application/octet-stream");
1899 let content_type = super::ContentType::from(content_type);
1900
1901 if !status.is_client_error() && !status.is_server_error() {
1902 let content = resp.text().await?;
1903 match content_type {
1904 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1905 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmIncomeV1RespItem>`"))),
1906 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::PmarginGetCmIncomeV1RespItem>`")))),
1907 }
1908 } else {
1909 let content = resp.text().await?;
1910 let entity: Option<PmarginGetCmIncomeV1Error> = serde_json::from_str(&content).ok();
1911 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1912 }
1913}
1914
1915pub async fn pmargin_get_cm_leverage_bracket_v1(configuration: &configuration::Configuration, params: PmarginGetCmLeverageBracketV1Params) -> Result<Vec<models::PmarginGetCmLeverageBracketV1RespItem>, Error<PmarginGetCmLeverageBracketV1Error>> {
1917
1918 let uri_str = format!("{}/papi/v1/cm/leverageBracket", configuration.base_path);
1919 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1920
1921 let mut query_params: Vec<(String, String)> = Vec::new();
1923
1924 if let Some(ref param_value) = params.symbol {
1925 query_params.push(("symbol".to_string(), param_value.to_string()));
1926 }
1927 if let Some(ref param_value) = params.recv_window {
1928 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1929 }
1930 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1931
1932 let mut header_params = std::collections::HashMap::new();
1934
1935 if let Some(ref binance_auth) = configuration.binance_auth {
1937 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1939
1940 let body_string: Option<Vec<u8>> = None;
1942
1943 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1945 Ok(sig) => sig,
1946 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1947 };
1948
1949 query_params.push(("signature".to_string(), signature));
1951 }
1952
1953 if !query_params.is_empty() {
1955 req_builder = req_builder.query(&query_params);
1956 }
1957
1958
1959 if let Some(ref user_agent) = configuration.user_agent {
1961 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1962 }
1963
1964 for (header_name, header_value) in header_params {
1966 req_builder = req_builder.header(&header_name, &header_value);
1967 }
1968
1969
1970 let req = req_builder.build()?;
1971 let resp = configuration.client.execute(req).await?;
1972
1973 let status = resp.status();
1974 let content_type = resp
1975 .headers()
1976 .get("content-type")
1977 .and_then(|v| v.to_str().ok())
1978 .unwrap_or("application/octet-stream");
1979 let content_type = super::ContentType::from(content_type);
1980
1981 if !status.is_client_error() && !status.is_server_error() {
1982 let content = resp.text().await?;
1983 match content_type {
1984 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1985 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmLeverageBracketV1RespItem>`"))),
1986 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::PmarginGetCmLeverageBracketV1RespItem>`")))),
1987 }
1988 } else {
1989 let content = resp.text().await?;
1990 let entity: Option<PmarginGetCmLeverageBracketV1Error> = serde_json::from_str(&content).ok();
1991 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1992 }
1993}
1994
1995pub async fn pmargin_get_cm_position_risk_v1(configuration: &configuration::Configuration, params: PmarginGetCmPositionRiskV1Params) -> Result<Vec<models::PmarginGetCmPositionRiskV1RespItem>, Error<PmarginGetCmPositionRiskV1Error>> {
1997
1998 let uri_str = format!("{}/papi/v1/cm/positionRisk", configuration.base_path);
1999 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2000
2001 let mut query_params: Vec<(String, String)> = Vec::new();
2003
2004 if let Some(ref param_value) = params.margin_asset {
2005 query_params.push(("marginAsset".to_string(), param_value.to_string()));
2006 }
2007 if let Some(ref param_value) = params.pair {
2008 query_params.push(("pair".to_string(), param_value.to_string()));
2009 }
2010 if let Some(ref param_value) = params.recv_window {
2011 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2012 }
2013 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2014
2015 let mut header_params = std::collections::HashMap::new();
2017
2018 if let Some(ref binance_auth) = configuration.binance_auth {
2020 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2022
2023 let body_string: Option<Vec<u8>> = None;
2025
2026 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2028 Ok(sig) => sig,
2029 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2030 };
2031
2032 query_params.push(("signature".to_string(), signature));
2034 }
2035
2036 if !query_params.is_empty() {
2038 req_builder = req_builder.query(&query_params);
2039 }
2040
2041
2042 if let Some(ref user_agent) = configuration.user_agent {
2044 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2045 }
2046
2047 for (header_name, header_value) in header_params {
2049 req_builder = req_builder.header(&header_name, &header_value);
2050 }
2051
2052
2053 let req = req_builder.build()?;
2054 let resp = configuration.client.execute(req).await?;
2055
2056 let status = resp.status();
2057 let content_type = resp
2058 .headers()
2059 .get("content-type")
2060 .and_then(|v| v.to_str().ok())
2061 .unwrap_or("application/octet-stream");
2062 let content_type = super::ContentType::from(content_type);
2063
2064 if !status.is_client_error() && !status.is_server_error() {
2065 let content = resp.text().await?;
2066 match content_type {
2067 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2068 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmPositionRiskV1RespItem>`"))),
2069 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::PmarginGetCmPositionRiskV1RespItem>`")))),
2070 }
2071 } else {
2072 let content = resp.text().await?;
2073 let entity: Option<PmarginGetCmPositionRiskV1Error> = serde_json::from_str(&content).ok();
2074 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2075 }
2076}
2077
2078pub async fn pmargin_get_cm_position_side_dual_v1(configuration: &configuration::Configuration, params: PmarginGetCmPositionSideDualV1Params) -> Result<models::PmarginGetCmPositionSideDualV1Resp, Error<PmarginGetCmPositionSideDualV1Error>> {
2080
2081 let uri_str = format!("{}/papi/v1/cm/positionSide/dual", configuration.base_path);
2082 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2083
2084 let mut query_params: Vec<(String, String)> = Vec::new();
2086
2087 if let Some(ref param_value) = params.recv_window {
2088 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2089 }
2090 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2091
2092 let mut header_params = std::collections::HashMap::new();
2094
2095 if let Some(ref binance_auth) = configuration.binance_auth {
2097 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2099
2100 let body_string: Option<Vec<u8>> = None;
2102
2103 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2105 Ok(sig) => sig,
2106 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2107 };
2108
2109 query_params.push(("signature".to_string(), signature));
2111 }
2112
2113 if !query_params.is_empty() {
2115 req_builder = req_builder.query(&query_params);
2116 }
2117
2118
2119 if let Some(ref user_agent) = configuration.user_agent {
2121 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2122 }
2123
2124 for (header_name, header_value) in header_params {
2126 req_builder = req_builder.header(&header_name, &header_value);
2127 }
2128
2129
2130 let req = req_builder.build()?;
2131 let resp = configuration.client.execute(req).await?;
2132
2133 let status = resp.status();
2134 let content_type = resp
2135 .headers()
2136 .get("content-type")
2137 .and_then(|v| v.to_str().ok())
2138 .unwrap_or("application/octet-stream");
2139 let content_type = super::ContentType::from(content_type);
2140
2141 if !status.is_client_error() && !status.is_server_error() {
2142 let content = resp.text().await?;
2143 match content_type {
2144 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2145 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetCmPositionSideDualV1Resp`"))),
2146 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::PmarginGetCmPositionSideDualV1Resp`")))),
2147 }
2148 } else {
2149 let content = resp.text().await?;
2150 let entity: Option<PmarginGetCmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
2151 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2152 }
2153}
2154
2155pub async fn pmargin_get_margin_margin_interest_history_v1(configuration: &configuration::Configuration, params: PmarginGetMarginMarginInterestHistoryV1Params) -> Result<models::PmarginGetMarginMarginInterestHistoryV1Resp, Error<PmarginGetMarginMarginInterestHistoryV1Error>> {
2157
2158 let uri_str = format!("{}/papi/v1/margin/marginInterestHistory", configuration.base_path);
2159 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2160
2161 let mut query_params: Vec<(String, String)> = Vec::new();
2163
2164 if let Some(ref param_value) = params.asset {
2165 query_params.push(("asset".to_string(), param_value.to_string()));
2166 }
2167 if let Some(ref param_value) = params.start_time {
2168 query_params.push(("startTime".to_string(), param_value.to_string()));
2169 }
2170 if let Some(ref param_value) = params.end_time {
2171 query_params.push(("endTime".to_string(), param_value.to_string()));
2172 }
2173 if let Some(ref param_value) = params.current {
2174 query_params.push(("current".to_string(), param_value.to_string()));
2175 }
2176 if let Some(ref param_value) = params.size {
2177 query_params.push(("size".to_string(), param_value.to_string()));
2178 }
2179 if let Some(ref param_value) = params.archived {
2180 query_params.push(("archived".to_string(), param_value.to_string()));
2181 }
2182 if let Some(ref param_value) = params.recv_window {
2183 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2184 }
2185 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2186
2187 let mut header_params = std::collections::HashMap::new();
2189
2190 if let Some(ref binance_auth) = configuration.binance_auth {
2192 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2194
2195 let body_string: Option<Vec<u8>> = None;
2197
2198 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2200 Ok(sig) => sig,
2201 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2202 };
2203
2204 query_params.push(("signature".to_string(), signature));
2206 }
2207
2208 if !query_params.is_empty() {
2210 req_builder = req_builder.query(&query_params);
2211 }
2212
2213
2214 if let Some(ref user_agent) = configuration.user_agent {
2216 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2217 }
2218
2219 for (header_name, header_value) in header_params {
2221 req_builder = req_builder.header(&header_name, &header_value);
2222 }
2223
2224
2225 let req = req_builder.build()?;
2226 let resp = configuration.client.execute(req).await?;
2227
2228 let status = resp.status();
2229 let content_type = resp
2230 .headers()
2231 .get("content-type")
2232 .and_then(|v| v.to_str().ok())
2233 .unwrap_or("application/octet-stream");
2234 let content_type = super::ContentType::from(content_type);
2235
2236 if !status.is_client_error() && !status.is_server_error() {
2237 let content = resp.text().await?;
2238 match content_type {
2239 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2240 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetMarginMarginInterestHistoryV1Resp`"))),
2241 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::PmarginGetMarginMarginInterestHistoryV1Resp`")))),
2242 }
2243 } else {
2244 let content = resp.text().await?;
2245 let entity: Option<PmarginGetMarginMarginInterestHistoryV1Error> = serde_json::from_str(&content).ok();
2246 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2247 }
2248}
2249
2250pub async fn pmargin_get_margin_margin_loan_v1(configuration: &configuration::Configuration, params: PmarginGetMarginMarginLoanV1Params) -> Result<models::PmarginGetMarginMarginLoanV1Resp, Error<PmarginGetMarginMarginLoanV1Error>> {
2252
2253 let uri_str = format!("{}/papi/v1/margin/marginLoan", configuration.base_path);
2254 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2255
2256 let mut query_params: Vec<(String, String)> = Vec::new();
2258
2259 query_params.push(("asset".to_string(), params.asset.to_string()));
2260 if let Some(ref param_value) = params.tx_id {
2261 query_params.push(("txId".to_string(), param_value.to_string()));
2262 }
2263 if let Some(ref param_value) = params.start_time {
2264 query_params.push(("startTime".to_string(), param_value.to_string()));
2265 }
2266 if let Some(ref param_value) = params.end_time {
2267 query_params.push(("endTime".to_string(), param_value.to_string()));
2268 }
2269 if let Some(ref param_value) = params.current {
2270 query_params.push(("current".to_string(), param_value.to_string()));
2271 }
2272 if let Some(ref param_value) = params.size {
2273 query_params.push(("size".to_string(), param_value.to_string()));
2274 }
2275 if let Some(ref param_value) = params.archived {
2276 query_params.push(("archived".to_string(), param_value.to_string()));
2277 }
2278 if let Some(ref param_value) = params.recv_window {
2279 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2280 }
2281 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2282
2283 let mut header_params = std::collections::HashMap::new();
2285
2286 if let Some(ref binance_auth) = configuration.binance_auth {
2288 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2290
2291 let body_string: Option<Vec<u8>> = None;
2293
2294 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2296 Ok(sig) => sig,
2297 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2298 };
2299
2300 query_params.push(("signature".to_string(), signature));
2302 }
2303
2304 if !query_params.is_empty() {
2306 req_builder = req_builder.query(&query_params);
2307 }
2308
2309
2310 if let Some(ref user_agent) = configuration.user_agent {
2312 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2313 }
2314
2315 for (header_name, header_value) in header_params {
2317 req_builder = req_builder.header(&header_name, &header_value);
2318 }
2319
2320
2321 let req = req_builder.build()?;
2322 let resp = configuration.client.execute(req).await?;
2323
2324 let status = resp.status();
2325 let content_type = resp
2326 .headers()
2327 .get("content-type")
2328 .and_then(|v| v.to_str().ok())
2329 .unwrap_or("application/octet-stream");
2330 let content_type = super::ContentType::from(content_type);
2331
2332 if !status.is_client_error() && !status.is_server_error() {
2333 let content = resp.text().await?;
2334 match content_type {
2335 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2336 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetMarginMarginLoanV1Resp`"))),
2337 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::PmarginGetMarginMarginLoanV1Resp`")))),
2338 }
2339 } else {
2340 let content = resp.text().await?;
2341 let entity: Option<PmarginGetMarginMarginLoanV1Error> = serde_json::from_str(&content).ok();
2342 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2343 }
2344}
2345
2346pub async fn pmargin_get_margin_max_borrowable_v1(configuration: &configuration::Configuration, params: PmarginGetMarginMaxBorrowableV1Params) -> Result<models::PmarginGetMarginMaxBorrowableV1Resp, Error<PmarginGetMarginMaxBorrowableV1Error>> {
2348
2349 let uri_str = format!("{}/papi/v1/margin/maxBorrowable", configuration.base_path);
2350 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2351
2352 let mut query_params: Vec<(String, String)> = Vec::new();
2354
2355 query_params.push(("asset".to_string(), params.asset.to_string()));
2356 if let Some(ref param_value) = params.recv_window {
2357 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2358 }
2359 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2360
2361 let mut header_params = std::collections::HashMap::new();
2363
2364 if let Some(ref binance_auth) = configuration.binance_auth {
2366 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2368
2369 let body_string: Option<Vec<u8>> = None;
2371
2372 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2374 Ok(sig) => sig,
2375 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2376 };
2377
2378 query_params.push(("signature".to_string(), signature));
2380 }
2381
2382 if !query_params.is_empty() {
2384 req_builder = req_builder.query(&query_params);
2385 }
2386
2387
2388 if let Some(ref user_agent) = configuration.user_agent {
2390 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2391 }
2392
2393 for (header_name, header_value) in header_params {
2395 req_builder = req_builder.header(&header_name, &header_value);
2396 }
2397
2398
2399 let req = req_builder.build()?;
2400 let resp = configuration.client.execute(req).await?;
2401
2402 let status = resp.status();
2403 let content_type = resp
2404 .headers()
2405 .get("content-type")
2406 .and_then(|v| v.to_str().ok())
2407 .unwrap_or("application/octet-stream");
2408 let content_type = super::ContentType::from(content_type);
2409
2410 if !status.is_client_error() && !status.is_server_error() {
2411 let content = resp.text().await?;
2412 match content_type {
2413 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2414 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetMarginMaxBorrowableV1Resp`"))),
2415 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::PmarginGetMarginMaxBorrowableV1Resp`")))),
2416 }
2417 } else {
2418 let content = resp.text().await?;
2419 let entity: Option<PmarginGetMarginMaxBorrowableV1Error> = serde_json::from_str(&content).ok();
2420 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2421 }
2422}
2423
2424pub async fn pmargin_get_margin_max_withdraw_v1(configuration: &configuration::Configuration, params: PmarginGetMarginMaxWithdrawV1Params) -> Result<models::PmarginGetMarginMaxWithdrawV1Resp, Error<PmarginGetMarginMaxWithdrawV1Error>> {
2426
2427 let uri_str = format!("{}/papi/v1/margin/maxWithdraw", configuration.base_path);
2428 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2429
2430 let mut query_params: Vec<(String, String)> = Vec::new();
2432
2433 query_params.push(("asset".to_string(), params.asset.to_string()));
2434 if let Some(ref param_value) = params.recv_window {
2435 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2436 }
2437 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2438
2439 let mut header_params = std::collections::HashMap::new();
2441
2442 if let Some(ref binance_auth) = configuration.binance_auth {
2444 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2446
2447 let body_string: Option<Vec<u8>> = None;
2449
2450 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2452 Ok(sig) => sig,
2453 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2454 };
2455
2456 query_params.push(("signature".to_string(), signature));
2458 }
2459
2460 if !query_params.is_empty() {
2462 req_builder = req_builder.query(&query_params);
2463 }
2464
2465
2466 if let Some(ref user_agent) = configuration.user_agent {
2468 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2469 }
2470
2471 for (header_name, header_value) in header_params {
2473 req_builder = req_builder.header(&header_name, &header_value);
2474 }
2475
2476
2477 let req = req_builder.build()?;
2478 let resp = configuration.client.execute(req).await?;
2479
2480 let status = resp.status();
2481 let content_type = resp
2482 .headers()
2483 .get("content-type")
2484 .and_then(|v| v.to_str().ok())
2485 .unwrap_or("application/octet-stream");
2486 let content_type = super::ContentType::from(content_type);
2487
2488 if !status.is_client_error() && !status.is_server_error() {
2489 let content = resp.text().await?;
2490 match content_type {
2491 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2492 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetMarginMaxWithdrawV1Resp`"))),
2493 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::PmarginGetMarginMaxWithdrawV1Resp`")))),
2494 }
2495 } else {
2496 let content = resp.text().await?;
2497 let entity: Option<PmarginGetMarginMaxWithdrawV1Error> = serde_json::from_str(&content).ok();
2498 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2499 }
2500}
2501
2502pub async fn pmargin_get_margin_repay_loan_v1(configuration: &configuration::Configuration, params: PmarginGetMarginRepayLoanV1Params) -> Result<models::PmarginGetMarginRepayLoanV1Resp, Error<PmarginGetMarginRepayLoanV1Error>> {
2504
2505 let uri_str = format!("{}/papi/v1/margin/repayLoan", configuration.base_path);
2506 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2507
2508 let mut query_params: Vec<(String, String)> = Vec::new();
2510
2511 query_params.push(("asset".to_string(), params.asset.to_string()));
2512 if let Some(ref param_value) = params.tx_id {
2513 query_params.push(("txId".to_string(), param_value.to_string()));
2514 }
2515 if let Some(ref param_value) = params.start_time {
2516 query_params.push(("startTime".to_string(), param_value.to_string()));
2517 }
2518 if let Some(ref param_value) = params.end_time {
2519 query_params.push(("endTime".to_string(), param_value.to_string()));
2520 }
2521 if let Some(ref param_value) = params.current {
2522 query_params.push(("current".to_string(), param_value.to_string()));
2523 }
2524 if let Some(ref param_value) = params.size {
2525 query_params.push(("size".to_string(), param_value.to_string()));
2526 }
2527 if let Some(ref param_value) = params.archived {
2528 query_params.push(("archived".to_string(), param_value.to_string()));
2529 }
2530 if let Some(ref param_value) = params.recv_window {
2531 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2532 }
2533 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2534
2535 let mut header_params = std::collections::HashMap::new();
2537
2538 if let Some(ref binance_auth) = configuration.binance_auth {
2540 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2542
2543 let body_string: Option<Vec<u8>> = None;
2545
2546 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2548 Ok(sig) => sig,
2549 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2550 };
2551
2552 query_params.push(("signature".to_string(), signature));
2554 }
2555
2556 if !query_params.is_empty() {
2558 req_builder = req_builder.query(&query_params);
2559 }
2560
2561
2562 if let Some(ref user_agent) = configuration.user_agent {
2564 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2565 }
2566
2567 for (header_name, header_value) in header_params {
2569 req_builder = req_builder.header(&header_name, &header_value);
2570 }
2571
2572
2573 let req = req_builder.build()?;
2574 let resp = configuration.client.execute(req).await?;
2575
2576 let status = resp.status();
2577 let content_type = resp
2578 .headers()
2579 .get("content-type")
2580 .and_then(|v| v.to_str().ok())
2581 .unwrap_or("application/octet-stream");
2582 let content_type = super::ContentType::from(content_type);
2583
2584 if !status.is_client_error() && !status.is_server_error() {
2585 let content = resp.text().await?;
2586 match content_type {
2587 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2588 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetMarginRepayLoanV1Resp`"))),
2589 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::PmarginGetMarginRepayLoanV1Resp`")))),
2590 }
2591 } else {
2592 let content = resp.text().await?;
2593 let entity: Option<PmarginGetMarginRepayLoanV1Error> = serde_json::from_str(&content).ok();
2594 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2595 }
2596}
2597
2598pub async fn pmargin_get_portfolio_interest_history_v1(configuration: &configuration::Configuration, params: PmarginGetPortfolioInterestHistoryV1Params) -> Result<Vec<models::PmarginGetPortfolioInterestHistoryV1RespItem>, Error<PmarginGetPortfolioInterestHistoryV1Error>> {
2600
2601 let uri_str = format!("{}/papi/v1/portfolio/interest-history", configuration.base_path);
2602 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2603
2604 let mut query_params: Vec<(String, String)> = Vec::new();
2606
2607 if let Some(ref param_value) = params.asset {
2608 query_params.push(("asset".to_string(), param_value.to_string()));
2609 }
2610 if let Some(ref param_value) = params.start_time {
2611 query_params.push(("startTime".to_string(), param_value.to_string()));
2612 }
2613 if let Some(ref param_value) = params.end_time {
2614 query_params.push(("endTime".to_string(), param_value.to_string()));
2615 }
2616 if let Some(ref param_value) = params.size {
2617 query_params.push(("size".to_string(), param_value.to_string()));
2618 }
2619 if let Some(ref param_value) = params.recv_window {
2620 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2621 }
2622 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2623
2624 let mut header_params = std::collections::HashMap::new();
2626
2627 if let Some(ref binance_auth) = configuration.binance_auth {
2629 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2631
2632 let body_string: Option<Vec<u8>> = None;
2634
2635 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2637 Ok(sig) => sig,
2638 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2639 };
2640
2641 query_params.push(("signature".to_string(), signature));
2643 }
2644
2645 if !query_params.is_empty() {
2647 req_builder = req_builder.query(&query_params);
2648 }
2649
2650
2651 if let Some(ref user_agent) = configuration.user_agent {
2653 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2654 }
2655
2656 for (header_name, header_value) in header_params {
2658 req_builder = req_builder.header(&header_name, &header_value);
2659 }
2660
2661
2662 let req = req_builder.build()?;
2663 let resp = configuration.client.execute(req).await?;
2664
2665 let status = resp.status();
2666 let content_type = resp
2667 .headers()
2668 .get("content-type")
2669 .and_then(|v| v.to_str().ok())
2670 .unwrap_or("application/octet-stream");
2671 let content_type = super::ContentType::from(content_type);
2672
2673 if !status.is_client_error() && !status.is_server_error() {
2674 let content = resp.text().await?;
2675 match content_type {
2676 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2677 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetPortfolioInterestHistoryV1RespItem>`"))),
2678 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::PmarginGetPortfolioInterestHistoryV1RespItem>`")))),
2679 }
2680 } else {
2681 let content = resp.text().await?;
2682 let entity: Option<PmarginGetPortfolioInterestHistoryV1Error> = serde_json::from_str(&content).ok();
2683 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2684 }
2685}
2686
2687pub async fn pmargin_get_portfolio_negative_balance_exchange_record_v1(configuration: &configuration::Configuration, params: PmarginGetPortfolioNegativeBalanceExchangeRecordV1Params) -> Result<models::PmarginGetPortfolioNegativeBalanceExchangeRecordV1Resp, Error<PmarginGetPortfolioNegativeBalanceExchangeRecordV1Error>> {
2689
2690 let uri_str = format!("{}/papi/v1/portfolio/negative-balance-exchange-record", configuration.base_path);
2691 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2692
2693 let mut query_params: Vec<(String, String)> = Vec::new();
2695
2696 query_params.push(("startTime".to_string(), params.start_time.to_string()));
2697 query_params.push(("endTime".to_string(), params.end_time.to_string()));
2698 if let Some(ref param_value) = params.recv_window {
2699 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2700 }
2701 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2702
2703 let mut header_params = std::collections::HashMap::new();
2705
2706 if let Some(ref binance_auth) = configuration.binance_auth {
2708 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2710
2711 let body_string: Option<Vec<u8>> = None;
2713
2714 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2716 Ok(sig) => sig,
2717 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2718 };
2719
2720 query_params.push(("signature".to_string(), signature));
2722 }
2723
2724 if !query_params.is_empty() {
2726 req_builder = req_builder.query(&query_params);
2727 }
2728
2729
2730 if let Some(ref user_agent) = configuration.user_agent {
2732 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2733 }
2734
2735 for (header_name, header_value) in header_params {
2737 req_builder = req_builder.header(&header_name, &header_value);
2738 }
2739
2740
2741 let req = req_builder.build()?;
2742 let resp = configuration.client.execute(req).await?;
2743
2744 let status = resp.status();
2745 let content_type = resp
2746 .headers()
2747 .get("content-type")
2748 .and_then(|v| v.to_str().ok())
2749 .unwrap_or("application/octet-stream");
2750 let content_type = super::ContentType::from(content_type);
2751
2752 if !status.is_client_error() && !status.is_server_error() {
2753 let content = resp.text().await?;
2754 match content_type {
2755 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2756 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetPortfolioNegativeBalanceExchangeRecordV1Resp`"))),
2757 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::PmarginGetPortfolioNegativeBalanceExchangeRecordV1Resp`")))),
2758 }
2759 } else {
2760 let content = resp.text().await?;
2761 let entity: Option<PmarginGetPortfolioNegativeBalanceExchangeRecordV1Error> = serde_json::from_str(&content).ok();
2762 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2763 }
2764}
2765
2766pub async fn pmargin_get_rate_limit_order_v1(configuration: &configuration::Configuration, params: PmarginGetRateLimitOrderV1Params) -> Result<Vec<models::PmarginGetRateLimitOrderV1RespItem>, Error<PmarginGetRateLimitOrderV1Error>> {
2768
2769 let uri_str = format!("{}/papi/v1/rateLimit/order", configuration.base_path);
2770 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2771
2772 let mut query_params: Vec<(String, String)> = Vec::new();
2774
2775 if let Some(ref param_value) = params.recv_window {
2776 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2777 }
2778 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2779
2780 let mut header_params = std::collections::HashMap::new();
2782
2783 if let Some(ref binance_auth) = configuration.binance_auth {
2785 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2787
2788 let body_string: Option<Vec<u8>> = None;
2790
2791 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2793 Ok(sig) => sig,
2794 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2795 };
2796
2797 query_params.push(("signature".to_string(), signature));
2799 }
2800
2801 if !query_params.is_empty() {
2803 req_builder = req_builder.query(&query_params);
2804 }
2805
2806
2807 if let Some(ref user_agent) = configuration.user_agent {
2809 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2810 }
2811
2812 for (header_name, header_value) in header_params {
2814 req_builder = req_builder.header(&header_name, &header_value);
2815 }
2816
2817
2818 let req = req_builder.build()?;
2819 let resp = configuration.client.execute(req).await?;
2820
2821 let status = resp.status();
2822 let content_type = resp
2823 .headers()
2824 .get("content-type")
2825 .and_then(|v| v.to_str().ok())
2826 .unwrap_or("application/octet-stream");
2827 let content_type = super::ContentType::from(content_type);
2828
2829 if !status.is_client_error() && !status.is_server_error() {
2830 let content = resp.text().await?;
2831 match content_type {
2832 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2833 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetRateLimitOrderV1RespItem>`"))),
2834 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::PmarginGetRateLimitOrderV1RespItem>`")))),
2835 }
2836 } else {
2837 let content = resp.text().await?;
2838 let entity: Option<PmarginGetRateLimitOrderV1Error> = serde_json::from_str(&content).ok();
2839 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2840 }
2841}
2842
2843pub async fn pmargin_get_repay_futures_switch_v1(configuration: &configuration::Configuration, params: PmarginGetRepayFuturesSwitchV1Params) -> Result<models::PmarginGetRepayFuturesSwitchV1Resp, Error<PmarginGetRepayFuturesSwitchV1Error>> {
2845
2846 let uri_str = format!("{}/papi/v1/repay-futures-switch", configuration.base_path);
2847 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2848
2849 let mut query_params: Vec<(String, String)> = Vec::new();
2851
2852 if let Some(ref param_value) = params.recv_window {
2853 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2854 }
2855 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2856
2857 let mut header_params = std::collections::HashMap::new();
2859
2860 if let Some(ref binance_auth) = configuration.binance_auth {
2862 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2864
2865 let body_string: Option<Vec<u8>> = None;
2867
2868 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2870 Ok(sig) => sig,
2871 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2872 };
2873
2874 query_params.push(("signature".to_string(), signature));
2876 }
2877
2878 if !query_params.is_empty() {
2880 req_builder = req_builder.query(&query_params);
2881 }
2882
2883
2884 if let Some(ref user_agent) = configuration.user_agent {
2886 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2887 }
2888
2889 for (header_name, header_value) in header_params {
2891 req_builder = req_builder.header(&header_name, &header_value);
2892 }
2893
2894
2895 let req = req_builder.build()?;
2896 let resp = configuration.client.execute(req).await?;
2897
2898 let status = resp.status();
2899 let content_type = resp
2900 .headers()
2901 .get("content-type")
2902 .and_then(|v| v.to_str().ok())
2903 .unwrap_or("application/octet-stream");
2904 let content_type = super::ContentType::from(content_type);
2905
2906 if !status.is_client_error() && !status.is_server_error() {
2907 let content = resp.text().await?;
2908 match content_type {
2909 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2910 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetRepayFuturesSwitchV1Resp`"))),
2911 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::PmarginGetRepayFuturesSwitchV1Resp`")))),
2912 }
2913 } else {
2914 let content = resp.text().await?;
2915 let entity: Option<PmarginGetRepayFuturesSwitchV1Error> = serde_json::from_str(&content).ok();
2916 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2917 }
2918}
2919
2920pub async fn pmargin_get_um_account_config_v1(configuration: &configuration::Configuration, params: PmarginGetUmAccountConfigV1Params) -> Result<models::PmarginGetUmAccountConfigV1Resp, Error<PmarginGetUmAccountConfigV1Error>> {
2922
2923 let uri_str = format!("{}/papi/v1/um/accountConfig", configuration.base_path);
2924 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2925
2926 let mut query_params: Vec<(String, String)> = Vec::new();
2928
2929 if let Some(ref param_value) = params.recv_window {
2930 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2931 }
2932 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2933
2934 let mut header_params = std::collections::HashMap::new();
2936
2937 if let Some(ref binance_auth) = configuration.binance_auth {
2939 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2941
2942 let body_string: Option<Vec<u8>> = None;
2944
2945 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2947 Ok(sig) => sig,
2948 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2949 };
2950
2951 query_params.push(("signature".to_string(), signature));
2953 }
2954
2955 if !query_params.is_empty() {
2957 req_builder = req_builder.query(&query_params);
2958 }
2959
2960
2961 if let Some(ref user_agent) = configuration.user_agent {
2963 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2964 }
2965
2966 for (header_name, header_value) in header_params {
2968 req_builder = req_builder.header(&header_name, &header_value);
2969 }
2970
2971
2972 let req = req_builder.build()?;
2973 let resp = configuration.client.execute(req).await?;
2974
2975 let status = resp.status();
2976 let content_type = resp
2977 .headers()
2978 .get("content-type")
2979 .and_then(|v| v.to_str().ok())
2980 .unwrap_or("application/octet-stream");
2981 let content_type = super::ContentType::from(content_type);
2982
2983 if !status.is_client_error() && !status.is_server_error() {
2984 let content = resp.text().await?;
2985 match content_type {
2986 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2987 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmAccountConfigV1Resp`"))),
2988 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::PmarginGetUmAccountConfigV1Resp`")))),
2989 }
2990 } else {
2991 let content = resp.text().await?;
2992 let entity: Option<PmarginGetUmAccountConfigV1Error> = serde_json::from_str(&content).ok();
2993 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2994 }
2995}
2996
2997pub async fn pmargin_get_um_account_v1(configuration: &configuration::Configuration, params: PmarginGetUmAccountV1Params) -> Result<models::PmarginGetUmAccountV1Resp, Error<PmarginGetUmAccountV1Error>> {
2999
3000 let uri_str = format!("{}/papi/v1/um/account", configuration.base_path);
3001 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3002
3003 let mut query_params: Vec<(String, String)> = Vec::new();
3005
3006 if let Some(ref param_value) = params.recv_window {
3007 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3008 }
3009 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3010
3011 let mut header_params = std::collections::HashMap::new();
3013
3014 if let Some(ref binance_auth) = configuration.binance_auth {
3016 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3018
3019 let body_string: Option<Vec<u8>> = None;
3021
3022 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3024 Ok(sig) => sig,
3025 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3026 };
3027
3028 query_params.push(("signature".to_string(), signature));
3030 }
3031
3032 if !query_params.is_empty() {
3034 req_builder = req_builder.query(&query_params);
3035 }
3036
3037
3038 if let Some(ref user_agent) = configuration.user_agent {
3040 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3041 }
3042
3043 for (header_name, header_value) in header_params {
3045 req_builder = req_builder.header(&header_name, &header_value);
3046 }
3047
3048
3049 let req = req_builder.build()?;
3050 let resp = configuration.client.execute(req).await?;
3051
3052 let status = resp.status();
3053 let content_type = resp
3054 .headers()
3055 .get("content-type")
3056 .and_then(|v| v.to_str().ok())
3057 .unwrap_or("application/octet-stream");
3058 let content_type = super::ContentType::from(content_type);
3059
3060 if !status.is_client_error() && !status.is_server_error() {
3061 let content = resp.text().await?;
3062 match content_type {
3063 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3064 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmAccountV1Resp`"))),
3065 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::PmarginGetUmAccountV1Resp`")))),
3066 }
3067 } else {
3068 let content = resp.text().await?;
3069 let entity: Option<PmarginGetUmAccountV1Error> = serde_json::from_str(&content).ok();
3070 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3071 }
3072}
3073
3074pub async fn pmargin_get_um_account_v2(configuration: &configuration::Configuration, params: PmarginGetUmAccountV2Params) -> Result<models::PmarginGetUmAccountV2Resp, Error<PmarginGetUmAccountV2Error>> {
3076
3077 let uri_str = format!("{}/papi/v2/um/account", configuration.base_path);
3078 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3079
3080 let mut query_params: Vec<(String, String)> = Vec::new();
3082
3083 if let Some(ref param_value) = params.recv_window {
3084 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3085 }
3086 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3087
3088 let mut header_params = std::collections::HashMap::new();
3090
3091 if let Some(ref binance_auth) = configuration.binance_auth {
3093 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3095
3096 let body_string: Option<Vec<u8>> = None;
3098
3099 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3101 Ok(sig) => sig,
3102 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3103 };
3104
3105 query_params.push(("signature".to_string(), signature));
3107 }
3108
3109 if !query_params.is_empty() {
3111 req_builder = req_builder.query(&query_params);
3112 }
3113
3114
3115 if let Some(ref user_agent) = configuration.user_agent {
3117 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3118 }
3119
3120 for (header_name, header_value) in header_params {
3122 req_builder = req_builder.header(&header_name, &header_value);
3123 }
3124
3125
3126 let req = req_builder.build()?;
3127 let resp = configuration.client.execute(req).await?;
3128
3129 let status = resp.status();
3130 let content_type = resp
3131 .headers()
3132 .get("content-type")
3133 .and_then(|v| v.to_str().ok())
3134 .unwrap_or("application/octet-stream");
3135 let content_type = super::ContentType::from(content_type);
3136
3137 if !status.is_client_error() && !status.is_server_error() {
3138 let content = resp.text().await?;
3139 match content_type {
3140 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3141 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmAccountV2Resp`"))),
3142 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::PmarginGetUmAccountV2Resp`")))),
3143 }
3144 } else {
3145 let content = resp.text().await?;
3146 let entity: Option<PmarginGetUmAccountV2Error> = serde_json::from_str(&content).ok();
3147 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3148 }
3149}
3150
3151pub async fn pmargin_get_um_api_trading_status_v1(configuration: &configuration::Configuration, params: PmarginGetUmApiTradingStatusV1Params) -> Result<models::PmarginGetUmApiTradingStatusV1Resp, Error<PmarginGetUmApiTradingStatusV1Error>> {
3153
3154 let uri_str = format!("{}/papi/v1/um/apiTradingStatus", configuration.base_path);
3155 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3156
3157 let mut query_params: Vec<(String, String)> = Vec::new();
3159
3160 if let Some(ref param_value) = params.symbol {
3161 query_params.push(("symbol".to_string(), param_value.to_string()));
3162 }
3163 if let Some(ref param_value) = params.recv_window {
3164 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3165 }
3166 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3167
3168 let mut header_params = std::collections::HashMap::new();
3170
3171 if let Some(ref binance_auth) = configuration.binance_auth {
3173 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3175
3176 let body_string: Option<Vec<u8>> = None;
3178
3179 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3181 Ok(sig) => sig,
3182 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3183 };
3184
3185 query_params.push(("signature".to_string(), signature));
3187 }
3188
3189 if !query_params.is_empty() {
3191 req_builder = req_builder.query(&query_params);
3192 }
3193
3194
3195 if let Some(ref user_agent) = configuration.user_agent {
3197 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3198 }
3199
3200 for (header_name, header_value) in header_params {
3202 req_builder = req_builder.header(&header_name, &header_value);
3203 }
3204
3205
3206 let req = req_builder.build()?;
3207 let resp = configuration.client.execute(req).await?;
3208
3209 let status = resp.status();
3210 let content_type = resp
3211 .headers()
3212 .get("content-type")
3213 .and_then(|v| v.to_str().ok())
3214 .unwrap_or("application/octet-stream");
3215 let content_type = super::ContentType::from(content_type);
3216
3217 if !status.is_client_error() && !status.is_server_error() {
3218 let content = resp.text().await?;
3219 match content_type {
3220 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3221 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmApiTradingStatusV1Resp`"))),
3222 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::PmarginGetUmApiTradingStatusV1Resp`")))),
3223 }
3224 } else {
3225 let content = resp.text().await?;
3226 let entity: Option<PmarginGetUmApiTradingStatusV1Error> = serde_json::from_str(&content).ok();
3227 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3228 }
3229}
3230
3231pub async fn pmargin_get_um_commission_rate_v1(configuration: &configuration::Configuration, params: PmarginGetUmCommissionRateV1Params) -> Result<models::PmarginGetUmCommissionRateV1Resp, Error<PmarginGetUmCommissionRateV1Error>> {
3233
3234 let uri_str = format!("{}/papi/v1/um/commissionRate", configuration.base_path);
3235 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3236
3237 let mut query_params: Vec<(String, String)> = Vec::new();
3239
3240 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3241 if let Some(ref param_value) = params.recv_window {
3242 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3243 }
3244 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3245
3246 let mut header_params = std::collections::HashMap::new();
3248
3249 if let Some(ref binance_auth) = configuration.binance_auth {
3251 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3253
3254 let body_string: Option<Vec<u8>> = None;
3256
3257 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3259 Ok(sig) => sig,
3260 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3261 };
3262
3263 query_params.push(("signature".to_string(), signature));
3265 }
3266
3267 if !query_params.is_empty() {
3269 req_builder = req_builder.query(&query_params);
3270 }
3271
3272
3273 if let Some(ref user_agent) = configuration.user_agent {
3275 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3276 }
3277
3278 for (header_name, header_value) in header_params {
3280 req_builder = req_builder.header(&header_name, &header_value);
3281 }
3282
3283
3284 let req = req_builder.build()?;
3285 let resp = configuration.client.execute(req).await?;
3286
3287 let status = resp.status();
3288 let content_type = resp
3289 .headers()
3290 .get("content-type")
3291 .and_then(|v| v.to_str().ok())
3292 .unwrap_or("application/octet-stream");
3293 let content_type = super::ContentType::from(content_type);
3294
3295 if !status.is_client_error() && !status.is_server_error() {
3296 let content = resp.text().await?;
3297 match content_type {
3298 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3299 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmCommissionRateV1Resp`"))),
3300 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::PmarginGetUmCommissionRateV1Resp`")))),
3301 }
3302 } else {
3303 let content = resp.text().await?;
3304 let entity: Option<PmarginGetUmCommissionRateV1Error> = serde_json::from_str(&content).ok();
3305 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3306 }
3307}
3308
3309pub async fn pmargin_get_um_income_asyn_id_v1(configuration: &configuration::Configuration, params: PmarginGetUmIncomeAsynIdV1Params) -> Result<models::PmarginGetUmIncomeAsynIdV1Resp, Error<PmarginGetUmIncomeAsynIdV1Error>> {
3311
3312 let uri_str = format!("{}/papi/v1/um/income/asyn/id", configuration.base_path);
3313 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3314
3315 let mut query_params: Vec<(String, String)> = Vec::new();
3317
3318 query_params.push(("downloadId".to_string(), params.download_id.to_string()));
3319 if let Some(ref param_value) = params.recv_window {
3320 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3321 }
3322 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3323
3324 let mut header_params = std::collections::HashMap::new();
3326
3327 if let Some(ref binance_auth) = configuration.binance_auth {
3329 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3331
3332 let body_string: Option<Vec<u8>> = None;
3334
3335 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3337 Ok(sig) => sig,
3338 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3339 };
3340
3341 query_params.push(("signature".to_string(), signature));
3343 }
3344
3345 if !query_params.is_empty() {
3347 req_builder = req_builder.query(&query_params);
3348 }
3349
3350
3351 if let Some(ref user_agent) = configuration.user_agent {
3353 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3354 }
3355
3356 for (header_name, header_value) in header_params {
3358 req_builder = req_builder.header(&header_name, &header_value);
3359 }
3360
3361
3362 let req = req_builder.build()?;
3363 let resp = configuration.client.execute(req).await?;
3364
3365 let status = resp.status();
3366 let content_type = resp
3367 .headers()
3368 .get("content-type")
3369 .and_then(|v| v.to_str().ok())
3370 .unwrap_or("application/octet-stream");
3371 let content_type = super::ContentType::from(content_type);
3372
3373 if !status.is_client_error() && !status.is_server_error() {
3374 let content = resp.text().await?;
3375 match content_type {
3376 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3377 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmIncomeAsynIdV1Resp`"))),
3378 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::PmarginGetUmIncomeAsynIdV1Resp`")))),
3379 }
3380 } else {
3381 let content = resp.text().await?;
3382 let entity: Option<PmarginGetUmIncomeAsynIdV1Error> = serde_json::from_str(&content).ok();
3383 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3384 }
3385}
3386
3387pub async fn pmargin_get_um_income_asyn_v1(configuration: &configuration::Configuration, params: PmarginGetUmIncomeAsynV1Params) -> Result<models::PmarginGetUmIncomeAsynV1Resp, Error<PmarginGetUmIncomeAsynV1Error>> {
3389
3390 let uri_str = format!("{}/papi/v1/um/income/asyn", configuration.base_path);
3391 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3392
3393 let mut query_params: Vec<(String, String)> = Vec::new();
3395
3396 query_params.push(("startTime".to_string(), params.start_time.to_string()));
3397 query_params.push(("endTime".to_string(), params.end_time.to_string()));
3398 if let Some(ref param_value) = params.recv_window {
3399 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3400 }
3401 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3402
3403 let mut header_params = std::collections::HashMap::new();
3405
3406 if let Some(ref binance_auth) = configuration.binance_auth {
3408 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3410
3411 let body_string: Option<Vec<u8>> = None;
3413
3414 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3416 Ok(sig) => sig,
3417 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3418 };
3419
3420 query_params.push(("signature".to_string(), signature));
3422 }
3423
3424 if !query_params.is_empty() {
3426 req_builder = req_builder.query(&query_params);
3427 }
3428
3429
3430 if let Some(ref user_agent) = configuration.user_agent {
3432 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3433 }
3434
3435 for (header_name, header_value) in header_params {
3437 req_builder = req_builder.header(&header_name, &header_value);
3438 }
3439
3440
3441 let req = req_builder.build()?;
3442 let resp = configuration.client.execute(req).await?;
3443
3444 let status = resp.status();
3445 let content_type = resp
3446 .headers()
3447 .get("content-type")
3448 .and_then(|v| v.to_str().ok())
3449 .unwrap_or("application/octet-stream");
3450 let content_type = super::ContentType::from(content_type);
3451
3452 if !status.is_client_error() && !status.is_server_error() {
3453 let content = resp.text().await?;
3454 match content_type {
3455 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3456 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmIncomeAsynV1Resp`"))),
3457 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::PmarginGetUmIncomeAsynV1Resp`")))),
3458 }
3459 } else {
3460 let content = resp.text().await?;
3461 let entity: Option<PmarginGetUmIncomeAsynV1Error> = serde_json::from_str(&content).ok();
3462 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3463 }
3464}
3465
3466pub async fn pmargin_get_um_income_v1(configuration: &configuration::Configuration, params: PmarginGetUmIncomeV1Params) -> Result<Vec<models::PmarginGetUmIncomeV1RespItem>, Error<PmarginGetUmIncomeV1Error>> {
3468
3469 let uri_str = format!("{}/papi/v1/um/income", configuration.base_path);
3470 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3471
3472 let mut query_params: Vec<(String, String)> = Vec::new();
3474
3475 if let Some(ref param_value) = params.symbol {
3476 query_params.push(("symbol".to_string(), param_value.to_string()));
3477 }
3478 if let Some(ref param_value) = params.income_type {
3479 query_params.push(("incomeType".to_string(), param_value.to_string()));
3480 }
3481 if let Some(ref param_value) = params.start_time {
3482 query_params.push(("startTime".to_string(), param_value.to_string()));
3483 }
3484 if let Some(ref param_value) = params.end_time {
3485 query_params.push(("endTime".to_string(), param_value.to_string()));
3486 }
3487 if let Some(ref param_value) = params.page {
3488 query_params.push(("page".to_string(), param_value.to_string()));
3489 }
3490 if let Some(ref param_value) = params.limit {
3491 query_params.push(("limit".to_string(), param_value.to_string()));
3492 }
3493 if let Some(ref param_value) = params.recv_window {
3494 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3495 }
3496 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3497
3498 let mut header_params = std::collections::HashMap::new();
3500
3501 if let Some(ref binance_auth) = configuration.binance_auth {
3503 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3505
3506 let body_string: Option<Vec<u8>> = None;
3508
3509 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3511 Ok(sig) => sig,
3512 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3513 };
3514
3515 query_params.push(("signature".to_string(), signature));
3517 }
3518
3519 if !query_params.is_empty() {
3521 req_builder = req_builder.query(&query_params);
3522 }
3523
3524
3525 if let Some(ref user_agent) = configuration.user_agent {
3527 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3528 }
3529
3530 for (header_name, header_value) in header_params {
3532 req_builder = req_builder.header(&header_name, &header_value);
3533 }
3534
3535
3536 let req = req_builder.build()?;
3537 let resp = configuration.client.execute(req).await?;
3538
3539 let status = resp.status();
3540 let content_type = resp
3541 .headers()
3542 .get("content-type")
3543 .and_then(|v| v.to_str().ok())
3544 .unwrap_or("application/octet-stream");
3545 let content_type = super::ContentType::from(content_type);
3546
3547 if !status.is_client_error() && !status.is_server_error() {
3548 let content = resp.text().await?;
3549 match content_type {
3550 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3551 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmIncomeV1RespItem>`"))),
3552 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::PmarginGetUmIncomeV1RespItem>`")))),
3553 }
3554 } else {
3555 let content = resp.text().await?;
3556 let entity: Option<PmarginGetUmIncomeV1Error> = serde_json::from_str(&content).ok();
3557 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3558 }
3559}
3560
3561pub async fn pmargin_get_um_leverage_bracket_v1(configuration: &configuration::Configuration, params: PmarginGetUmLeverageBracketV1Params) -> Result<Vec<models::PmarginGetUmLeverageBracketV1RespItem>, Error<PmarginGetUmLeverageBracketV1Error>> {
3563
3564 let uri_str = format!("{}/papi/v1/um/leverageBracket", configuration.base_path);
3565 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3566
3567 let mut query_params: Vec<(String, String)> = Vec::new();
3569
3570 if let Some(ref param_value) = params.symbol {
3571 query_params.push(("symbol".to_string(), param_value.to_string()));
3572 }
3573 if let Some(ref param_value) = params.recv_window {
3574 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3575 }
3576 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3577
3578 let mut header_params = std::collections::HashMap::new();
3580
3581 if let Some(ref binance_auth) = configuration.binance_auth {
3583 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3585
3586 let body_string: Option<Vec<u8>> = None;
3588
3589 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3591 Ok(sig) => sig,
3592 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3593 };
3594
3595 query_params.push(("signature".to_string(), signature));
3597 }
3598
3599 if !query_params.is_empty() {
3601 req_builder = req_builder.query(&query_params);
3602 }
3603
3604
3605 if let Some(ref user_agent) = configuration.user_agent {
3607 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3608 }
3609
3610 for (header_name, header_value) in header_params {
3612 req_builder = req_builder.header(&header_name, &header_value);
3613 }
3614
3615
3616 let req = req_builder.build()?;
3617 let resp = configuration.client.execute(req).await?;
3618
3619 let status = resp.status();
3620 let content_type = resp
3621 .headers()
3622 .get("content-type")
3623 .and_then(|v| v.to_str().ok())
3624 .unwrap_or("application/octet-stream");
3625 let content_type = super::ContentType::from(content_type);
3626
3627 if !status.is_client_error() && !status.is_server_error() {
3628 let content = resp.text().await?;
3629 match content_type {
3630 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3631 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmLeverageBracketV1RespItem>`"))),
3632 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::PmarginGetUmLeverageBracketV1RespItem>`")))),
3633 }
3634 } else {
3635 let content = resp.text().await?;
3636 let entity: Option<PmarginGetUmLeverageBracketV1Error> = serde_json::from_str(&content).ok();
3637 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3638 }
3639}
3640
3641pub async fn pmargin_get_um_order_asyn_id_v1(configuration: &configuration::Configuration, params: PmarginGetUmOrderAsynIdV1Params) -> Result<models::PmarginGetUmOrderAsynIdV1Resp, Error<PmarginGetUmOrderAsynIdV1Error>> {
3643
3644 let uri_str = format!("{}/papi/v1/um/order/asyn/id", configuration.base_path);
3645 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3646
3647 let mut query_params: Vec<(String, String)> = Vec::new();
3649
3650 query_params.push(("downloadId".to_string(), params.download_id.to_string()));
3651 if let Some(ref param_value) = params.recv_window {
3652 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3653 }
3654 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3655
3656 let mut header_params = std::collections::HashMap::new();
3658
3659 if let Some(ref binance_auth) = configuration.binance_auth {
3661 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3663
3664 let body_string: Option<Vec<u8>> = None;
3666
3667 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3669 Ok(sig) => sig,
3670 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3671 };
3672
3673 query_params.push(("signature".to_string(), signature));
3675 }
3676
3677 if !query_params.is_empty() {
3679 req_builder = req_builder.query(&query_params);
3680 }
3681
3682
3683 if let Some(ref user_agent) = configuration.user_agent {
3685 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3686 }
3687
3688 for (header_name, header_value) in header_params {
3690 req_builder = req_builder.header(&header_name, &header_value);
3691 }
3692
3693
3694 let req = req_builder.build()?;
3695 let resp = configuration.client.execute(req).await?;
3696
3697 let status = resp.status();
3698 let content_type = resp
3699 .headers()
3700 .get("content-type")
3701 .and_then(|v| v.to_str().ok())
3702 .unwrap_or("application/octet-stream");
3703 let content_type = super::ContentType::from(content_type);
3704
3705 if !status.is_client_error() && !status.is_server_error() {
3706 let content = resp.text().await?;
3707 match content_type {
3708 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3709 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmOrderAsynIdV1Resp`"))),
3710 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::PmarginGetUmOrderAsynIdV1Resp`")))),
3711 }
3712 } else {
3713 let content = resp.text().await?;
3714 let entity: Option<PmarginGetUmOrderAsynIdV1Error> = serde_json::from_str(&content).ok();
3715 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3716 }
3717}
3718
3719pub async fn pmargin_get_um_order_asyn_v1(configuration: &configuration::Configuration, params: PmarginGetUmOrderAsynV1Params) -> Result<models::PmarginGetUmOrderAsynV1Resp, Error<PmarginGetUmOrderAsynV1Error>> {
3721
3722 let uri_str = format!("{}/papi/v1/um/order/asyn", configuration.base_path);
3723 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3724
3725 let mut query_params: Vec<(String, String)> = Vec::new();
3727
3728 query_params.push(("startTime".to_string(), params.start_time.to_string()));
3729 query_params.push(("endTime".to_string(), params.end_time.to_string()));
3730 if let Some(ref param_value) = params.recv_window {
3731 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3732 }
3733 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3734
3735 let mut header_params = std::collections::HashMap::new();
3737
3738 if let Some(ref binance_auth) = configuration.binance_auth {
3740 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3742
3743 let body_string: Option<Vec<u8>> = None;
3745
3746 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3748 Ok(sig) => sig,
3749 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3750 };
3751
3752 query_params.push(("signature".to_string(), signature));
3754 }
3755
3756 if !query_params.is_empty() {
3758 req_builder = req_builder.query(&query_params);
3759 }
3760
3761
3762 if let Some(ref user_agent) = configuration.user_agent {
3764 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3765 }
3766
3767 for (header_name, header_value) in header_params {
3769 req_builder = req_builder.header(&header_name, &header_value);
3770 }
3771
3772
3773 let req = req_builder.build()?;
3774 let resp = configuration.client.execute(req).await?;
3775
3776 let status = resp.status();
3777 let content_type = resp
3778 .headers()
3779 .get("content-type")
3780 .and_then(|v| v.to_str().ok())
3781 .unwrap_or("application/octet-stream");
3782 let content_type = super::ContentType::from(content_type);
3783
3784 if !status.is_client_error() && !status.is_server_error() {
3785 let content = resp.text().await?;
3786 match content_type {
3787 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3788 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmOrderAsynV1Resp`"))),
3789 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::PmarginGetUmOrderAsynV1Resp`")))),
3790 }
3791 } else {
3792 let content = resp.text().await?;
3793 let entity: Option<PmarginGetUmOrderAsynV1Error> = serde_json::from_str(&content).ok();
3794 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3795 }
3796}
3797
3798pub async fn pmargin_get_um_position_risk_v1(configuration: &configuration::Configuration) -> Result<Vec<models::PmarginGetUmPositionRiskV1RespItem>, Error<PmarginGetUmPositionRiskV1Error>> {
3800
3801 let uri_str = format!("{}/papi/v1/um/positionRisk", configuration.base_path);
3802 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3803
3804 let mut query_params: Vec<(String, String)> = Vec::new();
3806
3807
3808 let mut header_params = std::collections::HashMap::new();
3810
3811 if let Some(ref binance_auth) = configuration.binance_auth {
3813 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3815
3816 let body_string: Option<Vec<u8>> = None;
3818
3819 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3821 Ok(sig) => sig,
3822 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3823 };
3824
3825 query_params.push(("signature".to_string(), signature));
3827 }
3828
3829 if !query_params.is_empty() {
3831 req_builder = req_builder.query(&query_params);
3832 }
3833
3834
3835 if let Some(ref user_agent) = configuration.user_agent {
3837 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3838 }
3839
3840 for (header_name, header_value) in header_params {
3842 req_builder = req_builder.header(&header_name, &header_value);
3843 }
3844
3845
3846 let req = req_builder.build()?;
3847 let resp = configuration.client.execute(req).await?;
3848
3849 let status = resp.status();
3850 let content_type = resp
3851 .headers()
3852 .get("content-type")
3853 .and_then(|v| v.to_str().ok())
3854 .unwrap_or("application/octet-stream");
3855 let content_type = super::ContentType::from(content_type);
3856
3857 if !status.is_client_error() && !status.is_server_error() {
3858 let content = resp.text().await?;
3859 match content_type {
3860 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3861 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmPositionRiskV1RespItem>`"))),
3862 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::PmarginGetUmPositionRiskV1RespItem>`")))),
3863 }
3864 } else {
3865 let content = resp.text().await?;
3866 let entity: Option<PmarginGetUmPositionRiskV1Error> = serde_json::from_str(&content).ok();
3867 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3868 }
3869}
3870
3871pub async fn pmargin_get_um_position_side_dual_v1(configuration: &configuration::Configuration, params: PmarginGetUmPositionSideDualV1Params) -> Result<models::PmarginGetUmPositionSideDualV1Resp, Error<PmarginGetUmPositionSideDualV1Error>> {
3873
3874 let uri_str = format!("{}/papi/v1/um/positionSide/dual", configuration.base_path);
3875 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3876
3877 let mut query_params: Vec<(String, String)> = Vec::new();
3879
3880 if let Some(ref param_value) = params.recv_window {
3881 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3882 }
3883 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3884
3885 let mut header_params = std::collections::HashMap::new();
3887
3888 if let Some(ref binance_auth) = configuration.binance_auth {
3890 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3892
3893 let body_string: Option<Vec<u8>> = None;
3895
3896 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3898 Ok(sig) => sig,
3899 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3900 };
3901
3902 query_params.push(("signature".to_string(), signature));
3904 }
3905
3906 if !query_params.is_empty() {
3908 req_builder = req_builder.query(&query_params);
3909 }
3910
3911
3912 if let Some(ref user_agent) = configuration.user_agent {
3914 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3915 }
3916
3917 for (header_name, header_value) in header_params {
3919 req_builder = req_builder.header(&header_name, &header_value);
3920 }
3921
3922
3923 let req = req_builder.build()?;
3924 let resp = configuration.client.execute(req).await?;
3925
3926 let status = resp.status();
3927 let content_type = resp
3928 .headers()
3929 .get("content-type")
3930 .and_then(|v| v.to_str().ok())
3931 .unwrap_or("application/octet-stream");
3932 let content_type = super::ContentType::from(content_type);
3933
3934 if !status.is_client_error() && !status.is_server_error() {
3935 let content = resp.text().await?;
3936 match content_type {
3937 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3938 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmPositionSideDualV1Resp`"))),
3939 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::PmarginGetUmPositionSideDualV1Resp`")))),
3940 }
3941 } else {
3942 let content = resp.text().await?;
3943 let entity: Option<PmarginGetUmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
3944 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3945 }
3946}
3947
3948pub async fn pmargin_get_um_symbol_config_v1(configuration: &configuration::Configuration, params: PmarginGetUmSymbolConfigV1Params) -> Result<Vec<models::PmarginGetUmSymbolConfigV1RespItem>, Error<PmarginGetUmSymbolConfigV1Error>> {
3950
3951 let uri_str = format!("{}/papi/v1/um/symbolConfig", configuration.base_path);
3952 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3953
3954 let mut query_params: Vec<(String, String)> = Vec::new();
3956
3957 if let Some(ref param_value) = params.symbol {
3958 query_params.push(("symbol".to_string(), param_value.to_string()));
3959 }
3960 if let Some(ref param_value) = params.recv_window {
3961 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3962 }
3963 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3964
3965 let mut header_params = std::collections::HashMap::new();
3967
3968 if let Some(ref binance_auth) = configuration.binance_auth {
3970 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3972
3973 let body_string: Option<Vec<u8>> = None;
3975
3976 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3978 Ok(sig) => sig,
3979 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3980 };
3981
3982 query_params.push(("signature".to_string(), signature));
3984 }
3985
3986 if !query_params.is_empty() {
3988 req_builder = req_builder.query(&query_params);
3989 }
3990
3991
3992 if let Some(ref user_agent) = configuration.user_agent {
3994 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3995 }
3996
3997 for (header_name, header_value) in header_params {
3999 req_builder = req_builder.header(&header_name, &header_value);
4000 }
4001
4002
4003 let req = req_builder.build()?;
4004 let resp = configuration.client.execute(req).await?;
4005
4006 let status = resp.status();
4007 let content_type = resp
4008 .headers()
4009 .get("content-type")
4010 .and_then(|v| v.to_str().ok())
4011 .unwrap_or("application/octet-stream");
4012 let content_type = super::ContentType::from(content_type);
4013
4014 if !status.is_client_error() && !status.is_server_error() {
4015 let content = resp.text().await?;
4016 match content_type {
4017 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4018 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmSymbolConfigV1RespItem>`"))),
4019 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::PmarginGetUmSymbolConfigV1RespItem>`")))),
4020 }
4021 } else {
4022 let content = resp.text().await?;
4023 let entity: Option<PmarginGetUmSymbolConfigV1Error> = serde_json::from_str(&content).ok();
4024 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4025 }
4026}
4027
4028pub async fn pmargin_get_um_trade_asyn_id_v1(configuration: &configuration::Configuration, params: PmarginGetUmTradeAsynIdV1Params) -> Result<models::PmarginGetUmTradeAsynIdV1Resp, Error<PmarginGetUmTradeAsynIdV1Error>> {
4030
4031 let uri_str = format!("{}/papi/v1/um/trade/asyn/id", configuration.base_path);
4032 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4033
4034 let mut query_params: Vec<(String, String)> = Vec::new();
4036
4037 query_params.push(("downloadId".to_string(), params.download_id.to_string()));
4038 if let Some(ref param_value) = params.recv_window {
4039 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4040 }
4041 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4042
4043 let mut header_params = std::collections::HashMap::new();
4045
4046 if let Some(ref binance_auth) = configuration.binance_auth {
4048 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4050
4051 let body_string: Option<Vec<u8>> = None;
4053
4054 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4056 Ok(sig) => sig,
4057 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4058 };
4059
4060 query_params.push(("signature".to_string(), signature));
4062 }
4063
4064 if !query_params.is_empty() {
4066 req_builder = req_builder.query(&query_params);
4067 }
4068
4069
4070 if let Some(ref user_agent) = configuration.user_agent {
4072 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4073 }
4074
4075 for (header_name, header_value) in header_params {
4077 req_builder = req_builder.header(&header_name, &header_value);
4078 }
4079
4080
4081 let req = req_builder.build()?;
4082 let resp = configuration.client.execute(req).await?;
4083
4084 let status = resp.status();
4085 let content_type = resp
4086 .headers()
4087 .get("content-type")
4088 .and_then(|v| v.to_str().ok())
4089 .unwrap_or("application/octet-stream");
4090 let content_type = super::ContentType::from(content_type);
4091
4092 if !status.is_client_error() && !status.is_server_error() {
4093 let content = resp.text().await?;
4094 match content_type {
4095 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4096 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmTradeAsynIdV1Resp`"))),
4097 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::PmarginGetUmTradeAsynIdV1Resp`")))),
4098 }
4099 } else {
4100 let content = resp.text().await?;
4101 let entity: Option<PmarginGetUmTradeAsynIdV1Error> = serde_json::from_str(&content).ok();
4102 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4103 }
4104}
4105
4106pub async fn pmargin_get_um_trade_asyn_v1(configuration: &configuration::Configuration, params: PmarginGetUmTradeAsynV1Params) -> Result<models::PmarginGetUmTradeAsynV1Resp, Error<PmarginGetUmTradeAsynV1Error>> {
4108
4109 let uri_str = format!("{}/papi/v1/um/trade/asyn", configuration.base_path);
4110 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4111
4112 let mut query_params: Vec<(String, String)> = Vec::new();
4114
4115 query_params.push(("startTime".to_string(), params.start_time.to_string()));
4116 query_params.push(("endTime".to_string(), params.end_time.to_string()));
4117 if let Some(ref param_value) = params.recv_window {
4118 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4119 }
4120 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4121
4122 let mut header_params = std::collections::HashMap::new();
4124
4125 if let Some(ref binance_auth) = configuration.binance_auth {
4127 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4129
4130 let body_string: Option<Vec<u8>> = None;
4132
4133 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4135 Ok(sig) => sig,
4136 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4137 };
4138
4139 query_params.push(("signature".to_string(), signature));
4141 }
4142
4143 if !query_params.is_empty() {
4145 req_builder = req_builder.query(&query_params);
4146 }
4147
4148
4149 if let Some(ref user_agent) = configuration.user_agent {
4151 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4152 }
4153
4154 for (header_name, header_value) in header_params {
4156 req_builder = req_builder.header(&header_name, &header_value);
4157 }
4158
4159
4160 let req = req_builder.build()?;
4161 let resp = configuration.client.execute(req).await?;
4162
4163 let status = resp.status();
4164 let content_type = resp
4165 .headers()
4166 .get("content-type")
4167 .and_then(|v| v.to_str().ok())
4168 .unwrap_or("application/octet-stream");
4169 let content_type = super::ContentType::from(content_type);
4170
4171 if !status.is_client_error() && !status.is_server_error() {
4172 let content = resp.text().await?;
4173 match content_type {
4174 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4175 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmTradeAsynV1Resp`"))),
4176 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::PmarginGetUmTradeAsynV1Resp`")))),
4177 }
4178 } else {
4179 let content = resp.text().await?;
4180 let entity: Option<PmarginGetUmTradeAsynV1Error> = serde_json::from_str(&content).ok();
4181 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4182 }
4183}
4184