1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::cmfutures::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct CreateBatchOrdersV1Params {
20 pub batch_orders: Vec<models::CmfuturesCreateBatchOrderV1ReqBatchOrdersItem>,
21 pub timestamp: i64,
22 pub recv_window: Option<i64>
23}
24
25#[derive(Clone, Debug, Default)]
27pub struct CreateCountdownCancelAllV1Params {
28 pub countdown_time: i64,
29 pub symbol: String,
30 pub timestamp: i64,
31 pub recv_window: Option<i64>
32}
33
34#[derive(Clone, Debug, Default)]
36pub struct CreateLeverageV1Params {
37 pub leverage: i32,
38 pub symbol: String,
39 pub timestamp: i64,
40 pub recv_window: Option<i64>
41}
42
43#[derive(Clone, Debug, Default)]
45pub struct CreateMarginTypeV1Params {
46 pub margin_type: String,
47 pub symbol: String,
48 pub timestamp: i64,
49 pub recv_window: Option<i64>
50}
51
52#[derive(Clone, Debug, Default)]
54pub struct CreateOrderV1Params {
55 pub side: String,
56 pub symbol: String,
57 pub timestamp: i64,
58 pub r#type: String,
59 pub activation_price: Option<String>,
60 pub callback_rate: Option<String>,
61 pub close_position: Option<String>,
62 pub new_client_order_id: Option<String>,
63 pub new_order_resp_type: Option<String>,
64 pub position_side: Option<String>,
65 pub price: Option<String>,
66 pub price_match: Option<String>,
67 pub price_protect: Option<String>,
68 pub quantity: Option<String>,
69 pub recv_window: Option<i64>,
70 pub reduce_only: Option<String>,
71 pub self_trade_prevention_mode: Option<String>,
72 pub stop_price: Option<String>,
73 pub time_in_force: Option<String>,
74 pub working_type: Option<String>
75}
76
77#[derive(Clone, Debug, Default)]
79pub struct CreatePositionMarginV1Params {
80 pub amount: String,
81 pub symbol: String,
82 pub timestamp: i64,
83 pub r#type: i32,
84 pub position_side: Option<String>,
85 pub recv_window: Option<i64>
86}
87
88#[derive(Clone, Debug, Default)]
90pub struct CreatePositionSideDualV1Params {
91 pub dual_side_position: String,
92 pub timestamp: i64,
93 pub recv_window: Option<i64>
94}
95
96#[derive(Clone, Debug, Default)]
98pub struct DeleteAllOpenOrdersV1Params {
99 pub symbol: String,
100 pub timestamp: i64,
101 pub recv_window: Option<i64>
102}
103
104#[derive(Clone, Debug, Default)]
106pub struct DeleteBatchOrdersV1Params {
107 pub symbol: String,
108 pub timestamp: i64,
109 pub order_id_list: Option<Vec<i64>>,
111 pub orig_client_order_id_list: Option<Vec<String>>,
113 pub recv_window: Option<i64>
114}
115
116#[derive(Clone, Debug, Default)]
118pub struct DeleteOrderV1Params {
119 pub symbol: String,
120 pub timestamp: i64,
121 pub order_id: Option<i64>,
122 pub orig_client_order_id: Option<String>,
123 pub recv_window: Option<i64>
124}
125
126#[derive(Clone, Debug, Default)]
128pub struct GetAccountV1Params {
129 pub timestamp: i64,
130 pub recv_window: Option<i64>
131}
132
133#[derive(Clone, Debug, Default)]
135pub struct GetAdlQuantileV1Params {
136 pub timestamp: i64,
137 pub symbol: Option<String>,
138 pub recv_window: Option<i64>
139}
140
141#[derive(Clone, Debug, Default)]
143pub struct GetAggTradesV1Params {
144 pub symbol: String,
145 pub from_id: Option<i64>,
147 pub start_time: Option<i64>,
149 pub end_time: Option<i64>,
151 pub limit: Option<i32>
153}
154
155#[derive(Clone, Debug, Default)]
157pub struct GetAllOrdersV1Params {
158 pub timestamp: i64,
159 pub symbol: Option<String>,
160 pub pair: Option<String>,
161 pub order_id: Option<i64>,
162 pub start_time: Option<i64>,
163 pub end_time: Option<i64>,
164 pub limit: Option<i32>,
166 pub recv_window: Option<i64>
167}
168
169#[derive(Clone, Debug, Default)]
171pub struct GetBalanceV1Params {
172 pub timestamp: i64,
173 pub recv_window: Option<i64>
174}
175
176#[derive(Clone, Debug, Default)]
178pub struct GetCommissionRateV1Params {
179 pub symbol: String,
180 pub timestamp: i64,
181 pub recv_window: Option<i64>
182}
183
184#[derive(Clone, Debug, Default)]
186pub struct GetConstituentsV1Params {
187 pub symbol: String
188}
189
190#[derive(Clone, Debug, Default)]
192pub struct GetContinuousKlinesV1Params {
193 pub pair: String,
194 pub contract_type: String,
195 pub interval: String,
196 pub start_time: Option<i64>,
197 pub end_time: Option<i64>,
198 pub limit: Option<i32>
200}
201
202#[derive(Clone, Debug, Default)]
204pub struct GetDepthV1Params {
205 pub symbol: String,
206 pub limit: Option<i32>
208}
209
210#[derive(Clone, Debug, Default)]
212pub struct GetForceOrdersV1Params {
213 pub timestamp: i64,
214 pub symbol: Option<String>,
215 pub auto_close_type: Option<String>,
216 pub recv_window: Option<i64>,
217 pub limit: Option<i32>,
218 pub start_time: Option<i64>,
219 pub end_time: Option<i64>
220}
221
222#[derive(Clone, Debug, Default)]
224pub struct GetFundingRateV1Params {
225 pub symbol: String,
226 pub start_time: Option<i64>,
228 pub end_time: Option<i64>,
230 pub limit: Option<i32>
232}
233
234#[derive(Clone, Debug, Default)]
236pub struct GetFuturesDataBasisParams {
237 pub pair: String,
239 pub contract_type: String,
241 pub period: String,
243 pub limit: Option<i64>,
245 pub start_time: Option<i64>,
246 pub end_time: Option<i64>
247}
248
249#[derive(Clone, Debug, Default)]
251pub struct GetFuturesDataGlobalLongShortAccountRatioParams {
252 pub pair: String,
254 pub period: String,
256 pub limit: Option<i64>,
258 pub start_time: Option<i64>,
259 pub end_time: Option<i64>
260}
261
262#[derive(Clone, Debug, Default)]
264pub struct GetFuturesDataOpenInterestHistParams {
265 pub pair: String,
267 pub contract_type: String,
269 pub period: String,
271 pub limit: Option<i64>,
273 pub start_time: Option<i64>,
274 pub end_time: Option<i64>
275}
276
277#[derive(Clone, Debug, Default)]
279pub struct GetFuturesDataTakerBuySellVolParams {
280 pub pair: String,
282 pub contract_type: String,
284 pub period: String,
286 pub limit: Option<i64>,
288 pub start_time: Option<i64>,
289 pub end_time: Option<i64>
290}
291
292#[derive(Clone, Debug, Default)]
294pub struct GetFuturesDataTopLongShortAccountRatioParams {
295 pub symbol: String,
296 pub period: String,
298 pub limit: Option<i64>,
300 pub start_time: Option<i64>,
301 pub end_time: Option<i64>
302}
303
304#[derive(Clone, Debug, Default)]
306pub struct GetFuturesDataTopLongShortPositionRatioParams {
307 pub pair: String,
309 pub period: String,
311 pub limit: Option<i64>,
313 pub start_time: Option<i64>,
314 pub end_time: Option<i64>
315}
316
317#[derive(Clone, Debug, Default)]
319pub struct GetHistoricalTradesV1Params {
320 pub symbol: String,
321 pub limit: Option<i32>,
323 pub from_id: Option<i64>
325}
326
327#[derive(Clone, Debug, Default)]
329pub struct GetIncomeAsynIdV1Params {
330 pub download_id: String,
332 pub timestamp: i64,
333 pub recv_window: Option<i64>
334}
335
336#[derive(Clone, Debug, Default)]
338pub struct GetIncomeAsynV1Params {
339 pub start_time: i64,
341 pub end_time: i64,
343 pub timestamp: i64,
344 pub recv_window: Option<i64>
345}
346
347#[derive(Clone, Debug, Default)]
349pub struct GetIncomeV1Params {
350 pub timestamp: i64,
351 pub symbol: Option<String>,
352 pub income_type: Option<String>,
354 pub start_time: Option<i64>,
356 pub end_time: Option<i64>,
358 pub page: Option<i32>,
359 pub limit: Option<i32>,
361 pub recv_window: Option<i64>
362}
363
364#[derive(Clone, Debug, Default)]
366pub struct GetIndexPriceKlinesV1Params {
367 pub pair: String,
368 pub interval: String,
369 pub start_time: Option<i64>,
370 pub end_time: Option<i64>,
371 pub limit: Option<i32>
373}
374
375#[derive(Clone, Debug, Default)]
377pub struct GetKlinesV1Params {
378 pub symbol: String,
379 pub interval: String,
380 pub start_time: Option<i64>,
381 pub end_time: Option<i64>,
382 pub limit: Option<i32>
384}
385
386#[derive(Clone, Debug, Default)]
388pub struct GetLeverageBracketV1Params {
389 pub timestamp: i64,
390 pub pair: Option<String>,
391 pub recv_window: Option<i64>
392}
393
394#[derive(Clone, Debug, Default)]
396pub struct GetLeverageBracketV2Params {
397 pub timestamp: i64,
398 pub symbol: Option<String>,
399 pub recv_window: Option<i64>
400}
401
402#[derive(Clone, Debug, Default)]
404pub struct GetMarkPriceKlinesV1Params {
405 pub symbol: String,
406 pub interval: String,
407 pub start_time: Option<i64>,
408 pub end_time: Option<i64>,
409 pub limit: Option<i32>
411}
412
413#[derive(Clone, Debug, Default)]
415pub struct GetOpenInterestV1Params {
416 pub symbol: String
417}
418
419#[derive(Clone, Debug, Default)]
421pub struct GetOpenOrderV1Params {
422 pub symbol: String,
423 pub timestamp: i64,
424 pub order_id: Option<i64>,
425 pub orig_client_order_id: Option<String>,
426 pub recv_window: Option<i64>
427}
428
429#[derive(Clone, Debug, Default)]
431pub struct GetOpenOrdersV1Params {
432 pub timestamp: i64,
433 pub symbol: Option<String>,
434 pub pair: Option<String>,
435 pub recv_window: Option<i64>
436}
437
438#[derive(Clone, Debug, Default)]
440pub struct GetOrderAmendmentV1Params {
441 pub symbol: String,
442 pub timestamp: i64,
443 pub order_id: Option<i64>,
444 pub orig_client_order_id: Option<String>,
445 pub start_time: Option<i64>,
447 pub end_time: Option<i64>,
449 pub limit: Option<i32>,
451 pub recv_window: Option<i64>
452}
453
454#[derive(Clone, Debug, Default)]
456pub struct GetOrderAsynIdV1Params {
457 pub download_id: String,
459 pub timestamp: i64,
460 pub recv_window: Option<i64>
461}
462
463#[derive(Clone, Debug, Default)]
465pub struct GetOrderAsynV1Params {
466 pub start_time: i64,
468 pub end_time: i64,
470 pub timestamp: i64,
471 pub recv_window: Option<i64>
472}
473
474#[derive(Clone, Debug, Default)]
476pub struct GetOrderV1Params {
477 pub symbol: String,
478 pub timestamp: i64,
479 pub order_id: Option<i64>,
480 pub orig_client_order_id: Option<String>,
481 pub recv_window: Option<i64>
482}
483
484#[derive(Clone, Debug, Default)]
486pub struct GetPmAccountInfoV1Params {
487 pub asset: String,
488 pub recv_window: Option<i64>
489}
490
491#[derive(Clone, Debug, Default)]
493pub struct GetPositionMarginHistoryV1Params {
494 pub symbol: String,
495 pub timestamp: i64,
496 pub r#type: Option<i32>,
498 pub start_time: Option<i64>,
499 pub end_time: Option<i64>,
500 pub limit: Option<i32>,
502 pub recv_window: Option<i64>
503}
504
505#[derive(Clone, Debug, Default)]
507pub struct GetPositionRiskV1Params {
508 pub timestamp: i64,
509 pub margin_asset: Option<String>,
510 pub pair: Option<String>,
511 pub recv_window: Option<i64>
512}
513
514#[derive(Clone, Debug, Default)]
516pub struct GetPositionSideDualV1Params {
517 pub timestamp: i64,
518 pub recv_window: Option<i64>
519}
520
521#[derive(Clone, Debug, Default)]
523pub struct GetPremiumIndexKlinesV1Params {
524 pub symbol: String,
525 pub interval: String,
526 pub start_time: Option<i64>,
527 pub end_time: Option<i64>,
528 pub limit: Option<i32>
530}
531
532#[derive(Clone, Debug, Default)]
534pub struct GetPremiumIndexV1Params {
535 pub symbol: Option<String>,
536 pub pair: Option<String>
537}
538
539#[derive(Clone, Debug, Default)]
541pub struct GetTicker24hrV1Params {
542 pub symbol: Option<String>,
543 pub pair: Option<String>
544}
545
546#[derive(Clone, Debug, Default)]
548pub struct GetTickerBookTickerV1Params {
549 pub symbol: Option<String>,
550 pub pair: Option<String>
551}
552
553#[derive(Clone, Debug, Default)]
555pub struct GetTickerPriceV1Params {
556 pub symbol: Option<String>,
557 pub pair: Option<String>
558}
559
560#[derive(Clone, Debug, Default)]
562pub struct GetTradeAsynIdV1Params {
563 pub download_id: String,
565 pub timestamp: i64,
566 pub recv_window: Option<i64>
567}
568
569#[derive(Clone, Debug, Default)]
571pub struct GetTradeAsynV1Params {
572 pub start_time: i64,
574 pub end_time: i64,
576 pub timestamp: i64,
577 pub recv_window: Option<i64>
578}
579
580#[derive(Clone, Debug, Default)]
582pub struct GetTradesV1Params {
583 pub symbol: String,
584 pub limit: Option<i32>
586}
587
588#[derive(Clone, Debug, Default)]
590pub struct GetUserTradesV1Params {
591 pub timestamp: i64,
592 pub symbol: Option<String>,
593 pub pair: Option<String>,
594 pub order_id: Option<String>,
595 pub start_time: Option<i64>,
596 pub end_time: Option<i64>,
597 pub from_id: Option<i64>,
599 pub limit: Option<i32>,
601 pub recv_window: Option<i64>
602}
603
604#[derive(Clone, Debug, Default)]
606pub struct UpdateBatchOrdersV1Params {
607 pub batch_orders: Vec<models::CmfuturesUpdateBatchOrdersV1ReqBatchOrdersItem>,
608 pub timestamp: i64,
609 pub recv_window: Option<i64>
610}
611
612#[derive(Clone, Debug, Default)]
614pub struct UpdateOrderV1Params {
615 pub side: String,
616 pub symbol: String,
617 pub timestamp: i64,
618 pub order_id: Option<i64>,
619 pub orig_client_order_id: Option<String>,
620 pub price: Option<String>,
621 pub price_match: Option<String>,
622 pub quantity: Option<String>,
623 pub recv_window: Option<i64>
624}
625
626
627#[derive(Debug, Clone, Serialize, Deserialize)]
629#[serde(untagged)]
630pub enum CreateBatchOrdersV1Error {
631 Status4XX(models::ApiError),
632 Status5XX(models::ApiError),
633 UnknownValue(serde_json::Value),
634}
635
636#[derive(Debug, Clone, Serialize, Deserialize)]
638#[serde(untagged)]
639pub enum CreateCountdownCancelAllV1Error {
640 Status4XX(models::ApiError),
641 Status5XX(models::ApiError),
642 UnknownValue(serde_json::Value),
643}
644
645#[derive(Debug, Clone, Serialize, Deserialize)]
647#[serde(untagged)]
648pub enum CreateLeverageV1Error {
649 Status4XX(models::ApiError),
650 Status5XX(models::ApiError),
651 UnknownValue(serde_json::Value),
652}
653
654#[derive(Debug, Clone, Serialize, Deserialize)]
656#[serde(untagged)]
657pub enum CreateListenKeyV1Error {
658 Status4XX(models::ApiError),
659 Status5XX(models::ApiError),
660 UnknownValue(serde_json::Value),
661}
662
663#[derive(Debug, Clone, Serialize, Deserialize)]
665#[serde(untagged)]
666pub enum CreateMarginTypeV1Error {
667 Status4XX(models::ApiError),
668 Status5XX(models::ApiError),
669 UnknownValue(serde_json::Value),
670}
671
672#[derive(Debug, Clone, Serialize, Deserialize)]
674#[serde(untagged)]
675pub enum CreateOrderV1Error {
676 Status4XX(models::ApiError),
677 Status5XX(models::ApiError),
678 UnknownValue(serde_json::Value),
679}
680
681#[derive(Debug, Clone, Serialize, Deserialize)]
683#[serde(untagged)]
684pub enum CreatePositionMarginV1Error {
685 Status4XX(models::ApiError),
686 Status5XX(models::ApiError),
687 UnknownValue(serde_json::Value),
688}
689
690#[derive(Debug, Clone, Serialize, Deserialize)]
692#[serde(untagged)]
693pub enum CreatePositionSideDualV1Error {
694 Status4XX(models::ApiError),
695 Status5XX(models::ApiError),
696 UnknownValue(serde_json::Value),
697}
698
699#[derive(Debug, Clone, Serialize, Deserialize)]
701#[serde(untagged)]
702pub enum DeleteAllOpenOrdersV1Error {
703 Status4XX(models::ApiError),
704 Status5XX(models::ApiError),
705 UnknownValue(serde_json::Value),
706}
707
708#[derive(Debug, Clone, Serialize, Deserialize)]
710#[serde(untagged)]
711pub enum DeleteBatchOrdersV1Error {
712 Status4XX(models::ApiError),
713 Status5XX(models::ApiError),
714 UnknownValue(serde_json::Value),
715}
716
717#[derive(Debug, Clone, Serialize, Deserialize)]
719#[serde(untagged)]
720pub enum DeleteListenKeyV1Error {
721 Status4XX(models::ApiError),
722 Status5XX(models::ApiError),
723 UnknownValue(serde_json::Value),
724}
725
726#[derive(Debug, Clone, Serialize, Deserialize)]
728#[serde(untagged)]
729pub enum DeleteOrderV1Error {
730 Status4XX(models::ApiError),
731 Status5XX(models::ApiError),
732 UnknownValue(serde_json::Value),
733}
734
735#[derive(Debug, Clone, Serialize, Deserialize)]
737#[serde(untagged)]
738pub enum GetAccountV1Error {
739 Status4XX(models::ApiError),
740 Status5XX(models::ApiError),
741 UnknownValue(serde_json::Value),
742}
743
744#[derive(Debug, Clone, Serialize, Deserialize)]
746#[serde(untagged)]
747pub enum GetAdlQuantileV1Error {
748 Status4XX(models::ApiError),
749 Status5XX(models::ApiError),
750 UnknownValue(serde_json::Value),
751}
752
753#[derive(Debug, Clone, Serialize, Deserialize)]
755#[serde(untagged)]
756pub enum GetAggTradesV1Error {
757 Status4XX(models::ApiError),
758 Status5XX(models::ApiError),
759 UnknownValue(serde_json::Value),
760}
761
762#[derive(Debug, Clone, Serialize, Deserialize)]
764#[serde(untagged)]
765pub enum GetAllOrdersV1Error {
766 Status4XX(models::ApiError),
767 Status5XX(models::ApiError),
768 UnknownValue(serde_json::Value),
769}
770
771#[derive(Debug, Clone, Serialize, Deserialize)]
773#[serde(untagged)]
774pub enum GetBalanceV1Error {
775 Status4XX(models::ApiError),
776 Status5XX(models::ApiError),
777 UnknownValue(serde_json::Value),
778}
779
780#[derive(Debug, Clone, Serialize, Deserialize)]
782#[serde(untagged)]
783pub enum GetCommissionRateV1Error {
784 Status4XX(models::ApiError),
785 Status5XX(models::ApiError),
786 UnknownValue(serde_json::Value),
787}
788
789#[derive(Debug, Clone, Serialize, Deserialize)]
791#[serde(untagged)]
792pub enum GetConstituentsV1Error {
793 Status4XX(models::ApiError),
794 Status5XX(models::ApiError),
795 UnknownValue(serde_json::Value),
796}
797
798#[derive(Debug, Clone, Serialize, Deserialize)]
800#[serde(untagged)]
801pub enum GetContinuousKlinesV1Error {
802 Status4XX(models::ApiError),
803 Status5XX(models::ApiError),
804 UnknownValue(serde_json::Value),
805}
806
807#[derive(Debug, Clone, Serialize, Deserialize)]
809#[serde(untagged)]
810pub enum GetDepthV1Error {
811 Status4XX(models::ApiError),
812 Status5XX(models::ApiError),
813 UnknownValue(serde_json::Value),
814}
815
816#[derive(Debug, Clone, Serialize, Deserialize)]
818#[serde(untagged)]
819pub enum GetExchangeInfoV1Error {
820 Status4XX(models::ApiError),
821 Status5XX(models::ApiError),
822 UnknownValue(serde_json::Value),
823}
824
825#[derive(Debug, Clone, Serialize, Deserialize)]
827#[serde(untagged)]
828pub enum GetForceOrdersV1Error {
829 Status4XX(models::ApiError),
830 Status5XX(models::ApiError),
831 UnknownValue(serde_json::Value),
832}
833
834#[derive(Debug, Clone, Serialize, Deserialize)]
836#[serde(untagged)]
837pub enum GetFundingInfoV1Error {
838 Status4XX(models::ApiError),
839 Status5XX(models::ApiError),
840 UnknownValue(serde_json::Value),
841}
842
843#[derive(Debug, Clone, Serialize, Deserialize)]
845#[serde(untagged)]
846pub enum GetFundingRateV1Error {
847 Status4XX(models::ApiError),
848 Status5XX(models::ApiError),
849 UnknownValue(serde_json::Value),
850}
851
852#[derive(Debug, Clone, Serialize, Deserialize)]
854#[serde(untagged)]
855pub enum GetFuturesDataBasisError {
856 Status4XX(models::ApiError),
857 Status5XX(models::ApiError),
858 UnknownValue(serde_json::Value),
859}
860
861#[derive(Debug, Clone, Serialize, Deserialize)]
863#[serde(untagged)]
864pub enum GetFuturesDataGlobalLongShortAccountRatioError {
865 Status4XX(models::ApiError),
866 Status5XX(models::ApiError),
867 UnknownValue(serde_json::Value),
868}
869
870#[derive(Debug, Clone, Serialize, Deserialize)]
872#[serde(untagged)]
873pub enum GetFuturesDataOpenInterestHistError {
874 Status4XX(models::ApiError),
875 Status5XX(models::ApiError),
876 UnknownValue(serde_json::Value),
877}
878
879#[derive(Debug, Clone, Serialize, Deserialize)]
881#[serde(untagged)]
882pub enum GetFuturesDataTakerBuySellVolError {
883 Status4XX(models::ApiError),
884 Status5XX(models::ApiError),
885 UnknownValue(serde_json::Value),
886}
887
888#[derive(Debug, Clone, Serialize, Deserialize)]
890#[serde(untagged)]
891pub enum GetFuturesDataTopLongShortAccountRatioError {
892 Status4XX(models::ApiError),
893 Status5XX(models::ApiError),
894 UnknownValue(serde_json::Value),
895}
896
897#[derive(Debug, Clone, Serialize, Deserialize)]
899#[serde(untagged)]
900pub enum GetFuturesDataTopLongShortPositionRatioError {
901 Status4XX(models::ApiError),
902 Status5XX(models::ApiError),
903 UnknownValue(serde_json::Value),
904}
905
906#[derive(Debug, Clone, Serialize, Deserialize)]
908#[serde(untagged)]
909pub enum GetHistoricalTradesV1Error {
910 Status4XX(models::ApiError),
911 Status5XX(models::ApiError),
912 UnknownValue(serde_json::Value),
913}
914
915#[derive(Debug, Clone, Serialize, Deserialize)]
917#[serde(untagged)]
918pub enum GetIncomeAsynIdV1Error {
919 Status4XX(models::ApiError),
920 Status5XX(models::ApiError),
921 UnknownValue(serde_json::Value),
922}
923
924#[derive(Debug, Clone, Serialize, Deserialize)]
926#[serde(untagged)]
927pub enum GetIncomeAsynV1Error {
928 Status4XX(models::ApiError),
929 Status5XX(models::ApiError),
930 UnknownValue(serde_json::Value),
931}
932
933#[derive(Debug, Clone, Serialize, Deserialize)]
935#[serde(untagged)]
936pub enum GetIncomeV1Error {
937 Status4XX(models::ApiError),
938 Status5XX(models::ApiError),
939 UnknownValue(serde_json::Value),
940}
941
942#[derive(Debug, Clone, Serialize, Deserialize)]
944#[serde(untagged)]
945pub enum GetIndexPriceKlinesV1Error {
946 Status4XX(models::ApiError),
947 Status5XX(models::ApiError),
948 UnknownValue(serde_json::Value),
949}
950
951#[derive(Debug, Clone, Serialize, Deserialize)]
953#[serde(untagged)]
954pub enum GetKlinesV1Error {
955 Status4XX(models::ApiError),
956 Status5XX(models::ApiError),
957 UnknownValue(serde_json::Value),
958}
959
960#[derive(Debug, Clone, Serialize, Deserialize)]
962#[serde(untagged)]
963pub enum GetLeverageBracketV1Error {
964 Status4XX(models::ApiError),
965 Status5XX(models::ApiError),
966 UnknownValue(serde_json::Value),
967}
968
969#[derive(Debug, Clone, Serialize, Deserialize)]
971#[serde(untagged)]
972pub enum GetLeverageBracketV2Error {
973 Status4XX(models::ApiError),
974 Status5XX(models::ApiError),
975 UnknownValue(serde_json::Value),
976}
977
978#[derive(Debug, Clone, Serialize, Deserialize)]
980#[serde(untagged)]
981pub enum GetMarkPriceKlinesV1Error {
982 Status4XX(models::ApiError),
983 Status5XX(models::ApiError),
984 UnknownValue(serde_json::Value),
985}
986
987#[derive(Debug, Clone, Serialize, Deserialize)]
989#[serde(untagged)]
990pub enum GetOpenInterestV1Error {
991 Status4XX(models::ApiError),
992 Status5XX(models::ApiError),
993 UnknownValue(serde_json::Value),
994}
995
996#[derive(Debug, Clone, Serialize, Deserialize)]
998#[serde(untagged)]
999pub enum GetOpenOrderV1Error {
1000 Status4XX(models::ApiError),
1001 Status5XX(models::ApiError),
1002 UnknownValue(serde_json::Value),
1003}
1004
1005#[derive(Debug, Clone, Serialize, Deserialize)]
1007#[serde(untagged)]
1008pub enum GetOpenOrdersV1Error {
1009 Status4XX(models::ApiError),
1010 Status5XX(models::ApiError),
1011 UnknownValue(serde_json::Value),
1012}
1013
1014#[derive(Debug, Clone, Serialize, Deserialize)]
1016#[serde(untagged)]
1017pub enum GetOrderAmendmentV1Error {
1018 Status4XX(models::ApiError),
1019 Status5XX(models::ApiError),
1020 UnknownValue(serde_json::Value),
1021}
1022
1023#[derive(Debug, Clone, Serialize, Deserialize)]
1025#[serde(untagged)]
1026pub enum GetOrderAsynIdV1Error {
1027 Status4XX(models::ApiError),
1028 Status5XX(models::ApiError),
1029 UnknownValue(serde_json::Value),
1030}
1031
1032#[derive(Debug, Clone, Serialize, Deserialize)]
1034#[serde(untagged)]
1035pub enum GetOrderAsynV1Error {
1036 Status4XX(models::ApiError),
1037 Status5XX(models::ApiError),
1038 UnknownValue(serde_json::Value),
1039}
1040
1041#[derive(Debug, Clone, Serialize, Deserialize)]
1043#[serde(untagged)]
1044pub enum GetOrderV1Error {
1045 Status4XX(models::ApiError),
1046 Status5XX(models::ApiError),
1047 UnknownValue(serde_json::Value),
1048}
1049
1050#[derive(Debug, Clone, Serialize, Deserialize)]
1052#[serde(untagged)]
1053pub enum GetPingV1Error {
1054 Status4XX(models::ApiError),
1055 Status5XX(models::ApiError),
1056 UnknownValue(serde_json::Value),
1057}
1058
1059#[derive(Debug, Clone, Serialize, Deserialize)]
1061#[serde(untagged)]
1062pub enum GetPmAccountInfoV1Error {
1063 Status4XX(models::ApiError),
1064 Status5XX(models::ApiError),
1065 UnknownValue(serde_json::Value),
1066}
1067
1068#[derive(Debug, Clone, Serialize, Deserialize)]
1070#[serde(untagged)]
1071pub enum GetPositionMarginHistoryV1Error {
1072 Status4XX(models::ApiError),
1073 Status5XX(models::ApiError),
1074 UnknownValue(serde_json::Value),
1075}
1076
1077#[derive(Debug, Clone, Serialize, Deserialize)]
1079#[serde(untagged)]
1080pub enum GetPositionRiskV1Error {
1081 Status4XX(models::ApiError),
1082 Status5XX(models::ApiError),
1083 UnknownValue(serde_json::Value),
1084}
1085
1086#[derive(Debug, Clone, Serialize, Deserialize)]
1088#[serde(untagged)]
1089pub enum GetPositionSideDualV1Error {
1090 Status4XX(models::ApiError),
1091 Status5XX(models::ApiError),
1092 UnknownValue(serde_json::Value),
1093}
1094
1095#[derive(Debug, Clone, Serialize, Deserialize)]
1097#[serde(untagged)]
1098pub enum GetPremiumIndexKlinesV1Error {
1099 Status4XX(models::ApiError),
1100 Status5XX(models::ApiError),
1101 UnknownValue(serde_json::Value),
1102}
1103
1104#[derive(Debug, Clone, Serialize, Deserialize)]
1106#[serde(untagged)]
1107pub enum GetPremiumIndexV1Error {
1108 Status4XX(models::ApiError),
1109 Status5XX(models::ApiError),
1110 UnknownValue(serde_json::Value),
1111}
1112
1113#[derive(Debug, Clone, Serialize, Deserialize)]
1115#[serde(untagged)]
1116pub enum GetTicker24hrV1Error {
1117 Status4XX(models::ApiError),
1118 Status5XX(models::ApiError),
1119 UnknownValue(serde_json::Value),
1120}
1121
1122#[derive(Debug, Clone, Serialize, Deserialize)]
1124#[serde(untagged)]
1125pub enum GetTickerBookTickerV1Error {
1126 Status4XX(models::ApiError),
1127 Status5XX(models::ApiError),
1128 UnknownValue(serde_json::Value),
1129}
1130
1131#[derive(Debug, Clone, Serialize, Deserialize)]
1133#[serde(untagged)]
1134pub enum GetTickerPriceV1Error {
1135 Status4XX(models::ApiError),
1136 Status5XX(models::ApiError),
1137 UnknownValue(serde_json::Value),
1138}
1139
1140#[derive(Debug, Clone, Serialize, Deserialize)]
1142#[serde(untagged)]
1143pub enum GetTimeV1Error {
1144 Status4XX(models::ApiError),
1145 Status5XX(models::ApiError),
1146 UnknownValue(serde_json::Value),
1147}
1148
1149#[derive(Debug, Clone, Serialize, Deserialize)]
1151#[serde(untagged)]
1152pub enum GetTradeAsynIdV1Error {
1153 Status4XX(models::ApiError),
1154 Status5XX(models::ApiError),
1155 UnknownValue(serde_json::Value),
1156}
1157
1158#[derive(Debug, Clone, Serialize, Deserialize)]
1160#[serde(untagged)]
1161pub enum GetTradeAsynV1Error {
1162 Status4XX(models::ApiError),
1163 Status5XX(models::ApiError),
1164 UnknownValue(serde_json::Value),
1165}
1166
1167#[derive(Debug, Clone, Serialize, Deserialize)]
1169#[serde(untagged)]
1170pub enum GetTradesV1Error {
1171 Status4XX(models::ApiError),
1172 Status5XX(models::ApiError),
1173 UnknownValue(serde_json::Value),
1174}
1175
1176#[derive(Debug, Clone, Serialize, Deserialize)]
1178#[serde(untagged)]
1179pub enum GetUserTradesV1Error {
1180 Status4XX(models::ApiError),
1181 Status5XX(models::ApiError),
1182 UnknownValue(serde_json::Value),
1183}
1184
1185#[derive(Debug, Clone, Serialize, Deserialize)]
1187#[serde(untagged)]
1188pub enum UpdateBatchOrdersV1Error {
1189 Status4XX(models::ApiError),
1190 Status5XX(models::ApiError),
1191 UnknownValue(serde_json::Value),
1192}
1193
1194#[derive(Debug, Clone, Serialize, Deserialize)]
1196#[serde(untagged)]
1197pub enum UpdateListenKeyV1Error {
1198 Status4XX(models::ApiError),
1199 Status5XX(models::ApiError),
1200 UnknownValue(serde_json::Value),
1201}
1202
1203#[derive(Debug, Clone, Serialize, Deserialize)]
1205#[serde(untagged)]
1206pub enum UpdateOrderV1Error {
1207 Status4XX(models::ApiError),
1208 Status5XX(models::ApiError),
1209 UnknownValue(serde_json::Value),
1210}
1211
1212
1213pub async fn create_batch_orders_v1(configuration: &configuration::Configuration, params: CreateBatchOrdersV1Params) -> Result<Vec<models::CmfuturesCreateBatchOrdersV1RespInner>, Error<CreateBatchOrdersV1Error>> {
1215
1216 let uri_str = format!("{}/dapi/v1/batchOrders", configuration.base_path);
1217 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1218
1219 let mut query_params: Vec<(String, String)> = Vec::new();
1221
1222
1223 let mut header_params = std::collections::HashMap::new();
1225
1226 if let Some(ref binance_auth) = configuration.binance_auth {
1228 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1230
1231 let body_string: Option<Vec<u8>> = None;
1233
1234 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1236 Ok(sig) => sig,
1237 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1238 };
1239
1240 query_params.push(("signature".to_string(), signature));
1242 }
1243
1244 if !query_params.is_empty() {
1246 req_builder = req_builder.query(&query_params);
1247 }
1248
1249
1250 if let Some(ref user_agent) = configuration.user_agent {
1252 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1253 }
1254
1255 for (header_name, header_value) in header_params {
1257 req_builder = req_builder.header(&header_name, &header_value);
1258 }
1259
1260 let mut multipart_form_params = std::collections::HashMap::new();
1261 multipart_form_params.insert("batchOrders", params.batch_orders.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
1262 if let Some(param_value) = params.recv_window {
1263 multipart_form_params.insert("recvWindow", param_value.to_string());
1264 }
1265 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1266 req_builder = req_builder.form(&multipart_form_params);
1267
1268 let req = req_builder.build()?;
1269 let resp = configuration.client.execute(req).await?;
1270
1271 let status = resp.status();
1272 let content_type = resp
1273 .headers()
1274 .get("content-type")
1275 .and_then(|v| v.to_str().ok())
1276 .unwrap_or("application/octet-stream");
1277 let content_type = super::ContentType::from(content_type);
1278
1279 if !status.is_client_error() && !status.is_server_error() {
1280 let content = resp.text().await?;
1281 match content_type {
1282 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1283 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesCreateBatchOrdersV1RespInner>`"))),
1284 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::CmfuturesCreateBatchOrdersV1RespInner>`")))),
1285 }
1286 } else {
1287 let content = resp.text().await?;
1288 let entity: Option<CreateBatchOrdersV1Error> = serde_json::from_str(&content).ok();
1289 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1290 }
1291}
1292
1293pub async fn create_countdown_cancel_all_v1(configuration: &configuration::Configuration, params: CreateCountdownCancelAllV1Params) -> Result<models::CreateCountdownCancelAllV1Resp, Error<CreateCountdownCancelAllV1Error>> {
1295
1296 let uri_str = format!("{}/dapi/v1/countdownCancelAll", configuration.base_path);
1297 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1298
1299 let mut query_params: Vec<(String, String)> = Vec::new();
1301
1302
1303 let mut header_params = std::collections::HashMap::new();
1305
1306 if let Some(ref binance_auth) = configuration.binance_auth {
1308 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1310
1311 let body_string: Option<Vec<u8>> = None;
1313
1314 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1316 Ok(sig) => sig,
1317 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1318 };
1319
1320 query_params.push(("signature".to_string(), signature));
1322 }
1323
1324 if !query_params.is_empty() {
1326 req_builder = req_builder.query(&query_params);
1327 }
1328
1329
1330 if let Some(ref user_agent) = configuration.user_agent {
1332 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1333 }
1334
1335 for (header_name, header_value) in header_params {
1337 req_builder = req_builder.header(&header_name, &header_value);
1338 }
1339
1340 let mut multipart_form_params = std::collections::HashMap::new();
1341 multipart_form_params.insert("countdownTime", params.countdown_time.to_string());
1342 if let Some(param_value) = params.recv_window {
1343 multipart_form_params.insert("recvWindow", param_value.to_string());
1344 }
1345 multipart_form_params.insert("symbol", params.symbol.to_string());
1346 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1347 req_builder = req_builder.form(&multipart_form_params);
1348
1349 let req = req_builder.build()?;
1350 let resp = configuration.client.execute(req).await?;
1351
1352 let status = resp.status();
1353 let content_type = resp
1354 .headers()
1355 .get("content-type")
1356 .and_then(|v| v.to_str().ok())
1357 .unwrap_or("application/octet-stream");
1358 let content_type = super::ContentType::from(content_type);
1359
1360 if !status.is_client_error() && !status.is_server_error() {
1361 let content = resp.text().await?;
1362 match content_type {
1363 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1364 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCountdownCancelAllV1Resp`"))),
1365 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::CreateCountdownCancelAllV1Resp`")))),
1366 }
1367 } else {
1368 let content = resp.text().await?;
1369 let entity: Option<CreateCountdownCancelAllV1Error> = serde_json::from_str(&content).ok();
1370 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1371 }
1372}
1373
1374pub async fn create_leverage_v1(configuration: &configuration::Configuration, params: CreateLeverageV1Params) -> Result<models::CreateLeverageV1Resp, Error<CreateLeverageV1Error>> {
1376
1377 let uri_str = format!("{}/dapi/v1/leverage", configuration.base_path);
1378 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1379
1380 let mut query_params: Vec<(String, String)> = Vec::new();
1382
1383
1384 let mut header_params = std::collections::HashMap::new();
1386
1387 if let Some(ref binance_auth) = configuration.binance_auth {
1389 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1391
1392 let body_string: Option<Vec<u8>> = None;
1394
1395 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1397 Ok(sig) => sig,
1398 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1399 };
1400
1401 query_params.push(("signature".to_string(), signature));
1403 }
1404
1405 if !query_params.is_empty() {
1407 req_builder = req_builder.query(&query_params);
1408 }
1409
1410
1411 if let Some(ref user_agent) = configuration.user_agent {
1413 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1414 }
1415
1416 for (header_name, header_value) in header_params {
1418 req_builder = req_builder.header(&header_name, &header_value);
1419 }
1420
1421 let mut multipart_form_params = std::collections::HashMap::new();
1422 multipart_form_params.insert("leverage", params.leverage.to_string());
1423 if let Some(param_value) = params.recv_window {
1424 multipart_form_params.insert("recvWindow", param_value.to_string());
1425 }
1426 multipart_form_params.insert("symbol", params.symbol.to_string());
1427 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1428 req_builder = req_builder.form(&multipart_form_params);
1429
1430 let req = req_builder.build()?;
1431 let resp = configuration.client.execute(req).await?;
1432
1433 let status = resp.status();
1434 let content_type = resp
1435 .headers()
1436 .get("content-type")
1437 .and_then(|v| v.to_str().ok())
1438 .unwrap_or("application/octet-stream");
1439 let content_type = super::ContentType::from(content_type);
1440
1441 if !status.is_client_error() && !status.is_server_error() {
1442 let content = resp.text().await?;
1443 match content_type {
1444 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1445 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateLeverageV1Resp`"))),
1446 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::CreateLeverageV1Resp`")))),
1447 }
1448 } else {
1449 let content = resp.text().await?;
1450 let entity: Option<CreateLeverageV1Error> = serde_json::from_str(&content).ok();
1451 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1452 }
1453}
1454
1455pub async fn create_listen_key_v1(configuration: &configuration::Configuration) -> Result<models::CreateListenKeyV1Resp, Error<CreateListenKeyV1Error>> {
1457
1458 let uri_str = format!("{}/dapi/v1/listenKey", configuration.base_path);
1459 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1460
1461 let mut query_params: Vec<(String, String)> = Vec::new();
1463
1464
1465 let mut header_params = std::collections::HashMap::new();
1467
1468 if let Some(ref binance_auth) = configuration.binance_auth {
1470 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1472
1473 let body_string: Option<Vec<u8>> = None;
1475
1476 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1478 Ok(sig) => sig,
1479 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1480 };
1481
1482 query_params.push(("signature".to_string(), signature));
1484 }
1485
1486 if !query_params.is_empty() {
1488 req_builder = req_builder.query(&query_params);
1489 }
1490
1491
1492 if let Some(ref user_agent) = configuration.user_agent {
1494 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1495 }
1496
1497 for (header_name, header_value) in header_params {
1499 req_builder = req_builder.header(&header_name, &header_value);
1500 }
1501
1502
1503 let req = req_builder.build()?;
1504 let resp = configuration.client.execute(req).await?;
1505
1506 let status = resp.status();
1507 let content_type = resp
1508 .headers()
1509 .get("content-type")
1510 .and_then(|v| v.to_str().ok())
1511 .unwrap_or("application/octet-stream");
1512 let content_type = super::ContentType::from(content_type);
1513
1514 if !status.is_client_error() && !status.is_server_error() {
1515 let content = resp.text().await?;
1516 match content_type {
1517 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1518 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateListenKeyV1Resp`"))),
1519 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::CreateListenKeyV1Resp`")))),
1520 }
1521 } else {
1522 let content = resp.text().await?;
1523 let entity: Option<CreateListenKeyV1Error> = serde_json::from_str(&content).ok();
1524 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1525 }
1526}
1527
1528pub async fn create_margin_type_v1(configuration: &configuration::Configuration, params: CreateMarginTypeV1Params) -> Result<models::CreateMarginTypeV1Resp, Error<CreateMarginTypeV1Error>> {
1530
1531 let uri_str = format!("{}/dapi/v1/marginType", configuration.base_path);
1532 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1533
1534 let mut query_params: Vec<(String, String)> = Vec::new();
1536
1537
1538 let mut header_params = std::collections::HashMap::new();
1540
1541 if let Some(ref binance_auth) = configuration.binance_auth {
1543 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1545
1546 let body_string: Option<Vec<u8>> = None;
1548
1549 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1551 Ok(sig) => sig,
1552 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1553 };
1554
1555 query_params.push(("signature".to_string(), signature));
1557 }
1558
1559 if !query_params.is_empty() {
1561 req_builder = req_builder.query(&query_params);
1562 }
1563
1564
1565 if let Some(ref user_agent) = configuration.user_agent {
1567 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1568 }
1569
1570 for (header_name, header_value) in header_params {
1572 req_builder = req_builder.header(&header_name, &header_value);
1573 }
1574
1575 let mut multipart_form_params = std::collections::HashMap::new();
1576 multipart_form_params.insert("marginType", params.margin_type.to_string());
1577 if let Some(param_value) = params.recv_window {
1578 multipart_form_params.insert("recvWindow", param_value.to_string());
1579 }
1580 multipart_form_params.insert("symbol", params.symbol.to_string());
1581 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1582 req_builder = req_builder.form(&multipart_form_params);
1583
1584 let req = req_builder.build()?;
1585 let resp = configuration.client.execute(req).await?;
1586
1587 let status = resp.status();
1588 let content_type = resp
1589 .headers()
1590 .get("content-type")
1591 .and_then(|v| v.to_str().ok())
1592 .unwrap_or("application/octet-stream");
1593 let content_type = super::ContentType::from(content_type);
1594
1595 if !status.is_client_error() && !status.is_server_error() {
1596 let content = resp.text().await?;
1597 match content_type {
1598 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1599 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginTypeV1Resp`"))),
1600 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::CreateMarginTypeV1Resp`")))),
1601 }
1602 } else {
1603 let content = resp.text().await?;
1604 let entity: Option<CreateMarginTypeV1Error> = serde_json::from_str(&content).ok();
1605 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1606 }
1607}
1608
1609pub async fn create_order_v1(configuration: &configuration::Configuration, params: CreateOrderV1Params) -> Result<models::CreateOrderV1Resp, Error<CreateOrderV1Error>> {
1611
1612 let uri_str = format!("{}/dapi/v1/order", configuration.base_path);
1613 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1614
1615 let mut query_params: Vec<(String, String)> = Vec::new();
1617
1618
1619 let mut header_params = std::collections::HashMap::new();
1621
1622 if let Some(ref binance_auth) = configuration.binance_auth {
1624 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1626
1627 let body_string: Option<Vec<u8>> = None;
1629
1630 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1632 Ok(sig) => sig,
1633 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1634 };
1635
1636 query_params.push(("signature".to_string(), signature));
1638 }
1639
1640 if !query_params.is_empty() {
1642 req_builder = req_builder.query(&query_params);
1643 }
1644
1645
1646 if let Some(ref user_agent) = configuration.user_agent {
1648 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1649 }
1650
1651 for (header_name, header_value) in header_params {
1653 req_builder = req_builder.header(&header_name, &header_value);
1654 }
1655
1656 let mut multipart_form_params = std::collections::HashMap::new();
1657 if let Some(param_value) = params.activation_price {
1658 multipart_form_params.insert("activationPrice", param_value.to_string());
1659 }
1660 if let Some(param_value) = params.callback_rate {
1661 multipart_form_params.insert("callbackRate", param_value.to_string());
1662 }
1663 if let Some(param_value) = params.close_position {
1664 multipart_form_params.insert("closePosition", param_value.to_string());
1665 }
1666 if let Some(param_value) = params.new_client_order_id {
1667 multipart_form_params.insert("newClientOrderId", param_value.to_string());
1668 }
1669 if let Some(param_value) = params.new_order_resp_type {
1670 multipart_form_params.insert("newOrderRespType", param_value.to_string());
1671 }
1672 if let Some(param_value) = params.position_side {
1673 multipart_form_params.insert("positionSide", param_value.to_string());
1674 }
1675 if let Some(param_value) = params.price {
1676 multipart_form_params.insert("price", param_value.to_string());
1677 }
1678 if let Some(param_value) = params.price_match {
1679 multipart_form_params.insert("priceMatch", param_value.to_string());
1680 }
1681 if let Some(param_value) = params.price_protect {
1682 multipart_form_params.insert("priceProtect", param_value.to_string());
1683 }
1684 if let Some(param_value) = params.quantity {
1685 multipart_form_params.insert("quantity", param_value.to_string());
1686 }
1687 if let Some(param_value) = params.recv_window {
1688 multipart_form_params.insert("recvWindow", param_value.to_string());
1689 }
1690 if let Some(param_value) = params.reduce_only {
1691 multipart_form_params.insert("reduceOnly", param_value.to_string());
1692 }
1693 if let Some(param_value) = params.self_trade_prevention_mode {
1694 multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1695 }
1696 multipart_form_params.insert("side", params.side.to_string());
1697 if let Some(param_value) = params.stop_price {
1698 multipart_form_params.insert("stopPrice", param_value.to_string());
1699 }
1700 multipart_form_params.insert("symbol", params.symbol.to_string());
1701 if let Some(param_value) = params.time_in_force {
1702 multipart_form_params.insert("timeInForce", param_value.to_string());
1703 }
1704 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1705 multipart_form_params.insert("type", params.r#type.to_string());
1706 if let Some(param_value) = params.working_type {
1707 multipart_form_params.insert("workingType", param_value.to_string());
1708 }
1709 req_builder = req_builder.form(&multipart_form_params);
1710
1711 let req = req_builder.build()?;
1712 let resp = configuration.client.execute(req).await?;
1713
1714 let status = resp.status();
1715 let content_type = resp
1716 .headers()
1717 .get("content-type")
1718 .and_then(|v| v.to_str().ok())
1719 .unwrap_or("application/octet-stream");
1720 let content_type = super::ContentType::from(content_type);
1721
1722 if !status.is_client_error() && !status.is_server_error() {
1723 let content = resp.text().await?;
1724 match content_type {
1725 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1726 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateOrderV1Resp`"))),
1727 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::CreateOrderV1Resp`")))),
1728 }
1729 } else {
1730 let content = resp.text().await?;
1731 let entity: Option<CreateOrderV1Error> = serde_json::from_str(&content).ok();
1732 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1733 }
1734}
1735
1736pub async fn create_position_margin_v1(configuration: &configuration::Configuration, params: CreatePositionMarginV1Params) -> Result<models::CreatePositionMarginV1Resp, Error<CreatePositionMarginV1Error>> {
1738
1739 let uri_str = format!("{}/dapi/v1/positionMargin", configuration.base_path);
1740 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1741
1742 let mut query_params: Vec<(String, String)> = Vec::new();
1744
1745
1746 let mut header_params = std::collections::HashMap::new();
1748
1749 if let Some(ref binance_auth) = configuration.binance_auth {
1751 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1753
1754 let body_string: Option<Vec<u8>> = None;
1756
1757 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1759 Ok(sig) => sig,
1760 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1761 };
1762
1763 query_params.push(("signature".to_string(), signature));
1765 }
1766
1767 if !query_params.is_empty() {
1769 req_builder = req_builder.query(&query_params);
1770 }
1771
1772
1773 if let Some(ref user_agent) = configuration.user_agent {
1775 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1776 }
1777
1778 for (header_name, header_value) in header_params {
1780 req_builder = req_builder.header(&header_name, &header_value);
1781 }
1782
1783 let mut multipart_form_params = std::collections::HashMap::new();
1784 multipart_form_params.insert("amount", params.amount.to_string());
1785 if let Some(param_value) = params.position_side {
1786 multipart_form_params.insert("positionSide", param_value.to_string());
1787 }
1788 if let Some(param_value) = params.recv_window {
1789 multipart_form_params.insert("recvWindow", param_value.to_string());
1790 }
1791 multipart_form_params.insert("symbol", params.symbol.to_string());
1792 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1793 multipart_form_params.insert("type", params.r#type.to_string());
1794 req_builder = req_builder.form(&multipart_form_params);
1795
1796 let req = req_builder.build()?;
1797 let resp = configuration.client.execute(req).await?;
1798
1799 let status = resp.status();
1800 let content_type = resp
1801 .headers()
1802 .get("content-type")
1803 .and_then(|v| v.to_str().ok())
1804 .unwrap_or("application/octet-stream");
1805 let content_type = super::ContentType::from(content_type);
1806
1807 if !status.is_client_error() && !status.is_server_error() {
1808 let content = resp.text().await?;
1809 match content_type {
1810 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1811 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePositionMarginV1Resp`"))),
1812 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::CreatePositionMarginV1Resp`")))),
1813 }
1814 } else {
1815 let content = resp.text().await?;
1816 let entity: Option<CreatePositionMarginV1Error> = serde_json::from_str(&content).ok();
1817 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1818 }
1819}
1820
1821pub async fn create_position_side_dual_v1(configuration: &configuration::Configuration, params: CreatePositionSideDualV1Params) -> Result<models::CreatePositionSideDualV1Resp, Error<CreatePositionSideDualV1Error>> {
1823
1824 let uri_str = format!("{}/dapi/v1/positionSide/dual", configuration.base_path);
1825 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1826
1827 let mut query_params: Vec<(String, String)> = Vec::new();
1829
1830
1831 let mut header_params = std::collections::HashMap::new();
1833
1834 if let Some(ref binance_auth) = configuration.binance_auth {
1836 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1838
1839 let body_string: Option<Vec<u8>> = None;
1841
1842 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1844 Ok(sig) => sig,
1845 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1846 };
1847
1848 query_params.push(("signature".to_string(), signature));
1850 }
1851
1852 if !query_params.is_empty() {
1854 req_builder = req_builder.query(&query_params);
1855 }
1856
1857
1858 if let Some(ref user_agent) = configuration.user_agent {
1860 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1861 }
1862
1863 for (header_name, header_value) in header_params {
1865 req_builder = req_builder.header(&header_name, &header_value);
1866 }
1867
1868 let mut multipart_form_params = std::collections::HashMap::new();
1869 multipart_form_params.insert("dualSidePosition", params.dual_side_position.to_string());
1870 if let Some(param_value) = params.recv_window {
1871 multipart_form_params.insert("recvWindow", param_value.to_string());
1872 }
1873 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1874 req_builder = req_builder.form(&multipart_form_params);
1875
1876 let req = req_builder.build()?;
1877 let resp = configuration.client.execute(req).await?;
1878
1879 let status = resp.status();
1880 let content_type = resp
1881 .headers()
1882 .get("content-type")
1883 .and_then(|v| v.to_str().ok())
1884 .unwrap_or("application/octet-stream");
1885 let content_type = super::ContentType::from(content_type);
1886
1887 if !status.is_client_error() && !status.is_server_error() {
1888 let content = resp.text().await?;
1889 match content_type {
1890 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1891 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePositionSideDualV1Resp`"))),
1892 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::CreatePositionSideDualV1Resp`")))),
1893 }
1894 } else {
1895 let content = resp.text().await?;
1896 let entity: Option<CreatePositionSideDualV1Error> = serde_json::from_str(&content).ok();
1897 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1898 }
1899}
1900
1901pub async fn delete_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteAllOpenOrdersV1Params) -> Result<models::DeleteAllOpenOrdersV1Resp, Error<DeleteAllOpenOrdersV1Error>> {
1903
1904 let uri_str = format!("{}/dapi/v1/allOpenOrders", configuration.base_path);
1905 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1906
1907 let mut query_params: Vec<(String, String)> = Vec::new();
1909
1910 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1911 if let Some(ref param_value) = params.recv_window {
1912 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1913 }
1914 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1915
1916 let mut header_params = std::collections::HashMap::new();
1918
1919 if let Some(ref binance_auth) = configuration.binance_auth {
1921 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1923
1924 let body_string: Option<Vec<u8>> = None;
1926
1927 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1929 Ok(sig) => sig,
1930 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1931 };
1932
1933 query_params.push(("signature".to_string(), signature));
1935 }
1936
1937 if !query_params.is_empty() {
1939 req_builder = req_builder.query(&query_params);
1940 }
1941
1942
1943 if let Some(ref user_agent) = configuration.user_agent {
1945 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1946 }
1947
1948 for (header_name, header_value) in header_params {
1950 req_builder = req_builder.header(&header_name, &header_value);
1951 }
1952
1953
1954 let req = req_builder.build()?;
1955 let resp = configuration.client.execute(req).await?;
1956
1957 let status = resp.status();
1958 let content_type = resp
1959 .headers()
1960 .get("content-type")
1961 .and_then(|v| v.to_str().ok())
1962 .unwrap_or("application/octet-stream");
1963 let content_type = super::ContentType::from(content_type);
1964
1965 if !status.is_client_error() && !status.is_server_error() {
1966 let content = resp.text().await?;
1967 match content_type {
1968 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1969 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAllOpenOrdersV1Resp`"))),
1970 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::DeleteAllOpenOrdersV1Resp`")))),
1971 }
1972 } else {
1973 let content = resp.text().await?;
1974 let entity: Option<DeleteAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
1975 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1976 }
1977}
1978
1979pub async fn delete_batch_orders_v1(configuration: &configuration::Configuration, params: DeleteBatchOrdersV1Params) -> Result<Vec<models::CmfuturesDeleteBatchOrdersV1RespInner>, Error<DeleteBatchOrdersV1Error>> {
1981
1982 let uri_str = format!("{}/dapi/v1/batchOrders", configuration.base_path);
1983 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1984
1985 let mut query_params: Vec<(String, String)> = Vec::new();
1987
1988 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1989 if let Some(ref param_value) = params.order_id_list {
1990 match "multi" {
1991 "multi" => {
1992 for p in param_value {
1993 query_params.push(("orderIdList".to_string(), p.to_string()));
1994 }
1995 },
1996 _ => {
1997 let joined = param_value.iter()
1998 .map(|p| p.to_string())
1999 .collect::<Vec<String>>()
2000 .join(",");
2001 query_params.push(("orderIdList".to_string(), joined));
2002 }
2003 };
2004 }
2005 if let Some(ref param_value) = params.orig_client_order_id_list {
2006 match "multi" {
2007 "multi" => {
2008 for p in param_value {
2009 query_params.push(("origClientOrderIdList".to_string(), p.to_string()));
2010 }
2011 },
2012 _ => {
2013 let joined = param_value.iter()
2014 .map(|p| p.to_string())
2015 .collect::<Vec<String>>()
2016 .join(",");
2017 query_params.push(("origClientOrderIdList".to_string(), joined));
2018 }
2019 };
2020 }
2021 if let Some(ref param_value) = params.recv_window {
2022 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2023 }
2024 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2025
2026 let mut header_params = std::collections::HashMap::new();
2028
2029 if let Some(ref binance_auth) = configuration.binance_auth {
2031 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2033
2034 let body_string: Option<Vec<u8>> = None;
2036
2037 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2039 Ok(sig) => sig,
2040 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2041 };
2042
2043 query_params.push(("signature".to_string(), signature));
2045 }
2046
2047 if !query_params.is_empty() {
2049 req_builder = req_builder.query(&query_params);
2050 }
2051
2052
2053 if let Some(ref user_agent) = configuration.user_agent {
2055 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2056 }
2057
2058 for (header_name, header_value) in header_params {
2060 req_builder = req_builder.header(&header_name, &header_value);
2061 }
2062
2063
2064 let req = req_builder.build()?;
2065 let resp = configuration.client.execute(req).await?;
2066
2067 let status = resp.status();
2068 let content_type = resp
2069 .headers()
2070 .get("content-type")
2071 .and_then(|v| v.to_str().ok())
2072 .unwrap_or("application/octet-stream");
2073 let content_type = super::ContentType::from(content_type);
2074
2075 if !status.is_client_error() && !status.is_server_error() {
2076 let content = resp.text().await?;
2077 match content_type {
2078 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2079 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesDeleteBatchOrdersV1RespInner>`"))),
2080 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::CmfuturesDeleteBatchOrdersV1RespInner>`")))),
2081 }
2082 } else {
2083 let content = resp.text().await?;
2084 let entity: Option<DeleteBatchOrdersV1Error> = serde_json::from_str(&content).ok();
2085 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2086 }
2087}
2088
2089pub async fn delete_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<DeleteListenKeyV1Error>> {
2091
2092 let uri_str = format!("{}/dapi/v1/listenKey", configuration.base_path);
2093 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2094
2095 let mut query_params: Vec<(String, String)> = Vec::new();
2097
2098
2099 let mut header_params = std::collections::HashMap::new();
2101
2102 if let Some(ref binance_auth) = configuration.binance_auth {
2104 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2106
2107 let body_string: Option<Vec<u8>> = None;
2109
2110 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2112 Ok(sig) => sig,
2113 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2114 };
2115
2116 query_params.push(("signature".to_string(), signature));
2118 }
2119
2120 if !query_params.is_empty() {
2122 req_builder = req_builder.query(&query_params);
2123 }
2124
2125
2126 if let Some(ref user_agent) = configuration.user_agent {
2128 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2129 }
2130
2131 for (header_name, header_value) in header_params {
2133 req_builder = req_builder.header(&header_name, &header_value);
2134 }
2135
2136
2137 let req = req_builder.build()?;
2138 let resp = configuration.client.execute(req).await?;
2139
2140 let status = resp.status();
2141 let content_type = resp
2142 .headers()
2143 .get("content-type")
2144 .and_then(|v| v.to_str().ok())
2145 .unwrap_or("application/octet-stream");
2146 let content_type = super::ContentType::from(content_type);
2147
2148 if !status.is_client_error() && !status.is_server_error() {
2149 let content = resp.text().await?;
2150 match content_type {
2151 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2152 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
2153 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
2154 }
2155 } else {
2156 let content = resp.text().await?;
2157 let entity: Option<DeleteListenKeyV1Error> = serde_json::from_str(&content).ok();
2158 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2159 }
2160}
2161
2162pub async fn delete_order_v1(configuration: &configuration::Configuration, params: DeleteOrderV1Params) -> Result<models::DeleteOrderV1Resp, Error<DeleteOrderV1Error>> {
2164
2165 let uri_str = format!("{}/dapi/v1/order", configuration.base_path);
2166 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2167
2168 let mut query_params: Vec<(String, String)> = Vec::new();
2170
2171 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2172 if let Some(ref param_value) = params.order_id {
2173 query_params.push(("orderId".to_string(), param_value.to_string()));
2174 }
2175 if let Some(ref param_value) = params.orig_client_order_id {
2176 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2177 }
2178 if let Some(ref param_value) = params.recv_window {
2179 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2180 }
2181 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2182
2183 let mut header_params = std::collections::HashMap::new();
2185
2186 if let Some(ref binance_auth) = configuration.binance_auth {
2188 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2190
2191 let body_string: Option<Vec<u8>> = None;
2193
2194 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2196 Ok(sig) => sig,
2197 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2198 };
2199
2200 query_params.push(("signature".to_string(), signature));
2202 }
2203
2204 if !query_params.is_empty() {
2206 req_builder = req_builder.query(&query_params);
2207 }
2208
2209
2210 if let Some(ref user_agent) = configuration.user_agent {
2212 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2213 }
2214
2215 for (header_name, header_value) in header_params {
2217 req_builder = req_builder.header(&header_name, &header_value);
2218 }
2219
2220
2221 let req = req_builder.build()?;
2222 let resp = configuration.client.execute(req).await?;
2223
2224 let status = resp.status();
2225 let content_type = resp
2226 .headers()
2227 .get("content-type")
2228 .and_then(|v| v.to_str().ok())
2229 .unwrap_or("application/octet-stream");
2230 let content_type = super::ContentType::from(content_type);
2231
2232 if !status.is_client_error() && !status.is_server_error() {
2233 let content = resp.text().await?;
2234 match content_type {
2235 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2236 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteOrderV1Resp`"))),
2237 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::DeleteOrderV1Resp`")))),
2238 }
2239 } else {
2240 let content = resp.text().await?;
2241 let entity: Option<DeleteOrderV1Error> = serde_json::from_str(&content).ok();
2242 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2243 }
2244}
2245
2246pub async fn get_account_v1(configuration: &configuration::Configuration, params: GetAccountV1Params) -> Result<models::GetAccountV1Resp, Error<GetAccountV1Error>> {
2248
2249 let uri_str = format!("{}/dapi/v1/account", configuration.base_path);
2250 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2251
2252 let mut query_params: Vec<(String, String)> = Vec::new();
2254
2255 if let Some(ref param_value) = params.recv_window {
2256 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2257 }
2258 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2259
2260 let mut header_params = std::collections::HashMap::new();
2262
2263 if let Some(ref binance_auth) = configuration.binance_auth {
2265 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2267
2268 let body_string: Option<Vec<u8>> = None;
2270
2271 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2273 Ok(sig) => sig,
2274 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2275 };
2276
2277 query_params.push(("signature".to_string(), signature));
2279 }
2280
2281 if !query_params.is_empty() {
2283 req_builder = req_builder.query(&query_params);
2284 }
2285
2286
2287 if let Some(ref user_agent) = configuration.user_agent {
2289 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2290 }
2291
2292 for (header_name, header_value) in header_params {
2294 req_builder = req_builder.header(&header_name, &header_value);
2295 }
2296
2297
2298 let req = req_builder.build()?;
2299 let resp = configuration.client.execute(req).await?;
2300
2301 let status = resp.status();
2302 let content_type = resp
2303 .headers()
2304 .get("content-type")
2305 .and_then(|v| v.to_str().ok())
2306 .unwrap_or("application/octet-stream");
2307 let content_type = super::ContentType::from(content_type);
2308
2309 if !status.is_client_error() && !status.is_server_error() {
2310 let content = resp.text().await?;
2311 match content_type {
2312 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2313 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountV1Resp`"))),
2314 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::GetAccountV1Resp`")))),
2315 }
2316 } else {
2317 let content = resp.text().await?;
2318 let entity: Option<GetAccountV1Error> = serde_json::from_str(&content).ok();
2319 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2320 }
2321}
2322
2323pub async fn get_adl_quantile_v1(configuration: &configuration::Configuration, params: GetAdlQuantileV1Params) -> Result<Vec<models::GetAdlQuantileV1RespItem>, Error<GetAdlQuantileV1Error>> {
2325
2326 let uri_str = format!("{}/dapi/v1/adlQuantile", configuration.base_path);
2327 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2328
2329 let mut query_params: Vec<(String, String)> = Vec::new();
2331
2332 if let Some(ref param_value) = params.symbol {
2333 query_params.push(("symbol".to_string(), param_value.to_string()));
2334 }
2335 if let Some(ref param_value) = params.recv_window {
2336 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2337 }
2338 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2339
2340 let mut header_params = std::collections::HashMap::new();
2342
2343 if let Some(ref binance_auth) = configuration.binance_auth {
2345 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2347
2348 let body_string: Option<Vec<u8>> = None;
2350
2351 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2353 Ok(sig) => sig,
2354 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2355 };
2356
2357 query_params.push(("signature".to_string(), signature));
2359 }
2360
2361 if !query_params.is_empty() {
2363 req_builder = req_builder.query(&query_params);
2364 }
2365
2366
2367 if let Some(ref user_agent) = configuration.user_agent {
2369 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2370 }
2371
2372 for (header_name, header_value) in header_params {
2374 req_builder = req_builder.header(&header_name, &header_value);
2375 }
2376
2377
2378 let req = req_builder.build()?;
2379 let resp = configuration.client.execute(req).await?;
2380
2381 let status = resp.status();
2382 let content_type = resp
2383 .headers()
2384 .get("content-type")
2385 .and_then(|v| v.to_str().ok())
2386 .unwrap_or("application/octet-stream");
2387 let content_type = super::ContentType::from(content_type);
2388
2389 if !status.is_client_error() && !status.is_server_error() {
2390 let content = resp.text().await?;
2391 match content_type {
2392 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2393 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetAdlQuantileV1RespItem>`"))),
2394 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::GetAdlQuantileV1RespItem>`")))),
2395 }
2396 } else {
2397 let content = resp.text().await?;
2398 let entity: Option<GetAdlQuantileV1Error> = serde_json::from_str(&content).ok();
2399 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2400 }
2401}
2402
2403pub async fn get_agg_trades_v1(configuration: &configuration::Configuration, params: GetAggTradesV1Params) -> Result<Vec<models::GetAggTradesV1RespItem>, Error<GetAggTradesV1Error>> {
2405
2406 let uri_str = format!("{}/dapi/v1/aggTrades", configuration.base_path);
2407 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2408
2409 let mut query_params: Vec<(String, String)> = Vec::new();
2411
2412 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2413 if let Some(ref param_value) = params.from_id {
2414 query_params.push(("fromId".to_string(), param_value.to_string()));
2415 }
2416 if let Some(ref param_value) = params.start_time {
2417 query_params.push(("startTime".to_string(), param_value.to_string()));
2418 }
2419 if let Some(ref param_value) = params.end_time {
2420 query_params.push(("endTime".to_string(), param_value.to_string()));
2421 }
2422 if let Some(ref param_value) = params.limit {
2423 query_params.push(("limit".to_string(), param_value.to_string()));
2424 }
2425
2426 let mut header_params = std::collections::HashMap::new();
2428
2429 if let Some(ref binance_auth) = configuration.binance_auth {
2431 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2433
2434 let body_string: Option<Vec<u8>> = None;
2436
2437 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2439 Ok(sig) => sig,
2440 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2441 };
2442
2443 query_params.push(("signature".to_string(), signature));
2445 }
2446
2447 if !query_params.is_empty() {
2449 req_builder = req_builder.query(&query_params);
2450 }
2451
2452
2453 if let Some(ref user_agent) = configuration.user_agent {
2455 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2456 }
2457
2458 for (header_name, header_value) in header_params {
2460 req_builder = req_builder.header(&header_name, &header_value);
2461 }
2462
2463
2464 let req = req_builder.build()?;
2465 let resp = configuration.client.execute(req).await?;
2466
2467 let status = resp.status();
2468 let content_type = resp
2469 .headers()
2470 .get("content-type")
2471 .and_then(|v| v.to_str().ok())
2472 .unwrap_or("application/octet-stream");
2473 let content_type = super::ContentType::from(content_type);
2474
2475 if !status.is_client_error() && !status.is_server_error() {
2476 let content = resp.text().await?;
2477 match content_type {
2478 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2479 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetAggTradesV1RespItem>`"))),
2480 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::GetAggTradesV1RespItem>`")))),
2481 }
2482 } else {
2483 let content = resp.text().await?;
2484 let entity: Option<GetAggTradesV1Error> = serde_json::from_str(&content).ok();
2485 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2486 }
2487}
2488
2489pub async fn get_all_orders_v1(configuration: &configuration::Configuration, params: GetAllOrdersV1Params) -> Result<Vec<models::GetAllOrdersV1RespItem>, Error<GetAllOrdersV1Error>> {
2491
2492 let uri_str = format!("{}/dapi/v1/allOrders", configuration.base_path);
2493 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2494
2495 let mut query_params: Vec<(String, String)> = Vec::new();
2497
2498 if let Some(ref param_value) = params.symbol {
2499 query_params.push(("symbol".to_string(), param_value.to_string()));
2500 }
2501 if let Some(ref param_value) = params.pair {
2502 query_params.push(("pair".to_string(), param_value.to_string()));
2503 }
2504 if let Some(ref param_value) = params.order_id {
2505 query_params.push(("orderId".to_string(), param_value.to_string()));
2506 }
2507 if let Some(ref param_value) = params.start_time {
2508 query_params.push(("startTime".to_string(), param_value.to_string()));
2509 }
2510 if let Some(ref param_value) = params.end_time {
2511 query_params.push(("endTime".to_string(), param_value.to_string()));
2512 }
2513 if let Some(ref param_value) = params.limit {
2514 query_params.push(("limit".to_string(), param_value.to_string()));
2515 }
2516 if let Some(ref param_value) = params.recv_window {
2517 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2518 }
2519 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2520
2521 let mut header_params = std::collections::HashMap::new();
2523
2524 if let Some(ref binance_auth) = configuration.binance_auth {
2526 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2528
2529 let body_string: Option<Vec<u8>> = None;
2531
2532 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2534 Ok(sig) => sig,
2535 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2536 };
2537
2538 query_params.push(("signature".to_string(), signature));
2540 }
2541
2542 if !query_params.is_empty() {
2544 req_builder = req_builder.query(&query_params);
2545 }
2546
2547
2548 if let Some(ref user_agent) = configuration.user_agent {
2550 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2551 }
2552
2553 for (header_name, header_value) in header_params {
2555 req_builder = req_builder.header(&header_name, &header_value);
2556 }
2557
2558
2559 let req = req_builder.build()?;
2560 let resp = configuration.client.execute(req).await?;
2561
2562 let status = resp.status();
2563 let content_type = resp
2564 .headers()
2565 .get("content-type")
2566 .and_then(|v| v.to_str().ok())
2567 .unwrap_or("application/octet-stream");
2568 let content_type = super::ContentType::from(content_type);
2569
2570 if !status.is_client_error() && !status.is_server_error() {
2571 let content = resp.text().await?;
2572 match content_type {
2573 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2574 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetAllOrdersV1RespItem>`"))),
2575 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::GetAllOrdersV1RespItem>`")))),
2576 }
2577 } else {
2578 let content = resp.text().await?;
2579 let entity: Option<GetAllOrdersV1Error> = serde_json::from_str(&content).ok();
2580 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2581 }
2582}
2583
2584pub async fn get_balance_v1(configuration: &configuration::Configuration, params: GetBalanceV1Params) -> Result<Vec<models::GetBalanceV1RespItem>, Error<GetBalanceV1Error>> {
2586
2587 let uri_str = format!("{}/dapi/v1/balance", configuration.base_path);
2588 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2589
2590 let mut query_params: Vec<(String, String)> = Vec::new();
2592
2593 if let Some(ref param_value) = params.recv_window {
2594 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2595 }
2596 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2597
2598 let mut header_params = std::collections::HashMap::new();
2600
2601 if let Some(ref binance_auth) = configuration.binance_auth {
2603 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2605
2606 let body_string: Option<Vec<u8>> = None;
2608
2609 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2611 Ok(sig) => sig,
2612 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2613 };
2614
2615 query_params.push(("signature".to_string(), signature));
2617 }
2618
2619 if !query_params.is_empty() {
2621 req_builder = req_builder.query(&query_params);
2622 }
2623
2624
2625 if let Some(ref user_agent) = configuration.user_agent {
2627 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2628 }
2629
2630 for (header_name, header_value) in header_params {
2632 req_builder = req_builder.header(&header_name, &header_value);
2633 }
2634
2635
2636 let req = req_builder.build()?;
2637 let resp = configuration.client.execute(req).await?;
2638
2639 let status = resp.status();
2640 let content_type = resp
2641 .headers()
2642 .get("content-type")
2643 .and_then(|v| v.to_str().ok())
2644 .unwrap_or("application/octet-stream");
2645 let content_type = super::ContentType::from(content_type);
2646
2647 if !status.is_client_error() && !status.is_server_error() {
2648 let content = resp.text().await?;
2649 match content_type {
2650 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2651 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBalanceV1RespItem>`"))),
2652 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::GetBalanceV1RespItem>`")))),
2653 }
2654 } else {
2655 let content = resp.text().await?;
2656 let entity: Option<GetBalanceV1Error> = serde_json::from_str(&content).ok();
2657 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2658 }
2659}
2660
2661pub async fn get_commission_rate_v1(configuration: &configuration::Configuration, params: GetCommissionRateV1Params) -> Result<models::GetCommissionRateV1Resp, Error<GetCommissionRateV1Error>> {
2663
2664 let uri_str = format!("{}/dapi/v1/commissionRate", configuration.base_path);
2665 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2666
2667 let mut query_params: Vec<(String, String)> = Vec::new();
2669
2670 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2671 if let Some(ref param_value) = params.recv_window {
2672 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2673 }
2674 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2675
2676 let mut header_params = std::collections::HashMap::new();
2678
2679 if let Some(ref binance_auth) = configuration.binance_auth {
2681 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2683
2684 let body_string: Option<Vec<u8>> = None;
2686
2687 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2689 Ok(sig) => sig,
2690 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2691 };
2692
2693 query_params.push(("signature".to_string(), signature));
2695 }
2696
2697 if !query_params.is_empty() {
2699 req_builder = req_builder.query(&query_params);
2700 }
2701
2702
2703 if let Some(ref user_agent) = configuration.user_agent {
2705 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2706 }
2707
2708 for (header_name, header_value) in header_params {
2710 req_builder = req_builder.header(&header_name, &header_value);
2711 }
2712
2713
2714 let req = req_builder.build()?;
2715 let resp = configuration.client.execute(req).await?;
2716
2717 let status = resp.status();
2718 let content_type = resp
2719 .headers()
2720 .get("content-type")
2721 .and_then(|v| v.to_str().ok())
2722 .unwrap_or("application/octet-stream");
2723 let content_type = super::ContentType::from(content_type);
2724
2725 if !status.is_client_error() && !status.is_server_error() {
2726 let content = resp.text().await?;
2727 match content_type {
2728 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2729 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCommissionRateV1Resp`"))),
2730 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::GetCommissionRateV1Resp`")))),
2731 }
2732 } else {
2733 let content = resp.text().await?;
2734 let entity: Option<GetCommissionRateV1Error> = serde_json::from_str(&content).ok();
2735 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2736 }
2737}
2738
2739pub async fn get_constituents_v1(configuration: &configuration::Configuration, params: GetConstituentsV1Params) -> Result<models::GetConstituentsV1Resp, Error<GetConstituentsV1Error>> {
2741
2742 let uri_str = format!("{}/dapi/v1/constituents", configuration.base_path);
2743 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2744
2745 let mut query_params: Vec<(String, String)> = Vec::new();
2747
2748 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2749
2750 let mut header_params = std::collections::HashMap::new();
2752
2753 if let Some(ref binance_auth) = configuration.binance_auth {
2755 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2757
2758 let body_string: Option<Vec<u8>> = None;
2760
2761 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2763 Ok(sig) => sig,
2764 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2765 };
2766
2767 query_params.push(("signature".to_string(), signature));
2769 }
2770
2771 if !query_params.is_empty() {
2773 req_builder = req_builder.query(&query_params);
2774 }
2775
2776
2777 if let Some(ref user_agent) = configuration.user_agent {
2779 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2780 }
2781
2782 for (header_name, header_value) in header_params {
2784 req_builder = req_builder.header(&header_name, &header_value);
2785 }
2786
2787
2788 let req = req_builder.build()?;
2789 let resp = configuration.client.execute(req).await?;
2790
2791 let status = resp.status();
2792 let content_type = resp
2793 .headers()
2794 .get("content-type")
2795 .and_then(|v| v.to_str().ok())
2796 .unwrap_or("application/octet-stream");
2797 let content_type = super::ContentType::from(content_type);
2798
2799 if !status.is_client_error() && !status.is_server_error() {
2800 let content = resp.text().await?;
2801 match content_type {
2802 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2803 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetConstituentsV1Resp`"))),
2804 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::GetConstituentsV1Resp`")))),
2805 }
2806 } else {
2807 let content = resp.text().await?;
2808 let entity: Option<GetConstituentsV1Error> = serde_json::from_str(&content).ok();
2809 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2810 }
2811}
2812
2813pub async fn get_continuous_klines_v1(configuration: &configuration::Configuration, params: GetContinuousKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<GetContinuousKlinesV1Error>> {
2815
2816 let uri_str = format!("{}/dapi/v1/continuousKlines", configuration.base_path);
2817 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2818
2819 let mut query_params: Vec<(String, String)> = Vec::new();
2821
2822 query_params.push(("pair".to_string(), params.pair.to_string()));
2823 query_params.push(("contractType".to_string(), params.contract_type.to_string()));
2824 query_params.push(("interval".to_string(), params.interval.to_string()));
2825 if let Some(ref param_value) = params.start_time {
2826 query_params.push(("startTime".to_string(), param_value.to_string()));
2827 }
2828 if let Some(ref param_value) = params.end_time {
2829 query_params.push(("endTime".to_string(), param_value.to_string()));
2830 }
2831 if let Some(ref param_value) = params.limit {
2832 query_params.push(("limit".to_string(), param_value.to_string()));
2833 }
2834
2835 let mut header_params = std::collections::HashMap::new();
2837
2838 if let Some(ref binance_auth) = configuration.binance_auth {
2840 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2842
2843 let body_string: Option<Vec<u8>> = None;
2845
2846 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2848 Ok(sig) => sig,
2849 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2850 };
2851
2852 query_params.push(("signature".to_string(), signature));
2854 }
2855
2856 if !query_params.is_empty() {
2858 req_builder = req_builder.query(&query_params);
2859 }
2860
2861
2862 if let Some(ref user_agent) = configuration.user_agent {
2864 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2865 }
2866
2867 for (header_name, header_value) in header_params {
2869 req_builder = req_builder.header(&header_name, &header_value);
2870 }
2871
2872
2873 let req = req_builder.build()?;
2874 let resp = configuration.client.execute(req).await?;
2875
2876 let status = resp.status();
2877 let content_type = resp
2878 .headers()
2879 .get("content-type")
2880 .and_then(|v| v.to_str().ok())
2881 .unwrap_or("application/octet-stream");
2882 let content_type = super::ContentType::from(content_type);
2883
2884 if !status.is_client_error() && !status.is_server_error() {
2885 let content = resp.text().await?;
2886 match content_type {
2887 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2888 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
2889 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<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
2890 }
2891 } else {
2892 let content = resp.text().await?;
2893 let entity: Option<GetContinuousKlinesV1Error> = serde_json::from_str(&content).ok();
2894 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2895 }
2896}
2897
2898pub async fn get_depth_v1(configuration: &configuration::Configuration, params: GetDepthV1Params) -> Result<models::GetDepthV1Resp, Error<GetDepthV1Error>> {
2900
2901 let uri_str = format!("{}/dapi/v1/depth", configuration.base_path);
2902 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2903
2904 let mut query_params: Vec<(String, String)> = Vec::new();
2906
2907 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2908 if let Some(ref param_value) = params.limit {
2909 query_params.push(("limit".to_string(), param_value.to_string()));
2910 }
2911
2912 let mut header_params = std::collections::HashMap::new();
2914
2915 if let Some(ref binance_auth) = configuration.binance_auth {
2917 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2919
2920 let body_string: Option<Vec<u8>> = None;
2922
2923 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2925 Ok(sig) => sig,
2926 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2927 };
2928
2929 query_params.push(("signature".to_string(), signature));
2931 }
2932
2933 if !query_params.is_empty() {
2935 req_builder = req_builder.query(&query_params);
2936 }
2937
2938
2939 if let Some(ref user_agent) = configuration.user_agent {
2941 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2942 }
2943
2944 for (header_name, header_value) in header_params {
2946 req_builder = req_builder.header(&header_name, &header_value);
2947 }
2948
2949
2950 let req = req_builder.build()?;
2951 let resp = configuration.client.execute(req).await?;
2952
2953 let status = resp.status();
2954 let content_type = resp
2955 .headers()
2956 .get("content-type")
2957 .and_then(|v| v.to_str().ok())
2958 .unwrap_or("application/octet-stream");
2959 let content_type = super::ContentType::from(content_type);
2960
2961 if !status.is_client_error() && !status.is_server_error() {
2962 let content = resp.text().await?;
2963 match content_type {
2964 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2965 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetDepthV1Resp`"))),
2966 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::GetDepthV1Resp`")))),
2967 }
2968 } else {
2969 let content = resp.text().await?;
2970 let entity: Option<GetDepthV1Error> = serde_json::from_str(&content).ok();
2971 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2972 }
2973}
2974
2975pub async fn get_exchange_info_v1(configuration: &configuration::Configuration) -> Result<models::CmfuturesGetExchangeInfoV1Resp, Error<GetExchangeInfoV1Error>> {
2977
2978 let uri_str = format!("{}/dapi/v1/exchangeInfo", configuration.base_path);
2979 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2980
2981 let mut query_params: Vec<(String, String)> = Vec::new();
2983
2984
2985 let mut header_params = std::collections::HashMap::new();
2987
2988 if let Some(ref binance_auth) = configuration.binance_auth {
2990 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2992
2993 let body_string: Option<Vec<u8>> = None;
2995
2996 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2998 Ok(sig) => sig,
2999 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3000 };
3001
3002 query_params.push(("signature".to_string(), signature));
3004 }
3005
3006 if !query_params.is_empty() {
3008 req_builder = req_builder.query(&query_params);
3009 }
3010
3011
3012 if let Some(ref user_agent) = configuration.user_agent {
3014 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3015 }
3016
3017 for (header_name, header_value) in header_params {
3019 req_builder = req_builder.header(&header_name, &header_value);
3020 }
3021
3022
3023 let req = req_builder.build()?;
3024 let resp = configuration.client.execute(req).await?;
3025
3026 let status = resp.status();
3027 let content_type = resp
3028 .headers()
3029 .get("content-type")
3030 .and_then(|v| v.to_str().ok())
3031 .unwrap_or("application/octet-stream");
3032 let content_type = super::ContentType::from(content_type);
3033
3034 if !status.is_client_error() && !status.is_server_error() {
3035 let content = resp.text().await?;
3036 match content_type {
3037 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3038 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CmfuturesGetExchangeInfoV1Resp`"))),
3039 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::CmfuturesGetExchangeInfoV1Resp`")))),
3040 }
3041 } else {
3042 let content = resp.text().await?;
3043 let entity: Option<GetExchangeInfoV1Error> = serde_json::from_str(&content).ok();
3044 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3045 }
3046}
3047
3048pub async fn get_force_orders_v1(configuration: &configuration::Configuration, params: GetForceOrdersV1Params) -> Result<Vec<models::CmfuturesGetForceOrdersV1RespItem>, Error<GetForceOrdersV1Error>> {
3050
3051 let uri_str = format!("{}/dapi/v1/forceOrders", configuration.base_path);
3052 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3053
3054 let mut query_params: Vec<(String, String)> = Vec::new();
3056
3057 if let Some(ref param_value) = params.symbol {
3058 query_params.push(("symbol".to_string(), param_value.to_string()));
3059 }
3060 if let Some(ref param_value) = params.auto_close_type {
3061 query_params.push(("autoCloseType".to_string(), param_value.to_string()));
3062 }
3063 if let Some(ref param_value) = params.recv_window {
3064 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3065 }
3066 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3067 if let Some(ref param_value) = params.limit {
3068 query_params.push(("limit".to_string(), param_value.to_string()));
3069 }
3070 if let Some(ref param_value) = params.start_time {
3071 query_params.push(("startTime".to_string(), param_value.to_string()));
3072 }
3073 if let Some(ref param_value) = params.end_time {
3074 query_params.push(("endTime".to_string(), param_value.to_string()));
3075 }
3076
3077 let mut header_params = std::collections::HashMap::new();
3079
3080 if let Some(ref binance_auth) = configuration.binance_auth {
3082 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3084
3085 let body_string: Option<Vec<u8>> = None;
3087
3088 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3090 Ok(sig) => sig,
3091 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3092 };
3093
3094 query_params.push(("signature".to_string(), signature));
3096 }
3097
3098 if !query_params.is_empty() {
3100 req_builder = req_builder.query(&query_params);
3101 }
3102
3103
3104 if let Some(ref user_agent) = configuration.user_agent {
3106 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3107 }
3108
3109 for (header_name, header_value) in header_params {
3111 req_builder = req_builder.header(&header_name, &header_value);
3112 }
3113
3114
3115 let req = req_builder.build()?;
3116 let resp = configuration.client.execute(req).await?;
3117
3118 let status = resp.status();
3119 let content_type = resp
3120 .headers()
3121 .get("content-type")
3122 .and_then(|v| v.to_str().ok())
3123 .unwrap_or("application/octet-stream");
3124 let content_type = super::ContentType::from(content_type);
3125
3126 if !status.is_client_error() && !status.is_server_error() {
3127 let content = resp.text().await?;
3128 match content_type {
3129 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3130 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetForceOrdersV1RespItem>`"))),
3131 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::CmfuturesGetForceOrdersV1RespItem>`")))),
3132 }
3133 } else {
3134 let content = resp.text().await?;
3135 let entity: Option<GetForceOrdersV1Error> = serde_json::from_str(&content).ok();
3136 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3137 }
3138}
3139
3140pub async fn get_funding_info_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetFundingInfoV1RespItem>, Error<GetFundingInfoV1Error>> {
3142
3143 let uri_str = format!("{}/dapi/v1/fundingInfo", configuration.base_path);
3144 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3145
3146 let mut query_params: Vec<(String, String)> = Vec::new();
3148
3149
3150 let mut header_params = std::collections::HashMap::new();
3152
3153 if let Some(ref binance_auth) = configuration.binance_auth {
3155 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3157
3158 let body_string: Option<Vec<u8>> = None;
3160
3161 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3163 Ok(sig) => sig,
3164 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3165 };
3166
3167 query_params.push(("signature".to_string(), signature));
3169 }
3170
3171 if !query_params.is_empty() {
3173 req_builder = req_builder.query(&query_params);
3174 }
3175
3176
3177 if let Some(ref user_agent) = configuration.user_agent {
3179 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3180 }
3181
3182 for (header_name, header_value) in header_params {
3184 req_builder = req_builder.header(&header_name, &header_value);
3185 }
3186
3187
3188 let req = req_builder.build()?;
3189 let resp = configuration.client.execute(req).await?;
3190
3191 let status = resp.status();
3192 let content_type = resp
3193 .headers()
3194 .get("content-type")
3195 .and_then(|v| v.to_str().ok())
3196 .unwrap_or("application/octet-stream");
3197 let content_type = super::ContentType::from(content_type);
3198
3199 if !status.is_client_error() && !status.is_server_error() {
3200 let content = resp.text().await?;
3201 match content_type {
3202 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3203 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetFundingInfoV1RespItem>`"))),
3204 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::GetFundingInfoV1RespItem>`")))),
3205 }
3206 } else {
3207 let content = resp.text().await?;
3208 let entity: Option<GetFundingInfoV1Error> = serde_json::from_str(&content).ok();
3209 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3210 }
3211}
3212
3213pub async fn get_funding_rate_v1(configuration: &configuration::Configuration, params: GetFundingRateV1Params) -> Result<Vec<models::GetFundingRateV1RespItem>, Error<GetFundingRateV1Error>> {
3215
3216 let uri_str = format!("{}/dapi/v1/fundingRate", configuration.base_path);
3217 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3218
3219 let mut query_params: Vec<(String, String)> = Vec::new();
3221
3222 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3223 if let Some(ref param_value) = params.start_time {
3224 query_params.push(("startTime".to_string(), param_value.to_string()));
3225 }
3226 if let Some(ref param_value) = params.end_time {
3227 query_params.push(("endTime".to_string(), param_value.to_string()));
3228 }
3229 if let Some(ref param_value) = params.limit {
3230 query_params.push(("limit".to_string(), param_value.to_string()));
3231 }
3232
3233 let mut header_params = std::collections::HashMap::new();
3235
3236 if let Some(ref binance_auth) = configuration.binance_auth {
3238 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3240
3241 let body_string: Option<Vec<u8>> = None;
3243
3244 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3246 Ok(sig) => sig,
3247 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3248 };
3249
3250 query_params.push(("signature".to_string(), signature));
3252 }
3253
3254 if !query_params.is_empty() {
3256 req_builder = req_builder.query(&query_params);
3257 }
3258
3259
3260 if let Some(ref user_agent) = configuration.user_agent {
3262 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3263 }
3264
3265 for (header_name, header_value) in header_params {
3267 req_builder = req_builder.header(&header_name, &header_value);
3268 }
3269
3270
3271 let req = req_builder.build()?;
3272 let resp = configuration.client.execute(req).await?;
3273
3274 let status = resp.status();
3275 let content_type = resp
3276 .headers()
3277 .get("content-type")
3278 .and_then(|v| v.to_str().ok())
3279 .unwrap_or("application/octet-stream");
3280 let content_type = super::ContentType::from(content_type);
3281
3282 if !status.is_client_error() && !status.is_server_error() {
3283 let content = resp.text().await?;
3284 match content_type {
3285 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3286 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetFundingRateV1RespItem>`"))),
3287 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::GetFundingRateV1RespItem>`")))),
3288 }
3289 } else {
3290 let content = resp.text().await?;
3291 let entity: Option<GetFundingRateV1Error> = serde_json::from_str(&content).ok();
3292 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3293 }
3294}
3295
3296pub async fn get_futures_data_basis(configuration: &configuration::Configuration, params: GetFuturesDataBasisParams) -> Result<Vec<models::GetFuturesDataBasisRespItem>, Error<GetFuturesDataBasisError>> {
3298
3299 let uri_str = format!("{}/futures/data/basis", configuration.base_path);
3300 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3301
3302 let mut query_params: Vec<(String, String)> = Vec::new();
3304
3305 query_params.push(("pair".to_string(), params.pair.to_string()));
3306 query_params.push(("contractType".to_string(), params.contract_type.to_string()));
3307 query_params.push(("period".to_string(), params.period.to_string()));
3308 if let Some(ref param_value) = params.limit {
3309 query_params.push(("limit".to_string(), param_value.to_string()));
3310 }
3311 if let Some(ref param_value) = params.start_time {
3312 query_params.push(("startTime".to_string(), param_value.to_string()));
3313 }
3314 if let Some(ref param_value) = params.end_time {
3315 query_params.push(("endTime".to_string(), param_value.to_string()));
3316 }
3317
3318 let mut header_params = std::collections::HashMap::new();
3320
3321 if let Some(ref binance_auth) = configuration.binance_auth {
3323 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3325
3326 let body_string: Option<Vec<u8>> = None;
3328
3329 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3331 Ok(sig) => sig,
3332 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3333 };
3334
3335 query_params.push(("signature".to_string(), signature));
3337 }
3338
3339 if !query_params.is_empty() {
3341 req_builder = req_builder.query(&query_params);
3342 }
3343
3344
3345 if let Some(ref user_agent) = configuration.user_agent {
3347 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3348 }
3349
3350 for (header_name, header_value) in header_params {
3352 req_builder = req_builder.header(&header_name, &header_value);
3353 }
3354
3355
3356 let req = req_builder.build()?;
3357 let resp = configuration.client.execute(req).await?;
3358
3359 let status = resp.status();
3360 let content_type = resp
3361 .headers()
3362 .get("content-type")
3363 .and_then(|v| v.to_str().ok())
3364 .unwrap_or("application/octet-stream");
3365 let content_type = super::ContentType::from(content_type);
3366
3367 if !status.is_client_error() && !status.is_server_error() {
3368 let content = resp.text().await?;
3369 match content_type {
3370 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3371 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetFuturesDataBasisRespItem>`"))),
3372 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::GetFuturesDataBasisRespItem>`")))),
3373 }
3374 } else {
3375 let content = resp.text().await?;
3376 let entity: Option<GetFuturesDataBasisError> = serde_json::from_str(&content).ok();
3377 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3378 }
3379}
3380
3381pub async fn get_futures_data_global_long_short_account_ratio(configuration: &configuration::Configuration, params: GetFuturesDataGlobalLongShortAccountRatioParams) -> Result<Vec<models::GetFuturesDataGlobalLongShortAccountRatioRespItem>, Error<GetFuturesDataGlobalLongShortAccountRatioError>> {
3383
3384 let uri_str = format!("{}/futures/data/globalLongShortAccountRatio", configuration.base_path);
3385 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3386
3387 let mut query_params: Vec<(String, String)> = Vec::new();
3389
3390 query_params.push(("pair".to_string(), params.pair.to_string()));
3391 query_params.push(("period".to_string(), params.period.to_string()));
3392 if let Some(ref param_value) = params.limit {
3393 query_params.push(("limit".to_string(), param_value.to_string()));
3394 }
3395 if let Some(ref param_value) = params.start_time {
3396 query_params.push(("startTime".to_string(), param_value.to_string()));
3397 }
3398 if let Some(ref param_value) = params.end_time {
3399 query_params.push(("endTime".to_string(), param_value.to_string()));
3400 }
3401
3402 let mut header_params = std::collections::HashMap::new();
3404
3405 if let Some(ref binance_auth) = configuration.binance_auth {
3407 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3409
3410 let body_string: Option<Vec<u8>> = None;
3412
3413 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3415 Ok(sig) => sig,
3416 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3417 };
3418
3419 query_params.push(("signature".to_string(), signature));
3421 }
3422
3423 if !query_params.is_empty() {
3425 req_builder = req_builder.query(&query_params);
3426 }
3427
3428
3429 if let Some(ref user_agent) = configuration.user_agent {
3431 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3432 }
3433
3434 for (header_name, header_value) in header_params {
3436 req_builder = req_builder.header(&header_name, &header_value);
3437 }
3438
3439
3440 let req = req_builder.build()?;
3441 let resp = configuration.client.execute(req).await?;
3442
3443 let status = resp.status();
3444 let content_type = resp
3445 .headers()
3446 .get("content-type")
3447 .and_then(|v| v.to_str().ok())
3448 .unwrap_or("application/octet-stream");
3449 let content_type = super::ContentType::from(content_type);
3450
3451 if !status.is_client_error() && !status.is_server_error() {
3452 let content = resp.text().await?;
3453 match content_type {
3454 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3455 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetFuturesDataGlobalLongShortAccountRatioRespItem>`"))),
3456 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::GetFuturesDataGlobalLongShortAccountRatioRespItem>`")))),
3457 }
3458 } else {
3459 let content = resp.text().await?;
3460 let entity: Option<GetFuturesDataGlobalLongShortAccountRatioError> = serde_json::from_str(&content).ok();
3461 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3462 }
3463}
3464
3465pub async fn get_futures_data_open_interest_hist(configuration: &configuration::Configuration, params: GetFuturesDataOpenInterestHistParams) -> Result<Vec<models::GetFuturesDataOpenInterestHistRespItem>, Error<GetFuturesDataOpenInterestHistError>> {
3467
3468 let uri_str = format!("{}/futures/data/openInterestHist", configuration.base_path);
3469 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3470
3471 let mut query_params: Vec<(String, String)> = Vec::new();
3473
3474 query_params.push(("pair".to_string(), params.pair.to_string()));
3475 query_params.push(("contractType".to_string(), params.contract_type.to_string()));
3476 query_params.push(("period".to_string(), params.period.to_string()));
3477 if let Some(ref param_value) = params.limit {
3478 query_params.push(("limit".to_string(), param_value.to_string()));
3479 }
3480 if let Some(ref param_value) = params.start_time {
3481 query_params.push(("startTime".to_string(), param_value.to_string()));
3482 }
3483 if let Some(ref param_value) = params.end_time {
3484 query_params.push(("endTime".to_string(), param_value.to_string()));
3485 }
3486
3487 let mut header_params = std::collections::HashMap::new();
3489
3490 if let Some(ref binance_auth) = configuration.binance_auth {
3492 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3494
3495 let body_string: Option<Vec<u8>> = None;
3497
3498 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3500 Ok(sig) => sig,
3501 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3502 };
3503
3504 query_params.push(("signature".to_string(), signature));
3506 }
3507
3508 if !query_params.is_empty() {
3510 req_builder = req_builder.query(&query_params);
3511 }
3512
3513
3514 if let Some(ref user_agent) = configuration.user_agent {
3516 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3517 }
3518
3519 for (header_name, header_value) in header_params {
3521 req_builder = req_builder.header(&header_name, &header_value);
3522 }
3523
3524
3525 let req = req_builder.build()?;
3526 let resp = configuration.client.execute(req).await?;
3527
3528 let status = resp.status();
3529 let content_type = resp
3530 .headers()
3531 .get("content-type")
3532 .and_then(|v| v.to_str().ok())
3533 .unwrap_or("application/octet-stream");
3534 let content_type = super::ContentType::from(content_type);
3535
3536 if !status.is_client_error() && !status.is_server_error() {
3537 let content = resp.text().await?;
3538 match content_type {
3539 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3540 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetFuturesDataOpenInterestHistRespItem>`"))),
3541 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::GetFuturesDataOpenInterestHistRespItem>`")))),
3542 }
3543 } else {
3544 let content = resp.text().await?;
3545 let entity: Option<GetFuturesDataOpenInterestHistError> = serde_json::from_str(&content).ok();
3546 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3547 }
3548}
3549
3550pub async fn get_futures_data_taker_buy_sell_vol(configuration: &configuration::Configuration, params: GetFuturesDataTakerBuySellVolParams) -> Result<Vec<models::GetFuturesDataTakerBuySellVolRespItem>, Error<GetFuturesDataTakerBuySellVolError>> {
3552
3553 let uri_str = format!("{}/futures/data/takerBuySellVol", configuration.base_path);
3554 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3555
3556 let mut query_params: Vec<(String, String)> = Vec::new();
3558
3559 query_params.push(("pair".to_string(), params.pair.to_string()));
3560 query_params.push(("contractType".to_string(), params.contract_type.to_string()));
3561 query_params.push(("period".to_string(), params.period.to_string()));
3562 if let Some(ref param_value) = params.limit {
3563 query_params.push(("limit".to_string(), param_value.to_string()));
3564 }
3565 if let Some(ref param_value) = params.start_time {
3566 query_params.push(("startTime".to_string(), param_value.to_string()));
3567 }
3568 if let Some(ref param_value) = params.end_time {
3569 query_params.push(("endTime".to_string(), param_value.to_string()));
3570 }
3571
3572 let mut header_params = std::collections::HashMap::new();
3574
3575 if let Some(ref binance_auth) = configuration.binance_auth {
3577 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3579
3580 let body_string: Option<Vec<u8>> = None;
3582
3583 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3585 Ok(sig) => sig,
3586 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3587 };
3588
3589 query_params.push(("signature".to_string(), signature));
3591 }
3592
3593 if !query_params.is_empty() {
3595 req_builder = req_builder.query(&query_params);
3596 }
3597
3598
3599 if let Some(ref user_agent) = configuration.user_agent {
3601 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3602 }
3603
3604 for (header_name, header_value) in header_params {
3606 req_builder = req_builder.header(&header_name, &header_value);
3607 }
3608
3609
3610 let req = req_builder.build()?;
3611 let resp = configuration.client.execute(req).await?;
3612
3613 let status = resp.status();
3614 let content_type = resp
3615 .headers()
3616 .get("content-type")
3617 .and_then(|v| v.to_str().ok())
3618 .unwrap_or("application/octet-stream");
3619 let content_type = super::ContentType::from(content_type);
3620
3621 if !status.is_client_error() && !status.is_server_error() {
3622 let content = resp.text().await?;
3623 match content_type {
3624 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3625 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetFuturesDataTakerBuySellVolRespItem>`"))),
3626 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::GetFuturesDataTakerBuySellVolRespItem>`")))),
3627 }
3628 } else {
3629 let content = resp.text().await?;
3630 let entity: Option<GetFuturesDataTakerBuySellVolError> = serde_json::from_str(&content).ok();
3631 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3632 }
3633}
3634
3635pub async fn get_futures_data_top_long_short_account_ratio(configuration: &configuration::Configuration, params: GetFuturesDataTopLongShortAccountRatioParams) -> Result<Vec<models::GetFuturesDataTopLongShortAccountRatioRespItem>, Error<GetFuturesDataTopLongShortAccountRatioError>> {
3637
3638 let uri_str = format!("{}/futures/data/topLongShortAccountRatio", configuration.base_path);
3639 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3640
3641 let mut query_params: Vec<(String, String)> = Vec::new();
3643
3644 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3645 query_params.push(("period".to_string(), params.period.to_string()));
3646 if let Some(ref param_value) = params.limit {
3647 query_params.push(("limit".to_string(), param_value.to_string()));
3648 }
3649 if let Some(ref param_value) = params.start_time {
3650 query_params.push(("startTime".to_string(), param_value.to_string()));
3651 }
3652 if let Some(ref param_value) = params.end_time {
3653 query_params.push(("endTime".to_string(), param_value.to_string()));
3654 }
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 `Vec<models::GetFuturesDataTopLongShortAccountRatioRespItem>`"))),
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 `Vec<models::GetFuturesDataTopLongShortAccountRatioRespItem>`")))),
3711 }
3712 } else {
3713 let content = resp.text().await?;
3714 let entity: Option<GetFuturesDataTopLongShortAccountRatioError> = serde_json::from_str(&content).ok();
3715 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3716 }
3717}
3718
3719pub async fn get_futures_data_top_long_short_position_ratio(configuration: &configuration::Configuration, params: GetFuturesDataTopLongShortPositionRatioParams) -> Result<Vec<models::GetFuturesDataTopLongShortPositionRatioRespItem>, Error<GetFuturesDataTopLongShortPositionRatioError>> {
3721
3722 let uri_str = format!("{}/futures/data/topLongShortPositionRatio", 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(("pair".to_string(), params.pair.to_string()));
3729 query_params.push(("period".to_string(), params.period.to_string()));
3730 if let Some(ref param_value) = params.limit {
3731 query_params.push(("limit".to_string(), param_value.to_string()));
3732 }
3733 if let Some(ref param_value) = params.start_time {
3734 query_params.push(("startTime".to_string(), param_value.to_string()));
3735 }
3736 if let Some(ref param_value) = params.end_time {
3737 query_params.push(("endTime".to_string(), param_value.to_string()));
3738 }
3739
3740 let mut header_params = std::collections::HashMap::new();
3742
3743 if let Some(ref binance_auth) = configuration.binance_auth {
3745 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3747
3748 let body_string: Option<Vec<u8>> = None;
3750
3751 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3753 Ok(sig) => sig,
3754 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3755 };
3756
3757 query_params.push(("signature".to_string(), signature));
3759 }
3760
3761 if !query_params.is_empty() {
3763 req_builder = req_builder.query(&query_params);
3764 }
3765
3766
3767 if let Some(ref user_agent) = configuration.user_agent {
3769 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3770 }
3771
3772 for (header_name, header_value) in header_params {
3774 req_builder = req_builder.header(&header_name, &header_value);
3775 }
3776
3777
3778 let req = req_builder.build()?;
3779 let resp = configuration.client.execute(req).await?;
3780
3781 let status = resp.status();
3782 let content_type = resp
3783 .headers()
3784 .get("content-type")
3785 .and_then(|v| v.to_str().ok())
3786 .unwrap_or("application/octet-stream");
3787 let content_type = super::ContentType::from(content_type);
3788
3789 if !status.is_client_error() && !status.is_server_error() {
3790 let content = resp.text().await?;
3791 match content_type {
3792 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3793 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetFuturesDataTopLongShortPositionRatioRespItem>`"))),
3794 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::GetFuturesDataTopLongShortPositionRatioRespItem>`")))),
3795 }
3796 } else {
3797 let content = resp.text().await?;
3798 let entity: Option<GetFuturesDataTopLongShortPositionRatioError> = serde_json::from_str(&content).ok();
3799 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3800 }
3801}
3802
3803pub async fn get_historical_trades_v1(configuration: &configuration::Configuration, params: GetHistoricalTradesV1Params) -> Result<Vec<models::GetHistoricalTradesV1RespItem>, Error<GetHistoricalTradesV1Error>> {
3805
3806 let uri_str = format!("{}/dapi/v1/historicalTrades", configuration.base_path);
3807 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3808
3809 let mut query_params: Vec<(String, String)> = Vec::new();
3811
3812 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3813 if let Some(ref param_value) = params.limit {
3814 query_params.push(("limit".to_string(), param_value.to_string()));
3815 }
3816 if let Some(ref param_value) = params.from_id {
3817 query_params.push(("fromId".to_string(), param_value.to_string()));
3818 }
3819
3820 let mut header_params = std::collections::HashMap::new();
3822
3823 if let Some(ref binance_auth) = configuration.binance_auth {
3825 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3827
3828 let body_string: Option<Vec<u8>> = None;
3830
3831 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3833 Ok(sig) => sig,
3834 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3835 };
3836
3837 query_params.push(("signature".to_string(), signature));
3839 }
3840
3841 if !query_params.is_empty() {
3843 req_builder = req_builder.query(&query_params);
3844 }
3845
3846
3847 if let Some(ref user_agent) = configuration.user_agent {
3849 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3850 }
3851
3852 for (header_name, header_value) in header_params {
3854 req_builder = req_builder.header(&header_name, &header_value);
3855 }
3856
3857
3858 let req = req_builder.build()?;
3859 let resp = configuration.client.execute(req).await?;
3860
3861 let status = resp.status();
3862 let content_type = resp
3863 .headers()
3864 .get("content-type")
3865 .and_then(|v| v.to_str().ok())
3866 .unwrap_or("application/octet-stream");
3867 let content_type = super::ContentType::from(content_type);
3868
3869 if !status.is_client_error() && !status.is_server_error() {
3870 let content = resp.text().await?;
3871 match content_type {
3872 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3873 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetHistoricalTradesV1RespItem>`"))),
3874 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::GetHistoricalTradesV1RespItem>`")))),
3875 }
3876 } else {
3877 let content = resp.text().await?;
3878 let entity: Option<GetHistoricalTradesV1Error> = serde_json::from_str(&content).ok();
3879 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3880 }
3881}
3882
3883pub async fn get_income_asyn_id_v1(configuration: &configuration::Configuration, params: GetIncomeAsynIdV1Params) -> Result<models::GetIncomeAsynIdV1Resp, Error<GetIncomeAsynIdV1Error>> {
3885
3886 let uri_str = format!("{}/dapi/v1/income/asyn/id", configuration.base_path);
3887 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3888
3889 let mut query_params: Vec<(String, String)> = Vec::new();
3891
3892 query_params.push(("downloadId".to_string(), params.download_id.to_string()));
3893 if let Some(ref param_value) = params.recv_window {
3894 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3895 }
3896 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3897
3898 let mut header_params = std::collections::HashMap::new();
3900
3901 if let Some(ref binance_auth) = configuration.binance_auth {
3903 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3905
3906 let body_string: Option<Vec<u8>> = None;
3908
3909 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3911 Ok(sig) => sig,
3912 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3913 };
3914
3915 query_params.push(("signature".to_string(), signature));
3917 }
3918
3919 if !query_params.is_empty() {
3921 req_builder = req_builder.query(&query_params);
3922 }
3923
3924
3925 if let Some(ref user_agent) = configuration.user_agent {
3927 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3928 }
3929
3930 for (header_name, header_value) in header_params {
3932 req_builder = req_builder.header(&header_name, &header_value);
3933 }
3934
3935
3936 let req = req_builder.build()?;
3937 let resp = configuration.client.execute(req).await?;
3938
3939 let status = resp.status();
3940 let content_type = resp
3941 .headers()
3942 .get("content-type")
3943 .and_then(|v| v.to_str().ok())
3944 .unwrap_or("application/octet-stream");
3945 let content_type = super::ContentType::from(content_type);
3946
3947 if !status.is_client_error() && !status.is_server_error() {
3948 let content = resp.text().await?;
3949 match content_type {
3950 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3951 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIncomeAsynIdV1Resp`"))),
3952 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::GetIncomeAsynIdV1Resp`")))),
3953 }
3954 } else {
3955 let content = resp.text().await?;
3956 let entity: Option<GetIncomeAsynIdV1Error> = serde_json::from_str(&content).ok();
3957 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3958 }
3959}
3960
3961pub async fn get_income_asyn_v1(configuration: &configuration::Configuration, params: GetIncomeAsynV1Params) -> Result<models::GetIncomeAsynV1Resp, Error<GetIncomeAsynV1Error>> {
3963
3964 let uri_str = format!("{}/dapi/v1/income/asyn", configuration.base_path);
3965 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3966
3967 let mut query_params: Vec<(String, String)> = Vec::new();
3969
3970 query_params.push(("startTime".to_string(), params.start_time.to_string()));
3971 query_params.push(("endTime".to_string(), params.end_time.to_string()));
3972 if let Some(ref param_value) = params.recv_window {
3973 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3974 }
3975 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3976
3977 let mut header_params = std::collections::HashMap::new();
3979
3980 if let Some(ref binance_auth) = configuration.binance_auth {
3982 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3984
3985 let body_string: Option<Vec<u8>> = None;
3987
3988 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3990 Ok(sig) => sig,
3991 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3992 };
3993
3994 query_params.push(("signature".to_string(), signature));
3996 }
3997
3998 if !query_params.is_empty() {
4000 req_builder = req_builder.query(&query_params);
4001 }
4002
4003
4004 if let Some(ref user_agent) = configuration.user_agent {
4006 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4007 }
4008
4009 for (header_name, header_value) in header_params {
4011 req_builder = req_builder.header(&header_name, &header_value);
4012 }
4013
4014
4015 let req = req_builder.build()?;
4016 let resp = configuration.client.execute(req).await?;
4017
4018 let status = resp.status();
4019 let content_type = resp
4020 .headers()
4021 .get("content-type")
4022 .and_then(|v| v.to_str().ok())
4023 .unwrap_or("application/octet-stream");
4024 let content_type = super::ContentType::from(content_type);
4025
4026 if !status.is_client_error() && !status.is_server_error() {
4027 let content = resp.text().await?;
4028 match content_type {
4029 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4030 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIncomeAsynV1Resp`"))),
4031 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::GetIncomeAsynV1Resp`")))),
4032 }
4033 } else {
4034 let content = resp.text().await?;
4035 let entity: Option<GetIncomeAsynV1Error> = serde_json::from_str(&content).ok();
4036 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4037 }
4038}
4039
4040pub async fn get_income_v1(configuration: &configuration::Configuration, params: GetIncomeV1Params) -> Result<Vec<models::GetIncomeV1RespItem>, Error<GetIncomeV1Error>> {
4042
4043 let uri_str = format!("{}/dapi/v1/income", configuration.base_path);
4044 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4045
4046 let mut query_params: Vec<(String, String)> = Vec::new();
4048
4049 if let Some(ref param_value) = params.symbol {
4050 query_params.push(("symbol".to_string(), param_value.to_string()));
4051 }
4052 if let Some(ref param_value) = params.income_type {
4053 query_params.push(("incomeType".to_string(), param_value.to_string()));
4054 }
4055 if let Some(ref param_value) = params.start_time {
4056 query_params.push(("startTime".to_string(), param_value.to_string()));
4057 }
4058 if let Some(ref param_value) = params.end_time {
4059 query_params.push(("endTime".to_string(), param_value.to_string()));
4060 }
4061 if let Some(ref param_value) = params.page {
4062 query_params.push(("page".to_string(), param_value.to_string()));
4063 }
4064 if let Some(ref param_value) = params.limit {
4065 query_params.push(("limit".to_string(), param_value.to_string()));
4066 }
4067 if let Some(ref param_value) = params.recv_window {
4068 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4069 }
4070 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4071
4072 let mut header_params = std::collections::HashMap::new();
4074
4075 if let Some(ref binance_auth) = configuration.binance_auth {
4077 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4079
4080 let body_string: Option<Vec<u8>> = None;
4082
4083 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4085 Ok(sig) => sig,
4086 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4087 };
4088
4089 query_params.push(("signature".to_string(), signature));
4091 }
4092
4093 if !query_params.is_empty() {
4095 req_builder = req_builder.query(&query_params);
4096 }
4097
4098
4099 if let Some(ref user_agent) = configuration.user_agent {
4101 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4102 }
4103
4104 for (header_name, header_value) in header_params {
4106 req_builder = req_builder.header(&header_name, &header_value);
4107 }
4108
4109
4110 let req = req_builder.build()?;
4111 let resp = configuration.client.execute(req).await?;
4112
4113 let status = resp.status();
4114 let content_type = resp
4115 .headers()
4116 .get("content-type")
4117 .and_then(|v| v.to_str().ok())
4118 .unwrap_or("application/octet-stream");
4119 let content_type = super::ContentType::from(content_type);
4120
4121 if !status.is_client_error() && !status.is_server_error() {
4122 let content = resp.text().await?;
4123 match content_type {
4124 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4125 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetIncomeV1RespItem>`"))),
4126 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::GetIncomeV1RespItem>`")))),
4127 }
4128 } else {
4129 let content = resp.text().await?;
4130 let entity: Option<GetIncomeV1Error> = serde_json::from_str(&content).ok();
4131 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4132 }
4133}
4134
4135pub async fn get_index_price_klines_v1(configuration: &configuration::Configuration, params: GetIndexPriceKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<GetIndexPriceKlinesV1Error>> {
4137
4138 let uri_str = format!("{}/dapi/v1/indexPriceKlines", configuration.base_path);
4139 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4140
4141 let mut query_params: Vec<(String, String)> = Vec::new();
4143
4144 query_params.push(("pair".to_string(), params.pair.to_string()));
4145 query_params.push(("interval".to_string(), params.interval.to_string()));
4146 if let Some(ref param_value) = params.start_time {
4147 query_params.push(("startTime".to_string(), param_value.to_string()));
4148 }
4149 if let Some(ref param_value) = params.end_time {
4150 query_params.push(("endTime".to_string(), param_value.to_string()));
4151 }
4152 if let Some(ref param_value) = params.limit {
4153 query_params.push(("limit".to_string(), param_value.to_string()));
4154 }
4155
4156 let mut header_params = std::collections::HashMap::new();
4158
4159 if let Some(ref binance_auth) = configuration.binance_auth {
4161 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4163
4164 let body_string: Option<Vec<u8>> = None;
4166
4167 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4169 Ok(sig) => sig,
4170 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4171 };
4172
4173 query_params.push(("signature".to_string(), signature));
4175 }
4176
4177 if !query_params.is_empty() {
4179 req_builder = req_builder.query(&query_params);
4180 }
4181
4182
4183 if let Some(ref user_agent) = configuration.user_agent {
4185 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4186 }
4187
4188 for (header_name, header_value) in header_params {
4190 req_builder = req_builder.header(&header_name, &header_value);
4191 }
4192
4193
4194 let req = req_builder.build()?;
4195 let resp = configuration.client.execute(req).await?;
4196
4197 let status = resp.status();
4198 let content_type = resp
4199 .headers()
4200 .get("content-type")
4201 .and_then(|v| v.to_str().ok())
4202 .unwrap_or("application/octet-stream");
4203 let content_type = super::ContentType::from(content_type);
4204
4205 if !status.is_client_error() && !status.is_server_error() {
4206 let content = resp.text().await?;
4207 match content_type {
4208 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4209 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
4210 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<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
4211 }
4212 } else {
4213 let content = resp.text().await?;
4214 let entity: Option<GetIndexPriceKlinesV1Error> = serde_json::from_str(&content).ok();
4215 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4216 }
4217}
4218
4219pub async fn get_klines_v1(configuration: &configuration::Configuration, params: GetKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<GetKlinesV1Error>> {
4221
4222 let uri_str = format!("{}/dapi/v1/klines", configuration.base_path);
4223 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4224
4225 let mut query_params: Vec<(String, String)> = Vec::new();
4227
4228 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4229 query_params.push(("interval".to_string(), params.interval.to_string()));
4230 if let Some(ref param_value) = params.start_time {
4231 query_params.push(("startTime".to_string(), param_value.to_string()));
4232 }
4233 if let Some(ref param_value) = params.end_time {
4234 query_params.push(("endTime".to_string(), param_value.to_string()));
4235 }
4236 if let Some(ref param_value) = params.limit {
4237 query_params.push(("limit".to_string(), param_value.to_string()));
4238 }
4239
4240 let mut header_params = std::collections::HashMap::new();
4242
4243 if let Some(ref binance_auth) = configuration.binance_auth {
4245 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4247
4248 let body_string: Option<Vec<u8>> = None;
4250
4251 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4253 Ok(sig) => sig,
4254 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4255 };
4256
4257 query_params.push(("signature".to_string(), signature));
4259 }
4260
4261 if !query_params.is_empty() {
4263 req_builder = req_builder.query(&query_params);
4264 }
4265
4266
4267 if let Some(ref user_agent) = configuration.user_agent {
4269 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4270 }
4271
4272 for (header_name, header_value) in header_params {
4274 req_builder = req_builder.header(&header_name, &header_value);
4275 }
4276
4277
4278 let req = req_builder.build()?;
4279 let resp = configuration.client.execute(req).await?;
4280
4281 let status = resp.status();
4282 let content_type = resp
4283 .headers()
4284 .get("content-type")
4285 .and_then(|v| v.to_str().ok())
4286 .unwrap_or("application/octet-stream");
4287 let content_type = super::ContentType::from(content_type);
4288
4289 if !status.is_client_error() && !status.is_server_error() {
4290 let content = resp.text().await?;
4291 match content_type {
4292 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4293 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
4294 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<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
4295 }
4296 } else {
4297 let content = resp.text().await?;
4298 let entity: Option<GetKlinesV1Error> = serde_json::from_str(&content).ok();
4299 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4300 }
4301}
4302
4303pub async fn get_leverage_bracket_v1(configuration: &configuration::Configuration, params: GetLeverageBracketV1Params) -> Result<Vec<models::GetLeverageBracketV1RespItem>, Error<GetLeverageBracketV1Error>> {
4305
4306 let uri_str = format!("{}/dapi/v1/leverageBracket", configuration.base_path);
4307 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4308
4309 let mut query_params: Vec<(String, String)> = Vec::new();
4311
4312 if let Some(ref param_value) = params.pair {
4313 query_params.push(("pair".to_string(), param_value.to_string()));
4314 }
4315 if let Some(ref param_value) = params.recv_window {
4316 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4317 }
4318 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4319
4320 let mut header_params = std::collections::HashMap::new();
4322
4323 if let Some(ref binance_auth) = configuration.binance_auth {
4325 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4327
4328 let body_string: Option<Vec<u8>> = None;
4330
4331 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4333 Ok(sig) => sig,
4334 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4335 };
4336
4337 query_params.push(("signature".to_string(), signature));
4339 }
4340
4341 if !query_params.is_empty() {
4343 req_builder = req_builder.query(&query_params);
4344 }
4345
4346
4347 if let Some(ref user_agent) = configuration.user_agent {
4349 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4350 }
4351
4352 for (header_name, header_value) in header_params {
4354 req_builder = req_builder.header(&header_name, &header_value);
4355 }
4356
4357
4358 let req = req_builder.build()?;
4359 let resp = configuration.client.execute(req).await?;
4360
4361 let status = resp.status();
4362 let content_type = resp
4363 .headers()
4364 .get("content-type")
4365 .and_then(|v| v.to_str().ok())
4366 .unwrap_or("application/octet-stream");
4367 let content_type = super::ContentType::from(content_type);
4368
4369 if !status.is_client_error() && !status.is_server_error() {
4370 let content = resp.text().await?;
4371 match content_type {
4372 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4373 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetLeverageBracketV1RespItem>`"))),
4374 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::GetLeverageBracketV1RespItem>`")))),
4375 }
4376 } else {
4377 let content = resp.text().await?;
4378 let entity: Option<GetLeverageBracketV1Error> = serde_json::from_str(&content).ok();
4379 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4380 }
4381}
4382
4383pub async fn get_leverage_bracket_v2(configuration: &configuration::Configuration, params: GetLeverageBracketV2Params) -> Result<Vec<models::GetLeverageBracketV2RespItem>, Error<GetLeverageBracketV2Error>> {
4385
4386 let uri_str = format!("{}/dapi/v2/leverageBracket", configuration.base_path);
4387 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4388
4389 let mut query_params: Vec<(String, String)> = Vec::new();
4391
4392 if let Some(ref param_value) = params.symbol {
4393 query_params.push(("symbol".to_string(), param_value.to_string()));
4394 }
4395 if let Some(ref param_value) = params.recv_window {
4396 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4397 }
4398 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4399
4400 let mut header_params = std::collections::HashMap::new();
4402
4403 if let Some(ref binance_auth) = configuration.binance_auth {
4405 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4407
4408 let body_string: Option<Vec<u8>> = None;
4410
4411 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4413 Ok(sig) => sig,
4414 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4415 };
4416
4417 query_params.push(("signature".to_string(), signature));
4419 }
4420
4421 if !query_params.is_empty() {
4423 req_builder = req_builder.query(&query_params);
4424 }
4425
4426
4427 if let Some(ref user_agent) = configuration.user_agent {
4429 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4430 }
4431
4432 for (header_name, header_value) in header_params {
4434 req_builder = req_builder.header(&header_name, &header_value);
4435 }
4436
4437
4438 let req = req_builder.build()?;
4439 let resp = configuration.client.execute(req).await?;
4440
4441 let status = resp.status();
4442 let content_type = resp
4443 .headers()
4444 .get("content-type")
4445 .and_then(|v| v.to_str().ok())
4446 .unwrap_or("application/octet-stream");
4447 let content_type = super::ContentType::from(content_type);
4448
4449 if !status.is_client_error() && !status.is_server_error() {
4450 let content = resp.text().await?;
4451 match content_type {
4452 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4453 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetLeverageBracketV2RespItem>`"))),
4454 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::GetLeverageBracketV2RespItem>`")))),
4455 }
4456 } else {
4457 let content = resp.text().await?;
4458 let entity: Option<GetLeverageBracketV2Error> = serde_json::from_str(&content).ok();
4459 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4460 }
4461}
4462
4463pub async fn get_mark_price_klines_v1(configuration: &configuration::Configuration, params: GetMarkPriceKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<GetMarkPriceKlinesV1Error>> {
4465
4466 let uri_str = format!("{}/dapi/v1/markPriceKlines", configuration.base_path);
4467 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4468
4469 let mut query_params: Vec<(String, String)> = Vec::new();
4471
4472 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4473 query_params.push(("interval".to_string(), params.interval.to_string()));
4474 if let Some(ref param_value) = params.start_time {
4475 query_params.push(("startTime".to_string(), param_value.to_string()));
4476 }
4477 if let Some(ref param_value) = params.end_time {
4478 query_params.push(("endTime".to_string(), param_value.to_string()));
4479 }
4480 if let Some(ref param_value) = params.limit {
4481 query_params.push(("limit".to_string(), param_value.to_string()));
4482 }
4483
4484 let mut header_params = std::collections::HashMap::new();
4486
4487 if let Some(ref binance_auth) = configuration.binance_auth {
4489 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4491
4492 let body_string: Option<Vec<u8>> = None;
4494
4495 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4497 Ok(sig) => sig,
4498 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4499 };
4500
4501 query_params.push(("signature".to_string(), signature));
4503 }
4504
4505 if !query_params.is_empty() {
4507 req_builder = req_builder.query(&query_params);
4508 }
4509
4510
4511 if let Some(ref user_agent) = configuration.user_agent {
4513 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4514 }
4515
4516 for (header_name, header_value) in header_params {
4518 req_builder = req_builder.header(&header_name, &header_value);
4519 }
4520
4521
4522 let req = req_builder.build()?;
4523 let resp = configuration.client.execute(req).await?;
4524
4525 let status = resp.status();
4526 let content_type = resp
4527 .headers()
4528 .get("content-type")
4529 .and_then(|v| v.to_str().ok())
4530 .unwrap_or("application/octet-stream");
4531 let content_type = super::ContentType::from(content_type);
4532
4533 if !status.is_client_error() && !status.is_server_error() {
4534 let content = resp.text().await?;
4535 match content_type {
4536 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4537 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
4538 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<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
4539 }
4540 } else {
4541 let content = resp.text().await?;
4542 let entity: Option<GetMarkPriceKlinesV1Error> = serde_json::from_str(&content).ok();
4543 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4544 }
4545}
4546
4547pub async fn get_open_interest_v1(configuration: &configuration::Configuration, params: GetOpenInterestV1Params) -> Result<models::GetOpenInterestV1Resp, Error<GetOpenInterestV1Error>> {
4549
4550 let uri_str = format!("{}/dapi/v1/openInterest", configuration.base_path);
4551 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4552
4553 let mut query_params: Vec<(String, String)> = Vec::new();
4555
4556 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4557
4558 let mut header_params = std::collections::HashMap::new();
4560
4561 if let Some(ref binance_auth) = configuration.binance_auth {
4563 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4565
4566 let body_string: Option<Vec<u8>> = None;
4568
4569 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4571 Ok(sig) => sig,
4572 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4573 };
4574
4575 query_params.push(("signature".to_string(), signature));
4577 }
4578
4579 if !query_params.is_empty() {
4581 req_builder = req_builder.query(&query_params);
4582 }
4583
4584
4585 if let Some(ref user_agent) = configuration.user_agent {
4587 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4588 }
4589
4590 for (header_name, header_value) in header_params {
4592 req_builder = req_builder.header(&header_name, &header_value);
4593 }
4594
4595
4596 let req = req_builder.build()?;
4597 let resp = configuration.client.execute(req).await?;
4598
4599 let status = resp.status();
4600 let content_type = resp
4601 .headers()
4602 .get("content-type")
4603 .and_then(|v| v.to_str().ok())
4604 .unwrap_or("application/octet-stream");
4605 let content_type = super::ContentType::from(content_type);
4606
4607 if !status.is_client_error() && !status.is_server_error() {
4608 let content = resp.text().await?;
4609 match content_type {
4610 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4611 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOpenInterestV1Resp`"))),
4612 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::GetOpenInterestV1Resp`")))),
4613 }
4614 } else {
4615 let content = resp.text().await?;
4616 let entity: Option<GetOpenInterestV1Error> = serde_json::from_str(&content).ok();
4617 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4618 }
4619}
4620
4621pub async fn get_open_order_v1(configuration: &configuration::Configuration, params: GetOpenOrderV1Params) -> Result<models::GetOpenOrderV1Resp, Error<GetOpenOrderV1Error>> {
4623
4624 let uri_str = format!("{}/dapi/v1/openOrder", configuration.base_path);
4625 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4626
4627 let mut query_params: Vec<(String, String)> = Vec::new();
4629
4630 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4631 if let Some(ref param_value) = params.order_id {
4632 query_params.push(("orderId".to_string(), param_value.to_string()));
4633 }
4634 if let Some(ref param_value) = params.orig_client_order_id {
4635 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
4636 }
4637 if let Some(ref param_value) = params.recv_window {
4638 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4639 }
4640 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4641
4642 let mut header_params = std::collections::HashMap::new();
4644
4645 if let Some(ref binance_auth) = configuration.binance_auth {
4647 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4649
4650 let body_string: Option<Vec<u8>> = None;
4652
4653 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4655 Ok(sig) => sig,
4656 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4657 };
4658
4659 query_params.push(("signature".to_string(), signature));
4661 }
4662
4663 if !query_params.is_empty() {
4665 req_builder = req_builder.query(&query_params);
4666 }
4667
4668
4669 if let Some(ref user_agent) = configuration.user_agent {
4671 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4672 }
4673
4674 for (header_name, header_value) in header_params {
4676 req_builder = req_builder.header(&header_name, &header_value);
4677 }
4678
4679
4680 let req = req_builder.build()?;
4681 let resp = configuration.client.execute(req).await?;
4682
4683 let status = resp.status();
4684 let content_type = resp
4685 .headers()
4686 .get("content-type")
4687 .and_then(|v| v.to_str().ok())
4688 .unwrap_or("application/octet-stream");
4689 let content_type = super::ContentType::from(content_type);
4690
4691 if !status.is_client_error() && !status.is_server_error() {
4692 let content = resp.text().await?;
4693 match content_type {
4694 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4695 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOpenOrderV1Resp`"))),
4696 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::GetOpenOrderV1Resp`")))),
4697 }
4698 } else {
4699 let content = resp.text().await?;
4700 let entity: Option<GetOpenOrderV1Error> = serde_json::from_str(&content).ok();
4701 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4702 }
4703}
4704
4705pub async fn get_open_orders_v1(configuration: &configuration::Configuration, params: GetOpenOrdersV1Params) -> Result<Vec<models::GetOpenOrdersV1RespItem>, Error<GetOpenOrdersV1Error>> {
4707
4708 let uri_str = format!("{}/dapi/v1/openOrders", configuration.base_path);
4709 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4710
4711 let mut query_params: Vec<(String, String)> = Vec::new();
4713
4714 if let Some(ref param_value) = params.symbol {
4715 query_params.push(("symbol".to_string(), param_value.to_string()));
4716 }
4717 if let Some(ref param_value) = params.pair {
4718 query_params.push(("pair".to_string(), param_value.to_string()));
4719 }
4720 if let Some(ref param_value) = params.recv_window {
4721 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4722 }
4723 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4724
4725 let mut header_params = std::collections::HashMap::new();
4727
4728 if let Some(ref binance_auth) = configuration.binance_auth {
4730 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4732
4733 let body_string: Option<Vec<u8>> = None;
4735
4736 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4738 Ok(sig) => sig,
4739 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4740 };
4741
4742 query_params.push(("signature".to_string(), signature));
4744 }
4745
4746 if !query_params.is_empty() {
4748 req_builder = req_builder.query(&query_params);
4749 }
4750
4751
4752 if let Some(ref user_agent) = configuration.user_agent {
4754 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4755 }
4756
4757 for (header_name, header_value) in header_params {
4759 req_builder = req_builder.header(&header_name, &header_value);
4760 }
4761
4762
4763 let req = req_builder.build()?;
4764 let resp = configuration.client.execute(req).await?;
4765
4766 let status = resp.status();
4767 let content_type = resp
4768 .headers()
4769 .get("content-type")
4770 .and_then(|v| v.to_str().ok())
4771 .unwrap_or("application/octet-stream");
4772 let content_type = super::ContentType::from(content_type);
4773
4774 if !status.is_client_error() && !status.is_server_error() {
4775 let content = resp.text().await?;
4776 match content_type {
4777 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4778 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetOpenOrdersV1RespItem>`"))),
4779 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::GetOpenOrdersV1RespItem>`")))),
4780 }
4781 } else {
4782 let content = resp.text().await?;
4783 let entity: Option<GetOpenOrdersV1Error> = serde_json::from_str(&content).ok();
4784 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4785 }
4786}
4787
4788pub async fn get_order_amendment_v1(configuration: &configuration::Configuration, params: GetOrderAmendmentV1Params) -> Result<Vec<models::GetOrderAmendmentV1RespItem>, Error<GetOrderAmendmentV1Error>> {
4790
4791 let uri_str = format!("{}/dapi/v1/orderAmendment", configuration.base_path);
4792 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4793
4794 let mut query_params: Vec<(String, String)> = Vec::new();
4796
4797 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4798 if let Some(ref param_value) = params.order_id {
4799 query_params.push(("orderId".to_string(), param_value.to_string()));
4800 }
4801 if let Some(ref param_value) = params.orig_client_order_id {
4802 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
4803 }
4804 if let Some(ref param_value) = params.start_time {
4805 query_params.push(("startTime".to_string(), param_value.to_string()));
4806 }
4807 if let Some(ref param_value) = params.end_time {
4808 query_params.push(("endTime".to_string(), param_value.to_string()));
4809 }
4810 if let Some(ref param_value) = params.limit {
4811 query_params.push(("limit".to_string(), param_value.to_string()));
4812 }
4813 if let Some(ref param_value) = params.recv_window {
4814 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4815 }
4816 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4817
4818 let mut header_params = std::collections::HashMap::new();
4820
4821 if let Some(ref binance_auth) = configuration.binance_auth {
4823 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4825
4826 let body_string: Option<Vec<u8>> = None;
4828
4829 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4831 Ok(sig) => sig,
4832 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4833 };
4834
4835 query_params.push(("signature".to_string(), signature));
4837 }
4838
4839 if !query_params.is_empty() {
4841 req_builder = req_builder.query(&query_params);
4842 }
4843
4844
4845 if let Some(ref user_agent) = configuration.user_agent {
4847 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4848 }
4849
4850 for (header_name, header_value) in header_params {
4852 req_builder = req_builder.header(&header_name, &header_value);
4853 }
4854
4855
4856 let req = req_builder.build()?;
4857 let resp = configuration.client.execute(req).await?;
4858
4859 let status = resp.status();
4860 let content_type = resp
4861 .headers()
4862 .get("content-type")
4863 .and_then(|v| v.to_str().ok())
4864 .unwrap_or("application/octet-stream");
4865 let content_type = super::ContentType::from(content_type);
4866
4867 if !status.is_client_error() && !status.is_server_error() {
4868 let content = resp.text().await?;
4869 match content_type {
4870 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4871 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetOrderAmendmentV1RespItem>`"))),
4872 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::GetOrderAmendmentV1RespItem>`")))),
4873 }
4874 } else {
4875 let content = resp.text().await?;
4876 let entity: Option<GetOrderAmendmentV1Error> = serde_json::from_str(&content).ok();
4877 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4878 }
4879}
4880
4881pub async fn get_order_asyn_id_v1(configuration: &configuration::Configuration, params: GetOrderAsynIdV1Params) -> Result<models::GetOrderAsynIdV1Resp, Error<GetOrderAsynIdV1Error>> {
4883
4884 let uri_str = format!("{}/dapi/v1/order/asyn/id", configuration.base_path);
4885 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4886
4887 let mut query_params: Vec<(String, String)> = Vec::new();
4889
4890 query_params.push(("downloadId".to_string(), params.download_id.to_string()));
4891 if let Some(ref param_value) = params.recv_window {
4892 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4893 }
4894 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4895
4896 let mut header_params = std::collections::HashMap::new();
4898
4899 if let Some(ref binance_auth) = configuration.binance_auth {
4901 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4903
4904 let body_string: Option<Vec<u8>> = None;
4906
4907 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4909 Ok(sig) => sig,
4910 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4911 };
4912
4913 query_params.push(("signature".to_string(), signature));
4915 }
4916
4917 if !query_params.is_empty() {
4919 req_builder = req_builder.query(&query_params);
4920 }
4921
4922
4923 if let Some(ref user_agent) = configuration.user_agent {
4925 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4926 }
4927
4928 for (header_name, header_value) in header_params {
4930 req_builder = req_builder.header(&header_name, &header_value);
4931 }
4932
4933
4934 let req = req_builder.build()?;
4935 let resp = configuration.client.execute(req).await?;
4936
4937 let status = resp.status();
4938 let content_type = resp
4939 .headers()
4940 .get("content-type")
4941 .and_then(|v| v.to_str().ok())
4942 .unwrap_or("application/octet-stream");
4943 let content_type = super::ContentType::from(content_type);
4944
4945 if !status.is_client_error() && !status.is_server_error() {
4946 let content = resp.text().await?;
4947 match content_type {
4948 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4949 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrderAsynIdV1Resp`"))),
4950 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::GetOrderAsynIdV1Resp`")))),
4951 }
4952 } else {
4953 let content = resp.text().await?;
4954 let entity: Option<GetOrderAsynIdV1Error> = serde_json::from_str(&content).ok();
4955 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4956 }
4957}
4958
4959pub async fn get_order_asyn_v1(configuration: &configuration::Configuration, params: GetOrderAsynV1Params) -> Result<models::GetOrderAsynV1Resp, Error<GetOrderAsynV1Error>> {
4961
4962 let uri_str = format!("{}/dapi/v1/order/asyn", configuration.base_path);
4963 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4964
4965 let mut query_params: Vec<(String, String)> = Vec::new();
4967
4968 query_params.push(("startTime".to_string(), params.start_time.to_string()));
4969 query_params.push(("endTime".to_string(), params.end_time.to_string()));
4970 if let Some(ref param_value) = params.recv_window {
4971 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4972 }
4973 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4974
4975 let mut header_params = std::collections::HashMap::new();
4977
4978 if let Some(ref binance_auth) = configuration.binance_auth {
4980 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4982
4983 let body_string: Option<Vec<u8>> = None;
4985
4986 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4988 Ok(sig) => sig,
4989 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4990 };
4991
4992 query_params.push(("signature".to_string(), signature));
4994 }
4995
4996 if !query_params.is_empty() {
4998 req_builder = req_builder.query(&query_params);
4999 }
5000
5001
5002 if let Some(ref user_agent) = configuration.user_agent {
5004 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5005 }
5006
5007 for (header_name, header_value) in header_params {
5009 req_builder = req_builder.header(&header_name, &header_value);
5010 }
5011
5012
5013 let req = req_builder.build()?;
5014 let resp = configuration.client.execute(req).await?;
5015
5016 let status = resp.status();
5017 let content_type = resp
5018 .headers()
5019 .get("content-type")
5020 .and_then(|v| v.to_str().ok())
5021 .unwrap_or("application/octet-stream");
5022 let content_type = super::ContentType::from(content_type);
5023
5024 if !status.is_client_error() && !status.is_server_error() {
5025 let content = resp.text().await?;
5026 match content_type {
5027 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5028 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrderAsynV1Resp`"))),
5029 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::GetOrderAsynV1Resp`")))),
5030 }
5031 } else {
5032 let content = resp.text().await?;
5033 let entity: Option<GetOrderAsynV1Error> = serde_json::from_str(&content).ok();
5034 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5035 }
5036}
5037
5038pub async fn get_order_v1(configuration: &configuration::Configuration, params: GetOrderV1Params) -> Result<models::GetOrderV1Resp, Error<GetOrderV1Error>> {
5040
5041 let uri_str = format!("{}/dapi/v1/order", configuration.base_path);
5042 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5043
5044 let mut query_params: Vec<(String, String)> = Vec::new();
5046
5047 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5048 if let Some(ref param_value) = params.order_id {
5049 query_params.push(("orderId".to_string(), param_value.to_string()));
5050 }
5051 if let Some(ref param_value) = params.orig_client_order_id {
5052 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
5053 }
5054 if let Some(ref param_value) = params.recv_window {
5055 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5056 }
5057 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5058
5059 let mut header_params = std::collections::HashMap::new();
5061
5062 if let Some(ref binance_auth) = configuration.binance_auth {
5064 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5066
5067 let body_string: Option<Vec<u8>> = None;
5069
5070 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5072 Ok(sig) => sig,
5073 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5074 };
5075
5076 query_params.push(("signature".to_string(), signature));
5078 }
5079
5080 if !query_params.is_empty() {
5082 req_builder = req_builder.query(&query_params);
5083 }
5084
5085
5086 if let Some(ref user_agent) = configuration.user_agent {
5088 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5089 }
5090
5091 for (header_name, header_value) in header_params {
5093 req_builder = req_builder.header(&header_name, &header_value);
5094 }
5095
5096
5097 let req = req_builder.build()?;
5098 let resp = configuration.client.execute(req).await?;
5099
5100 let status = resp.status();
5101 let content_type = resp
5102 .headers()
5103 .get("content-type")
5104 .and_then(|v| v.to_str().ok())
5105 .unwrap_or("application/octet-stream");
5106 let content_type = super::ContentType::from(content_type);
5107
5108 if !status.is_client_error() && !status.is_server_error() {
5109 let content = resp.text().await?;
5110 match content_type {
5111 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5112 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrderV1Resp`"))),
5113 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::GetOrderV1Resp`")))),
5114 }
5115 } else {
5116 let content = resp.text().await?;
5117 let entity: Option<GetOrderV1Error> = serde_json::from_str(&content).ok();
5118 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5119 }
5120}
5121
5122pub async fn get_ping_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<GetPingV1Error>> {
5124
5125 let uri_str = format!("{}/dapi/v1/ping", configuration.base_path);
5126 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5127
5128 let mut query_params: Vec<(String, String)> = Vec::new();
5130
5131
5132 let mut header_params = std::collections::HashMap::new();
5134
5135 if let Some(ref binance_auth) = configuration.binance_auth {
5137 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5139
5140 let body_string: Option<Vec<u8>> = None;
5142
5143 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5145 Ok(sig) => sig,
5146 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5147 };
5148
5149 query_params.push(("signature".to_string(), signature));
5151 }
5152
5153 if !query_params.is_empty() {
5155 req_builder = req_builder.query(&query_params);
5156 }
5157
5158
5159 if let Some(ref user_agent) = configuration.user_agent {
5161 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5162 }
5163
5164 for (header_name, header_value) in header_params {
5166 req_builder = req_builder.header(&header_name, &header_value);
5167 }
5168
5169
5170 let req = req_builder.build()?;
5171 let resp = configuration.client.execute(req).await?;
5172
5173 let status = resp.status();
5174 let content_type = resp
5175 .headers()
5176 .get("content-type")
5177 .and_then(|v| v.to_str().ok())
5178 .unwrap_or("application/octet-stream");
5179 let content_type = super::ContentType::from(content_type);
5180
5181 if !status.is_client_error() && !status.is_server_error() {
5182 let content = resp.text().await?;
5183 match content_type {
5184 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5185 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
5186 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
5187 }
5188 } else {
5189 let content = resp.text().await?;
5190 let entity: Option<GetPingV1Error> = serde_json::from_str(&content).ok();
5191 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5192 }
5193}
5194
5195pub async fn get_pm_account_info_v1(configuration: &configuration::Configuration, params: GetPmAccountInfoV1Params) -> Result<models::GetPmAccountInfoV1Resp, Error<GetPmAccountInfoV1Error>> {
5197
5198 let uri_str = format!("{}/dapi/v1/pmAccountInfo", configuration.base_path);
5199 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5200
5201 let mut query_params: Vec<(String, String)> = Vec::new();
5203
5204 query_params.push(("asset".to_string(), params.asset.to_string()));
5205 if let Some(ref param_value) = params.recv_window {
5206 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5207 }
5208
5209 let mut header_params = std::collections::HashMap::new();
5211
5212 if let Some(ref binance_auth) = configuration.binance_auth {
5214 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5216
5217 let body_string: Option<Vec<u8>> = None;
5219
5220 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5222 Ok(sig) => sig,
5223 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5224 };
5225
5226 query_params.push(("signature".to_string(), signature));
5228 }
5229
5230 if !query_params.is_empty() {
5232 req_builder = req_builder.query(&query_params);
5233 }
5234
5235
5236 if let Some(ref user_agent) = configuration.user_agent {
5238 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5239 }
5240
5241 for (header_name, header_value) in header_params {
5243 req_builder = req_builder.header(&header_name, &header_value);
5244 }
5245
5246
5247 let req = req_builder.build()?;
5248 let resp = configuration.client.execute(req).await?;
5249
5250 let status = resp.status();
5251 let content_type = resp
5252 .headers()
5253 .get("content-type")
5254 .and_then(|v| v.to_str().ok())
5255 .unwrap_or("application/octet-stream");
5256 let content_type = super::ContentType::from(content_type);
5257
5258 if !status.is_client_error() && !status.is_server_error() {
5259 let content = resp.text().await?;
5260 match content_type {
5261 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5262 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPmAccountInfoV1Resp`"))),
5263 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::GetPmAccountInfoV1Resp`")))),
5264 }
5265 } else {
5266 let content = resp.text().await?;
5267 let entity: Option<GetPmAccountInfoV1Error> = serde_json::from_str(&content).ok();
5268 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5269 }
5270}
5271
5272pub async fn get_position_margin_history_v1(configuration: &configuration::Configuration, params: GetPositionMarginHistoryV1Params) -> Result<Vec<models::GetPositionMarginHistoryV1RespItem>, Error<GetPositionMarginHistoryV1Error>> {
5274
5275 let uri_str = format!("{}/dapi/v1/positionMargin/history", configuration.base_path);
5276 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5277
5278 let mut query_params: Vec<(String, String)> = Vec::new();
5280
5281 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5282 if let Some(ref param_value) = params.r#type {
5283 query_params.push(("type".to_string(), param_value.to_string()));
5284 }
5285 if let Some(ref param_value) = params.start_time {
5286 query_params.push(("startTime".to_string(), param_value.to_string()));
5287 }
5288 if let Some(ref param_value) = params.end_time {
5289 query_params.push(("endTime".to_string(), param_value.to_string()));
5290 }
5291 if let Some(ref param_value) = params.limit {
5292 query_params.push(("limit".to_string(), param_value.to_string()));
5293 }
5294 if let Some(ref param_value) = params.recv_window {
5295 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5296 }
5297 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5298
5299 let mut header_params = std::collections::HashMap::new();
5301
5302 if let Some(ref binance_auth) = configuration.binance_auth {
5304 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5306
5307 let body_string: Option<Vec<u8>> = None;
5309
5310 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5312 Ok(sig) => sig,
5313 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5314 };
5315
5316 query_params.push(("signature".to_string(), signature));
5318 }
5319
5320 if !query_params.is_empty() {
5322 req_builder = req_builder.query(&query_params);
5323 }
5324
5325
5326 if let Some(ref user_agent) = configuration.user_agent {
5328 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5329 }
5330
5331 for (header_name, header_value) in header_params {
5333 req_builder = req_builder.header(&header_name, &header_value);
5334 }
5335
5336
5337 let req = req_builder.build()?;
5338 let resp = configuration.client.execute(req).await?;
5339
5340 let status = resp.status();
5341 let content_type = resp
5342 .headers()
5343 .get("content-type")
5344 .and_then(|v| v.to_str().ok())
5345 .unwrap_or("application/octet-stream");
5346 let content_type = super::ContentType::from(content_type);
5347
5348 if !status.is_client_error() && !status.is_server_error() {
5349 let content = resp.text().await?;
5350 match content_type {
5351 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5352 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPositionMarginHistoryV1RespItem>`"))),
5353 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::GetPositionMarginHistoryV1RespItem>`")))),
5354 }
5355 } else {
5356 let content = resp.text().await?;
5357 let entity: Option<GetPositionMarginHistoryV1Error> = serde_json::from_str(&content).ok();
5358 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5359 }
5360}
5361
5362pub async fn get_position_risk_v1(configuration: &configuration::Configuration, params: GetPositionRiskV1Params) -> Result<Vec<models::GetPositionRiskV1RespItem>, Error<GetPositionRiskV1Error>> {
5364
5365 let uri_str = format!("{}/dapi/v1/positionRisk", configuration.base_path);
5366 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5367
5368 let mut query_params: Vec<(String, String)> = Vec::new();
5370
5371 if let Some(ref param_value) = params.margin_asset {
5372 query_params.push(("marginAsset".to_string(), param_value.to_string()));
5373 }
5374 if let Some(ref param_value) = params.pair {
5375 query_params.push(("pair".to_string(), param_value.to_string()));
5376 }
5377 if let Some(ref param_value) = params.recv_window {
5378 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5379 }
5380 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5381
5382 let mut header_params = std::collections::HashMap::new();
5384
5385 if let Some(ref binance_auth) = configuration.binance_auth {
5387 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5389
5390 let body_string: Option<Vec<u8>> = None;
5392
5393 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5395 Ok(sig) => sig,
5396 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5397 };
5398
5399 query_params.push(("signature".to_string(), signature));
5401 }
5402
5403 if !query_params.is_empty() {
5405 req_builder = req_builder.query(&query_params);
5406 }
5407
5408
5409 if let Some(ref user_agent) = configuration.user_agent {
5411 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5412 }
5413
5414 for (header_name, header_value) in header_params {
5416 req_builder = req_builder.header(&header_name, &header_value);
5417 }
5418
5419
5420 let req = req_builder.build()?;
5421 let resp = configuration.client.execute(req).await?;
5422
5423 let status = resp.status();
5424 let content_type = resp
5425 .headers()
5426 .get("content-type")
5427 .and_then(|v| v.to_str().ok())
5428 .unwrap_or("application/octet-stream");
5429 let content_type = super::ContentType::from(content_type);
5430
5431 if !status.is_client_error() && !status.is_server_error() {
5432 let content = resp.text().await?;
5433 match content_type {
5434 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5435 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPositionRiskV1RespItem>`"))),
5436 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::GetPositionRiskV1RespItem>`")))),
5437 }
5438 } else {
5439 let content = resp.text().await?;
5440 let entity: Option<GetPositionRiskV1Error> = serde_json::from_str(&content).ok();
5441 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5442 }
5443}
5444
5445pub async fn get_position_side_dual_v1(configuration: &configuration::Configuration, params: GetPositionSideDualV1Params) -> Result<models::GetPositionSideDualV1Resp, Error<GetPositionSideDualV1Error>> {
5447
5448 let uri_str = format!("{}/dapi/v1/positionSide/dual", configuration.base_path);
5449 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5450
5451 let mut query_params: Vec<(String, String)> = Vec::new();
5453
5454 if let Some(ref param_value) = params.recv_window {
5455 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5456 }
5457 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5458
5459 let mut header_params = std::collections::HashMap::new();
5461
5462 if let Some(ref binance_auth) = configuration.binance_auth {
5464 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5466
5467 let body_string: Option<Vec<u8>> = None;
5469
5470 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5472 Ok(sig) => sig,
5473 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5474 };
5475
5476 query_params.push(("signature".to_string(), signature));
5478 }
5479
5480 if !query_params.is_empty() {
5482 req_builder = req_builder.query(&query_params);
5483 }
5484
5485
5486 if let Some(ref user_agent) = configuration.user_agent {
5488 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5489 }
5490
5491 for (header_name, header_value) in header_params {
5493 req_builder = req_builder.header(&header_name, &header_value);
5494 }
5495
5496
5497 let req = req_builder.build()?;
5498 let resp = configuration.client.execute(req).await?;
5499
5500 let status = resp.status();
5501 let content_type = resp
5502 .headers()
5503 .get("content-type")
5504 .and_then(|v| v.to_str().ok())
5505 .unwrap_or("application/octet-stream");
5506 let content_type = super::ContentType::from(content_type);
5507
5508 if !status.is_client_error() && !status.is_server_error() {
5509 let content = resp.text().await?;
5510 match content_type {
5511 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5512 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPositionSideDualV1Resp`"))),
5513 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::GetPositionSideDualV1Resp`")))),
5514 }
5515 } else {
5516 let content = resp.text().await?;
5517 let entity: Option<GetPositionSideDualV1Error> = serde_json::from_str(&content).ok();
5518 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5519 }
5520}
5521
5522pub async fn get_premium_index_klines_v1(configuration: &configuration::Configuration, params: GetPremiumIndexKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<GetPremiumIndexKlinesV1Error>> {
5524
5525 let uri_str = format!("{}/dapi/v1/premiumIndexKlines", configuration.base_path);
5526 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5527
5528 let mut query_params: Vec<(String, String)> = Vec::new();
5530
5531 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5532 query_params.push(("interval".to_string(), params.interval.to_string()));
5533 if let Some(ref param_value) = params.start_time {
5534 query_params.push(("startTime".to_string(), param_value.to_string()));
5535 }
5536 if let Some(ref param_value) = params.end_time {
5537 query_params.push(("endTime".to_string(), param_value.to_string()));
5538 }
5539 if let Some(ref param_value) = params.limit {
5540 query_params.push(("limit".to_string(), param_value.to_string()));
5541 }
5542
5543 let mut header_params = std::collections::HashMap::new();
5545
5546 if let Some(ref binance_auth) = configuration.binance_auth {
5548 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5550
5551 let body_string: Option<Vec<u8>> = None;
5553
5554 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5556 Ok(sig) => sig,
5557 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5558 };
5559
5560 query_params.push(("signature".to_string(), signature));
5562 }
5563
5564 if !query_params.is_empty() {
5566 req_builder = req_builder.query(&query_params);
5567 }
5568
5569
5570 if let Some(ref user_agent) = configuration.user_agent {
5572 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5573 }
5574
5575 for (header_name, header_value) in header_params {
5577 req_builder = req_builder.header(&header_name, &header_value);
5578 }
5579
5580
5581 let req = req_builder.build()?;
5582 let resp = configuration.client.execute(req).await?;
5583
5584 let status = resp.status();
5585 let content_type = resp
5586 .headers()
5587 .get("content-type")
5588 .and_then(|v| v.to_str().ok())
5589 .unwrap_or("application/octet-stream");
5590 let content_type = super::ContentType::from(content_type);
5591
5592 if !status.is_client_error() && !status.is_server_error() {
5593 let content = resp.text().await?;
5594 match content_type {
5595 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5596 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
5597 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<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
5598 }
5599 } else {
5600 let content = resp.text().await?;
5601 let entity: Option<GetPremiumIndexKlinesV1Error> = serde_json::from_str(&content).ok();
5602 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5603 }
5604}
5605
5606pub async fn get_premium_index_v1(configuration: &configuration::Configuration, params: GetPremiumIndexV1Params) -> Result<Vec<models::GetPremiumIndexV1RespItem>, Error<GetPremiumIndexV1Error>> {
5608
5609 let uri_str = format!("{}/dapi/v1/premiumIndex", configuration.base_path);
5610 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5611
5612 let mut query_params: Vec<(String, String)> = Vec::new();
5614
5615 if let Some(ref param_value) = params.symbol {
5616 query_params.push(("symbol".to_string(), param_value.to_string()));
5617 }
5618 if let Some(ref param_value) = params.pair {
5619 query_params.push(("pair".to_string(), param_value.to_string()));
5620 }
5621
5622 let mut header_params = std::collections::HashMap::new();
5624
5625 if let Some(ref binance_auth) = configuration.binance_auth {
5627 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5629
5630 let body_string: Option<Vec<u8>> = None;
5632
5633 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5635 Ok(sig) => sig,
5636 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5637 };
5638
5639 query_params.push(("signature".to_string(), signature));
5641 }
5642
5643 if !query_params.is_empty() {
5645 req_builder = req_builder.query(&query_params);
5646 }
5647
5648
5649 if let Some(ref user_agent) = configuration.user_agent {
5651 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5652 }
5653
5654 for (header_name, header_value) in header_params {
5656 req_builder = req_builder.header(&header_name, &header_value);
5657 }
5658
5659
5660 let req = req_builder.build()?;
5661 let resp = configuration.client.execute(req).await?;
5662
5663 let status = resp.status();
5664 let content_type = resp
5665 .headers()
5666 .get("content-type")
5667 .and_then(|v| v.to_str().ok())
5668 .unwrap_or("application/octet-stream");
5669 let content_type = super::ContentType::from(content_type);
5670
5671 if !status.is_client_error() && !status.is_server_error() {
5672 let content = resp.text().await?;
5673 match content_type {
5674 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5675 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPremiumIndexV1RespItem>`"))),
5676 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::GetPremiumIndexV1RespItem>`")))),
5677 }
5678 } else {
5679 let content = resp.text().await?;
5680 let entity: Option<GetPremiumIndexV1Error> = serde_json::from_str(&content).ok();
5681 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5682 }
5683}
5684
5685pub async fn get_ticker24hr_v1(configuration: &configuration::Configuration, params: GetTicker24hrV1Params) -> Result<Vec<models::GetTicker24hrV1RespItem>, Error<GetTicker24hrV1Error>> {
5687
5688 let uri_str = format!("{}/dapi/v1/ticker/24hr", configuration.base_path);
5689 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5690
5691 let mut query_params: Vec<(String, String)> = Vec::new();
5693
5694 if let Some(ref param_value) = params.symbol {
5695 query_params.push(("symbol".to_string(), param_value.to_string()));
5696 }
5697 if let Some(ref param_value) = params.pair {
5698 query_params.push(("pair".to_string(), param_value.to_string()));
5699 }
5700
5701 let mut header_params = std::collections::HashMap::new();
5703
5704 if let Some(ref binance_auth) = configuration.binance_auth {
5706 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5708
5709 let body_string: Option<Vec<u8>> = None;
5711
5712 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5714 Ok(sig) => sig,
5715 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5716 };
5717
5718 query_params.push(("signature".to_string(), signature));
5720 }
5721
5722 if !query_params.is_empty() {
5724 req_builder = req_builder.query(&query_params);
5725 }
5726
5727
5728 if let Some(ref user_agent) = configuration.user_agent {
5730 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5731 }
5732
5733 for (header_name, header_value) in header_params {
5735 req_builder = req_builder.header(&header_name, &header_value);
5736 }
5737
5738
5739 let req = req_builder.build()?;
5740 let resp = configuration.client.execute(req).await?;
5741
5742 let status = resp.status();
5743 let content_type = resp
5744 .headers()
5745 .get("content-type")
5746 .and_then(|v| v.to_str().ok())
5747 .unwrap_or("application/octet-stream");
5748 let content_type = super::ContentType::from(content_type);
5749
5750 if !status.is_client_error() && !status.is_server_error() {
5751 let content = resp.text().await?;
5752 match content_type {
5753 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5754 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetTicker24hrV1RespItem>`"))),
5755 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::GetTicker24hrV1RespItem>`")))),
5756 }
5757 } else {
5758 let content = resp.text().await?;
5759 let entity: Option<GetTicker24hrV1Error> = serde_json::from_str(&content).ok();
5760 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5761 }
5762}
5763
5764pub async fn get_ticker_book_ticker_v1(configuration: &configuration::Configuration, params: GetTickerBookTickerV1Params) -> Result<Vec<models::GetTickerBookTickerV1RespItem>, Error<GetTickerBookTickerV1Error>> {
5766
5767 let uri_str = format!("{}/dapi/v1/ticker/bookTicker", configuration.base_path);
5768 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5769
5770 let mut query_params: Vec<(String, String)> = Vec::new();
5772
5773 if let Some(ref param_value) = params.symbol {
5774 query_params.push(("symbol".to_string(), param_value.to_string()));
5775 }
5776 if let Some(ref param_value) = params.pair {
5777 query_params.push(("pair".to_string(), param_value.to_string()));
5778 }
5779
5780 let mut header_params = std::collections::HashMap::new();
5782
5783 if let Some(ref binance_auth) = configuration.binance_auth {
5785 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5787
5788 let body_string: Option<Vec<u8>> = None;
5790
5791 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5793 Ok(sig) => sig,
5794 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5795 };
5796
5797 query_params.push(("signature".to_string(), signature));
5799 }
5800
5801 if !query_params.is_empty() {
5803 req_builder = req_builder.query(&query_params);
5804 }
5805
5806
5807 if let Some(ref user_agent) = configuration.user_agent {
5809 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5810 }
5811
5812 for (header_name, header_value) in header_params {
5814 req_builder = req_builder.header(&header_name, &header_value);
5815 }
5816
5817
5818 let req = req_builder.build()?;
5819 let resp = configuration.client.execute(req).await?;
5820
5821 let status = resp.status();
5822 let content_type = resp
5823 .headers()
5824 .get("content-type")
5825 .and_then(|v| v.to_str().ok())
5826 .unwrap_or("application/octet-stream");
5827 let content_type = super::ContentType::from(content_type);
5828
5829 if !status.is_client_error() && !status.is_server_error() {
5830 let content = resp.text().await?;
5831 match content_type {
5832 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5833 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetTickerBookTickerV1RespItem>`"))),
5834 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::GetTickerBookTickerV1RespItem>`")))),
5835 }
5836 } else {
5837 let content = resp.text().await?;
5838 let entity: Option<GetTickerBookTickerV1Error> = serde_json::from_str(&content).ok();
5839 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5840 }
5841}
5842
5843pub async fn get_ticker_price_v1(configuration: &configuration::Configuration, params: GetTickerPriceV1Params) -> Result<Vec<models::GetTickerPriceV1RespItem>, Error<GetTickerPriceV1Error>> {
5845
5846 let uri_str = format!("{}/dapi/v1/ticker/price", configuration.base_path);
5847 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5848
5849 let mut query_params: Vec<(String, String)> = Vec::new();
5851
5852 if let Some(ref param_value) = params.symbol {
5853 query_params.push(("symbol".to_string(), param_value.to_string()));
5854 }
5855 if let Some(ref param_value) = params.pair {
5856 query_params.push(("pair".to_string(), param_value.to_string()));
5857 }
5858
5859 let mut header_params = std::collections::HashMap::new();
5861
5862 if let Some(ref binance_auth) = configuration.binance_auth {
5864 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5866
5867 let body_string: Option<Vec<u8>> = None;
5869
5870 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5872 Ok(sig) => sig,
5873 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5874 };
5875
5876 query_params.push(("signature".to_string(), signature));
5878 }
5879
5880 if !query_params.is_empty() {
5882 req_builder = req_builder.query(&query_params);
5883 }
5884
5885
5886 if let Some(ref user_agent) = configuration.user_agent {
5888 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5889 }
5890
5891 for (header_name, header_value) in header_params {
5893 req_builder = req_builder.header(&header_name, &header_value);
5894 }
5895
5896
5897 let req = req_builder.build()?;
5898 let resp = configuration.client.execute(req).await?;
5899
5900 let status = resp.status();
5901 let content_type = resp
5902 .headers()
5903 .get("content-type")
5904 .and_then(|v| v.to_str().ok())
5905 .unwrap_or("application/octet-stream");
5906 let content_type = super::ContentType::from(content_type);
5907
5908 if !status.is_client_error() && !status.is_server_error() {
5909 let content = resp.text().await?;
5910 match content_type {
5911 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5912 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetTickerPriceV1RespItem>`"))),
5913 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::GetTickerPriceV1RespItem>`")))),
5914 }
5915 } else {
5916 let content = resp.text().await?;
5917 let entity: Option<GetTickerPriceV1Error> = serde_json::from_str(&content).ok();
5918 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5919 }
5920}
5921
5922pub async fn get_time_v1(configuration: &configuration::Configuration) -> Result<models::GetTimeV1Resp, Error<GetTimeV1Error>> {
5924
5925 let uri_str = format!("{}/dapi/v1/time", configuration.base_path);
5926 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5927
5928 let mut query_params: Vec<(String, String)> = Vec::new();
5930
5931
5932 let mut header_params = std::collections::HashMap::new();
5934
5935 if let Some(ref binance_auth) = configuration.binance_auth {
5937 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5939
5940 let body_string: Option<Vec<u8>> = None;
5942
5943 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5945 Ok(sig) => sig,
5946 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5947 };
5948
5949 query_params.push(("signature".to_string(), signature));
5951 }
5952
5953 if !query_params.is_empty() {
5955 req_builder = req_builder.query(&query_params);
5956 }
5957
5958
5959 if let Some(ref user_agent) = configuration.user_agent {
5961 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5962 }
5963
5964 for (header_name, header_value) in header_params {
5966 req_builder = req_builder.header(&header_name, &header_value);
5967 }
5968
5969
5970 let req = req_builder.build()?;
5971 let resp = configuration.client.execute(req).await?;
5972
5973 let status = resp.status();
5974 let content_type = resp
5975 .headers()
5976 .get("content-type")
5977 .and_then(|v| v.to_str().ok())
5978 .unwrap_or("application/octet-stream");
5979 let content_type = super::ContentType::from(content_type);
5980
5981 if !status.is_client_error() && !status.is_server_error() {
5982 let content = resp.text().await?;
5983 match content_type {
5984 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5985 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTimeV1Resp`"))),
5986 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::GetTimeV1Resp`")))),
5987 }
5988 } else {
5989 let content = resp.text().await?;
5990 let entity: Option<GetTimeV1Error> = serde_json::from_str(&content).ok();
5991 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5992 }
5993}
5994
5995pub async fn get_trade_asyn_id_v1(configuration: &configuration::Configuration, params: GetTradeAsynIdV1Params) -> Result<models::GetTradeAsynIdV1Resp, Error<GetTradeAsynIdV1Error>> {
5997
5998 let uri_str = format!("{}/dapi/v1/trade/asyn/id", configuration.base_path);
5999 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6000
6001 let mut query_params: Vec<(String, String)> = Vec::new();
6003
6004 query_params.push(("downloadId".to_string(), params.download_id.to_string()));
6005 if let Some(ref param_value) = params.recv_window {
6006 query_params.push(("recvWindow".to_string(), param_value.to_string()));
6007 }
6008 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6009
6010 let mut header_params = std::collections::HashMap::new();
6012
6013 if let Some(ref binance_auth) = configuration.binance_auth {
6015 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6017
6018 let body_string: Option<Vec<u8>> = None;
6020
6021 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6023 Ok(sig) => sig,
6024 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6025 };
6026
6027 query_params.push(("signature".to_string(), signature));
6029 }
6030
6031 if !query_params.is_empty() {
6033 req_builder = req_builder.query(&query_params);
6034 }
6035
6036
6037 if let Some(ref user_agent) = configuration.user_agent {
6039 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6040 }
6041
6042 for (header_name, header_value) in header_params {
6044 req_builder = req_builder.header(&header_name, &header_value);
6045 }
6046
6047
6048 let req = req_builder.build()?;
6049 let resp = configuration.client.execute(req).await?;
6050
6051 let status = resp.status();
6052 let content_type = resp
6053 .headers()
6054 .get("content-type")
6055 .and_then(|v| v.to_str().ok())
6056 .unwrap_or("application/octet-stream");
6057 let content_type = super::ContentType::from(content_type);
6058
6059 if !status.is_client_error() && !status.is_server_error() {
6060 let content = resp.text().await?;
6061 match content_type {
6062 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6063 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTradeAsynIdV1Resp`"))),
6064 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::GetTradeAsynIdV1Resp`")))),
6065 }
6066 } else {
6067 let content = resp.text().await?;
6068 let entity: Option<GetTradeAsynIdV1Error> = serde_json::from_str(&content).ok();
6069 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6070 }
6071}
6072
6073pub async fn get_trade_asyn_v1(configuration: &configuration::Configuration, params: GetTradeAsynV1Params) -> Result<models::GetTradeAsynV1Resp, Error<GetTradeAsynV1Error>> {
6075
6076 let uri_str = format!("{}/dapi/v1/trade/asyn", configuration.base_path);
6077 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6078
6079 let mut query_params: Vec<(String, String)> = Vec::new();
6081
6082 query_params.push(("startTime".to_string(), params.start_time.to_string()));
6083 query_params.push(("endTime".to_string(), params.end_time.to_string()));
6084 if let Some(ref param_value) = params.recv_window {
6085 query_params.push(("recvWindow".to_string(), param_value.to_string()));
6086 }
6087 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6088
6089 let mut header_params = std::collections::HashMap::new();
6091
6092 if let Some(ref binance_auth) = configuration.binance_auth {
6094 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6096
6097 let body_string: Option<Vec<u8>> = None;
6099
6100 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6102 Ok(sig) => sig,
6103 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6104 };
6105
6106 query_params.push(("signature".to_string(), signature));
6108 }
6109
6110 if !query_params.is_empty() {
6112 req_builder = req_builder.query(&query_params);
6113 }
6114
6115
6116 if let Some(ref user_agent) = configuration.user_agent {
6118 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6119 }
6120
6121 for (header_name, header_value) in header_params {
6123 req_builder = req_builder.header(&header_name, &header_value);
6124 }
6125
6126
6127 let req = req_builder.build()?;
6128 let resp = configuration.client.execute(req).await?;
6129
6130 let status = resp.status();
6131 let content_type = resp
6132 .headers()
6133 .get("content-type")
6134 .and_then(|v| v.to_str().ok())
6135 .unwrap_or("application/octet-stream");
6136 let content_type = super::ContentType::from(content_type);
6137
6138 if !status.is_client_error() && !status.is_server_error() {
6139 let content = resp.text().await?;
6140 match content_type {
6141 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6142 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTradeAsynV1Resp`"))),
6143 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::GetTradeAsynV1Resp`")))),
6144 }
6145 } else {
6146 let content = resp.text().await?;
6147 let entity: Option<GetTradeAsynV1Error> = serde_json::from_str(&content).ok();
6148 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6149 }
6150}
6151
6152pub async fn get_trades_v1(configuration: &configuration::Configuration, params: GetTradesV1Params) -> Result<Vec<models::GetTradesV1RespItem>, Error<GetTradesV1Error>> {
6154
6155 let uri_str = format!("{}/dapi/v1/trades", configuration.base_path);
6156 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6157
6158 let mut query_params: Vec<(String, String)> = Vec::new();
6160
6161 query_params.push(("symbol".to_string(), params.symbol.to_string()));
6162 if let Some(ref param_value) = params.limit {
6163 query_params.push(("limit".to_string(), param_value.to_string()));
6164 }
6165
6166 let mut header_params = std::collections::HashMap::new();
6168
6169 if let Some(ref binance_auth) = configuration.binance_auth {
6171 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6173
6174 let body_string: Option<Vec<u8>> = None;
6176
6177 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6179 Ok(sig) => sig,
6180 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6181 };
6182
6183 query_params.push(("signature".to_string(), signature));
6185 }
6186
6187 if !query_params.is_empty() {
6189 req_builder = req_builder.query(&query_params);
6190 }
6191
6192
6193 if let Some(ref user_agent) = configuration.user_agent {
6195 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6196 }
6197
6198 for (header_name, header_value) in header_params {
6200 req_builder = req_builder.header(&header_name, &header_value);
6201 }
6202
6203
6204 let req = req_builder.build()?;
6205 let resp = configuration.client.execute(req).await?;
6206
6207 let status = resp.status();
6208 let content_type = resp
6209 .headers()
6210 .get("content-type")
6211 .and_then(|v| v.to_str().ok())
6212 .unwrap_or("application/octet-stream");
6213 let content_type = super::ContentType::from(content_type);
6214
6215 if !status.is_client_error() && !status.is_server_error() {
6216 let content = resp.text().await?;
6217 match content_type {
6218 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6219 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetTradesV1RespItem>`"))),
6220 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::GetTradesV1RespItem>`")))),
6221 }
6222 } else {
6223 let content = resp.text().await?;
6224 let entity: Option<GetTradesV1Error> = serde_json::from_str(&content).ok();
6225 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6226 }
6227}
6228
6229pub async fn get_user_trades_v1(configuration: &configuration::Configuration, params: GetUserTradesV1Params) -> Result<Vec<models::GetUserTradesV1RespItem>, Error<GetUserTradesV1Error>> {
6231
6232 let uri_str = format!("{}/dapi/v1/userTrades", configuration.base_path);
6233 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6234
6235 let mut query_params: Vec<(String, String)> = Vec::new();
6237
6238 if let Some(ref param_value) = params.symbol {
6239 query_params.push(("symbol".to_string(), param_value.to_string()));
6240 }
6241 if let Some(ref param_value) = params.pair {
6242 query_params.push(("pair".to_string(), param_value.to_string()));
6243 }
6244 if let Some(ref param_value) = params.order_id {
6245 query_params.push(("orderId".to_string(), param_value.to_string()));
6246 }
6247 if let Some(ref param_value) = params.start_time {
6248 query_params.push(("startTime".to_string(), param_value.to_string()));
6249 }
6250 if let Some(ref param_value) = params.end_time {
6251 query_params.push(("endTime".to_string(), param_value.to_string()));
6252 }
6253 if let Some(ref param_value) = params.from_id {
6254 query_params.push(("fromId".to_string(), param_value.to_string()));
6255 }
6256 if let Some(ref param_value) = params.limit {
6257 query_params.push(("limit".to_string(), param_value.to_string()));
6258 }
6259 if let Some(ref param_value) = params.recv_window {
6260 query_params.push(("recvWindow".to_string(), param_value.to_string()));
6261 }
6262 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6263
6264 let mut header_params = std::collections::HashMap::new();
6266
6267 if let Some(ref binance_auth) = configuration.binance_auth {
6269 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6271
6272 let body_string: Option<Vec<u8>> = None;
6274
6275 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6277 Ok(sig) => sig,
6278 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6279 };
6280
6281 query_params.push(("signature".to_string(), signature));
6283 }
6284
6285 if !query_params.is_empty() {
6287 req_builder = req_builder.query(&query_params);
6288 }
6289
6290
6291 if let Some(ref user_agent) = configuration.user_agent {
6293 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6294 }
6295
6296 for (header_name, header_value) in header_params {
6298 req_builder = req_builder.header(&header_name, &header_value);
6299 }
6300
6301
6302 let req = req_builder.build()?;
6303 let resp = configuration.client.execute(req).await?;
6304
6305 let status = resp.status();
6306 let content_type = resp
6307 .headers()
6308 .get("content-type")
6309 .and_then(|v| v.to_str().ok())
6310 .unwrap_or("application/octet-stream");
6311 let content_type = super::ContentType::from(content_type);
6312
6313 if !status.is_client_error() && !status.is_server_error() {
6314 let content = resp.text().await?;
6315 match content_type {
6316 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6317 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetUserTradesV1RespItem>`"))),
6318 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::GetUserTradesV1RespItem>`")))),
6319 }
6320 } else {
6321 let content = resp.text().await?;
6322 let entity: Option<GetUserTradesV1Error> = serde_json::from_str(&content).ok();
6323 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6324 }
6325}
6326
6327pub async fn update_batch_orders_v1(configuration: &configuration::Configuration, params: UpdateBatchOrdersV1Params) -> Result<Vec<models::CmfuturesUpdateBatchOrdersV1RespInner>, Error<UpdateBatchOrdersV1Error>> {
6329
6330 let uri_str = format!("{}/dapi/v1/batchOrders", configuration.base_path);
6331 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6332
6333 let mut query_params: Vec<(String, String)> = Vec::new();
6335
6336
6337 let mut header_params = std::collections::HashMap::new();
6339
6340 if let Some(ref binance_auth) = configuration.binance_auth {
6342 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6344
6345 let body_string: Option<Vec<u8>> = None;
6347
6348 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6350 Ok(sig) => sig,
6351 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6352 };
6353
6354 query_params.push(("signature".to_string(), signature));
6356 }
6357
6358 if !query_params.is_empty() {
6360 req_builder = req_builder.query(&query_params);
6361 }
6362
6363
6364 if let Some(ref user_agent) = configuration.user_agent {
6366 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6367 }
6368
6369 for (header_name, header_value) in header_params {
6371 req_builder = req_builder.header(&header_name, &header_value);
6372 }
6373
6374 let mut multipart_form_params = std::collections::HashMap::new();
6375 multipart_form_params.insert("batchOrders", params.batch_orders.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
6376 if let Some(param_value) = params.recv_window {
6377 multipart_form_params.insert("recvWindow", param_value.to_string());
6378 }
6379 multipart_form_params.insert("timestamp", params.timestamp.to_string());
6380 req_builder = req_builder.form(&multipart_form_params);
6381
6382 let req = req_builder.build()?;
6383 let resp = configuration.client.execute(req).await?;
6384
6385 let status = resp.status();
6386 let content_type = resp
6387 .headers()
6388 .get("content-type")
6389 .and_then(|v| v.to_str().ok())
6390 .unwrap_or("application/octet-stream");
6391 let content_type = super::ContentType::from(content_type);
6392
6393 if !status.is_client_error() && !status.is_server_error() {
6394 let content = resp.text().await?;
6395 match content_type {
6396 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6397 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesUpdateBatchOrdersV1RespInner>`"))),
6398 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::CmfuturesUpdateBatchOrdersV1RespInner>`")))),
6399 }
6400 } else {
6401 let content = resp.text().await?;
6402 let entity: Option<UpdateBatchOrdersV1Error> = serde_json::from_str(&content).ok();
6403 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6404 }
6405}
6406
6407pub async fn update_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<UpdateListenKeyV1Error>> {
6409
6410 let uri_str = format!("{}/dapi/v1/listenKey", configuration.base_path);
6411 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6412
6413 let mut query_params: Vec<(String, String)> = Vec::new();
6415
6416
6417 let mut header_params = std::collections::HashMap::new();
6419
6420 if let Some(ref binance_auth) = configuration.binance_auth {
6422 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6424
6425 let body_string: Option<Vec<u8>> = None;
6427
6428 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6430 Ok(sig) => sig,
6431 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6432 };
6433
6434 query_params.push(("signature".to_string(), signature));
6436 }
6437
6438 if !query_params.is_empty() {
6440 req_builder = req_builder.query(&query_params);
6441 }
6442
6443
6444 if let Some(ref user_agent) = configuration.user_agent {
6446 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6447 }
6448
6449 for (header_name, header_value) in header_params {
6451 req_builder = req_builder.header(&header_name, &header_value);
6452 }
6453
6454
6455 let req = req_builder.build()?;
6456 let resp = configuration.client.execute(req).await?;
6457
6458 let status = resp.status();
6459 let content_type = resp
6460 .headers()
6461 .get("content-type")
6462 .and_then(|v| v.to_str().ok())
6463 .unwrap_or("application/octet-stream");
6464 let content_type = super::ContentType::from(content_type);
6465
6466 if !status.is_client_error() && !status.is_server_error() {
6467 let content = resp.text().await?;
6468 match content_type {
6469 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6470 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
6471 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
6472 }
6473 } else {
6474 let content = resp.text().await?;
6475 let entity: Option<UpdateListenKeyV1Error> = serde_json::from_str(&content).ok();
6476 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6477 }
6478}
6479
6480pub async fn update_order_v1(configuration: &configuration::Configuration, params: UpdateOrderV1Params) -> Result<models::UpdateOrderV1Resp, Error<UpdateOrderV1Error>> {
6482
6483 let uri_str = format!("{}/dapi/v1/order", configuration.base_path);
6484 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6485
6486 let mut query_params: Vec<(String, String)> = Vec::new();
6488
6489
6490 let mut header_params = std::collections::HashMap::new();
6492
6493 if let Some(ref binance_auth) = configuration.binance_auth {
6495 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6497
6498 let body_string: Option<Vec<u8>> = None;
6500
6501 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6503 Ok(sig) => sig,
6504 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6505 };
6506
6507 query_params.push(("signature".to_string(), signature));
6509 }
6510
6511 if !query_params.is_empty() {
6513 req_builder = req_builder.query(&query_params);
6514 }
6515
6516
6517 if let Some(ref user_agent) = configuration.user_agent {
6519 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6520 }
6521
6522 for (header_name, header_value) in header_params {
6524 req_builder = req_builder.header(&header_name, &header_value);
6525 }
6526
6527 let mut multipart_form_params = std::collections::HashMap::new();
6528 if let Some(param_value) = params.order_id {
6529 multipart_form_params.insert("orderId", param_value.to_string());
6530 }
6531 if let Some(param_value) = params.orig_client_order_id {
6532 multipart_form_params.insert("origClientOrderId", param_value.to_string());
6533 }
6534 if let Some(param_value) = params.price {
6535 multipart_form_params.insert("price", param_value.to_string());
6536 }
6537 if let Some(param_value) = params.price_match {
6538 multipart_form_params.insert("priceMatch", param_value.to_string());
6539 }
6540 if let Some(param_value) = params.quantity {
6541 multipart_form_params.insert("quantity", param_value.to_string());
6542 }
6543 if let Some(param_value) = params.recv_window {
6544 multipart_form_params.insert("recvWindow", param_value.to_string());
6545 }
6546 multipart_form_params.insert("side", params.side.to_string());
6547 multipart_form_params.insert("symbol", params.symbol.to_string());
6548 multipart_form_params.insert("timestamp", params.timestamp.to_string());
6549 req_builder = req_builder.form(&multipart_form_params);
6550
6551 let req = req_builder.build()?;
6552 let resp = configuration.client.execute(req).await?;
6553
6554 let status = resp.status();
6555 let content_type = resp
6556 .headers()
6557 .get("content-type")
6558 .and_then(|v| v.to_str().ok())
6559 .unwrap_or("application/octet-stream");
6560 let content_type = super::ContentType::from(content_type);
6561
6562 if !status.is_client_error() && !status.is_server_error() {
6563 let content = resp.text().await?;
6564 match content_type {
6565 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6566 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateOrderV1Resp`"))),
6567 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::UpdateOrderV1Resp`")))),
6568 }
6569 } else {
6570 let content = resp.text().await?;
6571 let entity: Option<UpdateOrderV1Error> = serde_json::from_str(&content).ok();
6572 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6573 }
6574}
6575