1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::spot::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct CreateMarginApiKeyV1Params {
20 pub api_name: String,
21 pub timestamp: i64,
22 pub ip: Option<String>,
23 pub permission_mode: Option<String>,
24 pub public_key: Option<String>,
25 pub recv_window: Option<i64>,
26 pub symbol: Option<String>
27}
28
29#[derive(Clone, Debug, Default)]
31pub struct CreateMarginBorrowRepayV1Params {
32 pub amount: String,
33 pub asset: String,
34 pub is_isolated: String,
35 pub symbol: String,
36 pub timestamp: i64,
37 pub r#type: String,
38 pub recv_window: Option<i64>
39}
40
41#[derive(Clone, Debug, Default)]
43pub struct CreateMarginExchangeSmallLiabilityV1Params {
44 pub asset_names: Vec<String>,
45 pub timestamp: i64,
46 pub recv_window: Option<i64>
47}
48
49#[derive(Clone, Debug, Default)]
51pub struct CreateMarginIsolatedAccountV1Params {
52 pub symbol: String,
53 pub timestamp: i64,
54 pub recv_window: Option<i64>
55}
56
57#[derive(Clone, Debug, Default)]
59pub struct CreateMarginManualLiquidationV1Params {
60 pub timestamp: i64,
61 pub r#type: String,
62 pub recv_window: Option<i64>,
63 pub symbol: Option<String>
64}
65
66#[derive(Clone, Debug, Default)]
68pub struct CreateMarginMaxLeverageV1Params {
69 pub max_leverage: i32
70}
71
72#[derive(Clone, Debug, Default)]
74pub struct CreateMarginOrderOcoV1Params {
75 pub price: String,
76 pub quantity: String,
77 pub side: String,
78 pub stop_price: String,
79 pub symbol: String,
80 pub timestamp: i64,
81 pub auto_repay_at_cancel: Option<bool>,
82 pub is_isolated: Option<String>,
83 pub limit_client_order_id: Option<String>,
84 pub limit_iceberg_qty: Option<String>,
85 pub list_client_order_id: Option<String>,
86 pub new_order_resp_type: Option<String>,
87 pub recv_window: Option<i64>,
88 pub self_trade_prevention_mode: Option<String>,
89 pub side_effect_type: Option<String>,
90 pub stop_client_order_id: Option<String>,
91 pub stop_iceberg_qty: Option<String>,
92 pub stop_limit_price: Option<String>,
93 pub stop_limit_time_in_force: Option<String>
94}
95
96#[derive(Clone, Debug, Default)]
98pub struct CreateMarginOrderOtoV1Params {
99 pub pending_quantity: String,
100 pub pending_side: String,
101 pub pending_type: String,
102 pub symbol: String,
103 pub working_iceberg_qty: String,
104 pub working_price: String,
105 pub working_quantity: String,
106 pub working_side: String,
107 pub working_type: String,
108 pub auto_repay_at_cancel: Option<bool>,
109 pub is_isolated: Option<String>,
110 pub list_client_order_id: Option<String>,
111 pub new_order_resp_type: Option<String>,
112 pub pending_client_order_id: Option<String>,
113 pub pending_iceberg_qty: Option<String>,
114 pub pending_price: Option<String>,
115 pub pending_stop_price: Option<String>,
116 pub pending_time_in_force: Option<String>,
117 pub pending_trailing_delta: Option<String>,
118 pub self_trade_prevention_mode: Option<String>,
119 pub side_effect_type: Option<String>,
120 pub working_client_order_id: Option<String>,
121 pub working_time_in_force: Option<String>
122}
123
124#[derive(Clone, Debug, Default)]
126pub struct CreateMarginOrderOtocoV1Params {
127 pub pending_above_type: String,
128 pub pending_quantity: String,
129 pub pending_side: String,
130 pub symbol: String,
131 pub working_price: String,
132 pub working_quantity: String,
133 pub working_side: String,
134 pub working_type: String,
135 pub auto_repay_at_cancel: Option<bool>,
136 pub is_isolated: Option<String>,
137 pub list_client_order_id: Option<String>,
138 pub new_order_resp_type: Option<String>,
139 pub pending_above_client_order_id: Option<String>,
140 pub pending_above_iceberg_qty: Option<String>,
141 pub pending_above_price: Option<String>,
142 pub pending_above_stop_price: Option<String>,
143 pub pending_above_time_in_force: Option<String>,
144 pub pending_above_trailing_delta: Option<String>,
145 pub pending_below_client_order_id: Option<String>,
146 pub pending_below_iceberg_qty: Option<String>,
147 pub pending_below_price: Option<String>,
148 pub pending_below_stop_price: Option<String>,
149 pub pending_below_time_in_force: Option<String>,
150 pub pending_below_trailing_delta: Option<String>,
151 pub pending_below_type: Option<String>,
152 pub self_trade_prevention_mode: Option<String>,
153 pub side_effect_type: Option<String>,
154 pub working_client_order_id: Option<String>,
155 pub working_iceberg_qty: Option<String>,
156 pub working_time_in_force: Option<String>
157}
158
159#[derive(Clone, Debug, Default)]
161pub struct CreateMarginOrderV1Params {
162 pub side: String,
163 pub symbol: String,
164 pub timestamp: i64,
165 pub r#type: String,
166 pub auto_repay_at_cancel: Option<bool>,
167 pub iceberg_qty: Option<String>,
168 pub is_isolated: Option<String>,
169 pub new_client_order_id: Option<String>,
170 pub new_order_resp_type: Option<String>,
171 pub price: Option<String>,
172 pub quantity: Option<String>,
173 pub quote_order_qty: Option<String>,
174 pub recv_window: Option<i64>,
175 pub self_trade_prevention_mode: Option<String>,
176 pub side_effect_type: Option<String>,
177 pub stop_price: Option<String>,
178 pub time_in_force: Option<String>
179}
180
181#[derive(Clone, Debug, Default)]
183pub struct CreateUserDataStreamIsolatedV1Params {
184 pub symbol: String
185}
186
187#[derive(Clone, Debug, Default)]
189pub struct DeleteMarginApiKeyV1Params {
190 pub timestamp: i64,
191 pub api_key: Option<String>,
192 pub api_name: Option<String>,
193 pub symbol: Option<String>,
195 pub recv_window: Option<i64>
197}
198
199#[derive(Clone, Debug, Default)]
201pub struct DeleteMarginIsolatedAccountV1Params {
202 pub symbol: String,
203 pub timestamp: i64,
204 pub recv_window: Option<i64>
206}
207
208#[derive(Clone, Debug, Default)]
210pub struct DeleteMarginOpenOrdersV1Params {
211 pub symbol: String,
212 pub timestamp: i64,
213 pub is_isolated: Option<String>,
215 pub recv_window: Option<i64>
217}
218
219#[derive(Clone, Debug, Default)]
221pub struct DeleteMarginOrderListV1Params {
222 pub symbol: String,
223 pub timestamp: i64,
224 pub is_isolated: Option<String>,
226 pub order_list_id: Option<i64>,
228 pub list_client_order_id: Option<String>,
230 pub new_client_order_id: Option<String>,
232 pub recv_window: Option<i64>
234}
235
236#[derive(Clone, Debug, Default)]
238pub struct DeleteMarginOrderV1Params {
239 pub symbol: String,
240 pub timestamp: i64,
241 pub is_isolated: Option<String>,
243 pub order_id: Option<i64>,
244 pub orig_client_order_id: Option<String>,
245 pub new_client_order_id: Option<String>,
247 pub recv_window: Option<i64>
249}
250
251#[derive(Clone, Debug, Default)]
253pub struct DeleteUserDataStreamIsolatedV1Params {
254 pub symbol: String,
255 pub listenkey: String
256}
257
258#[derive(Clone, Debug, Default)]
260pub struct DeleteUserDataStreamV1Params {
261 pub listenkey: String
262}
263
264#[derive(Clone, Debug, Default)]
266pub struct GetBnbBurnV1Params {
267 pub timestamp: i64,
268 pub recv_window: Option<i64>
270}
271
272#[derive(Clone, Debug, Default)]
274pub struct GetMarginAccountV1Params {
275 pub timestamp: i64,
276 pub recv_window: Option<i64>
278}
279
280#[derive(Clone, Debug, Default)]
282pub struct GetMarginAllAssetsV1Params {
283 pub asset: Option<String>
284}
285
286#[derive(Clone, Debug, Default)]
288pub struct GetMarginAllOrderListV1Params {
289 pub timestamp: i64,
290 pub is_isolated: Option<String>,
292 pub symbol: Option<String>,
294 pub from_id: Option<i64>,
296 pub start_time: Option<i64>,
297 pub end_time: Option<i64>,
298 pub limit: Option<i32>,
300 pub recv_window: Option<i64>
302}
303
304#[derive(Clone, Debug, Default)]
306pub struct GetMarginAllOrdersV1Params {
307 pub symbol: String,
308 pub timestamp: i64,
309 pub is_isolated: Option<String>,
311 pub order_id: Option<i64>,
312 pub start_time: Option<i64>,
313 pub end_time: Option<i64>,
314 pub limit: Option<i32>,
316 pub recv_window: Option<i64>
318}
319
320#[derive(Clone, Debug, Default)]
322pub struct GetMarginAllPairsV1Params {
323 pub symbol: Option<String>
324}
325
326#[derive(Clone, Debug, Default)]
328pub struct GetMarginApiKeyListV1Params {
329 pub timestamp: i64,
330 pub symbol: Option<String>,
332 pub recv_window: Option<i64>
334}
335
336#[derive(Clone, Debug, Default)]
338pub struct GetMarginApiKeyV1Params {
339 pub api_key: String,
340 pub timestamp: i64,
341 pub symbol: Option<String>,
343 pub recv_window: Option<i64>
345}
346
347#[derive(Clone, Debug, Default)]
349pub struct GetMarginAvailableInventoryV1Params {
350 pub r#type: String
352}
353
354#[derive(Clone, Debug, Default)]
356pub struct GetMarginBorrowRepayV1Params {
357 pub r#type: String,
359 pub timestamp: i64,
360 pub asset: Option<String>,
361 pub isolated_symbol: Option<String>,
363 pub tx_id: Option<i64>,
365 pub start_time: Option<i64>,
366 pub end_time: Option<i64>,
367 pub current: Option<i64>,
369 pub size: Option<i64>,
371 pub recv_window: Option<i64>
373}
374
375#[derive(Clone, Debug, Default)]
377pub struct GetMarginCapitalFlowV1Params {
378 pub timestamp: i64,
379 pub asset: Option<String>,
380 pub symbol: Option<String>,
382 pub r#type: Option<String>,
383 pub start_time: Option<i64>,
385 pub end_time: Option<i64>,
386 pub from_id: Option<i64>,
388 pub limit: Option<i64>,
390 pub recv_window: Option<i64>
392}
393
394#[derive(Clone, Debug, Default)]
396pub struct GetMarginCrossMarginDataV1Params {
397 pub timestamp: i64,
398 pub vip_level: Option<i32>,
400 pub coin: Option<String>,
401 pub recv_window: Option<i64>
403}
404
405#[derive(Clone, Debug, Default)]
407pub struct GetMarginDelistScheduleV1Params {
408 pub timestamp: i64,
409 pub recv_window: Option<i64>
410}
411
412#[derive(Clone, Debug, Default)]
414pub struct GetMarginExchangeSmallLiabilityHistoryV1Params {
415 pub current: i32,
417 pub size: i32,
419 pub timestamp: i64,
420 pub start_time: Option<i64>,
422 pub end_time: Option<i64>,
424 pub recv_window: Option<i64>
425}
426
427#[derive(Clone, Debug, Default)]
429pub struct GetMarginExchangeSmallLiabilityV1Params {
430 pub timestamp: i64,
431 pub recv_window: Option<i64>
432}
433
434#[derive(Clone, Debug, Default)]
436pub struct GetMarginForceLiquidationRecV1Params {
437 pub timestamp: i64,
438 pub start_time: Option<i64>,
439 pub end_time: Option<i64>,
440 pub isolated_symbol: Option<String>,
441 pub current: Option<i64>,
443 pub size: Option<i64>,
445 pub recv_window: Option<i64>
447}
448
449#[derive(Clone, Debug, Default)]
451pub struct GetMarginInterestHistoryV1Params {
452 pub timestamp: i64,
453 pub asset: Option<String>,
454 pub isolated_symbol: Option<String>,
456 pub start_time: Option<i64>,
457 pub end_time: Option<i64>,
458 pub current: Option<i64>,
460 pub size: Option<i64>,
462 pub recv_window: Option<i64>
464}
465
466#[derive(Clone, Debug, Default)]
468pub struct GetMarginInterestRateHistoryV1Params {
469 pub asset: String,
470 pub timestamp: i64,
471 pub vip_level: Option<i32>,
473 pub start_time: Option<i64>,
475 pub end_time: Option<i64>,
477 pub recv_window: Option<i64>
479}
480
481#[derive(Clone, Debug, Default)]
483pub struct GetMarginIsolatedAccountLimitV1Params {
484 pub timestamp: i64,
485 pub recv_window: Option<i64>
487}
488
489#[derive(Clone, Debug, Default)]
491pub struct GetMarginIsolatedAccountV1Params {
492 pub timestamp: i64,
493 pub symbols: Option<String>,
495 pub recv_window: Option<i64>
497}
498
499#[derive(Clone, Debug, Default)]
501pub struct GetMarginIsolatedAllPairsV1Params {
502 pub timestamp: i64,
503 pub symbol: Option<String>,
504 pub recv_window: Option<i64>
506}
507
508#[derive(Clone, Debug, Default)]
510pub struct GetMarginIsolatedMarginDataV1Params {
511 pub timestamp: i64,
512 pub vip_level: Option<i32>,
514 pub symbol: Option<String>,
515 pub recv_window: Option<i64>
517}
518
519#[derive(Clone, Debug, Default)]
521pub struct GetMarginIsolatedMarginTierV1Params {
522 pub symbol: String,
523 pub timestamp: i64,
524 pub tier: Option<i32>,
526 pub recv_window: Option<i64>
528}
529
530#[derive(Clone, Debug, Default)]
532pub struct GetMarginMaxBorrowableV1Params {
533 pub asset: String,
534 pub timestamp: i64,
535 pub isolated_symbol: Option<String>,
537 pub recv_window: Option<i64>
539}
540
541#[derive(Clone, Debug, Default)]
543pub struct GetMarginMaxTransferableV1Params {
544 pub asset: String,
545 pub timestamp: i64,
546 pub isolated_symbol: Option<String>,
548 pub recv_window: Option<i64>
550}
551
552#[derive(Clone, Debug, Default)]
554pub struct GetMarginMyTradesV1Params {
555 pub symbol: String,
556 pub timestamp: i64,
557 pub is_isolated: Option<String>,
559 pub order_id: Option<i64>,
560 pub start_time: Option<i64>,
561 pub end_time: Option<i64>,
562 pub from_id: Option<i64>,
564 pub limit: Option<i32>,
566 pub recv_window: Option<i64>
568}
569
570#[derive(Clone, Debug, Default)]
572pub struct GetMarginNextHourlyInterestRateV1Params {
573 pub assets: String,
575 pub is_isolated: bool
577}
578
579#[derive(Clone, Debug, Default)]
581pub struct GetMarginOpenOrderListV1Params {
582 pub timestamp: i64,
583 pub is_isolated: Option<String>,
585 pub symbol: Option<String>,
587 pub recv_window: Option<i64>
589}
590
591#[derive(Clone, Debug, Default)]
593pub struct GetMarginOpenOrdersV1Params {
594 pub timestamp: i64,
595 pub symbol: Option<String>,
596 pub is_isolated: Option<String>,
598 pub recv_window: Option<i64>
600}
601
602#[derive(Clone, Debug, Default)]
604pub struct GetMarginOrderListV1Params {
605 pub timestamp: i64,
606 pub is_isolated: Option<String>,
608 pub symbol: Option<String>,
610 pub order_list_id: Option<i64>,
612 pub orig_client_order_id: Option<String>,
614 pub recv_window: Option<i64>
616}
617
618#[derive(Clone, Debug, Default)]
620pub struct GetMarginOrderV1Params {
621 pub symbol: String,
622 pub timestamp: i64,
623 pub is_isolated: Option<String>,
625 pub order_id: Option<i64>,
626 pub orig_client_order_id: Option<String>,
627 pub recv_window: Option<i64>
629}
630
631#[derive(Clone, Debug, Default)]
633pub struct GetMarginPriceIndexV1Params {
634 pub symbol: String
635}
636
637#[derive(Clone, Debug, Default)]
639pub struct GetMarginRateLimitOrderV1Params {
640 pub timestamp: i64,
641 pub is_isolated: Option<String>,
643 pub symbol: Option<String>,
645 pub recv_window: Option<i64>
647}
648
649#[derive(Clone, Debug, Default)]
651pub struct GetMarginTradeCoeffV1Params {
652 pub timestamp: i64,
653 pub recv_window: Option<i64>
654}
655
656#[derive(Clone, Debug, Default)]
658pub struct GetMarginTransferV1Params {
659 pub timestamp: i64,
660 pub asset: Option<String>,
661 pub r#type: Option<String>,
663 pub start_time: Option<i64>,
664 pub end_time: Option<i64>,
665 pub current: Option<i64>,
667 pub size: Option<i64>,
669 pub isolated_symbol: Option<String>,
671 pub recv_window: Option<i64>
673}
674
675#[derive(Clone, Debug, Default)]
677pub struct UpdateMarginApiKeyIpV1Params {
678 pub api_key: String,
679 pub ip: String,
680 pub timestamp: i64,
681 pub recv_window: Option<i64>,
682 pub symbol: Option<String>
683}
684
685#[derive(Clone, Debug, Default)]
687pub struct UpdateMarginListenKeyV1Params {
688 pub listen_key: String
689}
690
691#[derive(Clone, Debug, Default)]
693pub struct UpdateUserDataStreamIsolatedV1Params {
694 pub listen_key: String,
695 pub symbol: String
696}
697
698#[derive(Clone, Debug, Default)]
700pub struct UpdateUserDataStreamV1Params {
701 pub listen_key: String
702}
703
704
705#[derive(Debug, Clone, Serialize, Deserialize)]
707#[serde(untagged)]
708pub enum CreateMarginApiKeyV1Error {
709 Status4XX(models::ApiError),
710 Status5XX(models::ApiError),
711 UnknownValue(serde_json::Value),
712}
713
714#[derive(Debug, Clone, Serialize, Deserialize)]
716#[serde(untagged)]
717pub enum CreateMarginBorrowRepayV1Error {
718 Status4XX(models::ApiError),
719 Status5XX(models::ApiError),
720 UnknownValue(serde_json::Value),
721}
722
723#[derive(Debug, Clone, Serialize, Deserialize)]
725#[serde(untagged)]
726pub enum CreateMarginExchangeSmallLiabilityV1Error {
727 Status4XX(models::ApiError),
728 Status5XX(models::ApiError),
729 UnknownValue(serde_json::Value),
730}
731
732#[derive(Debug, Clone, Serialize, Deserialize)]
734#[serde(untagged)]
735pub enum CreateMarginIsolatedAccountV1Error {
736 Status4XX(models::ApiError),
737 Status5XX(models::ApiError),
738 UnknownValue(serde_json::Value),
739}
740
741#[derive(Debug, Clone, Serialize, Deserialize)]
743#[serde(untagged)]
744pub enum CreateMarginListenKeyV1Error {
745 Status4XX(models::ApiError),
746 Status5XX(models::ApiError),
747 UnknownValue(serde_json::Value),
748}
749
750#[derive(Debug, Clone, Serialize, Deserialize)]
752#[serde(untagged)]
753pub enum CreateMarginManualLiquidationV1Error {
754 Status4XX(models::ApiError),
755 Status5XX(models::ApiError),
756 UnknownValue(serde_json::Value),
757}
758
759#[derive(Debug, Clone, Serialize, Deserialize)]
761#[serde(untagged)]
762pub enum CreateMarginMaxLeverageV1Error {
763 Status4XX(models::ApiError),
764 Status5XX(models::ApiError),
765 UnknownValue(serde_json::Value),
766}
767
768#[derive(Debug, Clone, Serialize, Deserialize)]
770#[serde(untagged)]
771pub enum CreateMarginOrderOcoV1Error {
772 Status4XX(models::ApiError),
773 Status5XX(models::ApiError),
774 UnknownValue(serde_json::Value),
775}
776
777#[derive(Debug, Clone, Serialize, Deserialize)]
779#[serde(untagged)]
780pub enum CreateMarginOrderOtoV1Error {
781 Status4XX(models::ApiError),
782 Status5XX(models::ApiError),
783 UnknownValue(serde_json::Value),
784}
785
786#[derive(Debug, Clone, Serialize, Deserialize)]
788#[serde(untagged)]
789pub enum CreateMarginOrderOtocoV1Error {
790 Status4XX(models::ApiError),
791 Status5XX(models::ApiError),
792 UnknownValue(serde_json::Value),
793}
794
795#[derive(Debug, Clone, Serialize, Deserialize)]
797#[serde(untagged)]
798pub enum CreateMarginOrderV1Error {
799 Status4XX(models::ApiError),
800 Status5XX(models::ApiError),
801 UnknownValue(serde_json::Value),
802}
803
804#[derive(Debug, Clone, Serialize, Deserialize)]
806#[serde(untagged)]
807pub enum CreateUserDataStreamIsolatedV1Error {
808 Status4XX(models::ApiError),
809 Status5XX(models::ApiError),
810 UnknownValue(serde_json::Value),
811}
812
813#[derive(Debug, Clone, Serialize, Deserialize)]
815#[serde(untagged)]
816pub enum CreateUserDataStreamV1Error {
817 Status4XX(models::ApiError),
818 Status5XX(models::ApiError),
819 UnknownValue(serde_json::Value),
820}
821
822#[derive(Debug, Clone, Serialize, Deserialize)]
824#[serde(untagged)]
825pub enum DeleteMarginApiKeyV1Error {
826 Status4XX(models::ApiError),
827 Status5XX(models::ApiError),
828 UnknownValue(serde_json::Value),
829}
830
831#[derive(Debug, Clone, Serialize, Deserialize)]
833#[serde(untagged)]
834pub enum DeleteMarginIsolatedAccountV1Error {
835 Status4XX(models::ApiError),
836 Status5XX(models::ApiError),
837 UnknownValue(serde_json::Value),
838}
839
840#[derive(Debug, Clone, Serialize, Deserialize)]
842#[serde(untagged)]
843pub enum DeleteMarginListenKeyV1Error {
844 Status4XX(models::ApiError),
845 Status5XX(models::ApiError),
846 UnknownValue(serde_json::Value),
847}
848
849#[derive(Debug, Clone, Serialize, Deserialize)]
851#[serde(untagged)]
852pub enum DeleteMarginOpenOrdersV1Error {
853 Status4XX(models::ApiError),
854 Status5XX(models::ApiError),
855 UnknownValue(serde_json::Value),
856}
857
858#[derive(Debug, Clone, Serialize, Deserialize)]
860#[serde(untagged)]
861pub enum DeleteMarginOrderListV1Error {
862 Status4XX(models::ApiError),
863 Status5XX(models::ApiError),
864 UnknownValue(serde_json::Value),
865}
866
867#[derive(Debug, Clone, Serialize, Deserialize)]
869#[serde(untagged)]
870pub enum DeleteMarginOrderV1Error {
871 Status4XX(models::ApiError),
872 Status5XX(models::ApiError),
873 UnknownValue(serde_json::Value),
874}
875
876#[derive(Debug, Clone, Serialize, Deserialize)]
878#[serde(untagged)]
879pub enum DeleteUserDataStreamIsolatedV1Error {
880 Status4XX(models::ApiError),
881 Status5XX(models::ApiError),
882 UnknownValue(serde_json::Value),
883}
884
885#[derive(Debug, Clone, Serialize, Deserialize)]
887#[serde(untagged)]
888pub enum DeleteUserDataStreamV1Error {
889 Status4XX(models::ApiError),
890 Status5XX(models::ApiError),
891 UnknownValue(serde_json::Value),
892}
893
894#[derive(Debug, Clone, Serialize, Deserialize)]
896#[serde(untagged)]
897pub enum GetBnbBurnV1Error {
898 Status4XX(models::ApiError),
899 Status5XX(models::ApiError),
900 UnknownValue(serde_json::Value),
901}
902
903#[derive(Debug, Clone, Serialize, Deserialize)]
905#[serde(untagged)]
906pub enum GetMarginAccountV1Error {
907 Status4XX(models::ApiError),
908 Status5XX(models::ApiError),
909 UnknownValue(serde_json::Value),
910}
911
912#[derive(Debug, Clone, Serialize, Deserialize)]
914#[serde(untagged)]
915pub enum GetMarginAllAssetsV1Error {
916 Status4XX(models::ApiError),
917 Status5XX(models::ApiError),
918 UnknownValue(serde_json::Value),
919}
920
921#[derive(Debug, Clone, Serialize, Deserialize)]
923#[serde(untagged)]
924pub enum GetMarginAllOrderListV1Error {
925 Status4XX(models::ApiError),
926 Status5XX(models::ApiError),
927 UnknownValue(serde_json::Value),
928}
929
930#[derive(Debug, Clone, Serialize, Deserialize)]
932#[serde(untagged)]
933pub enum GetMarginAllOrdersV1Error {
934 Status4XX(models::ApiError),
935 Status5XX(models::ApiError),
936 UnknownValue(serde_json::Value),
937}
938
939#[derive(Debug, Clone, Serialize, Deserialize)]
941#[serde(untagged)]
942pub enum GetMarginAllPairsV1Error {
943 Status4XX(models::ApiError),
944 Status5XX(models::ApiError),
945 UnknownValue(serde_json::Value),
946}
947
948#[derive(Debug, Clone, Serialize, Deserialize)]
950#[serde(untagged)]
951pub enum GetMarginApiKeyListV1Error {
952 Status4XX(models::ApiError),
953 Status5XX(models::ApiError),
954 UnknownValue(serde_json::Value),
955}
956
957#[derive(Debug, Clone, Serialize, Deserialize)]
959#[serde(untagged)]
960pub enum GetMarginApiKeyV1Error {
961 Status4XX(models::ApiError),
962 Status5XX(models::ApiError),
963 UnknownValue(serde_json::Value),
964}
965
966#[derive(Debug, Clone, Serialize, Deserialize)]
968#[serde(untagged)]
969pub enum GetMarginAvailableInventoryV1Error {
970 Status4XX(models::ApiError),
971 Status5XX(models::ApiError),
972 UnknownValue(serde_json::Value),
973}
974
975#[derive(Debug, Clone, Serialize, Deserialize)]
977#[serde(untagged)]
978pub enum GetMarginBorrowRepayV1Error {
979 Status4XX(models::ApiError),
980 Status5XX(models::ApiError),
981 UnknownValue(serde_json::Value),
982}
983
984#[derive(Debug, Clone, Serialize, Deserialize)]
986#[serde(untagged)]
987pub enum GetMarginCapitalFlowV1Error {
988 Status4XX(models::ApiError),
989 Status5XX(models::ApiError),
990 UnknownValue(serde_json::Value),
991}
992
993#[derive(Debug, Clone, Serialize, Deserialize)]
995#[serde(untagged)]
996pub enum GetMarginCrossMarginCollateralRatioV1Error {
997 Status4XX(models::ApiError),
998 Status5XX(models::ApiError),
999 UnknownValue(serde_json::Value),
1000}
1001
1002#[derive(Debug, Clone, Serialize, Deserialize)]
1004#[serde(untagged)]
1005pub enum GetMarginCrossMarginDataV1Error {
1006 Status4XX(models::ApiError),
1007 Status5XX(models::ApiError),
1008 UnknownValue(serde_json::Value),
1009}
1010
1011#[derive(Debug, Clone, Serialize, Deserialize)]
1013#[serde(untagged)]
1014pub enum GetMarginDelistScheduleV1Error {
1015 Status4XX(models::ApiError),
1016 Status5XX(models::ApiError),
1017 UnknownValue(serde_json::Value),
1018}
1019
1020#[derive(Debug, Clone, Serialize, Deserialize)]
1022#[serde(untagged)]
1023pub enum GetMarginExchangeSmallLiabilityHistoryV1Error {
1024 Status4XX(models::ApiError),
1025 Status5XX(models::ApiError),
1026 UnknownValue(serde_json::Value),
1027}
1028
1029#[derive(Debug, Clone, Serialize, Deserialize)]
1031#[serde(untagged)]
1032pub enum GetMarginExchangeSmallLiabilityV1Error {
1033 Status4XX(models::ApiError),
1034 Status5XX(models::ApiError),
1035 UnknownValue(serde_json::Value),
1036}
1037
1038#[derive(Debug, Clone, Serialize, Deserialize)]
1040#[serde(untagged)]
1041pub enum GetMarginForceLiquidationRecV1Error {
1042 Status4XX(models::ApiError),
1043 Status5XX(models::ApiError),
1044 UnknownValue(serde_json::Value),
1045}
1046
1047#[derive(Debug, Clone, Serialize, Deserialize)]
1049#[serde(untagged)]
1050pub enum GetMarginInterestHistoryV1Error {
1051 Status4XX(models::ApiError),
1052 Status5XX(models::ApiError),
1053 UnknownValue(serde_json::Value),
1054}
1055
1056#[derive(Debug, Clone, Serialize, Deserialize)]
1058#[serde(untagged)]
1059pub enum GetMarginInterestRateHistoryV1Error {
1060 Status4XX(models::ApiError),
1061 Status5XX(models::ApiError),
1062 UnknownValue(serde_json::Value),
1063}
1064
1065#[derive(Debug, Clone, Serialize, Deserialize)]
1067#[serde(untagged)]
1068pub enum GetMarginIsolatedAccountLimitV1Error {
1069 Status4XX(models::ApiError),
1070 Status5XX(models::ApiError),
1071 UnknownValue(serde_json::Value),
1072}
1073
1074#[derive(Debug, Clone, Serialize, Deserialize)]
1076#[serde(untagged)]
1077pub enum GetMarginIsolatedAccountV1Error {
1078 Status4XX(models::ApiError),
1079 Status5XX(models::ApiError),
1080 UnknownValue(serde_json::Value),
1081}
1082
1083#[derive(Debug, Clone, Serialize, Deserialize)]
1085#[serde(untagged)]
1086pub enum GetMarginIsolatedAllPairsV1Error {
1087 Status4XX(models::ApiError),
1088 Status5XX(models::ApiError),
1089 UnknownValue(serde_json::Value),
1090}
1091
1092#[derive(Debug, Clone, Serialize, Deserialize)]
1094#[serde(untagged)]
1095pub enum GetMarginIsolatedMarginDataV1Error {
1096 Status4XX(models::ApiError),
1097 Status5XX(models::ApiError),
1098 UnknownValue(serde_json::Value),
1099}
1100
1101#[derive(Debug, Clone, Serialize, Deserialize)]
1103#[serde(untagged)]
1104pub enum GetMarginIsolatedMarginTierV1Error {
1105 Status4XX(models::ApiError),
1106 Status5XX(models::ApiError),
1107 UnknownValue(serde_json::Value),
1108}
1109
1110#[derive(Debug, Clone, Serialize, Deserialize)]
1112#[serde(untagged)]
1113pub enum GetMarginLeverageBracketV1Error {
1114 Status4XX(models::ApiError),
1115 Status5XX(models::ApiError),
1116 UnknownValue(serde_json::Value),
1117}
1118
1119#[derive(Debug, Clone, Serialize, Deserialize)]
1121#[serde(untagged)]
1122pub enum GetMarginMaxBorrowableV1Error {
1123 Status4XX(models::ApiError),
1124 Status5XX(models::ApiError),
1125 UnknownValue(serde_json::Value),
1126}
1127
1128#[derive(Debug, Clone, Serialize, Deserialize)]
1130#[serde(untagged)]
1131pub enum GetMarginMaxTransferableV1Error {
1132 Status4XX(models::ApiError),
1133 Status5XX(models::ApiError),
1134 UnknownValue(serde_json::Value),
1135}
1136
1137#[derive(Debug, Clone, Serialize, Deserialize)]
1139#[serde(untagged)]
1140pub enum GetMarginMyTradesV1Error {
1141 Status4XX(models::ApiError),
1142 Status5XX(models::ApiError),
1143 UnknownValue(serde_json::Value),
1144}
1145
1146#[derive(Debug, Clone, Serialize, Deserialize)]
1148#[serde(untagged)]
1149pub enum GetMarginNextHourlyInterestRateV1Error {
1150 Status4XX(models::ApiError),
1151 Status5XX(models::ApiError),
1152 UnknownValue(serde_json::Value),
1153}
1154
1155#[derive(Debug, Clone, Serialize, Deserialize)]
1157#[serde(untagged)]
1158pub enum GetMarginOpenOrderListV1Error {
1159 Status4XX(models::ApiError),
1160 Status5XX(models::ApiError),
1161 UnknownValue(serde_json::Value),
1162}
1163
1164#[derive(Debug, Clone, Serialize, Deserialize)]
1166#[serde(untagged)]
1167pub enum GetMarginOpenOrdersV1Error {
1168 Status4XX(models::ApiError),
1169 Status5XX(models::ApiError),
1170 UnknownValue(serde_json::Value),
1171}
1172
1173#[derive(Debug, Clone, Serialize, Deserialize)]
1175#[serde(untagged)]
1176pub enum GetMarginOrderListV1Error {
1177 Status4XX(models::ApiError),
1178 Status5XX(models::ApiError),
1179 UnknownValue(serde_json::Value),
1180}
1181
1182#[derive(Debug, Clone, Serialize, Deserialize)]
1184#[serde(untagged)]
1185pub enum GetMarginOrderV1Error {
1186 Status4XX(models::ApiError),
1187 Status5XX(models::ApiError),
1188 UnknownValue(serde_json::Value),
1189}
1190
1191#[derive(Debug, Clone, Serialize, Deserialize)]
1193#[serde(untagged)]
1194pub enum GetMarginPriceIndexV1Error {
1195 Status4XX(models::ApiError),
1196 Status5XX(models::ApiError),
1197 UnknownValue(serde_json::Value),
1198}
1199
1200#[derive(Debug, Clone, Serialize, Deserialize)]
1202#[serde(untagged)]
1203pub enum GetMarginRateLimitOrderV1Error {
1204 Status4XX(models::ApiError),
1205 Status5XX(models::ApiError),
1206 UnknownValue(serde_json::Value),
1207}
1208
1209#[derive(Debug, Clone, Serialize, Deserialize)]
1211#[serde(untagged)]
1212pub enum GetMarginTradeCoeffV1Error {
1213 Status4XX(models::ApiError),
1214 Status5XX(models::ApiError),
1215 UnknownValue(serde_json::Value),
1216}
1217
1218#[derive(Debug, Clone, Serialize, Deserialize)]
1220#[serde(untagged)]
1221pub enum GetMarginTransferV1Error {
1222 Status4XX(models::ApiError),
1223 Status5XX(models::ApiError),
1224 UnknownValue(serde_json::Value),
1225}
1226
1227#[derive(Debug, Clone, Serialize, Deserialize)]
1229#[serde(untagged)]
1230pub enum UpdateMarginApiKeyIpV1Error {
1231 Status4XX(models::ApiError),
1232 Status5XX(models::ApiError),
1233 UnknownValue(serde_json::Value),
1234}
1235
1236#[derive(Debug, Clone, Serialize, Deserialize)]
1238#[serde(untagged)]
1239pub enum UpdateMarginListenKeyV1Error {
1240 Status4XX(models::ApiError),
1241 Status5XX(models::ApiError),
1242 UnknownValue(serde_json::Value),
1243}
1244
1245#[derive(Debug, Clone, Serialize, Deserialize)]
1247#[serde(untagged)]
1248pub enum UpdateUserDataStreamIsolatedV1Error {
1249 Status4XX(models::ApiError),
1250 Status5XX(models::ApiError),
1251 UnknownValue(serde_json::Value),
1252}
1253
1254#[derive(Debug, Clone, Serialize, Deserialize)]
1256#[serde(untagged)]
1257pub enum UpdateUserDataStreamV1Error {
1258 Status4XX(models::ApiError),
1259 Status5XX(models::ApiError),
1260 UnknownValue(serde_json::Value),
1261}
1262
1263
1264pub async fn create_margin_api_key_v1(configuration: &configuration::Configuration, params: CreateMarginApiKeyV1Params) -> Result<models::CreateMarginApiKeyV1Resp, Error<CreateMarginApiKeyV1Error>> {
1266
1267 let uri_str = format!("{}/sapi/v1/margin/apiKey", configuration.base_path);
1268 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1269
1270 let mut query_params: Vec<(String, String)> = Vec::new();
1272
1273
1274 let mut header_params = std::collections::HashMap::new();
1276
1277 if let Some(ref binance_auth) = configuration.binance_auth {
1279 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1281
1282 let body_string: Option<Vec<u8>> = None;
1284
1285 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1287 Ok(sig) => sig,
1288 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1289 };
1290
1291 query_params.push(("signature".to_string(), signature));
1293 }
1294
1295 if !query_params.is_empty() {
1297 req_builder = req_builder.query(&query_params);
1298 }
1299
1300
1301 if let Some(ref user_agent) = configuration.user_agent {
1303 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1304 }
1305
1306 for (header_name, header_value) in header_params {
1308 req_builder = req_builder.header(&header_name, &header_value);
1309 }
1310
1311 let mut multipart_form_params = std::collections::HashMap::new();
1312 multipart_form_params.insert("apiName", params.api_name.to_string());
1313 if let Some(param_value) = params.ip {
1314 multipart_form_params.insert("ip", param_value.to_string());
1315 }
1316 if let Some(param_value) = params.permission_mode {
1317 multipart_form_params.insert("permissionMode", param_value.to_string());
1318 }
1319 if let Some(param_value) = params.public_key {
1320 multipart_form_params.insert("publicKey", param_value.to_string());
1321 }
1322 if let Some(param_value) = params.recv_window {
1323 multipart_form_params.insert("recvWindow", param_value.to_string());
1324 }
1325 if let Some(param_value) = params.symbol {
1326 multipart_form_params.insert("symbol", param_value.to_string());
1327 }
1328 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1329 req_builder = req_builder.form(&multipart_form_params);
1330
1331 let req = req_builder.build()?;
1332 let resp = configuration.client.execute(req).await?;
1333
1334 let status = resp.status();
1335 let content_type = resp
1336 .headers()
1337 .get("content-type")
1338 .and_then(|v| v.to_str().ok())
1339 .unwrap_or("application/octet-stream");
1340 let content_type = super::ContentType::from(content_type);
1341
1342 if !status.is_client_error() && !status.is_server_error() {
1343 let content = resp.text().await?;
1344 match content_type {
1345 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1346 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginApiKeyV1Resp`"))),
1347 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::CreateMarginApiKeyV1Resp`")))),
1348 }
1349 } else {
1350 let content = resp.text().await?;
1351 let entity: Option<CreateMarginApiKeyV1Error> = serde_json::from_str(&content).ok();
1352 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1353 }
1354}
1355
1356pub async fn create_margin_borrow_repay_v1(configuration: &configuration::Configuration, params: CreateMarginBorrowRepayV1Params) -> Result<models::CreateMarginBorrowRepayV1Resp, Error<CreateMarginBorrowRepayV1Error>> {
1358
1359 let uri_str = format!("{}/sapi/v1/margin/borrow-repay", configuration.base_path);
1360 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1361
1362 let mut query_params: Vec<(String, String)> = Vec::new();
1364
1365
1366 let mut header_params = std::collections::HashMap::new();
1368
1369 if let Some(ref binance_auth) = configuration.binance_auth {
1371 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1373
1374 let body_string: Option<Vec<u8>> = None;
1376
1377 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1379 Ok(sig) => sig,
1380 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1381 };
1382
1383 query_params.push(("signature".to_string(), signature));
1385 }
1386
1387 if !query_params.is_empty() {
1389 req_builder = req_builder.query(&query_params);
1390 }
1391
1392
1393 if let Some(ref user_agent) = configuration.user_agent {
1395 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1396 }
1397
1398 for (header_name, header_value) in header_params {
1400 req_builder = req_builder.header(&header_name, &header_value);
1401 }
1402
1403 let mut multipart_form_params = std::collections::HashMap::new();
1404 multipart_form_params.insert("amount", params.amount.to_string());
1405 multipart_form_params.insert("asset", params.asset.to_string());
1406 multipart_form_params.insert("isIsolated", params.is_isolated.to_string());
1407 if let Some(param_value) = params.recv_window {
1408 multipart_form_params.insert("recvWindow", param_value.to_string());
1409 }
1410 multipart_form_params.insert("symbol", params.symbol.to_string());
1411 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1412 multipart_form_params.insert("type", params.r#type.to_string());
1413 req_builder = req_builder.form(&multipart_form_params);
1414
1415 let req = req_builder.build()?;
1416 let resp = configuration.client.execute(req).await?;
1417
1418 let status = resp.status();
1419 let content_type = resp
1420 .headers()
1421 .get("content-type")
1422 .and_then(|v| v.to_str().ok())
1423 .unwrap_or("application/octet-stream");
1424 let content_type = super::ContentType::from(content_type);
1425
1426 if !status.is_client_error() && !status.is_server_error() {
1427 let content = resp.text().await?;
1428 match content_type {
1429 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1430 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginBorrowRepayV1Resp`"))),
1431 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::CreateMarginBorrowRepayV1Resp`")))),
1432 }
1433 } else {
1434 let content = resp.text().await?;
1435 let entity: Option<CreateMarginBorrowRepayV1Error> = serde_json::from_str(&content).ok();
1436 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1437 }
1438}
1439
1440pub async fn create_margin_exchange_small_liability_v1(configuration: &configuration::Configuration, params: CreateMarginExchangeSmallLiabilityV1Params) -> Result<models::MarginCreateMarginExchangeSmallLiabilityV1Resp, Error<CreateMarginExchangeSmallLiabilityV1Error>> {
1442
1443 let uri_str = format!("{}/sapi/v1/margin/exchange-small-liability", configuration.base_path);
1444 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1445
1446 let mut query_params: Vec<(String, String)> = Vec::new();
1448
1449
1450 let mut header_params = std::collections::HashMap::new();
1452
1453 if let Some(ref binance_auth) = configuration.binance_auth {
1455 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1457
1458 let body_string: Option<Vec<u8>> = None;
1460
1461 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1463 Ok(sig) => sig,
1464 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1465 };
1466
1467 query_params.push(("signature".to_string(), signature));
1469 }
1470
1471 if !query_params.is_empty() {
1473 req_builder = req_builder.query(&query_params);
1474 }
1475
1476
1477 if let Some(ref user_agent) = configuration.user_agent {
1479 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1480 }
1481
1482 for (header_name, header_value) in header_params {
1484 req_builder = req_builder.header(&header_name, &header_value);
1485 }
1486
1487 let mut multipart_form_params = std::collections::HashMap::new();
1488 multipart_form_params.insert("assetNames", params.asset_names.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
1489 if let Some(param_value) = params.recv_window {
1490 multipart_form_params.insert("recvWindow", param_value.to_string());
1491 }
1492 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1493 req_builder = req_builder.form(&multipart_form_params);
1494
1495 let req = req_builder.build()?;
1496 let resp = configuration.client.execute(req).await?;
1497
1498 let status = resp.status();
1499 let content_type = resp
1500 .headers()
1501 .get("content-type")
1502 .and_then(|v| v.to_str().ok())
1503 .unwrap_or("application/octet-stream");
1504 let content_type = super::ContentType::from(content_type);
1505
1506 if !status.is_client_error() && !status.is_server_error() {
1507 let content = resp.text().await?;
1508 match content_type {
1509 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1510 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginExchangeSmallLiabilityV1Resp`"))),
1511 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::MarginCreateMarginExchangeSmallLiabilityV1Resp`")))),
1512 }
1513 } else {
1514 let content = resp.text().await?;
1515 let entity: Option<CreateMarginExchangeSmallLiabilityV1Error> = serde_json::from_str(&content).ok();
1516 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1517 }
1518}
1519
1520pub async fn create_margin_isolated_account_v1(configuration: &configuration::Configuration, params: CreateMarginIsolatedAccountV1Params) -> Result<models::CreateMarginIsolatedAccountV1Resp, Error<CreateMarginIsolatedAccountV1Error>> {
1522
1523 let uri_str = format!("{}/sapi/v1/margin/isolated/account", configuration.base_path);
1524 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1525
1526 let mut query_params: Vec<(String, String)> = Vec::new();
1528
1529
1530 let mut header_params = std::collections::HashMap::new();
1532
1533 if let Some(ref binance_auth) = configuration.binance_auth {
1535 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1537
1538 let body_string: Option<Vec<u8>> = None;
1540
1541 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1543 Ok(sig) => sig,
1544 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1545 };
1546
1547 query_params.push(("signature".to_string(), signature));
1549 }
1550
1551 if !query_params.is_empty() {
1553 req_builder = req_builder.query(&query_params);
1554 }
1555
1556
1557 if let Some(ref user_agent) = configuration.user_agent {
1559 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1560 }
1561
1562 for (header_name, header_value) in header_params {
1564 req_builder = req_builder.header(&header_name, &header_value);
1565 }
1566
1567 let mut multipart_form_params = std::collections::HashMap::new();
1568 if let Some(param_value) = params.recv_window {
1569 multipart_form_params.insert("recvWindow", param_value.to_string());
1570 }
1571 multipart_form_params.insert("symbol", params.symbol.to_string());
1572 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1573 req_builder = req_builder.form(&multipart_form_params);
1574
1575 let req = req_builder.build()?;
1576 let resp = configuration.client.execute(req).await?;
1577
1578 let status = resp.status();
1579 let content_type = resp
1580 .headers()
1581 .get("content-type")
1582 .and_then(|v| v.to_str().ok())
1583 .unwrap_or("application/octet-stream");
1584 let content_type = super::ContentType::from(content_type);
1585
1586 if !status.is_client_error() && !status.is_server_error() {
1587 let content = resp.text().await?;
1588 match content_type {
1589 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1590 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginIsolatedAccountV1Resp`"))),
1591 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::CreateMarginIsolatedAccountV1Resp`")))),
1592 }
1593 } else {
1594 let content = resp.text().await?;
1595 let entity: Option<CreateMarginIsolatedAccountV1Error> = serde_json::from_str(&content).ok();
1596 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1597 }
1598}
1599
1600pub async fn create_margin_listen_key_v1(configuration: &configuration::Configuration) -> Result<models::CreateMarginListenKeyV1Resp, Error<CreateMarginListenKeyV1Error>> {
1602
1603 let uri_str = format!("{}/sapi/v1/margin/listen-key", configuration.base_path);
1604 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1605
1606 let mut query_params: Vec<(String, String)> = Vec::new();
1608
1609
1610 let mut header_params = std::collections::HashMap::new();
1612
1613 if let Some(ref binance_auth) = configuration.binance_auth {
1615 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1617
1618 let body_string: Option<Vec<u8>> = None;
1620
1621 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1623 Ok(sig) => sig,
1624 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1625 };
1626
1627 query_params.push(("signature".to_string(), signature));
1629 }
1630
1631 if !query_params.is_empty() {
1633 req_builder = req_builder.query(&query_params);
1634 }
1635
1636
1637 if let Some(ref user_agent) = configuration.user_agent {
1639 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1640 }
1641
1642 for (header_name, header_value) in header_params {
1644 req_builder = req_builder.header(&header_name, &header_value);
1645 }
1646
1647
1648 let req = req_builder.build()?;
1649 let resp = configuration.client.execute(req).await?;
1650
1651 let status = resp.status();
1652 let content_type = resp
1653 .headers()
1654 .get("content-type")
1655 .and_then(|v| v.to_str().ok())
1656 .unwrap_or("application/octet-stream");
1657 let content_type = super::ContentType::from(content_type);
1658
1659 if !status.is_client_error() && !status.is_server_error() {
1660 let content = resp.text().await?;
1661 match content_type {
1662 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1663 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginListenKeyV1Resp`"))),
1664 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::CreateMarginListenKeyV1Resp`")))),
1665 }
1666 } else {
1667 let content = resp.text().await?;
1668 let entity: Option<CreateMarginListenKeyV1Error> = serde_json::from_str(&content).ok();
1669 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1670 }
1671}
1672
1673pub async fn create_margin_manual_liquidation_v1(configuration: &configuration::Configuration, params: CreateMarginManualLiquidationV1Params) -> Result<models::CreateMarginManualLiquidationV1Resp, Error<CreateMarginManualLiquidationV1Error>> {
1675
1676 let uri_str = format!("{}/sapi/v1/margin/manual-liquidation", configuration.base_path);
1677 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1678
1679 let mut query_params: Vec<(String, String)> = Vec::new();
1681
1682
1683 let mut header_params = std::collections::HashMap::new();
1685
1686 if let Some(ref binance_auth) = configuration.binance_auth {
1688 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1690
1691 let body_string: Option<Vec<u8>> = None;
1693
1694 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1696 Ok(sig) => sig,
1697 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1698 };
1699
1700 query_params.push(("signature".to_string(), signature));
1702 }
1703
1704 if !query_params.is_empty() {
1706 req_builder = req_builder.query(&query_params);
1707 }
1708
1709
1710 if let Some(ref user_agent) = configuration.user_agent {
1712 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1713 }
1714
1715 for (header_name, header_value) in header_params {
1717 req_builder = req_builder.header(&header_name, &header_value);
1718 }
1719
1720 let mut multipart_form_params = std::collections::HashMap::new();
1721 if let Some(param_value) = params.recv_window {
1722 multipart_form_params.insert("recvWindow", param_value.to_string());
1723 }
1724 if let Some(param_value) = params.symbol {
1725 multipart_form_params.insert("symbol", param_value.to_string());
1726 }
1727 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1728 multipart_form_params.insert("type", params.r#type.to_string());
1729 req_builder = req_builder.form(&multipart_form_params);
1730
1731 let req = req_builder.build()?;
1732 let resp = configuration.client.execute(req).await?;
1733
1734 let status = resp.status();
1735 let content_type = resp
1736 .headers()
1737 .get("content-type")
1738 .and_then(|v| v.to_str().ok())
1739 .unwrap_or("application/octet-stream");
1740 let content_type = super::ContentType::from(content_type);
1741
1742 if !status.is_client_error() && !status.is_server_error() {
1743 let content = resp.text().await?;
1744 match content_type {
1745 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1746 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginManualLiquidationV1Resp`"))),
1747 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::CreateMarginManualLiquidationV1Resp`")))),
1748 }
1749 } else {
1750 let content = resp.text().await?;
1751 let entity: Option<CreateMarginManualLiquidationV1Error> = serde_json::from_str(&content).ok();
1752 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1753 }
1754}
1755
1756pub async fn create_margin_max_leverage_v1(configuration: &configuration::Configuration, params: CreateMarginMaxLeverageV1Params) -> Result<models::CreateMarginMaxLeverageV1Resp, Error<CreateMarginMaxLeverageV1Error>> {
1758
1759 let uri_str = format!("{}/sapi/v1/margin/max-leverage", configuration.base_path);
1760 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1761
1762 let mut query_params: Vec<(String, String)> = Vec::new();
1764
1765
1766 let mut header_params = std::collections::HashMap::new();
1768
1769 if let Some(ref binance_auth) = configuration.binance_auth {
1771 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1773
1774 let body_string: Option<Vec<u8>> = None;
1776
1777 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1779 Ok(sig) => sig,
1780 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1781 };
1782
1783 query_params.push(("signature".to_string(), signature));
1785 }
1786
1787 if !query_params.is_empty() {
1789 req_builder = req_builder.query(&query_params);
1790 }
1791
1792
1793 if let Some(ref user_agent) = configuration.user_agent {
1795 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1796 }
1797
1798 for (header_name, header_value) in header_params {
1800 req_builder = req_builder.header(&header_name, &header_value);
1801 }
1802
1803 let mut multipart_form_params = std::collections::HashMap::new();
1804 multipart_form_params.insert("maxLeverage", params.max_leverage.to_string());
1805 req_builder = req_builder.form(&multipart_form_params);
1806
1807 let req = req_builder.build()?;
1808 let resp = configuration.client.execute(req).await?;
1809
1810 let status = resp.status();
1811 let content_type = resp
1812 .headers()
1813 .get("content-type")
1814 .and_then(|v| v.to_str().ok())
1815 .unwrap_or("application/octet-stream");
1816 let content_type = super::ContentType::from(content_type);
1817
1818 if !status.is_client_error() && !status.is_server_error() {
1819 let content = resp.text().await?;
1820 match content_type {
1821 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1822 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginMaxLeverageV1Resp`"))),
1823 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::CreateMarginMaxLeverageV1Resp`")))),
1824 }
1825 } else {
1826 let content = resp.text().await?;
1827 let entity: Option<CreateMarginMaxLeverageV1Error> = serde_json::from_str(&content).ok();
1828 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1829 }
1830}
1831
1832pub async fn create_margin_order_oco_v1(configuration: &configuration::Configuration, params: CreateMarginOrderOcoV1Params) -> Result<models::CreateMarginOrderOcoV1Resp, Error<CreateMarginOrderOcoV1Error>> {
1834
1835 let uri_str = format!("{}/sapi/v1/margin/order/oco", configuration.base_path);
1836 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1837
1838 let mut query_params: Vec<(String, String)> = Vec::new();
1840
1841
1842 let mut header_params = std::collections::HashMap::new();
1844
1845 if let Some(ref binance_auth) = configuration.binance_auth {
1847 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1849
1850 let body_string: Option<Vec<u8>> = None;
1852
1853 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1855 Ok(sig) => sig,
1856 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1857 };
1858
1859 query_params.push(("signature".to_string(), signature));
1861 }
1862
1863 if !query_params.is_empty() {
1865 req_builder = req_builder.query(&query_params);
1866 }
1867
1868
1869 if let Some(ref user_agent) = configuration.user_agent {
1871 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1872 }
1873
1874 for (header_name, header_value) in header_params {
1876 req_builder = req_builder.header(&header_name, &header_value);
1877 }
1878
1879 let mut multipart_form_params = std::collections::HashMap::new();
1880 if let Some(param_value) = params.auto_repay_at_cancel {
1881 multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
1882 }
1883 if let Some(param_value) = params.is_isolated {
1884 multipart_form_params.insert("isIsolated", param_value.to_string());
1885 }
1886 if let Some(param_value) = params.limit_client_order_id {
1887 multipart_form_params.insert("limitClientOrderId", param_value.to_string());
1888 }
1889 if let Some(param_value) = params.limit_iceberg_qty {
1890 multipart_form_params.insert("limitIcebergQty", param_value.to_string());
1891 }
1892 if let Some(param_value) = params.list_client_order_id {
1893 multipart_form_params.insert("listClientOrderId", param_value.to_string());
1894 }
1895 if let Some(param_value) = params.new_order_resp_type {
1896 multipart_form_params.insert("newOrderRespType", param_value.to_string());
1897 }
1898 multipart_form_params.insert("price", params.price.to_string());
1899 multipart_form_params.insert("quantity", params.quantity.to_string());
1900 if let Some(param_value) = params.recv_window {
1901 multipart_form_params.insert("recvWindow", param_value.to_string());
1902 }
1903 if let Some(param_value) = params.self_trade_prevention_mode {
1904 multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1905 }
1906 multipart_form_params.insert("side", params.side.to_string());
1907 if let Some(param_value) = params.side_effect_type {
1908 multipart_form_params.insert("sideEffectType", param_value.to_string());
1909 }
1910 if let Some(param_value) = params.stop_client_order_id {
1911 multipart_form_params.insert("stopClientOrderId", param_value.to_string());
1912 }
1913 if let Some(param_value) = params.stop_iceberg_qty {
1914 multipart_form_params.insert("stopIcebergQty", param_value.to_string());
1915 }
1916 if let Some(param_value) = params.stop_limit_price {
1917 multipart_form_params.insert("stopLimitPrice", param_value.to_string());
1918 }
1919 if let Some(param_value) = params.stop_limit_time_in_force {
1920 multipart_form_params.insert("stopLimitTimeInForce", param_value.to_string());
1921 }
1922 multipart_form_params.insert("stopPrice", params.stop_price.to_string());
1923 multipart_form_params.insert("symbol", params.symbol.to_string());
1924 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1925 req_builder = req_builder.form(&multipart_form_params);
1926
1927 let req = req_builder.build()?;
1928 let resp = configuration.client.execute(req).await?;
1929
1930 let status = resp.status();
1931 let content_type = resp
1932 .headers()
1933 .get("content-type")
1934 .and_then(|v| v.to_str().ok())
1935 .unwrap_or("application/octet-stream");
1936 let content_type = super::ContentType::from(content_type);
1937
1938 if !status.is_client_error() && !status.is_server_error() {
1939 let content = resp.text().await?;
1940 match content_type {
1941 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1942 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginOrderOcoV1Resp`"))),
1943 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::CreateMarginOrderOcoV1Resp`")))),
1944 }
1945 } else {
1946 let content = resp.text().await?;
1947 let entity: Option<CreateMarginOrderOcoV1Error> = serde_json::from_str(&content).ok();
1948 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1949 }
1950}
1951
1952pub async fn create_margin_order_oto_v1(configuration: &configuration::Configuration, params: CreateMarginOrderOtoV1Params) -> Result<models::CreateMarginOrderOtoV1Resp, Error<CreateMarginOrderOtoV1Error>> {
1954
1955 let uri_str = format!("{}/sapi/v1/margin/order/oto", configuration.base_path);
1956 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1957
1958 let mut query_params: Vec<(String, String)> = Vec::new();
1960
1961
1962 let mut header_params = std::collections::HashMap::new();
1964
1965 if let Some(ref binance_auth) = configuration.binance_auth {
1967 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1969
1970 let body_string: Option<Vec<u8>> = None;
1972
1973 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1975 Ok(sig) => sig,
1976 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1977 };
1978
1979 query_params.push(("signature".to_string(), signature));
1981 }
1982
1983 if !query_params.is_empty() {
1985 req_builder = req_builder.query(&query_params);
1986 }
1987
1988
1989 if let Some(ref user_agent) = configuration.user_agent {
1991 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1992 }
1993
1994 for (header_name, header_value) in header_params {
1996 req_builder = req_builder.header(&header_name, &header_value);
1997 }
1998
1999 let mut multipart_form_params = std::collections::HashMap::new();
2000 if let Some(param_value) = params.auto_repay_at_cancel {
2001 multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
2002 }
2003 if let Some(param_value) = params.is_isolated {
2004 multipart_form_params.insert("isIsolated", param_value.to_string());
2005 }
2006 if let Some(param_value) = params.list_client_order_id {
2007 multipart_form_params.insert("listClientOrderId", param_value.to_string());
2008 }
2009 if let Some(param_value) = params.new_order_resp_type {
2010 multipart_form_params.insert("newOrderRespType", param_value.to_string());
2011 }
2012 if let Some(param_value) = params.pending_client_order_id {
2013 multipart_form_params.insert("pendingClientOrderId", param_value.to_string());
2014 }
2015 if let Some(param_value) = params.pending_iceberg_qty {
2016 multipart_form_params.insert("pendingIcebergQty", param_value.to_string());
2017 }
2018 if let Some(param_value) = params.pending_price {
2019 multipart_form_params.insert("pendingPrice", param_value.to_string());
2020 }
2021 multipart_form_params.insert("pendingQuantity", params.pending_quantity.to_string());
2022 multipart_form_params.insert("pendingSide", params.pending_side.to_string());
2023 if let Some(param_value) = params.pending_stop_price {
2024 multipart_form_params.insert("pendingStopPrice", param_value.to_string());
2025 }
2026 if let Some(param_value) = params.pending_time_in_force {
2027 multipart_form_params.insert("pendingTimeInForce", param_value.to_string());
2028 }
2029 if let Some(param_value) = params.pending_trailing_delta {
2030 multipart_form_params.insert("pendingTrailingDelta", param_value.to_string());
2031 }
2032 multipart_form_params.insert("pendingType", params.pending_type.to_string());
2033 if let Some(param_value) = params.self_trade_prevention_mode {
2034 multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
2035 }
2036 if let Some(param_value) = params.side_effect_type {
2037 multipart_form_params.insert("sideEffectType", param_value.to_string());
2038 }
2039 multipart_form_params.insert("symbol", params.symbol.to_string());
2040 if let Some(param_value) = params.working_client_order_id {
2041 multipart_form_params.insert("workingClientOrderId", param_value.to_string());
2042 }
2043 multipart_form_params.insert("workingIcebergQty", params.working_iceberg_qty.to_string());
2044 multipart_form_params.insert("workingPrice", params.working_price.to_string());
2045 multipart_form_params.insert("workingQuantity", params.working_quantity.to_string());
2046 multipart_form_params.insert("workingSide", params.working_side.to_string());
2047 if let Some(param_value) = params.working_time_in_force {
2048 multipart_form_params.insert("workingTimeInForce", param_value.to_string());
2049 }
2050 multipart_form_params.insert("workingType", params.working_type.to_string());
2051 req_builder = req_builder.form(&multipart_form_params);
2052
2053 let req = req_builder.build()?;
2054 let resp = configuration.client.execute(req).await?;
2055
2056 let status = resp.status();
2057 let content_type = resp
2058 .headers()
2059 .get("content-type")
2060 .and_then(|v| v.to_str().ok())
2061 .unwrap_or("application/octet-stream");
2062 let content_type = super::ContentType::from(content_type);
2063
2064 if !status.is_client_error() && !status.is_server_error() {
2065 let content = resp.text().await?;
2066 match content_type {
2067 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2068 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginOrderOtoV1Resp`"))),
2069 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateMarginOrderOtoV1Resp`")))),
2070 }
2071 } else {
2072 let content = resp.text().await?;
2073 let entity: Option<CreateMarginOrderOtoV1Error> = serde_json::from_str(&content).ok();
2074 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2075 }
2076}
2077
2078pub async fn create_margin_order_otoco_v1(configuration: &configuration::Configuration, params: CreateMarginOrderOtocoV1Params) -> Result<models::CreateMarginOrderOtocoV1Resp, Error<CreateMarginOrderOtocoV1Error>> {
2080
2081 let uri_str = format!("{}/sapi/v1/margin/order/otoco", configuration.base_path);
2082 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2083
2084 let mut query_params: Vec<(String, String)> = Vec::new();
2086
2087
2088 let mut header_params = std::collections::HashMap::new();
2090
2091 if let Some(ref binance_auth) = configuration.binance_auth {
2093 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2095
2096 let body_string: Option<Vec<u8>> = None;
2098
2099 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2101 Ok(sig) => sig,
2102 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2103 };
2104
2105 query_params.push(("signature".to_string(), signature));
2107 }
2108
2109 if !query_params.is_empty() {
2111 req_builder = req_builder.query(&query_params);
2112 }
2113
2114
2115 if let Some(ref user_agent) = configuration.user_agent {
2117 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2118 }
2119
2120 for (header_name, header_value) in header_params {
2122 req_builder = req_builder.header(&header_name, &header_value);
2123 }
2124
2125 let mut multipart_form_params = std::collections::HashMap::new();
2126 if let Some(param_value) = params.auto_repay_at_cancel {
2127 multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
2128 }
2129 if let Some(param_value) = params.is_isolated {
2130 multipart_form_params.insert("isIsolated", param_value.to_string());
2131 }
2132 if let Some(param_value) = params.list_client_order_id {
2133 multipart_form_params.insert("listClientOrderId", param_value.to_string());
2134 }
2135 if let Some(param_value) = params.new_order_resp_type {
2136 multipart_form_params.insert("newOrderRespType", param_value.to_string());
2137 }
2138 if let Some(param_value) = params.pending_above_client_order_id {
2139 multipart_form_params.insert("pendingAboveClientOrderId", param_value.to_string());
2140 }
2141 if let Some(param_value) = params.pending_above_iceberg_qty {
2142 multipart_form_params.insert("pendingAboveIcebergQty", param_value.to_string());
2143 }
2144 if let Some(param_value) = params.pending_above_price {
2145 multipart_form_params.insert("pendingAbovePrice", param_value.to_string());
2146 }
2147 if let Some(param_value) = params.pending_above_stop_price {
2148 multipart_form_params.insert("pendingAboveStopPrice", param_value.to_string());
2149 }
2150 if let Some(param_value) = params.pending_above_time_in_force {
2151 multipart_form_params.insert("pendingAboveTimeInForce", param_value.to_string());
2152 }
2153 if let Some(param_value) = params.pending_above_trailing_delta {
2154 multipart_form_params.insert("pendingAboveTrailingDelta", param_value.to_string());
2155 }
2156 multipart_form_params.insert("pendingAboveType", params.pending_above_type.to_string());
2157 if let Some(param_value) = params.pending_below_client_order_id {
2158 multipart_form_params.insert("pendingBelowClientOrderId", param_value.to_string());
2159 }
2160 if let Some(param_value) = params.pending_below_iceberg_qty {
2161 multipart_form_params.insert("pendingBelowIcebergQty", param_value.to_string());
2162 }
2163 if let Some(param_value) = params.pending_below_price {
2164 multipart_form_params.insert("pendingBelowPrice", param_value.to_string());
2165 }
2166 if let Some(param_value) = params.pending_below_stop_price {
2167 multipart_form_params.insert("pendingBelowStopPrice", param_value.to_string());
2168 }
2169 if let Some(param_value) = params.pending_below_time_in_force {
2170 multipart_form_params.insert("pendingBelowTimeInForce", param_value.to_string());
2171 }
2172 if let Some(param_value) = params.pending_below_trailing_delta {
2173 multipart_form_params.insert("pendingBelowTrailingDelta", param_value.to_string());
2174 }
2175 if let Some(param_value) = params.pending_below_type {
2176 multipart_form_params.insert("pendingBelowType", param_value.to_string());
2177 }
2178 multipart_form_params.insert("pendingQuantity", params.pending_quantity.to_string());
2179 multipart_form_params.insert("pendingSide", params.pending_side.to_string());
2180 if let Some(param_value) = params.self_trade_prevention_mode {
2181 multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
2182 }
2183 if let Some(param_value) = params.side_effect_type {
2184 multipart_form_params.insert("sideEffectType", param_value.to_string());
2185 }
2186 multipart_form_params.insert("symbol", params.symbol.to_string());
2187 if let Some(param_value) = params.working_client_order_id {
2188 multipart_form_params.insert("workingClientOrderId", param_value.to_string());
2189 }
2190 if let Some(param_value) = params.working_iceberg_qty {
2191 multipart_form_params.insert("workingIcebergQty", param_value.to_string());
2192 }
2193 multipart_form_params.insert("workingPrice", params.working_price.to_string());
2194 multipart_form_params.insert("workingQuantity", params.working_quantity.to_string());
2195 multipart_form_params.insert("workingSide", params.working_side.to_string());
2196 if let Some(param_value) = params.working_time_in_force {
2197 multipart_form_params.insert("workingTimeInForce", param_value.to_string());
2198 }
2199 multipart_form_params.insert("workingType", params.working_type.to_string());
2200 req_builder = req_builder.form(&multipart_form_params);
2201
2202 let req = req_builder.build()?;
2203 let resp = configuration.client.execute(req).await?;
2204
2205 let status = resp.status();
2206 let content_type = resp
2207 .headers()
2208 .get("content-type")
2209 .and_then(|v| v.to_str().ok())
2210 .unwrap_or("application/octet-stream");
2211 let content_type = super::ContentType::from(content_type);
2212
2213 if !status.is_client_error() && !status.is_server_error() {
2214 let content = resp.text().await?;
2215 match content_type {
2216 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2217 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginOrderOtocoV1Resp`"))),
2218 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::CreateMarginOrderOtocoV1Resp`")))),
2219 }
2220 } else {
2221 let content = resp.text().await?;
2222 let entity: Option<CreateMarginOrderOtocoV1Error> = serde_json::from_str(&content).ok();
2223 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2224 }
2225}
2226
2227pub async fn create_margin_order_v1(configuration: &configuration::Configuration, params: CreateMarginOrderV1Params) -> Result<models::MarginCreateMarginOrderV1Resp, Error<CreateMarginOrderV1Error>> {
2229
2230 let uri_str = format!("{}/sapi/v1/margin/order", configuration.base_path);
2231 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2232
2233 let mut query_params: Vec<(String, String)> = Vec::new();
2235
2236
2237 let mut header_params = std::collections::HashMap::new();
2239
2240 if let Some(ref binance_auth) = configuration.binance_auth {
2242 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2244
2245 let body_string: Option<Vec<u8>> = None;
2247
2248 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2250 Ok(sig) => sig,
2251 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2252 };
2253
2254 query_params.push(("signature".to_string(), signature));
2256 }
2257
2258 if !query_params.is_empty() {
2260 req_builder = req_builder.query(&query_params);
2261 }
2262
2263
2264 if let Some(ref user_agent) = configuration.user_agent {
2266 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2267 }
2268
2269 for (header_name, header_value) in header_params {
2271 req_builder = req_builder.header(&header_name, &header_value);
2272 }
2273
2274 let mut multipart_form_params = std::collections::HashMap::new();
2275 if let Some(param_value) = params.auto_repay_at_cancel {
2276 multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
2277 }
2278 if let Some(param_value) = params.iceberg_qty {
2279 multipart_form_params.insert("icebergQty", param_value.to_string());
2280 }
2281 if let Some(param_value) = params.is_isolated {
2282 multipart_form_params.insert("isIsolated", param_value.to_string());
2283 }
2284 if let Some(param_value) = params.new_client_order_id {
2285 multipart_form_params.insert("newClientOrderId", param_value.to_string());
2286 }
2287 if let Some(param_value) = params.new_order_resp_type {
2288 multipart_form_params.insert("newOrderRespType", param_value.to_string());
2289 }
2290 if let Some(param_value) = params.price {
2291 multipart_form_params.insert("price", param_value.to_string());
2292 }
2293 if let Some(param_value) = params.quantity {
2294 multipart_form_params.insert("quantity", param_value.to_string());
2295 }
2296 if let Some(param_value) = params.quote_order_qty {
2297 multipart_form_params.insert("quoteOrderQty", param_value.to_string());
2298 }
2299 if let Some(param_value) = params.recv_window {
2300 multipart_form_params.insert("recvWindow", param_value.to_string());
2301 }
2302 if let Some(param_value) = params.self_trade_prevention_mode {
2303 multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
2304 }
2305 multipart_form_params.insert("side", params.side.to_string());
2306 if let Some(param_value) = params.side_effect_type {
2307 multipart_form_params.insert("sideEffectType", param_value.to_string());
2308 }
2309 if let Some(param_value) = params.stop_price {
2310 multipart_form_params.insert("stopPrice", param_value.to_string());
2311 }
2312 multipart_form_params.insert("symbol", params.symbol.to_string());
2313 if let Some(param_value) = params.time_in_force {
2314 multipart_form_params.insert("timeInForce", param_value.to_string());
2315 }
2316 multipart_form_params.insert("timestamp", params.timestamp.to_string());
2317 multipart_form_params.insert("type", params.r#type.to_string());
2318 req_builder = req_builder.form(&multipart_form_params);
2319
2320 let req = req_builder.build()?;
2321 let resp = configuration.client.execute(req).await?;
2322
2323 let status = resp.status();
2324 let content_type = resp
2325 .headers()
2326 .get("content-type")
2327 .and_then(|v| v.to_str().ok())
2328 .unwrap_or("application/octet-stream");
2329 let content_type = super::ContentType::from(content_type);
2330
2331 if !status.is_client_error() && !status.is_server_error() {
2332 let content = resp.text().await?;
2333 match content_type {
2334 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2335 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginOrderV1Resp`"))),
2336 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::MarginCreateMarginOrderV1Resp`")))),
2337 }
2338 } else {
2339 let content = resp.text().await?;
2340 let entity: Option<CreateMarginOrderV1Error> = serde_json::from_str(&content).ok();
2341 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2342 }
2343}
2344
2345pub async fn create_user_data_stream_isolated_v1(configuration: &configuration::Configuration, params: CreateUserDataStreamIsolatedV1Params) -> Result<models::CreateUserDataStreamIsolatedV1Resp, Error<CreateUserDataStreamIsolatedV1Error>> {
2347
2348 let uri_str = format!("{}/sapi/v1/userDataStream/isolated", configuration.base_path);
2349 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2350
2351 let mut query_params: Vec<(String, String)> = Vec::new();
2353
2354
2355 let mut header_params = std::collections::HashMap::new();
2357
2358 if let Some(ref binance_auth) = configuration.binance_auth {
2360 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2362
2363 let body_string: Option<Vec<u8>> = None;
2365
2366 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2368 Ok(sig) => sig,
2369 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2370 };
2371
2372 query_params.push(("signature".to_string(), signature));
2374 }
2375
2376 if !query_params.is_empty() {
2378 req_builder = req_builder.query(&query_params);
2379 }
2380
2381
2382 if let Some(ref user_agent) = configuration.user_agent {
2384 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2385 }
2386
2387 for (header_name, header_value) in header_params {
2389 req_builder = req_builder.header(&header_name, &header_value);
2390 }
2391
2392 let mut multipart_form_params = std::collections::HashMap::new();
2393 multipart_form_params.insert("symbol", params.symbol.to_string());
2394 req_builder = req_builder.form(&multipart_form_params);
2395
2396 let req = req_builder.build()?;
2397 let resp = configuration.client.execute(req).await?;
2398
2399 let status = resp.status();
2400 let content_type = resp
2401 .headers()
2402 .get("content-type")
2403 .and_then(|v| v.to_str().ok())
2404 .unwrap_or("application/octet-stream");
2405 let content_type = super::ContentType::from(content_type);
2406
2407 if !status.is_client_error() && !status.is_server_error() {
2408 let content = resp.text().await?;
2409 match content_type {
2410 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2411 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateUserDataStreamIsolatedV1Resp`"))),
2412 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::CreateUserDataStreamIsolatedV1Resp`")))),
2413 }
2414 } else {
2415 let content = resp.text().await?;
2416 let entity: Option<CreateUserDataStreamIsolatedV1Error> = serde_json::from_str(&content).ok();
2417 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2418 }
2419}
2420
2421pub async fn create_user_data_stream_v1(configuration: &configuration::Configuration) -> Result<models::CreateUserDataStreamV1Resp, Error<CreateUserDataStreamV1Error>> {
2423
2424 let uri_str = format!("{}/sapi/v1/userDataStream", configuration.base_path);
2425 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2426
2427 let mut query_params: Vec<(String, String)> = Vec::new();
2429
2430
2431 let mut header_params = std::collections::HashMap::new();
2433
2434 if let Some(ref binance_auth) = configuration.binance_auth {
2436 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2438
2439 let body_string: Option<Vec<u8>> = None;
2441
2442 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2444 Ok(sig) => sig,
2445 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2446 };
2447
2448 query_params.push(("signature".to_string(), signature));
2450 }
2451
2452 if !query_params.is_empty() {
2454 req_builder = req_builder.query(&query_params);
2455 }
2456
2457
2458 if let Some(ref user_agent) = configuration.user_agent {
2460 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2461 }
2462
2463 for (header_name, header_value) in header_params {
2465 req_builder = req_builder.header(&header_name, &header_value);
2466 }
2467
2468
2469 let req = req_builder.build()?;
2470 let resp = configuration.client.execute(req).await?;
2471
2472 let status = resp.status();
2473 let content_type = resp
2474 .headers()
2475 .get("content-type")
2476 .and_then(|v| v.to_str().ok())
2477 .unwrap_or("application/octet-stream");
2478 let content_type = super::ContentType::from(content_type);
2479
2480 if !status.is_client_error() && !status.is_server_error() {
2481 let content = resp.text().await?;
2482 match content_type {
2483 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2484 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateUserDataStreamV1Resp`"))),
2485 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::CreateUserDataStreamV1Resp`")))),
2486 }
2487 } else {
2488 let content = resp.text().await?;
2489 let entity: Option<CreateUserDataStreamV1Error> = serde_json::from_str(&content).ok();
2490 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2491 }
2492}
2493
2494pub async fn delete_margin_api_key_v1(configuration: &configuration::Configuration, params: DeleteMarginApiKeyV1Params) -> Result<serde_json::Value, Error<DeleteMarginApiKeyV1Error>> {
2496
2497 let uri_str = format!("{}/sapi/v1/margin/apiKey", configuration.base_path);
2498 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2499
2500 let mut query_params: Vec<(String, String)> = Vec::new();
2502
2503 if let Some(ref param_value) = params.api_key {
2504 query_params.push(("apiKey".to_string(), param_value.to_string()));
2505 }
2506 if let Some(ref param_value) = params.api_name {
2507 query_params.push(("apiName".to_string(), param_value.to_string()));
2508 }
2509 if let Some(ref param_value) = params.symbol {
2510 query_params.push(("symbol".to_string(), param_value.to_string()));
2511 }
2512 if let Some(ref param_value) = params.recv_window {
2513 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2514 }
2515 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2516
2517 let mut header_params = std::collections::HashMap::new();
2519
2520 if let Some(ref binance_auth) = configuration.binance_auth {
2522 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2524
2525 let body_string: Option<Vec<u8>> = None;
2527
2528 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2530 Ok(sig) => sig,
2531 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2532 };
2533
2534 query_params.push(("signature".to_string(), signature));
2536 }
2537
2538 if !query_params.is_empty() {
2540 req_builder = req_builder.query(&query_params);
2541 }
2542
2543
2544 if let Some(ref user_agent) = configuration.user_agent {
2546 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2547 }
2548
2549 for (header_name, header_value) in header_params {
2551 req_builder = req_builder.header(&header_name, &header_value);
2552 }
2553
2554
2555 let req = req_builder.build()?;
2556 let resp = configuration.client.execute(req).await?;
2557
2558 let status = resp.status();
2559 let content_type = resp
2560 .headers()
2561 .get("content-type")
2562 .and_then(|v| v.to_str().ok())
2563 .unwrap_or("application/octet-stream");
2564 let content_type = super::ContentType::from(content_type);
2565
2566 if !status.is_client_error() && !status.is_server_error() {
2567 let content = resp.text().await?;
2568 match content_type {
2569 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2570 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
2571 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`")))),
2572 }
2573 } else {
2574 let content = resp.text().await?;
2575 let entity: Option<DeleteMarginApiKeyV1Error> = serde_json::from_str(&content).ok();
2576 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2577 }
2578}
2579
2580pub async fn delete_margin_isolated_account_v1(configuration: &configuration::Configuration, params: DeleteMarginIsolatedAccountV1Params) -> Result<models::DeleteMarginIsolatedAccountV1Resp, Error<DeleteMarginIsolatedAccountV1Error>> {
2582
2583 let uri_str = format!("{}/sapi/v1/margin/isolated/account", configuration.base_path);
2584 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2585
2586 let mut query_params: Vec<(String, String)> = Vec::new();
2588
2589 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2590 if let Some(ref param_value) = params.recv_window {
2591 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2592 }
2593 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2594
2595 let mut header_params = std::collections::HashMap::new();
2597
2598 if let Some(ref binance_auth) = configuration.binance_auth {
2600 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2602
2603 let body_string: Option<Vec<u8>> = None;
2605
2606 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2608 Ok(sig) => sig,
2609 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2610 };
2611
2612 query_params.push(("signature".to_string(), signature));
2614 }
2615
2616 if !query_params.is_empty() {
2618 req_builder = req_builder.query(&query_params);
2619 }
2620
2621
2622 if let Some(ref user_agent) = configuration.user_agent {
2624 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2625 }
2626
2627 for (header_name, header_value) in header_params {
2629 req_builder = req_builder.header(&header_name, &header_value);
2630 }
2631
2632
2633 let req = req_builder.build()?;
2634 let resp = configuration.client.execute(req).await?;
2635
2636 let status = resp.status();
2637 let content_type = resp
2638 .headers()
2639 .get("content-type")
2640 .and_then(|v| v.to_str().ok())
2641 .unwrap_or("application/octet-stream");
2642 let content_type = super::ContentType::from(content_type);
2643
2644 if !status.is_client_error() && !status.is_server_error() {
2645 let content = resp.text().await?;
2646 match content_type {
2647 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2648 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMarginIsolatedAccountV1Resp`"))),
2649 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::DeleteMarginIsolatedAccountV1Resp`")))),
2650 }
2651 } else {
2652 let content = resp.text().await?;
2653 let entity: Option<DeleteMarginIsolatedAccountV1Error> = serde_json::from_str(&content).ok();
2654 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2655 }
2656}
2657
2658pub async fn delete_margin_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<DeleteMarginListenKeyV1Error>> {
2660
2661 let uri_str = format!("{}/sapi/v1/margin/listen-key", configuration.base_path);
2662 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2663
2664 let mut query_params: Vec<(String, String)> = Vec::new();
2666
2667
2668 let mut header_params = std::collections::HashMap::new();
2670
2671 if let Some(ref binance_auth) = configuration.binance_auth {
2673 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2675
2676 let body_string: Option<Vec<u8>> = None;
2678
2679 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2681 Ok(sig) => sig,
2682 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2683 };
2684
2685 query_params.push(("signature".to_string(), signature));
2687 }
2688
2689 if !query_params.is_empty() {
2691 req_builder = req_builder.query(&query_params);
2692 }
2693
2694
2695 if let Some(ref user_agent) = configuration.user_agent {
2697 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2698 }
2699
2700 for (header_name, header_value) in header_params {
2702 req_builder = req_builder.header(&header_name, &header_value);
2703 }
2704
2705
2706 let req = req_builder.build()?;
2707 let resp = configuration.client.execute(req).await?;
2708
2709 let status = resp.status();
2710 let content_type = resp
2711 .headers()
2712 .get("content-type")
2713 .and_then(|v| v.to_str().ok())
2714 .unwrap_or("application/octet-stream");
2715 let content_type = super::ContentType::from(content_type);
2716
2717 if !status.is_client_error() && !status.is_server_error() {
2718 let content = resp.text().await?;
2719 match content_type {
2720 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2721 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
2722 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`")))),
2723 }
2724 } else {
2725 let content = resp.text().await?;
2726 let entity: Option<DeleteMarginListenKeyV1Error> = serde_json::from_str(&content).ok();
2727 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2728 }
2729}
2730
2731pub async fn delete_margin_open_orders_v1(configuration: &configuration::Configuration, params: DeleteMarginOpenOrdersV1Params) -> Result<Vec<models::DeleteMarginOpenOrdersV1RespItem>, Error<DeleteMarginOpenOrdersV1Error>> {
2733
2734 let uri_str = format!("{}/sapi/v1/margin/openOrders", configuration.base_path);
2735 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2736
2737 let mut query_params: Vec<(String, String)> = Vec::new();
2739
2740 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2741 if let Some(ref param_value) = params.is_isolated {
2742 query_params.push(("isIsolated".to_string(), param_value.to_string()));
2743 }
2744 if let Some(ref param_value) = params.recv_window {
2745 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2746 }
2747 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2748
2749 let mut header_params = std::collections::HashMap::new();
2751
2752 if let Some(ref binance_auth) = configuration.binance_auth {
2754 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2756
2757 let body_string: Option<Vec<u8>> = None;
2759
2760 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2762 Ok(sig) => sig,
2763 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2764 };
2765
2766 query_params.push(("signature".to_string(), signature));
2768 }
2769
2770 if !query_params.is_empty() {
2772 req_builder = req_builder.query(&query_params);
2773 }
2774
2775
2776 if let Some(ref user_agent) = configuration.user_agent {
2778 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2779 }
2780
2781 for (header_name, header_value) in header_params {
2783 req_builder = req_builder.header(&header_name, &header_value);
2784 }
2785
2786
2787 let req = req_builder.build()?;
2788 let resp = configuration.client.execute(req).await?;
2789
2790 let status = resp.status();
2791 let content_type = resp
2792 .headers()
2793 .get("content-type")
2794 .and_then(|v| v.to_str().ok())
2795 .unwrap_or("application/octet-stream");
2796 let content_type = super::ContentType::from(content_type);
2797
2798 if !status.is_client_error() && !status.is_server_error() {
2799 let content = resp.text().await?;
2800 match content_type {
2801 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2802 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::DeleteMarginOpenOrdersV1RespItem>`"))),
2803 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::DeleteMarginOpenOrdersV1RespItem>`")))),
2804 }
2805 } else {
2806 let content = resp.text().await?;
2807 let entity: Option<DeleteMarginOpenOrdersV1Error> = serde_json::from_str(&content).ok();
2808 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2809 }
2810}
2811
2812pub async fn delete_margin_order_list_v1(configuration: &configuration::Configuration, params: DeleteMarginOrderListV1Params) -> Result<models::DeleteMarginOrderListV1Resp, Error<DeleteMarginOrderListV1Error>> {
2814
2815 let uri_str = format!("{}/sapi/v1/margin/orderList", configuration.base_path);
2816 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2817
2818 let mut query_params: Vec<(String, String)> = Vec::new();
2820
2821 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2822 if let Some(ref param_value) = params.is_isolated {
2823 query_params.push(("isIsolated".to_string(), param_value.to_string()));
2824 }
2825 if let Some(ref param_value) = params.order_list_id {
2826 query_params.push(("orderListId".to_string(), param_value.to_string()));
2827 }
2828 if let Some(ref param_value) = params.list_client_order_id {
2829 query_params.push(("listClientOrderId".to_string(), param_value.to_string()));
2830 }
2831 if let Some(ref param_value) = params.new_client_order_id {
2832 query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
2833 }
2834 if let Some(ref param_value) = params.recv_window {
2835 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2836 }
2837 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2838
2839 let mut header_params = std::collections::HashMap::new();
2841
2842 if let Some(ref binance_auth) = configuration.binance_auth {
2844 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2846
2847 let body_string: Option<Vec<u8>> = None;
2849
2850 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2852 Ok(sig) => sig,
2853 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2854 };
2855
2856 query_params.push(("signature".to_string(), signature));
2858 }
2859
2860 if !query_params.is_empty() {
2862 req_builder = req_builder.query(&query_params);
2863 }
2864
2865
2866 if let Some(ref user_agent) = configuration.user_agent {
2868 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2869 }
2870
2871 for (header_name, header_value) in header_params {
2873 req_builder = req_builder.header(&header_name, &header_value);
2874 }
2875
2876
2877 let req = req_builder.build()?;
2878 let resp = configuration.client.execute(req).await?;
2879
2880 let status = resp.status();
2881 let content_type = resp
2882 .headers()
2883 .get("content-type")
2884 .and_then(|v| v.to_str().ok())
2885 .unwrap_or("application/octet-stream");
2886 let content_type = super::ContentType::from(content_type);
2887
2888 if !status.is_client_error() && !status.is_server_error() {
2889 let content = resp.text().await?;
2890 match content_type {
2891 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2892 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMarginOrderListV1Resp`"))),
2893 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::DeleteMarginOrderListV1Resp`")))),
2894 }
2895 } else {
2896 let content = resp.text().await?;
2897 let entity: Option<DeleteMarginOrderListV1Error> = serde_json::from_str(&content).ok();
2898 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2899 }
2900}
2901
2902pub async fn delete_margin_order_v1(configuration: &configuration::Configuration, params: DeleteMarginOrderV1Params) -> Result<models::DeleteMarginOrderV1Resp, Error<DeleteMarginOrderV1Error>> {
2904
2905 let uri_str = format!("{}/sapi/v1/margin/order", configuration.base_path);
2906 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2907
2908 let mut query_params: Vec<(String, String)> = Vec::new();
2910
2911 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2912 if let Some(ref param_value) = params.is_isolated {
2913 query_params.push(("isIsolated".to_string(), param_value.to_string()));
2914 }
2915 if let Some(ref param_value) = params.order_id {
2916 query_params.push(("orderId".to_string(), param_value.to_string()));
2917 }
2918 if let Some(ref param_value) = params.orig_client_order_id {
2919 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2920 }
2921 if let Some(ref param_value) = params.new_client_order_id {
2922 query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
2923 }
2924 if let Some(ref param_value) = params.recv_window {
2925 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2926 }
2927 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2928
2929 let mut header_params = std::collections::HashMap::new();
2931
2932 if let Some(ref binance_auth) = configuration.binance_auth {
2934 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2936
2937 let body_string: Option<Vec<u8>> = None;
2939
2940 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2942 Ok(sig) => sig,
2943 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2944 };
2945
2946 query_params.push(("signature".to_string(), signature));
2948 }
2949
2950 if !query_params.is_empty() {
2952 req_builder = req_builder.query(&query_params);
2953 }
2954
2955
2956 if let Some(ref user_agent) = configuration.user_agent {
2958 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2959 }
2960
2961 for (header_name, header_value) in header_params {
2963 req_builder = req_builder.header(&header_name, &header_value);
2964 }
2965
2966
2967 let req = req_builder.build()?;
2968 let resp = configuration.client.execute(req).await?;
2969
2970 let status = resp.status();
2971 let content_type = resp
2972 .headers()
2973 .get("content-type")
2974 .and_then(|v| v.to_str().ok())
2975 .unwrap_or("application/octet-stream");
2976 let content_type = super::ContentType::from(content_type);
2977
2978 if !status.is_client_error() && !status.is_server_error() {
2979 let content = resp.text().await?;
2980 match content_type {
2981 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2982 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMarginOrderV1Resp`"))),
2983 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::DeleteMarginOrderV1Resp`")))),
2984 }
2985 } else {
2986 let content = resp.text().await?;
2987 let entity: Option<DeleteMarginOrderV1Error> = serde_json::from_str(&content).ok();
2988 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2989 }
2990}
2991
2992pub async fn delete_user_data_stream_isolated_v1(configuration: &configuration::Configuration, params: DeleteUserDataStreamIsolatedV1Params) -> Result<serde_json::Value, Error<DeleteUserDataStreamIsolatedV1Error>> {
2994
2995 let uri_str = format!("{}/sapi/v1/userDataStream/isolated", configuration.base_path);
2996 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2997
2998 let mut query_params: Vec<(String, String)> = Vec::new();
3000
3001 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3002 query_params.push(("listenkey".to_string(), params.listenkey.to_string()));
3003
3004 let mut header_params = std::collections::HashMap::new();
3006
3007 if let Some(ref binance_auth) = configuration.binance_auth {
3009 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3011
3012 let body_string: Option<Vec<u8>> = None;
3014
3015 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3017 Ok(sig) => sig,
3018 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3019 };
3020
3021 query_params.push(("signature".to_string(), signature));
3023 }
3024
3025 if !query_params.is_empty() {
3027 req_builder = req_builder.query(&query_params);
3028 }
3029
3030
3031 if let Some(ref user_agent) = configuration.user_agent {
3033 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3034 }
3035
3036 for (header_name, header_value) in header_params {
3038 req_builder = req_builder.header(&header_name, &header_value);
3039 }
3040
3041
3042 let req = req_builder.build()?;
3043 let resp = configuration.client.execute(req).await?;
3044
3045 let status = resp.status();
3046 let content_type = resp
3047 .headers()
3048 .get("content-type")
3049 .and_then(|v| v.to_str().ok())
3050 .unwrap_or("application/octet-stream");
3051 let content_type = super::ContentType::from(content_type);
3052
3053 if !status.is_client_error() && !status.is_server_error() {
3054 let content = resp.text().await?;
3055 match content_type {
3056 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3057 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
3058 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`")))),
3059 }
3060 } else {
3061 let content = resp.text().await?;
3062 let entity: Option<DeleteUserDataStreamIsolatedV1Error> = serde_json::from_str(&content).ok();
3063 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3064 }
3065}
3066
3067pub async fn delete_user_data_stream_v1(configuration: &configuration::Configuration, params: DeleteUserDataStreamV1Params) -> Result<serde_json::Value, Error<DeleteUserDataStreamV1Error>> {
3069
3070 let uri_str = format!("{}/sapi/v1/userDataStream", configuration.base_path);
3071 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
3072
3073 let mut query_params: Vec<(String, String)> = Vec::new();
3075
3076 query_params.push(("listenkey".to_string(), params.listenkey.to_string()));
3077
3078 let mut header_params = std::collections::HashMap::new();
3080
3081 if let Some(ref binance_auth) = configuration.binance_auth {
3083 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3085
3086 let body_string: Option<Vec<u8>> = None;
3088
3089 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3091 Ok(sig) => sig,
3092 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3093 };
3094
3095 query_params.push(("signature".to_string(), signature));
3097 }
3098
3099 if !query_params.is_empty() {
3101 req_builder = req_builder.query(&query_params);
3102 }
3103
3104
3105 if let Some(ref user_agent) = configuration.user_agent {
3107 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3108 }
3109
3110 for (header_name, header_value) in header_params {
3112 req_builder = req_builder.header(&header_name, &header_value);
3113 }
3114
3115
3116 let req = req_builder.build()?;
3117 let resp = configuration.client.execute(req).await?;
3118
3119 let status = resp.status();
3120 let content_type = resp
3121 .headers()
3122 .get("content-type")
3123 .and_then(|v| v.to_str().ok())
3124 .unwrap_or("application/octet-stream");
3125 let content_type = super::ContentType::from(content_type);
3126
3127 if !status.is_client_error() && !status.is_server_error() {
3128 let content = resp.text().await?;
3129 match content_type {
3130 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3131 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
3132 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`")))),
3133 }
3134 } else {
3135 let content = resp.text().await?;
3136 let entity: Option<DeleteUserDataStreamV1Error> = serde_json::from_str(&content).ok();
3137 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3138 }
3139}
3140
3141pub async fn get_bnb_burn_v1(configuration: &configuration::Configuration, params: GetBnbBurnV1Params) -> Result<models::GetBnbBurnV1Resp, Error<GetBnbBurnV1Error>> {
3143
3144 let uri_str = format!("{}/sapi/v1/bnbBurn", configuration.base_path);
3145 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3146
3147 let mut query_params: Vec<(String, String)> = Vec::new();
3149
3150 if let Some(ref param_value) = params.recv_window {
3151 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3152 }
3153 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3154
3155 let mut header_params = std::collections::HashMap::new();
3157
3158 if let Some(ref binance_auth) = configuration.binance_auth {
3160 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3162
3163 let body_string: Option<Vec<u8>> = None;
3165
3166 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3168 Ok(sig) => sig,
3169 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3170 };
3171
3172 query_params.push(("signature".to_string(), signature));
3174 }
3175
3176 if !query_params.is_empty() {
3178 req_builder = req_builder.query(&query_params);
3179 }
3180
3181
3182 if let Some(ref user_agent) = configuration.user_agent {
3184 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3185 }
3186
3187 for (header_name, header_value) in header_params {
3189 req_builder = req_builder.header(&header_name, &header_value);
3190 }
3191
3192
3193 let req = req_builder.build()?;
3194 let resp = configuration.client.execute(req).await?;
3195
3196 let status = resp.status();
3197 let content_type = resp
3198 .headers()
3199 .get("content-type")
3200 .and_then(|v| v.to_str().ok())
3201 .unwrap_or("application/octet-stream");
3202 let content_type = super::ContentType::from(content_type);
3203
3204 if !status.is_client_error() && !status.is_server_error() {
3205 let content = resp.text().await?;
3206 match content_type {
3207 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3208 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetBnbBurnV1Resp`"))),
3209 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::GetBnbBurnV1Resp`")))),
3210 }
3211 } else {
3212 let content = resp.text().await?;
3213 let entity: Option<GetBnbBurnV1Error> = serde_json::from_str(&content).ok();
3214 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3215 }
3216}
3217
3218pub async fn get_margin_account_v1(configuration: &configuration::Configuration, params: GetMarginAccountV1Params) -> Result<models::GetMarginAccountV1Resp, Error<GetMarginAccountV1Error>> {
3220
3221 let uri_str = format!("{}/sapi/v1/margin/account", configuration.base_path);
3222 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3223
3224 let mut query_params: Vec<(String, String)> = Vec::new();
3226
3227 if let Some(ref param_value) = params.recv_window {
3228 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3229 }
3230 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3231
3232 let mut header_params = std::collections::HashMap::new();
3234
3235 if let Some(ref binance_auth) = configuration.binance_auth {
3237 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3239
3240 let body_string: Option<Vec<u8>> = None;
3242
3243 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3245 Ok(sig) => sig,
3246 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3247 };
3248
3249 query_params.push(("signature".to_string(), signature));
3251 }
3252
3253 if !query_params.is_empty() {
3255 req_builder = req_builder.query(&query_params);
3256 }
3257
3258
3259 if let Some(ref user_agent) = configuration.user_agent {
3261 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3262 }
3263
3264 for (header_name, header_value) in header_params {
3266 req_builder = req_builder.header(&header_name, &header_value);
3267 }
3268
3269
3270 let req = req_builder.build()?;
3271 let resp = configuration.client.execute(req).await?;
3272
3273 let status = resp.status();
3274 let content_type = resp
3275 .headers()
3276 .get("content-type")
3277 .and_then(|v| v.to_str().ok())
3278 .unwrap_or("application/octet-stream");
3279 let content_type = super::ContentType::from(content_type);
3280
3281 if !status.is_client_error() && !status.is_server_error() {
3282 let content = resp.text().await?;
3283 match content_type {
3284 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3285 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginAccountV1Resp`"))),
3286 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::GetMarginAccountV1Resp`")))),
3287 }
3288 } else {
3289 let content = resp.text().await?;
3290 let entity: Option<GetMarginAccountV1Error> = serde_json::from_str(&content).ok();
3291 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3292 }
3293}
3294
3295pub async fn get_margin_all_assets_v1(configuration: &configuration::Configuration, params: GetMarginAllAssetsV1Params) -> Result<Vec<models::GetMarginAllAssetsV1RespItem>, Error<GetMarginAllAssetsV1Error>> {
3297
3298 let uri_str = format!("{}/sapi/v1/margin/allAssets", configuration.base_path);
3299 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3300
3301 let mut query_params: Vec<(String, String)> = Vec::new();
3303
3304 if let Some(ref param_value) = params.asset {
3305 query_params.push(("asset".to_string(), param_value.to_string()));
3306 }
3307
3308 let mut header_params = std::collections::HashMap::new();
3310
3311 if let Some(ref binance_auth) = configuration.binance_auth {
3313 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3315
3316 let body_string: Option<Vec<u8>> = None;
3318
3319 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3321 Ok(sig) => sig,
3322 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3323 };
3324
3325 query_params.push(("signature".to_string(), signature));
3327 }
3328
3329 if !query_params.is_empty() {
3331 req_builder = req_builder.query(&query_params);
3332 }
3333
3334
3335 if let Some(ref user_agent) = configuration.user_agent {
3337 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3338 }
3339
3340 for (header_name, header_value) in header_params {
3342 req_builder = req_builder.header(&header_name, &header_value);
3343 }
3344
3345
3346 let req = req_builder.build()?;
3347 let resp = configuration.client.execute(req).await?;
3348
3349 let status = resp.status();
3350 let content_type = resp
3351 .headers()
3352 .get("content-type")
3353 .and_then(|v| v.to_str().ok())
3354 .unwrap_or("application/octet-stream");
3355 let content_type = super::ContentType::from(content_type);
3356
3357 if !status.is_client_error() && !status.is_server_error() {
3358 let content = resp.text().await?;
3359 match content_type {
3360 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3361 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginAllAssetsV1RespItem>`"))),
3362 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::GetMarginAllAssetsV1RespItem>`")))),
3363 }
3364 } else {
3365 let content = resp.text().await?;
3366 let entity: Option<GetMarginAllAssetsV1Error> = serde_json::from_str(&content).ok();
3367 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3368 }
3369}
3370
3371pub async fn get_margin_all_order_list_v1(configuration: &configuration::Configuration, params: GetMarginAllOrderListV1Params) -> Result<Vec<models::GetMarginAllOrderListV1RespItem>, Error<GetMarginAllOrderListV1Error>> {
3373
3374 let uri_str = format!("{}/sapi/v1/margin/allOrderList", configuration.base_path);
3375 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3376
3377 let mut query_params: Vec<(String, String)> = Vec::new();
3379
3380 if let Some(ref param_value) = params.is_isolated {
3381 query_params.push(("isIsolated".to_string(), param_value.to_string()));
3382 }
3383 if let Some(ref param_value) = params.symbol {
3384 query_params.push(("symbol".to_string(), param_value.to_string()));
3385 }
3386 if let Some(ref param_value) = params.from_id {
3387 query_params.push(("fromId".to_string(), param_value.to_string()));
3388 }
3389 if let Some(ref param_value) = params.start_time {
3390 query_params.push(("startTime".to_string(), param_value.to_string()));
3391 }
3392 if let Some(ref param_value) = params.end_time {
3393 query_params.push(("endTime".to_string(), param_value.to_string()));
3394 }
3395 if let Some(ref param_value) = params.limit {
3396 query_params.push(("limit".to_string(), param_value.to_string()));
3397 }
3398 if let Some(ref param_value) = params.recv_window {
3399 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3400 }
3401 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3402
3403 let mut header_params = std::collections::HashMap::new();
3405
3406 if let Some(ref binance_auth) = configuration.binance_auth {
3408 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3410
3411 let body_string: Option<Vec<u8>> = None;
3413
3414 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3416 Ok(sig) => sig,
3417 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3418 };
3419
3420 query_params.push(("signature".to_string(), signature));
3422 }
3423
3424 if !query_params.is_empty() {
3426 req_builder = req_builder.query(&query_params);
3427 }
3428
3429
3430 if let Some(ref user_agent) = configuration.user_agent {
3432 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3433 }
3434
3435 for (header_name, header_value) in header_params {
3437 req_builder = req_builder.header(&header_name, &header_value);
3438 }
3439
3440
3441 let req = req_builder.build()?;
3442 let resp = configuration.client.execute(req).await?;
3443
3444 let status = resp.status();
3445 let content_type = resp
3446 .headers()
3447 .get("content-type")
3448 .and_then(|v| v.to_str().ok())
3449 .unwrap_or("application/octet-stream");
3450 let content_type = super::ContentType::from(content_type);
3451
3452 if !status.is_client_error() && !status.is_server_error() {
3453 let content = resp.text().await?;
3454 match content_type {
3455 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3456 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginAllOrderListV1RespItem>`"))),
3457 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetMarginAllOrderListV1RespItem>`")))),
3458 }
3459 } else {
3460 let content = resp.text().await?;
3461 let entity: Option<GetMarginAllOrderListV1Error> = serde_json::from_str(&content).ok();
3462 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3463 }
3464}
3465
3466pub async fn get_margin_all_orders_v1(configuration: &configuration::Configuration, params: GetMarginAllOrdersV1Params) -> Result<Vec<models::GetMarginAllOrdersV1RespItem>, Error<GetMarginAllOrdersV1Error>> {
3468
3469 let uri_str = format!("{}/sapi/v1/margin/allOrders", configuration.base_path);
3470 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3471
3472 let mut query_params: Vec<(String, String)> = Vec::new();
3474
3475 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3476 if let Some(ref param_value) = params.is_isolated {
3477 query_params.push(("isIsolated".to_string(), param_value.to_string()));
3478 }
3479 if let Some(ref param_value) = params.order_id {
3480 query_params.push(("orderId".to_string(), param_value.to_string()));
3481 }
3482 if let Some(ref param_value) = params.start_time {
3483 query_params.push(("startTime".to_string(), param_value.to_string()));
3484 }
3485 if let Some(ref param_value) = params.end_time {
3486 query_params.push(("endTime".to_string(), param_value.to_string()));
3487 }
3488 if let Some(ref param_value) = params.limit {
3489 query_params.push(("limit".to_string(), param_value.to_string()));
3490 }
3491 if let Some(ref param_value) = params.recv_window {
3492 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3493 }
3494 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3495
3496 let mut header_params = std::collections::HashMap::new();
3498
3499 if let Some(ref binance_auth) = configuration.binance_auth {
3501 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3503
3504 let body_string: Option<Vec<u8>> = None;
3506
3507 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3509 Ok(sig) => sig,
3510 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3511 };
3512
3513 query_params.push(("signature".to_string(), signature));
3515 }
3516
3517 if !query_params.is_empty() {
3519 req_builder = req_builder.query(&query_params);
3520 }
3521
3522
3523 if let Some(ref user_agent) = configuration.user_agent {
3525 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3526 }
3527
3528 for (header_name, header_value) in header_params {
3530 req_builder = req_builder.header(&header_name, &header_value);
3531 }
3532
3533
3534 let req = req_builder.build()?;
3535 let resp = configuration.client.execute(req).await?;
3536
3537 let status = resp.status();
3538 let content_type = resp
3539 .headers()
3540 .get("content-type")
3541 .and_then(|v| v.to_str().ok())
3542 .unwrap_or("application/octet-stream");
3543 let content_type = super::ContentType::from(content_type);
3544
3545 if !status.is_client_error() && !status.is_server_error() {
3546 let content = resp.text().await?;
3547 match content_type {
3548 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3549 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginAllOrdersV1RespItem>`"))),
3550 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::GetMarginAllOrdersV1RespItem>`")))),
3551 }
3552 } else {
3553 let content = resp.text().await?;
3554 let entity: Option<GetMarginAllOrdersV1Error> = serde_json::from_str(&content).ok();
3555 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3556 }
3557}
3558
3559pub async fn get_margin_all_pairs_v1(configuration: &configuration::Configuration, params: GetMarginAllPairsV1Params) -> Result<Vec<models::GetMarginAllPairsV1RespItem>, Error<GetMarginAllPairsV1Error>> {
3561
3562 let uri_str = format!("{}/sapi/v1/margin/allPairs", configuration.base_path);
3563 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3564
3565 let mut query_params: Vec<(String, String)> = Vec::new();
3567
3568 if let Some(ref param_value) = params.symbol {
3569 query_params.push(("symbol".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::GetMarginAllPairsV1RespItem>`"))),
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::GetMarginAllPairsV1RespItem>`")))),
3627 }
3628 } else {
3629 let content = resp.text().await?;
3630 let entity: Option<GetMarginAllPairsV1Error> = serde_json::from_str(&content).ok();
3631 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3632 }
3633}
3634
3635pub async fn get_margin_api_key_list_v1(configuration: &configuration::Configuration, params: GetMarginApiKeyListV1Params) -> Result<Vec<models::GetMarginApiKeyListV1RespItem>, Error<GetMarginApiKeyListV1Error>> {
3637
3638 let uri_str = format!("{}/sapi/v1/margin/api-key-list", 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 if let Some(ref param_value) = params.symbol {
3645 query_params.push(("symbol".to_string(), param_value.to_string()));
3646 }
3647 if let Some(ref param_value) = params.recv_window {
3648 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3649 }
3650 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3651
3652 let mut header_params = std::collections::HashMap::new();
3654
3655 if let Some(ref binance_auth) = configuration.binance_auth {
3657 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3659
3660 let body_string: Option<Vec<u8>> = None;
3662
3663 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3665 Ok(sig) => sig,
3666 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3667 };
3668
3669 query_params.push(("signature".to_string(), signature));
3671 }
3672
3673 if !query_params.is_empty() {
3675 req_builder = req_builder.query(&query_params);
3676 }
3677
3678
3679 if let Some(ref user_agent) = configuration.user_agent {
3681 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3682 }
3683
3684 for (header_name, header_value) in header_params {
3686 req_builder = req_builder.header(&header_name, &header_value);
3687 }
3688
3689
3690 let req = req_builder.build()?;
3691 let resp = configuration.client.execute(req).await?;
3692
3693 let status = resp.status();
3694 let content_type = resp
3695 .headers()
3696 .get("content-type")
3697 .and_then(|v| v.to_str().ok())
3698 .unwrap_or("application/octet-stream");
3699 let content_type = super::ContentType::from(content_type);
3700
3701 if !status.is_client_error() && !status.is_server_error() {
3702 let content = resp.text().await?;
3703 match content_type {
3704 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3705 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginApiKeyListV1RespItem>`"))),
3706 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::GetMarginApiKeyListV1RespItem>`")))),
3707 }
3708 } else {
3709 let content = resp.text().await?;
3710 let entity: Option<GetMarginApiKeyListV1Error> = serde_json::from_str(&content).ok();
3711 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3712 }
3713}
3714
3715pub async fn get_margin_api_key_v1(configuration: &configuration::Configuration, params: GetMarginApiKeyV1Params) -> Result<models::GetMarginApiKeyV1Resp, Error<GetMarginApiKeyV1Error>> {
3717
3718 let uri_str = format!("{}/sapi/v1/margin/apiKey", configuration.base_path);
3719 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3720
3721 let mut query_params: Vec<(String, String)> = Vec::new();
3723
3724 query_params.push(("apiKey".to_string(), params.api_key.to_string()));
3725 if let Some(ref param_value) = params.symbol {
3726 query_params.push(("symbol".to_string(), param_value.to_string()));
3727 }
3728 if let Some(ref param_value) = params.recv_window {
3729 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3730 }
3731 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3732
3733 let mut header_params = std::collections::HashMap::new();
3735
3736 if let Some(ref binance_auth) = configuration.binance_auth {
3738 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3740
3741 let body_string: Option<Vec<u8>> = None;
3743
3744 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3746 Ok(sig) => sig,
3747 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3748 };
3749
3750 query_params.push(("signature".to_string(), signature));
3752 }
3753
3754 if !query_params.is_empty() {
3756 req_builder = req_builder.query(&query_params);
3757 }
3758
3759
3760 if let Some(ref user_agent) = configuration.user_agent {
3762 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3763 }
3764
3765 for (header_name, header_value) in header_params {
3767 req_builder = req_builder.header(&header_name, &header_value);
3768 }
3769
3770
3771 let req = req_builder.build()?;
3772 let resp = configuration.client.execute(req).await?;
3773
3774 let status = resp.status();
3775 let content_type = resp
3776 .headers()
3777 .get("content-type")
3778 .and_then(|v| v.to_str().ok())
3779 .unwrap_or("application/octet-stream");
3780 let content_type = super::ContentType::from(content_type);
3781
3782 if !status.is_client_error() && !status.is_server_error() {
3783 let content = resp.text().await?;
3784 match content_type {
3785 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3786 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginApiKeyV1Resp`"))),
3787 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::GetMarginApiKeyV1Resp`")))),
3788 }
3789 } else {
3790 let content = resp.text().await?;
3791 let entity: Option<GetMarginApiKeyV1Error> = serde_json::from_str(&content).ok();
3792 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3793 }
3794}
3795
3796pub async fn get_margin_available_inventory_v1(configuration: &configuration::Configuration, params: GetMarginAvailableInventoryV1Params) -> Result<models::MarginGetMarginAvailableInventoryV1Resp, Error<GetMarginAvailableInventoryV1Error>> {
3798
3799 let uri_str = format!("{}/sapi/v1/margin/available-inventory", configuration.base_path);
3800 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3801
3802 let mut query_params: Vec<(String, String)> = Vec::new();
3804
3805 query_params.push(("type".to_string(), params.r#type.to_string()));
3806
3807 let mut header_params = std::collections::HashMap::new();
3809
3810 if let Some(ref binance_auth) = configuration.binance_auth {
3812 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3814
3815 let body_string: Option<Vec<u8>> = None;
3817
3818 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3820 Ok(sig) => sig,
3821 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3822 };
3823
3824 query_params.push(("signature".to_string(), signature));
3826 }
3827
3828 if !query_params.is_empty() {
3830 req_builder = req_builder.query(&query_params);
3831 }
3832
3833
3834 if let Some(ref user_agent) = configuration.user_agent {
3836 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3837 }
3838
3839 for (header_name, header_value) in header_params {
3841 req_builder = req_builder.header(&header_name, &header_value);
3842 }
3843
3844
3845 let req = req_builder.build()?;
3846 let resp = configuration.client.execute(req).await?;
3847
3848 let status = resp.status();
3849 let content_type = resp
3850 .headers()
3851 .get("content-type")
3852 .and_then(|v| v.to_str().ok())
3853 .unwrap_or("application/octet-stream");
3854 let content_type = super::ContentType::from(content_type);
3855
3856 if !status.is_client_error() && !status.is_server_error() {
3857 let content = resp.text().await?;
3858 match content_type {
3859 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3860 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginAvailableInventoryV1Resp`"))),
3861 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::MarginGetMarginAvailableInventoryV1Resp`")))),
3862 }
3863 } else {
3864 let content = resp.text().await?;
3865 let entity: Option<GetMarginAvailableInventoryV1Error> = serde_json::from_str(&content).ok();
3866 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3867 }
3868}
3869
3870pub async fn get_margin_borrow_repay_v1(configuration: &configuration::Configuration, params: GetMarginBorrowRepayV1Params) -> Result<models::GetMarginBorrowRepayV1Resp, Error<GetMarginBorrowRepayV1Error>> {
3872
3873 let uri_str = format!("{}/sapi/v1/margin/borrow-repay", configuration.base_path);
3874 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3875
3876 let mut query_params: Vec<(String, String)> = Vec::new();
3878
3879 if let Some(ref param_value) = params.asset {
3880 query_params.push(("asset".to_string(), param_value.to_string()));
3881 }
3882 if let Some(ref param_value) = params.isolated_symbol {
3883 query_params.push(("isolatedSymbol".to_string(), param_value.to_string()));
3884 }
3885 if let Some(ref param_value) = params.tx_id {
3886 query_params.push(("txId".to_string(), param_value.to_string()));
3887 }
3888 if let Some(ref param_value) = params.start_time {
3889 query_params.push(("startTime".to_string(), param_value.to_string()));
3890 }
3891 if let Some(ref param_value) = params.end_time {
3892 query_params.push(("endTime".to_string(), param_value.to_string()));
3893 }
3894 if let Some(ref param_value) = params.current {
3895 query_params.push(("current".to_string(), param_value.to_string()));
3896 }
3897 if let Some(ref param_value) = params.size {
3898 query_params.push(("size".to_string(), param_value.to_string()));
3899 }
3900 query_params.push(("type".to_string(), params.r#type.to_string()));
3901 if let Some(ref param_value) = params.recv_window {
3902 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3903 }
3904 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3905
3906 let mut header_params = std::collections::HashMap::new();
3908
3909 if let Some(ref binance_auth) = configuration.binance_auth {
3911 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3913
3914 let body_string: Option<Vec<u8>> = None;
3916
3917 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3919 Ok(sig) => sig,
3920 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3921 };
3922
3923 query_params.push(("signature".to_string(), signature));
3925 }
3926
3927 if !query_params.is_empty() {
3929 req_builder = req_builder.query(&query_params);
3930 }
3931
3932
3933 if let Some(ref user_agent) = configuration.user_agent {
3935 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3936 }
3937
3938 for (header_name, header_value) in header_params {
3940 req_builder = req_builder.header(&header_name, &header_value);
3941 }
3942
3943
3944 let req = req_builder.build()?;
3945 let resp = configuration.client.execute(req).await?;
3946
3947 let status = resp.status();
3948 let content_type = resp
3949 .headers()
3950 .get("content-type")
3951 .and_then(|v| v.to_str().ok())
3952 .unwrap_or("application/octet-stream");
3953 let content_type = super::ContentType::from(content_type);
3954
3955 if !status.is_client_error() && !status.is_server_error() {
3956 let content = resp.text().await?;
3957 match content_type {
3958 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3959 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginBorrowRepayV1Resp`"))),
3960 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::GetMarginBorrowRepayV1Resp`")))),
3961 }
3962 } else {
3963 let content = resp.text().await?;
3964 let entity: Option<GetMarginBorrowRepayV1Error> = serde_json::from_str(&content).ok();
3965 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3966 }
3967}
3968
3969pub async fn get_margin_capital_flow_v1(configuration: &configuration::Configuration, params: GetMarginCapitalFlowV1Params) -> Result<Vec<models::GetMarginCapitalFlowV1RespItem>, Error<GetMarginCapitalFlowV1Error>> {
3971
3972 let uri_str = format!("{}/sapi/v1/margin/capital-flow", configuration.base_path);
3973 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3974
3975 let mut query_params: Vec<(String, String)> = Vec::new();
3977
3978 if let Some(ref param_value) = params.asset {
3979 query_params.push(("asset".to_string(), param_value.to_string()));
3980 }
3981 if let Some(ref param_value) = params.symbol {
3982 query_params.push(("symbol".to_string(), param_value.to_string()));
3983 }
3984 if let Some(ref param_value) = params.r#type {
3985 query_params.push(("type".to_string(), param_value.to_string()));
3986 }
3987 if let Some(ref param_value) = params.start_time {
3988 query_params.push(("startTime".to_string(), param_value.to_string()));
3989 }
3990 if let Some(ref param_value) = params.end_time {
3991 query_params.push(("endTime".to_string(), param_value.to_string()));
3992 }
3993 if let Some(ref param_value) = params.from_id {
3994 query_params.push(("fromId".to_string(), param_value.to_string()));
3995 }
3996 if let Some(ref param_value) = params.limit {
3997 query_params.push(("limit".to_string(), param_value.to_string()));
3998 }
3999 if let Some(ref param_value) = params.recv_window {
4000 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4001 }
4002 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4003
4004 let mut header_params = std::collections::HashMap::new();
4006
4007 if let Some(ref binance_auth) = configuration.binance_auth {
4009 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4011
4012 let body_string: Option<Vec<u8>> = None;
4014
4015 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4017 Ok(sig) => sig,
4018 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4019 };
4020
4021 query_params.push(("signature".to_string(), signature));
4023 }
4024
4025 if !query_params.is_empty() {
4027 req_builder = req_builder.query(&query_params);
4028 }
4029
4030
4031 if let Some(ref user_agent) = configuration.user_agent {
4033 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4034 }
4035
4036 for (header_name, header_value) in header_params {
4038 req_builder = req_builder.header(&header_name, &header_value);
4039 }
4040
4041
4042 let req = req_builder.build()?;
4043 let resp = configuration.client.execute(req).await?;
4044
4045 let status = resp.status();
4046 let content_type = resp
4047 .headers()
4048 .get("content-type")
4049 .and_then(|v| v.to_str().ok())
4050 .unwrap_or("application/octet-stream");
4051 let content_type = super::ContentType::from(content_type);
4052
4053 if !status.is_client_error() && !status.is_server_error() {
4054 let content = resp.text().await?;
4055 match content_type {
4056 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4057 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginCapitalFlowV1RespItem>`"))),
4058 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::GetMarginCapitalFlowV1RespItem>`")))),
4059 }
4060 } else {
4061 let content = resp.text().await?;
4062 let entity: Option<GetMarginCapitalFlowV1Error> = serde_json::from_str(&content).ok();
4063 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4064 }
4065}
4066
4067pub async fn get_margin_cross_margin_collateral_ratio_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetMarginCrossMarginCollateralRatioV1RespItem>, Error<GetMarginCrossMarginCollateralRatioV1Error>> {
4069
4070 let uri_str = format!("{}/sapi/v1/margin/crossMarginCollateralRatio", configuration.base_path);
4071 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4072
4073 let mut query_params: Vec<(String, String)> = Vec::new();
4075
4076
4077 let mut header_params = std::collections::HashMap::new();
4079
4080 if let Some(ref binance_auth) = configuration.binance_auth {
4082 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4084
4085 let body_string: Option<Vec<u8>> = None;
4087
4088 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4090 Ok(sig) => sig,
4091 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4092 };
4093
4094 query_params.push(("signature".to_string(), signature));
4096 }
4097
4098 if !query_params.is_empty() {
4100 req_builder = req_builder.query(&query_params);
4101 }
4102
4103
4104 if let Some(ref user_agent) = configuration.user_agent {
4106 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4107 }
4108
4109 for (header_name, header_value) in header_params {
4111 req_builder = req_builder.header(&header_name, &header_value);
4112 }
4113
4114
4115 let req = req_builder.build()?;
4116 let resp = configuration.client.execute(req).await?;
4117
4118 let status = resp.status();
4119 let content_type = resp
4120 .headers()
4121 .get("content-type")
4122 .and_then(|v| v.to_str().ok())
4123 .unwrap_or("application/octet-stream");
4124 let content_type = super::ContentType::from(content_type);
4125
4126 if !status.is_client_error() && !status.is_server_error() {
4127 let content = resp.text().await?;
4128 match content_type {
4129 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4130 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginCrossMarginCollateralRatioV1RespItem>`"))),
4131 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::GetMarginCrossMarginCollateralRatioV1RespItem>`")))),
4132 }
4133 } else {
4134 let content = resp.text().await?;
4135 let entity: Option<GetMarginCrossMarginCollateralRatioV1Error> = serde_json::from_str(&content).ok();
4136 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4137 }
4138}
4139
4140pub async fn get_margin_cross_margin_data_v1(configuration: &configuration::Configuration, params: GetMarginCrossMarginDataV1Params) -> Result<Vec<models::GetMarginCrossMarginDataV1RespItem>, Error<GetMarginCrossMarginDataV1Error>> {
4142
4143 let uri_str = format!("{}/sapi/v1/margin/crossMarginData", configuration.base_path);
4144 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4145
4146 let mut query_params: Vec<(String, String)> = Vec::new();
4148
4149 if let Some(ref param_value) = params.vip_level {
4150 query_params.push(("vipLevel".to_string(), param_value.to_string()));
4151 }
4152 if let Some(ref param_value) = params.coin {
4153 query_params.push(("coin".to_string(), param_value.to_string()));
4154 }
4155 if let Some(ref param_value) = params.recv_window {
4156 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4157 }
4158 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4159
4160 let mut header_params = std::collections::HashMap::new();
4162
4163 if let Some(ref binance_auth) = configuration.binance_auth {
4165 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4167
4168 let body_string: Option<Vec<u8>> = None;
4170
4171 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4173 Ok(sig) => sig,
4174 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4175 };
4176
4177 query_params.push(("signature".to_string(), signature));
4179 }
4180
4181 if !query_params.is_empty() {
4183 req_builder = req_builder.query(&query_params);
4184 }
4185
4186
4187 if let Some(ref user_agent) = configuration.user_agent {
4189 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4190 }
4191
4192 for (header_name, header_value) in header_params {
4194 req_builder = req_builder.header(&header_name, &header_value);
4195 }
4196
4197
4198 let req = req_builder.build()?;
4199 let resp = configuration.client.execute(req).await?;
4200
4201 let status = resp.status();
4202 let content_type = resp
4203 .headers()
4204 .get("content-type")
4205 .and_then(|v| v.to_str().ok())
4206 .unwrap_or("application/octet-stream");
4207 let content_type = super::ContentType::from(content_type);
4208
4209 if !status.is_client_error() && !status.is_server_error() {
4210 let content = resp.text().await?;
4211 match content_type {
4212 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4213 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginCrossMarginDataV1RespItem>`"))),
4214 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::GetMarginCrossMarginDataV1RespItem>`")))),
4215 }
4216 } else {
4217 let content = resp.text().await?;
4218 let entity: Option<GetMarginCrossMarginDataV1Error> = serde_json::from_str(&content).ok();
4219 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4220 }
4221}
4222
4223pub async fn get_margin_delist_schedule_v1(configuration: &configuration::Configuration, params: GetMarginDelistScheduleV1Params) -> Result<Vec<models::GetMarginDelistScheduleV1RespItem>, Error<GetMarginDelistScheduleV1Error>> {
4225
4226 let uri_str = format!("{}/sapi/v1/margin/delist-schedule", configuration.base_path);
4227 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4228
4229 let mut query_params: Vec<(String, String)> = Vec::new();
4231
4232 if let Some(ref param_value) = params.recv_window {
4233 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4234 }
4235 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4236
4237 let mut header_params = std::collections::HashMap::new();
4239
4240 if let Some(ref binance_auth) = configuration.binance_auth {
4242 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4244
4245 let body_string: Option<Vec<u8>> = None;
4247
4248 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4250 Ok(sig) => sig,
4251 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4252 };
4253
4254 query_params.push(("signature".to_string(), signature));
4256 }
4257
4258 if !query_params.is_empty() {
4260 req_builder = req_builder.query(&query_params);
4261 }
4262
4263
4264 if let Some(ref user_agent) = configuration.user_agent {
4266 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4267 }
4268
4269 for (header_name, header_value) in header_params {
4271 req_builder = req_builder.header(&header_name, &header_value);
4272 }
4273
4274
4275 let req = req_builder.build()?;
4276 let resp = configuration.client.execute(req).await?;
4277
4278 let status = resp.status();
4279 let content_type = resp
4280 .headers()
4281 .get("content-type")
4282 .and_then(|v| v.to_str().ok())
4283 .unwrap_or("application/octet-stream");
4284 let content_type = super::ContentType::from(content_type);
4285
4286 if !status.is_client_error() && !status.is_server_error() {
4287 let content = resp.text().await?;
4288 match content_type {
4289 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4290 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginDelistScheduleV1RespItem>`"))),
4291 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::GetMarginDelistScheduleV1RespItem>`")))),
4292 }
4293 } else {
4294 let content = resp.text().await?;
4295 let entity: Option<GetMarginDelistScheduleV1Error> = serde_json::from_str(&content).ok();
4296 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4297 }
4298}
4299
4300pub async fn get_margin_exchange_small_liability_history_v1(configuration: &configuration::Configuration, params: GetMarginExchangeSmallLiabilityHistoryV1Params) -> Result<models::GetMarginExchangeSmallLiabilityHistoryV1Resp, Error<GetMarginExchangeSmallLiabilityHistoryV1Error>> {
4302
4303 let uri_str = format!("{}/sapi/v1/margin/exchange-small-liability-history", configuration.base_path);
4304 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4305
4306 let mut query_params: Vec<(String, String)> = Vec::new();
4308
4309 query_params.push(("current".to_string(), params.current.to_string()));
4310 query_params.push(("size".to_string(), params.size.to_string()));
4311 if let Some(ref param_value) = params.start_time {
4312 query_params.push(("startTime".to_string(), param_value.to_string()));
4313 }
4314 if let Some(ref param_value) = params.end_time {
4315 query_params.push(("endTime".to_string(), param_value.to_string()));
4316 }
4317 if let Some(ref param_value) = params.recv_window {
4318 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4319 }
4320 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4321
4322 let mut header_params = std::collections::HashMap::new();
4324
4325 if let Some(ref binance_auth) = configuration.binance_auth {
4327 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4329
4330 let body_string: Option<Vec<u8>> = None;
4332
4333 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4335 Ok(sig) => sig,
4336 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4337 };
4338
4339 query_params.push(("signature".to_string(), signature));
4341 }
4342
4343 if !query_params.is_empty() {
4345 req_builder = req_builder.query(&query_params);
4346 }
4347
4348
4349 if let Some(ref user_agent) = configuration.user_agent {
4351 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4352 }
4353
4354 for (header_name, header_value) in header_params {
4356 req_builder = req_builder.header(&header_name, &header_value);
4357 }
4358
4359
4360 let req = req_builder.build()?;
4361 let resp = configuration.client.execute(req).await?;
4362
4363 let status = resp.status();
4364 let content_type = resp
4365 .headers()
4366 .get("content-type")
4367 .and_then(|v| v.to_str().ok())
4368 .unwrap_or("application/octet-stream");
4369 let content_type = super::ContentType::from(content_type);
4370
4371 if !status.is_client_error() && !status.is_server_error() {
4372 let content = resp.text().await?;
4373 match content_type {
4374 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4375 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginExchangeSmallLiabilityHistoryV1Resp`"))),
4376 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::GetMarginExchangeSmallLiabilityHistoryV1Resp`")))),
4377 }
4378 } else {
4379 let content = resp.text().await?;
4380 let entity: Option<GetMarginExchangeSmallLiabilityHistoryV1Error> = serde_json::from_str(&content).ok();
4381 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4382 }
4383}
4384
4385pub async fn get_margin_exchange_small_liability_v1(configuration: &configuration::Configuration, params: GetMarginExchangeSmallLiabilityV1Params) -> Result<Vec<models::GetMarginExchangeSmallLiabilityV1RespItem>, Error<GetMarginExchangeSmallLiabilityV1Error>> {
4387
4388 let uri_str = format!("{}/sapi/v1/margin/exchange-small-liability", configuration.base_path);
4389 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4390
4391 let mut query_params: Vec<(String, String)> = Vec::new();
4393
4394 if let Some(ref param_value) = params.recv_window {
4395 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4396 }
4397 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4398
4399 let mut header_params = std::collections::HashMap::new();
4401
4402 if let Some(ref binance_auth) = configuration.binance_auth {
4404 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4406
4407 let body_string: Option<Vec<u8>> = None;
4409
4410 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4412 Ok(sig) => sig,
4413 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4414 };
4415
4416 query_params.push(("signature".to_string(), signature));
4418 }
4419
4420 if !query_params.is_empty() {
4422 req_builder = req_builder.query(&query_params);
4423 }
4424
4425
4426 if let Some(ref user_agent) = configuration.user_agent {
4428 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4429 }
4430
4431 for (header_name, header_value) in header_params {
4433 req_builder = req_builder.header(&header_name, &header_value);
4434 }
4435
4436
4437 let req = req_builder.build()?;
4438 let resp = configuration.client.execute(req).await?;
4439
4440 let status = resp.status();
4441 let content_type = resp
4442 .headers()
4443 .get("content-type")
4444 .and_then(|v| v.to_str().ok())
4445 .unwrap_or("application/octet-stream");
4446 let content_type = super::ContentType::from(content_type);
4447
4448 if !status.is_client_error() && !status.is_server_error() {
4449 let content = resp.text().await?;
4450 match content_type {
4451 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4452 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginExchangeSmallLiabilityV1RespItem>`"))),
4453 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::GetMarginExchangeSmallLiabilityV1RespItem>`")))),
4454 }
4455 } else {
4456 let content = resp.text().await?;
4457 let entity: Option<GetMarginExchangeSmallLiabilityV1Error> = serde_json::from_str(&content).ok();
4458 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4459 }
4460}
4461
4462pub async fn get_margin_force_liquidation_rec_v1(configuration: &configuration::Configuration, params: GetMarginForceLiquidationRecV1Params) -> Result<models::GetMarginForceLiquidationRecV1Resp, Error<GetMarginForceLiquidationRecV1Error>> {
4464
4465 let uri_str = format!("{}/sapi/v1/margin/forceLiquidationRec", configuration.base_path);
4466 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4467
4468 let mut query_params: Vec<(String, String)> = Vec::new();
4470
4471 if let Some(ref param_value) = params.start_time {
4472 query_params.push(("startTime".to_string(), param_value.to_string()));
4473 }
4474 if let Some(ref param_value) = params.end_time {
4475 query_params.push(("endTime".to_string(), param_value.to_string()));
4476 }
4477 if let Some(ref param_value) = params.isolated_symbol {
4478 query_params.push(("isolatedSymbol".to_string(), param_value.to_string()));
4479 }
4480 if let Some(ref param_value) = params.current {
4481 query_params.push(("current".to_string(), param_value.to_string()));
4482 }
4483 if let Some(ref param_value) = params.size {
4484 query_params.push(("size".to_string(), param_value.to_string()));
4485 }
4486 if let Some(ref param_value) = params.recv_window {
4487 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4488 }
4489 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4490
4491 let mut header_params = std::collections::HashMap::new();
4493
4494 if let Some(ref binance_auth) = configuration.binance_auth {
4496 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4498
4499 let body_string: Option<Vec<u8>> = None;
4501
4502 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4504 Ok(sig) => sig,
4505 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4506 };
4507
4508 query_params.push(("signature".to_string(), signature));
4510 }
4511
4512 if !query_params.is_empty() {
4514 req_builder = req_builder.query(&query_params);
4515 }
4516
4517
4518 if let Some(ref user_agent) = configuration.user_agent {
4520 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4521 }
4522
4523 for (header_name, header_value) in header_params {
4525 req_builder = req_builder.header(&header_name, &header_value);
4526 }
4527
4528
4529 let req = req_builder.build()?;
4530 let resp = configuration.client.execute(req).await?;
4531
4532 let status = resp.status();
4533 let content_type = resp
4534 .headers()
4535 .get("content-type")
4536 .and_then(|v| v.to_str().ok())
4537 .unwrap_or("application/octet-stream");
4538 let content_type = super::ContentType::from(content_type);
4539
4540 if !status.is_client_error() && !status.is_server_error() {
4541 let content = resp.text().await?;
4542 match content_type {
4543 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4544 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginForceLiquidationRecV1Resp`"))),
4545 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::GetMarginForceLiquidationRecV1Resp`")))),
4546 }
4547 } else {
4548 let content = resp.text().await?;
4549 let entity: Option<GetMarginForceLiquidationRecV1Error> = serde_json::from_str(&content).ok();
4550 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4551 }
4552}
4553
4554pub async fn get_margin_interest_history_v1(configuration: &configuration::Configuration, params: GetMarginInterestHistoryV1Params) -> Result<models::GetMarginInterestHistoryV1Resp, Error<GetMarginInterestHistoryV1Error>> {
4556
4557 let uri_str = format!("{}/sapi/v1/margin/interestHistory", configuration.base_path);
4558 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4559
4560 let mut query_params: Vec<(String, String)> = Vec::new();
4562
4563 if let Some(ref param_value) = params.asset {
4564 query_params.push(("asset".to_string(), param_value.to_string()));
4565 }
4566 if let Some(ref param_value) = params.isolated_symbol {
4567 query_params.push(("isolatedSymbol".to_string(), param_value.to_string()));
4568 }
4569 if let Some(ref param_value) = params.start_time {
4570 query_params.push(("startTime".to_string(), param_value.to_string()));
4571 }
4572 if let Some(ref param_value) = params.end_time {
4573 query_params.push(("endTime".to_string(), param_value.to_string()));
4574 }
4575 if let Some(ref param_value) = params.current {
4576 query_params.push(("current".to_string(), param_value.to_string()));
4577 }
4578 if let Some(ref param_value) = params.size {
4579 query_params.push(("size".to_string(), param_value.to_string()));
4580 }
4581 if let Some(ref param_value) = params.recv_window {
4582 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4583 }
4584 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4585
4586 let mut header_params = std::collections::HashMap::new();
4588
4589 if let Some(ref binance_auth) = configuration.binance_auth {
4591 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4593
4594 let body_string: Option<Vec<u8>> = None;
4596
4597 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4599 Ok(sig) => sig,
4600 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4601 };
4602
4603 query_params.push(("signature".to_string(), signature));
4605 }
4606
4607 if !query_params.is_empty() {
4609 req_builder = req_builder.query(&query_params);
4610 }
4611
4612
4613 if let Some(ref user_agent) = configuration.user_agent {
4615 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4616 }
4617
4618 for (header_name, header_value) in header_params {
4620 req_builder = req_builder.header(&header_name, &header_value);
4621 }
4622
4623
4624 let req = req_builder.build()?;
4625 let resp = configuration.client.execute(req).await?;
4626
4627 let status = resp.status();
4628 let content_type = resp
4629 .headers()
4630 .get("content-type")
4631 .and_then(|v| v.to_str().ok())
4632 .unwrap_or("application/octet-stream");
4633 let content_type = super::ContentType::from(content_type);
4634
4635 if !status.is_client_error() && !status.is_server_error() {
4636 let content = resp.text().await?;
4637 match content_type {
4638 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4639 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginInterestHistoryV1Resp`"))),
4640 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::GetMarginInterestHistoryV1Resp`")))),
4641 }
4642 } else {
4643 let content = resp.text().await?;
4644 let entity: Option<GetMarginInterestHistoryV1Error> = serde_json::from_str(&content).ok();
4645 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4646 }
4647}
4648
4649pub async fn get_margin_interest_rate_history_v1(configuration: &configuration::Configuration, params: GetMarginInterestRateHistoryV1Params) -> Result<Vec<models::GetMarginInterestRateHistoryV1RespItem>, Error<GetMarginInterestRateHistoryV1Error>> {
4651
4652 let uri_str = format!("{}/sapi/v1/margin/interestRateHistory", configuration.base_path);
4653 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4654
4655 let mut query_params: Vec<(String, String)> = Vec::new();
4657
4658 query_params.push(("asset".to_string(), params.asset.to_string()));
4659 if let Some(ref param_value) = params.vip_level {
4660 query_params.push(("vipLevel".to_string(), param_value.to_string()));
4661 }
4662 if let Some(ref param_value) = params.start_time {
4663 query_params.push(("startTime".to_string(), param_value.to_string()));
4664 }
4665 if let Some(ref param_value) = params.end_time {
4666 query_params.push(("endTime".to_string(), param_value.to_string()));
4667 }
4668 if let Some(ref param_value) = params.recv_window {
4669 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4670 }
4671 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4672
4673 let mut header_params = std::collections::HashMap::new();
4675
4676 if let Some(ref binance_auth) = configuration.binance_auth {
4678 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4680
4681 let body_string: Option<Vec<u8>> = None;
4683
4684 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4686 Ok(sig) => sig,
4687 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4688 };
4689
4690 query_params.push(("signature".to_string(), signature));
4692 }
4693
4694 if !query_params.is_empty() {
4696 req_builder = req_builder.query(&query_params);
4697 }
4698
4699
4700 if let Some(ref user_agent) = configuration.user_agent {
4702 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4703 }
4704
4705 for (header_name, header_value) in header_params {
4707 req_builder = req_builder.header(&header_name, &header_value);
4708 }
4709
4710
4711 let req = req_builder.build()?;
4712 let resp = configuration.client.execute(req).await?;
4713
4714 let status = resp.status();
4715 let content_type = resp
4716 .headers()
4717 .get("content-type")
4718 .and_then(|v| v.to_str().ok())
4719 .unwrap_or("application/octet-stream");
4720 let content_type = super::ContentType::from(content_type);
4721
4722 if !status.is_client_error() && !status.is_server_error() {
4723 let content = resp.text().await?;
4724 match content_type {
4725 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4726 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginInterestRateHistoryV1RespItem>`"))),
4727 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::GetMarginInterestRateHistoryV1RespItem>`")))),
4728 }
4729 } else {
4730 let content = resp.text().await?;
4731 let entity: Option<GetMarginInterestRateHistoryV1Error> = serde_json::from_str(&content).ok();
4732 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4733 }
4734}
4735
4736pub async fn get_margin_isolated_account_limit_v1(configuration: &configuration::Configuration, params: GetMarginIsolatedAccountLimitV1Params) -> Result<models::GetMarginIsolatedAccountLimitV1Resp, Error<GetMarginIsolatedAccountLimitV1Error>> {
4738
4739 let uri_str = format!("{}/sapi/v1/margin/isolated/accountLimit", configuration.base_path);
4740 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4741
4742 let mut query_params: Vec<(String, String)> = Vec::new();
4744
4745 if let Some(ref param_value) = params.recv_window {
4746 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4747 }
4748 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4749
4750 let mut header_params = std::collections::HashMap::new();
4752
4753 if let Some(ref binance_auth) = configuration.binance_auth {
4755 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4757
4758 let body_string: Option<Vec<u8>> = None;
4760
4761 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4763 Ok(sig) => sig,
4764 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4765 };
4766
4767 query_params.push(("signature".to_string(), signature));
4769 }
4770
4771 if !query_params.is_empty() {
4773 req_builder = req_builder.query(&query_params);
4774 }
4775
4776
4777 if let Some(ref user_agent) = configuration.user_agent {
4779 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4780 }
4781
4782 for (header_name, header_value) in header_params {
4784 req_builder = req_builder.header(&header_name, &header_value);
4785 }
4786
4787
4788 let req = req_builder.build()?;
4789 let resp = configuration.client.execute(req).await?;
4790
4791 let status = resp.status();
4792 let content_type = resp
4793 .headers()
4794 .get("content-type")
4795 .and_then(|v| v.to_str().ok())
4796 .unwrap_or("application/octet-stream");
4797 let content_type = super::ContentType::from(content_type);
4798
4799 if !status.is_client_error() && !status.is_server_error() {
4800 let content = resp.text().await?;
4801 match content_type {
4802 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4803 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginIsolatedAccountLimitV1Resp`"))),
4804 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::GetMarginIsolatedAccountLimitV1Resp`")))),
4805 }
4806 } else {
4807 let content = resp.text().await?;
4808 let entity: Option<GetMarginIsolatedAccountLimitV1Error> = serde_json::from_str(&content).ok();
4809 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4810 }
4811}
4812
4813pub async fn get_margin_isolated_account_v1(configuration: &configuration::Configuration, params: GetMarginIsolatedAccountV1Params) -> Result<models::GetMarginIsolatedAccountV1Resp, Error<GetMarginIsolatedAccountV1Error>> {
4815
4816 let uri_str = format!("{}/sapi/v1/margin/isolated/account", configuration.base_path);
4817 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4818
4819 let mut query_params: Vec<(String, String)> = Vec::new();
4821
4822 if let Some(ref param_value) = params.symbols {
4823 query_params.push(("symbols".to_string(), param_value.to_string()));
4824 }
4825 if let Some(ref param_value) = params.recv_window {
4826 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4827 }
4828 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4829
4830 let mut header_params = std::collections::HashMap::new();
4832
4833 if let Some(ref binance_auth) = configuration.binance_auth {
4835 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4837
4838 let body_string: Option<Vec<u8>> = None;
4840
4841 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4843 Ok(sig) => sig,
4844 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4845 };
4846
4847 query_params.push(("signature".to_string(), signature));
4849 }
4850
4851 if !query_params.is_empty() {
4853 req_builder = req_builder.query(&query_params);
4854 }
4855
4856
4857 if let Some(ref user_agent) = configuration.user_agent {
4859 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4860 }
4861
4862 for (header_name, header_value) in header_params {
4864 req_builder = req_builder.header(&header_name, &header_value);
4865 }
4866
4867
4868 let req = req_builder.build()?;
4869 let resp = configuration.client.execute(req).await?;
4870
4871 let status = resp.status();
4872 let content_type = resp
4873 .headers()
4874 .get("content-type")
4875 .and_then(|v| v.to_str().ok())
4876 .unwrap_or("application/octet-stream");
4877 let content_type = super::ContentType::from(content_type);
4878
4879 if !status.is_client_error() && !status.is_server_error() {
4880 let content = resp.text().await?;
4881 match content_type {
4882 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4883 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginIsolatedAccountV1Resp`"))),
4884 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::GetMarginIsolatedAccountV1Resp`")))),
4885 }
4886 } else {
4887 let content = resp.text().await?;
4888 let entity: Option<GetMarginIsolatedAccountV1Error> = serde_json::from_str(&content).ok();
4889 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4890 }
4891}
4892
4893pub async fn get_margin_isolated_all_pairs_v1(configuration: &configuration::Configuration, params: GetMarginIsolatedAllPairsV1Params) -> Result<Vec<models::GetMarginIsolatedAllPairsV1RespItem>, Error<GetMarginIsolatedAllPairsV1Error>> {
4895
4896 let uri_str = format!("{}/sapi/v1/margin/isolated/allPairs", configuration.base_path);
4897 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4898
4899 let mut query_params: Vec<(String, String)> = Vec::new();
4901
4902 if let Some(ref param_value) = params.symbol {
4903 query_params.push(("symbol".to_string(), param_value.to_string()));
4904 }
4905 if let Some(ref param_value) = params.recv_window {
4906 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4907 }
4908 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4909
4910 let mut header_params = std::collections::HashMap::new();
4912
4913 if let Some(ref binance_auth) = configuration.binance_auth {
4915 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4917
4918 let body_string: Option<Vec<u8>> = None;
4920
4921 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4923 Ok(sig) => sig,
4924 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4925 };
4926
4927 query_params.push(("signature".to_string(), signature));
4929 }
4930
4931 if !query_params.is_empty() {
4933 req_builder = req_builder.query(&query_params);
4934 }
4935
4936
4937 if let Some(ref user_agent) = configuration.user_agent {
4939 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4940 }
4941
4942 for (header_name, header_value) in header_params {
4944 req_builder = req_builder.header(&header_name, &header_value);
4945 }
4946
4947
4948 let req = req_builder.build()?;
4949 let resp = configuration.client.execute(req).await?;
4950
4951 let status = resp.status();
4952 let content_type = resp
4953 .headers()
4954 .get("content-type")
4955 .and_then(|v| v.to_str().ok())
4956 .unwrap_or("application/octet-stream");
4957 let content_type = super::ContentType::from(content_type);
4958
4959 if !status.is_client_error() && !status.is_server_error() {
4960 let content = resp.text().await?;
4961 match content_type {
4962 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4963 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginIsolatedAllPairsV1RespItem>`"))),
4964 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::GetMarginIsolatedAllPairsV1RespItem>`")))),
4965 }
4966 } else {
4967 let content = resp.text().await?;
4968 let entity: Option<GetMarginIsolatedAllPairsV1Error> = serde_json::from_str(&content).ok();
4969 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4970 }
4971}
4972
4973pub async fn get_margin_isolated_margin_data_v1(configuration: &configuration::Configuration, params: GetMarginIsolatedMarginDataV1Params) -> Result<Vec<models::GetMarginIsolatedMarginDataV1RespItem>, Error<GetMarginIsolatedMarginDataV1Error>> {
4975
4976 let uri_str = format!("{}/sapi/v1/margin/isolatedMarginData", configuration.base_path);
4977 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4978
4979 let mut query_params: Vec<(String, String)> = Vec::new();
4981
4982 if let Some(ref param_value) = params.vip_level {
4983 query_params.push(("vipLevel".to_string(), param_value.to_string()));
4984 }
4985 if let Some(ref param_value) = params.symbol {
4986 query_params.push(("symbol".to_string(), param_value.to_string()));
4987 }
4988 if let Some(ref param_value) = params.recv_window {
4989 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4990 }
4991 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4992
4993 let mut header_params = std::collections::HashMap::new();
4995
4996 if let Some(ref binance_auth) = configuration.binance_auth {
4998 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5000
5001 let body_string: Option<Vec<u8>> = None;
5003
5004 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5006 Ok(sig) => sig,
5007 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5008 };
5009
5010 query_params.push(("signature".to_string(), signature));
5012 }
5013
5014 if !query_params.is_empty() {
5016 req_builder = req_builder.query(&query_params);
5017 }
5018
5019
5020 if let Some(ref user_agent) = configuration.user_agent {
5022 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5023 }
5024
5025 for (header_name, header_value) in header_params {
5027 req_builder = req_builder.header(&header_name, &header_value);
5028 }
5029
5030
5031 let req = req_builder.build()?;
5032 let resp = configuration.client.execute(req).await?;
5033
5034 let status = resp.status();
5035 let content_type = resp
5036 .headers()
5037 .get("content-type")
5038 .and_then(|v| v.to_str().ok())
5039 .unwrap_or("application/octet-stream");
5040 let content_type = super::ContentType::from(content_type);
5041
5042 if !status.is_client_error() && !status.is_server_error() {
5043 let content = resp.text().await?;
5044 match content_type {
5045 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5046 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginIsolatedMarginDataV1RespItem>`"))),
5047 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::GetMarginIsolatedMarginDataV1RespItem>`")))),
5048 }
5049 } else {
5050 let content = resp.text().await?;
5051 let entity: Option<GetMarginIsolatedMarginDataV1Error> = serde_json::from_str(&content).ok();
5052 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5053 }
5054}
5055
5056pub async fn get_margin_isolated_margin_tier_v1(configuration: &configuration::Configuration, params: GetMarginIsolatedMarginTierV1Params) -> Result<Vec<models::GetMarginIsolatedMarginTierV1RespItem>, Error<GetMarginIsolatedMarginTierV1Error>> {
5058
5059 let uri_str = format!("{}/sapi/v1/margin/isolatedMarginTier", configuration.base_path);
5060 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5061
5062 let mut query_params: Vec<(String, String)> = Vec::new();
5064
5065 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5066 if let Some(ref param_value) = params.tier {
5067 query_params.push(("tier".to_string(), param_value.to_string()));
5068 }
5069 if let Some(ref param_value) = params.recv_window {
5070 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5071 }
5072 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5073
5074 let mut header_params = std::collections::HashMap::new();
5076
5077 if let Some(ref binance_auth) = configuration.binance_auth {
5079 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5081
5082 let body_string: Option<Vec<u8>> = None;
5084
5085 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5087 Ok(sig) => sig,
5088 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5089 };
5090
5091 query_params.push(("signature".to_string(), signature));
5093 }
5094
5095 if !query_params.is_empty() {
5097 req_builder = req_builder.query(&query_params);
5098 }
5099
5100
5101 if let Some(ref user_agent) = configuration.user_agent {
5103 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5104 }
5105
5106 for (header_name, header_value) in header_params {
5108 req_builder = req_builder.header(&header_name, &header_value);
5109 }
5110
5111
5112 let req = req_builder.build()?;
5113 let resp = configuration.client.execute(req).await?;
5114
5115 let status = resp.status();
5116 let content_type = resp
5117 .headers()
5118 .get("content-type")
5119 .and_then(|v| v.to_str().ok())
5120 .unwrap_or("application/octet-stream");
5121 let content_type = super::ContentType::from(content_type);
5122
5123 if !status.is_client_error() && !status.is_server_error() {
5124 let content = resp.text().await?;
5125 match content_type {
5126 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5127 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginIsolatedMarginTierV1RespItem>`"))),
5128 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::GetMarginIsolatedMarginTierV1RespItem>`")))),
5129 }
5130 } else {
5131 let content = resp.text().await?;
5132 let entity: Option<GetMarginIsolatedMarginTierV1Error> = serde_json::from_str(&content).ok();
5133 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5134 }
5135}
5136
5137pub async fn get_margin_leverage_bracket_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetMarginLeverageBracketV1RespItem>, Error<GetMarginLeverageBracketV1Error>> {
5139
5140 let uri_str = format!("{}/sapi/v1/margin/leverageBracket", configuration.base_path);
5141 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5142
5143 let mut query_params: Vec<(String, String)> = Vec::new();
5145
5146
5147 let mut header_params = std::collections::HashMap::new();
5149
5150 if let Some(ref binance_auth) = configuration.binance_auth {
5152 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5154
5155 let body_string: Option<Vec<u8>> = None;
5157
5158 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5160 Ok(sig) => sig,
5161 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5162 };
5163
5164 query_params.push(("signature".to_string(), signature));
5166 }
5167
5168 if !query_params.is_empty() {
5170 req_builder = req_builder.query(&query_params);
5171 }
5172
5173
5174 if let Some(ref user_agent) = configuration.user_agent {
5176 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5177 }
5178
5179 for (header_name, header_value) in header_params {
5181 req_builder = req_builder.header(&header_name, &header_value);
5182 }
5183
5184
5185 let req = req_builder.build()?;
5186 let resp = configuration.client.execute(req).await?;
5187
5188 let status = resp.status();
5189 let content_type = resp
5190 .headers()
5191 .get("content-type")
5192 .and_then(|v| v.to_str().ok())
5193 .unwrap_or("application/octet-stream");
5194 let content_type = super::ContentType::from(content_type);
5195
5196 if !status.is_client_error() && !status.is_server_error() {
5197 let content = resp.text().await?;
5198 match content_type {
5199 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5200 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginLeverageBracketV1RespItem>`"))),
5201 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::GetMarginLeverageBracketV1RespItem>`")))),
5202 }
5203 } else {
5204 let content = resp.text().await?;
5205 let entity: Option<GetMarginLeverageBracketV1Error> = serde_json::from_str(&content).ok();
5206 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5207 }
5208}
5209
5210pub async fn get_margin_max_borrowable_v1(configuration: &configuration::Configuration, params: GetMarginMaxBorrowableV1Params) -> Result<models::GetMarginMaxBorrowableV1Resp, Error<GetMarginMaxBorrowableV1Error>> {
5212
5213 let uri_str = format!("{}/sapi/v1/margin/maxBorrowable", configuration.base_path);
5214 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5215
5216 let mut query_params: Vec<(String, String)> = Vec::new();
5218
5219 query_params.push(("asset".to_string(), params.asset.to_string()));
5220 if let Some(ref param_value) = params.isolated_symbol {
5221 query_params.push(("isolatedSymbol".to_string(), param_value.to_string()));
5222 }
5223 if let Some(ref param_value) = params.recv_window {
5224 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5225 }
5226 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5227
5228 let mut header_params = std::collections::HashMap::new();
5230
5231 if let Some(ref binance_auth) = configuration.binance_auth {
5233 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5235
5236 let body_string: Option<Vec<u8>> = None;
5238
5239 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5241 Ok(sig) => sig,
5242 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5243 };
5244
5245 query_params.push(("signature".to_string(), signature));
5247 }
5248
5249 if !query_params.is_empty() {
5251 req_builder = req_builder.query(&query_params);
5252 }
5253
5254
5255 if let Some(ref user_agent) = configuration.user_agent {
5257 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5258 }
5259
5260 for (header_name, header_value) in header_params {
5262 req_builder = req_builder.header(&header_name, &header_value);
5263 }
5264
5265
5266 let req = req_builder.build()?;
5267 let resp = configuration.client.execute(req).await?;
5268
5269 let status = resp.status();
5270 let content_type = resp
5271 .headers()
5272 .get("content-type")
5273 .and_then(|v| v.to_str().ok())
5274 .unwrap_or("application/octet-stream");
5275 let content_type = super::ContentType::from(content_type);
5276
5277 if !status.is_client_error() && !status.is_server_error() {
5278 let content = resp.text().await?;
5279 match content_type {
5280 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5281 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginMaxBorrowableV1Resp`"))),
5282 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::GetMarginMaxBorrowableV1Resp`")))),
5283 }
5284 } else {
5285 let content = resp.text().await?;
5286 let entity: Option<GetMarginMaxBorrowableV1Error> = serde_json::from_str(&content).ok();
5287 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5288 }
5289}
5290
5291pub async fn get_margin_max_transferable_v1(configuration: &configuration::Configuration, params: GetMarginMaxTransferableV1Params) -> Result<models::GetMarginMaxTransferableV1Resp, Error<GetMarginMaxTransferableV1Error>> {
5293
5294 let uri_str = format!("{}/sapi/v1/margin/maxTransferable", configuration.base_path);
5295 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5296
5297 let mut query_params: Vec<(String, String)> = Vec::new();
5299
5300 query_params.push(("asset".to_string(), params.asset.to_string()));
5301 if let Some(ref param_value) = params.isolated_symbol {
5302 query_params.push(("isolatedSymbol".to_string(), param_value.to_string()));
5303 }
5304 if let Some(ref param_value) = params.recv_window {
5305 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5306 }
5307 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5308
5309 let mut header_params = std::collections::HashMap::new();
5311
5312 if let Some(ref binance_auth) = configuration.binance_auth {
5314 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5316
5317 let body_string: Option<Vec<u8>> = None;
5319
5320 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5322 Ok(sig) => sig,
5323 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5324 };
5325
5326 query_params.push(("signature".to_string(), signature));
5328 }
5329
5330 if !query_params.is_empty() {
5332 req_builder = req_builder.query(&query_params);
5333 }
5334
5335
5336 if let Some(ref user_agent) = configuration.user_agent {
5338 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5339 }
5340
5341 for (header_name, header_value) in header_params {
5343 req_builder = req_builder.header(&header_name, &header_value);
5344 }
5345
5346
5347 let req = req_builder.build()?;
5348 let resp = configuration.client.execute(req).await?;
5349
5350 let status = resp.status();
5351 let content_type = resp
5352 .headers()
5353 .get("content-type")
5354 .and_then(|v| v.to_str().ok())
5355 .unwrap_or("application/octet-stream");
5356 let content_type = super::ContentType::from(content_type);
5357
5358 if !status.is_client_error() && !status.is_server_error() {
5359 let content = resp.text().await?;
5360 match content_type {
5361 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5362 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginMaxTransferableV1Resp`"))),
5363 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::GetMarginMaxTransferableV1Resp`")))),
5364 }
5365 } else {
5366 let content = resp.text().await?;
5367 let entity: Option<GetMarginMaxTransferableV1Error> = serde_json::from_str(&content).ok();
5368 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5369 }
5370}
5371
5372pub async fn get_margin_my_trades_v1(configuration: &configuration::Configuration, params: GetMarginMyTradesV1Params) -> Result<Vec<models::GetMarginMyTradesV1RespItem>, Error<GetMarginMyTradesV1Error>> {
5374
5375 let uri_str = format!("{}/sapi/v1/margin/myTrades", configuration.base_path);
5376 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5377
5378 let mut query_params: Vec<(String, String)> = Vec::new();
5380
5381 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5382 if let Some(ref param_value) = params.is_isolated {
5383 query_params.push(("isIsolated".to_string(), param_value.to_string()));
5384 }
5385 if let Some(ref param_value) = params.order_id {
5386 query_params.push(("orderId".to_string(), param_value.to_string()));
5387 }
5388 if let Some(ref param_value) = params.start_time {
5389 query_params.push(("startTime".to_string(), param_value.to_string()));
5390 }
5391 if let Some(ref param_value) = params.end_time {
5392 query_params.push(("endTime".to_string(), param_value.to_string()));
5393 }
5394 if let Some(ref param_value) = params.from_id {
5395 query_params.push(("fromId".to_string(), param_value.to_string()));
5396 }
5397 if let Some(ref param_value) = params.limit {
5398 query_params.push(("limit".to_string(), param_value.to_string()));
5399 }
5400 if let Some(ref param_value) = params.recv_window {
5401 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5402 }
5403 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5404
5405 let mut header_params = std::collections::HashMap::new();
5407
5408 if let Some(ref binance_auth) = configuration.binance_auth {
5410 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5412
5413 let body_string: Option<Vec<u8>> = None;
5415
5416 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5418 Ok(sig) => sig,
5419 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5420 };
5421
5422 query_params.push(("signature".to_string(), signature));
5424 }
5425
5426 if !query_params.is_empty() {
5428 req_builder = req_builder.query(&query_params);
5429 }
5430
5431
5432 if let Some(ref user_agent) = configuration.user_agent {
5434 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5435 }
5436
5437 for (header_name, header_value) in header_params {
5439 req_builder = req_builder.header(&header_name, &header_value);
5440 }
5441
5442
5443 let req = req_builder.build()?;
5444 let resp = configuration.client.execute(req).await?;
5445
5446 let status = resp.status();
5447 let content_type = resp
5448 .headers()
5449 .get("content-type")
5450 .and_then(|v| v.to_str().ok())
5451 .unwrap_or("application/octet-stream");
5452 let content_type = super::ContentType::from(content_type);
5453
5454 if !status.is_client_error() && !status.is_server_error() {
5455 let content = resp.text().await?;
5456 match content_type {
5457 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5458 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginMyTradesV1RespItem>`"))),
5459 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::GetMarginMyTradesV1RespItem>`")))),
5460 }
5461 } else {
5462 let content = resp.text().await?;
5463 let entity: Option<GetMarginMyTradesV1Error> = serde_json::from_str(&content).ok();
5464 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5465 }
5466}
5467
5468pub async fn get_margin_next_hourly_interest_rate_v1(configuration: &configuration::Configuration, params: GetMarginNextHourlyInterestRateV1Params) -> Result<Vec<models::GetMarginNextHourlyInterestRateV1RespItem>, Error<GetMarginNextHourlyInterestRateV1Error>> {
5470
5471 let uri_str = format!("{}/sapi/v1/margin/next-hourly-interest-rate", configuration.base_path);
5472 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5473
5474 let mut query_params: Vec<(String, String)> = Vec::new();
5476
5477 query_params.push(("assets".to_string(), params.assets.to_string()));
5478 query_params.push(("isIsolated".to_string(), params.is_isolated.to_string()));
5479
5480 let mut header_params = std::collections::HashMap::new();
5482
5483 if let Some(ref binance_auth) = configuration.binance_auth {
5485 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5487
5488 let body_string: Option<Vec<u8>> = None;
5490
5491 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5493 Ok(sig) => sig,
5494 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5495 };
5496
5497 query_params.push(("signature".to_string(), signature));
5499 }
5500
5501 if !query_params.is_empty() {
5503 req_builder = req_builder.query(&query_params);
5504 }
5505
5506
5507 if let Some(ref user_agent) = configuration.user_agent {
5509 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5510 }
5511
5512 for (header_name, header_value) in header_params {
5514 req_builder = req_builder.header(&header_name, &header_value);
5515 }
5516
5517
5518 let req = req_builder.build()?;
5519 let resp = configuration.client.execute(req).await?;
5520
5521 let status = resp.status();
5522 let content_type = resp
5523 .headers()
5524 .get("content-type")
5525 .and_then(|v| v.to_str().ok())
5526 .unwrap_or("application/octet-stream");
5527 let content_type = super::ContentType::from(content_type);
5528
5529 if !status.is_client_error() && !status.is_server_error() {
5530 let content = resp.text().await?;
5531 match content_type {
5532 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5533 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginNextHourlyInterestRateV1RespItem>`"))),
5534 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::GetMarginNextHourlyInterestRateV1RespItem>`")))),
5535 }
5536 } else {
5537 let content = resp.text().await?;
5538 let entity: Option<GetMarginNextHourlyInterestRateV1Error> = serde_json::from_str(&content).ok();
5539 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5540 }
5541}
5542
5543pub async fn get_margin_open_order_list_v1(configuration: &configuration::Configuration, params: GetMarginOpenOrderListV1Params) -> Result<Vec<models::GetMarginOpenOrderListV1RespItem>, Error<GetMarginOpenOrderListV1Error>> {
5545
5546 let uri_str = format!("{}/sapi/v1/margin/openOrderList", configuration.base_path);
5547 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5548
5549 let mut query_params: Vec<(String, String)> = Vec::new();
5551
5552 if let Some(ref param_value) = params.is_isolated {
5553 query_params.push(("isIsolated".to_string(), param_value.to_string()));
5554 }
5555 if let Some(ref param_value) = params.symbol {
5556 query_params.push(("symbol".to_string(), param_value.to_string()));
5557 }
5558 if let Some(ref param_value) = params.recv_window {
5559 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5560 }
5561 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5562
5563 let mut header_params = std::collections::HashMap::new();
5565
5566 if let Some(ref binance_auth) = configuration.binance_auth {
5568 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5570
5571 let body_string: Option<Vec<u8>> = None;
5573
5574 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5576 Ok(sig) => sig,
5577 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5578 };
5579
5580 query_params.push(("signature".to_string(), signature));
5582 }
5583
5584 if !query_params.is_empty() {
5586 req_builder = req_builder.query(&query_params);
5587 }
5588
5589
5590 if let Some(ref user_agent) = configuration.user_agent {
5592 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5593 }
5594
5595 for (header_name, header_value) in header_params {
5597 req_builder = req_builder.header(&header_name, &header_value);
5598 }
5599
5600
5601 let req = req_builder.build()?;
5602 let resp = configuration.client.execute(req).await?;
5603
5604 let status = resp.status();
5605 let content_type = resp
5606 .headers()
5607 .get("content-type")
5608 .and_then(|v| v.to_str().ok())
5609 .unwrap_or("application/octet-stream");
5610 let content_type = super::ContentType::from(content_type);
5611
5612 if !status.is_client_error() && !status.is_server_error() {
5613 let content = resp.text().await?;
5614 match content_type {
5615 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5616 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginOpenOrderListV1RespItem>`"))),
5617 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::GetMarginOpenOrderListV1RespItem>`")))),
5618 }
5619 } else {
5620 let content = resp.text().await?;
5621 let entity: Option<GetMarginOpenOrderListV1Error> = serde_json::from_str(&content).ok();
5622 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5623 }
5624}
5625
5626pub async fn get_margin_open_orders_v1(configuration: &configuration::Configuration, params: GetMarginOpenOrdersV1Params) -> Result<Vec<models::MarginGetMarginOpenOrdersV1RespItem>, Error<GetMarginOpenOrdersV1Error>> {
5628
5629 let uri_str = format!("{}/sapi/v1/margin/openOrders", configuration.base_path);
5630 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5631
5632 let mut query_params: Vec<(String, String)> = Vec::new();
5634
5635 if let Some(ref param_value) = params.symbol {
5636 query_params.push(("symbol".to_string(), param_value.to_string()));
5637 }
5638 if let Some(ref param_value) = params.is_isolated {
5639 query_params.push(("isIsolated".to_string(), param_value.to_string()));
5640 }
5641 if let Some(ref param_value) = params.recv_window {
5642 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5643 }
5644 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5645
5646 let mut header_params = std::collections::HashMap::new();
5648
5649 if let Some(ref binance_auth) = configuration.binance_auth {
5651 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5653
5654 let body_string: Option<Vec<u8>> = None;
5656
5657 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5659 Ok(sig) => sig,
5660 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5661 };
5662
5663 query_params.push(("signature".to_string(), signature));
5665 }
5666
5667 if !query_params.is_empty() {
5669 req_builder = req_builder.query(&query_params);
5670 }
5671
5672
5673 if let Some(ref user_agent) = configuration.user_agent {
5675 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5676 }
5677
5678 for (header_name, header_value) in header_params {
5680 req_builder = req_builder.header(&header_name, &header_value);
5681 }
5682
5683
5684 let req = req_builder.build()?;
5685 let resp = configuration.client.execute(req).await?;
5686
5687 let status = resp.status();
5688 let content_type = resp
5689 .headers()
5690 .get("content-type")
5691 .and_then(|v| v.to_str().ok())
5692 .unwrap_or("application/octet-stream");
5693 let content_type = super::ContentType::from(content_type);
5694
5695 if !status.is_client_error() && !status.is_server_error() {
5696 let content = resp.text().await?;
5697 match content_type {
5698 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5699 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::MarginGetMarginOpenOrdersV1RespItem>`"))),
5700 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::MarginGetMarginOpenOrdersV1RespItem>`")))),
5701 }
5702 } else {
5703 let content = resp.text().await?;
5704 let entity: Option<GetMarginOpenOrdersV1Error> = serde_json::from_str(&content).ok();
5705 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5706 }
5707}
5708
5709pub async fn get_margin_order_list_v1(configuration: &configuration::Configuration, params: GetMarginOrderListV1Params) -> Result<models::GetMarginOrderListV1Resp, Error<GetMarginOrderListV1Error>> {
5711
5712 let uri_str = format!("{}/sapi/v1/margin/orderList", configuration.base_path);
5713 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5714
5715 let mut query_params: Vec<(String, String)> = Vec::new();
5717
5718 if let Some(ref param_value) = params.is_isolated {
5719 query_params.push(("isIsolated".to_string(), param_value.to_string()));
5720 }
5721 if let Some(ref param_value) = params.symbol {
5722 query_params.push(("symbol".to_string(), param_value.to_string()));
5723 }
5724 if let Some(ref param_value) = params.order_list_id {
5725 query_params.push(("orderListId".to_string(), param_value.to_string()));
5726 }
5727 if let Some(ref param_value) = params.orig_client_order_id {
5728 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
5729 }
5730 if let Some(ref param_value) = params.recv_window {
5731 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5732 }
5733 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5734
5735 let mut header_params = std::collections::HashMap::new();
5737
5738 if let Some(ref binance_auth) = configuration.binance_auth {
5740 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5742
5743 let body_string: Option<Vec<u8>> = None;
5745
5746 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5748 Ok(sig) => sig,
5749 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5750 };
5751
5752 query_params.push(("signature".to_string(), signature));
5754 }
5755
5756 if !query_params.is_empty() {
5758 req_builder = req_builder.query(&query_params);
5759 }
5760
5761
5762 if let Some(ref user_agent) = configuration.user_agent {
5764 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5765 }
5766
5767 for (header_name, header_value) in header_params {
5769 req_builder = req_builder.header(&header_name, &header_value);
5770 }
5771
5772
5773 let req = req_builder.build()?;
5774 let resp = configuration.client.execute(req).await?;
5775
5776 let status = resp.status();
5777 let content_type = resp
5778 .headers()
5779 .get("content-type")
5780 .and_then(|v| v.to_str().ok())
5781 .unwrap_or("application/octet-stream");
5782 let content_type = super::ContentType::from(content_type);
5783
5784 if !status.is_client_error() && !status.is_server_error() {
5785 let content = resp.text().await?;
5786 match content_type {
5787 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5788 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginOrderListV1Resp`"))),
5789 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::GetMarginOrderListV1Resp`")))),
5790 }
5791 } else {
5792 let content = resp.text().await?;
5793 let entity: Option<GetMarginOrderListV1Error> = serde_json::from_str(&content).ok();
5794 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5795 }
5796}
5797
5798pub async fn get_margin_order_v1(configuration: &configuration::Configuration, params: GetMarginOrderV1Params) -> Result<models::GetMarginOrderV1Resp, Error<GetMarginOrderV1Error>> {
5800
5801 let uri_str = format!("{}/sapi/v1/margin/order", configuration.base_path);
5802 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5803
5804 let mut query_params: Vec<(String, String)> = Vec::new();
5806
5807 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5808 if let Some(ref param_value) = params.is_isolated {
5809 query_params.push(("isIsolated".to_string(), param_value.to_string()));
5810 }
5811 if let Some(ref param_value) = params.order_id {
5812 query_params.push(("orderId".to_string(), param_value.to_string()));
5813 }
5814 if let Some(ref param_value) = params.orig_client_order_id {
5815 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
5816 }
5817 if let Some(ref param_value) = params.recv_window {
5818 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5819 }
5820 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5821
5822 let mut header_params = std::collections::HashMap::new();
5824
5825 if let Some(ref binance_auth) = configuration.binance_auth {
5827 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5829
5830 let body_string: Option<Vec<u8>> = None;
5832
5833 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5835 Ok(sig) => sig,
5836 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5837 };
5838
5839 query_params.push(("signature".to_string(), signature));
5841 }
5842
5843 if !query_params.is_empty() {
5845 req_builder = req_builder.query(&query_params);
5846 }
5847
5848
5849 if let Some(ref user_agent) = configuration.user_agent {
5851 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5852 }
5853
5854 for (header_name, header_value) in header_params {
5856 req_builder = req_builder.header(&header_name, &header_value);
5857 }
5858
5859
5860 let req = req_builder.build()?;
5861 let resp = configuration.client.execute(req).await?;
5862
5863 let status = resp.status();
5864 let content_type = resp
5865 .headers()
5866 .get("content-type")
5867 .and_then(|v| v.to_str().ok())
5868 .unwrap_or("application/octet-stream");
5869 let content_type = super::ContentType::from(content_type);
5870
5871 if !status.is_client_error() && !status.is_server_error() {
5872 let content = resp.text().await?;
5873 match content_type {
5874 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5875 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginOrderV1Resp`"))),
5876 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::GetMarginOrderV1Resp`")))),
5877 }
5878 } else {
5879 let content = resp.text().await?;
5880 let entity: Option<GetMarginOrderV1Error> = serde_json::from_str(&content).ok();
5881 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5882 }
5883}
5884
5885pub async fn get_margin_price_index_v1(configuration: &configuration::Configuration, params: GetMarginPriceIndexV1Params) -> Result<models::GetMarginPriceIndexV1Resp, Error<GetMarginPriceIndexV1Error>> {
5887
5888 let uri_str = format!("{}/sapi/v1/margin/priceIndex", configuration.base_path);
5889 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5890
5891 let mut query_params: Vec<(String, String)> = Vec::new();
5893
5894 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5895
5896 let mut header_params = std::collections::HashMap::new();
5898
5899 if let Some(ref binance_auth) = configuration.binance_auth {
5901 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5903
5904 let body_string: Option<Vec<u8>> = None;
5906
5907 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5909 Ok(sig) => sig,
5910 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5911 };
5912
5913 query_params.push(("signature".to_string(), signature));
5915 }
5916
5917 if !query_params.is_empty() {
5919 req_builder = req_builder.query(&query_params);
5920 }
5921
5922
5923 if let Some(ref user_agent) = configuration.user_agent {
5925 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5926 }
5927
5928 for (header_name, header_value) in header_params {
5930 req_builder = req_builder.header(&header_name, &header_value);
5931 }
5932
5933
5934 let req = req_builder.build()?;
5935 let resp = configuration.client.execute(req).await?;
5936
5937 let status = resp.status();
5938 let content_type = resp
5939 .headers()
5940 .get("content-type")
5941 .and_then(|v| v.to_str().ok())
5942 .unwrap_or("application/octet-stream");
5943 let content_type = super::ContentType::from(content_type);
5944
5945 if !status.is_client_error() && !status.is_server_error() {
5946 let content = resp.text().await?;
5947 match content_type {
5948 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5949 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginPriceIndexV1Resp`"))),
5950 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::GetMarginPriceIndexV1Resp`")))),
5951 }
5952 } else {
5953 let content = resp.text().await?;
5954 let entity: Option<GetMarginPriceIndexV1Error> = serde_json::from_str(&content).ok();
5955 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5956 }
5957}
5958
5959pub async fn get_margin_rate_limit_order_v1(configuration: &configuration::Configuration, params: GetMarginRateLimitOrderV1Params) -> Result<Vec<models::GetMarginRateLimitOrderV1RespItem>, Error<GetMarginRateLimitOrderV1Error>> {
5961
5962 let uri_str = format!("{}/sapi/v1/margin/rateLimit/order", configuration.base_path);
5963 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5964
5965 let mut query_params: Vec<(String, String)> = Vec::new();
5967
5968 if let Some(ref param_value) = params.is_isolated {
5969 query_params.push(("isIsolated".to_string(), param_value.to_string()));
5970 }
5971 if let Some(ref param_value) = params.symbol {
5972 query_params.push(("symbol".to_string(), param_value.to_string()));
5973 }
5974 if let Some(ref param_value) = params.recv_window {
5975 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5976 }
5977 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5978
5979 let mut header_params = std::collections::HashMap::new();
5981
5982 if let Some(ref binance_auth) = configuration.binance_auth {
5984 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5986
5987 let body_string: Option<Vec<u8>> = None;
5989
5990 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5992 Ok(sig) => sig,
5993 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5994 };
5995
5996 query_params.push(("signature".to_string(), signature));
5998 }
5999
6000 if !query_params.is_empty() {
6002 req_builder = req_builder.query(&query_params);
6003 }
6004
6005
6006 if let Some(ref user_agent) = configuration.user_agent {
6008 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6009 }
6010
6011 for (header_name, header_value) in header_params {
6013 req_builder = req_builder.header(&header_name, &header_value);
6014 }
6015
6016
6017 let req = req_builder.build()?;
6018 let resp = configuration.client.execute(req).await?;
6019
6020 let status = resp.status();
6021 let content_type = resp
6022 .headers()
6023 .get("content-type")
6024 .and_then(|v| v.to_str().ok())
6025 .unwrap_or("application/octet-stream");
6026 let content_type = super::ContentType::from(content_type);
6027
6028 if !status.is_client_error() && !status.is_server_error() {
6029 let content = resp.text().await?;
6030 match content_type {
6031 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6032 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarginRateLimitOrderV1RespItem>`"))),
6033 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::GetMarginRateLimitOrderV1RespItem>`")))),
6034 }
6035 } else {
6036 let content = resp.text().await?;
6037 let entity: Option<GetMarginRateLimitOrderV1Error> = serde_json::from_str(&content).ok();
6038 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6039 }
6040}
6041
6042pub async fn get_margin_trade_coeff_v1(configuration: &configuration::Configuration, params: GetMarginTradeCoeffV1Params) -> Result<models::GetMarginTradeCoeffV1Resp, Error<GetMarginTradeCoeffV1Error>> {
6044
6045 let uri_str = format!("{}/sapi/v1/margin/tradeCoeff", configuration.base_path);
6046 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6047
6048 let mut query_params: Vec<(String, String)> = Vec::new();
6050
6051 if let Some(ref param_value) = params.recv_window {
6052 query_params.push(("recvWindow".to_string(), param_value.to_string()));
6053 }
6054 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6055
6056 let mut header_params = std::collections::HashMap::new();
6058
6059 if let Some(ref binance_auth) = configuration.binance_auth {
6061 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6063
6064 let body_string: Option<Vec<u8>> = None;
6066
6067 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6069 Ok(sig) => sig,
6070 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6071 };
6072
6073 query_params.push(("signature".to_string(), signature));
6075 }
6076
6077 if !query_params.is_empty() {
6079 req_builder = req_builder.query(&query_params);
6080 }
6081
6082
6083 if let Some(ref user_agent) = configuration.user_agent {
6085 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6086 }
6087
6088 for (header_name, header_value) in header_params {
6090 req_builder = req_builder.header(&header_name, &header_value);
6091 }
6092
6093
6094 let req = req_builder.build()?;
6095 let resp = configuration.client.execute(req).await?;
6096
6097 let status = resp.status();
6098 let content_type = resp
6099 .headers()
6100 .get("content-type")
6101 .and_then(|v| v.to_str().ok())
6102 .unwrap_or("application/octet-stream");
6103 let content_type = super::ContentType::from(content_type);
6104
6105 if !status.is_client_error() && !status.is_server_error() {
6106 let content = resp.text().await?;
6107 match content_type {
6108 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6109 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginTradeCoeffV1Resp`"))),
6110 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::GetMarginTradeCoeffV1Resp`")))),
6111 }
6112 } else {
6113 let content = resp.text().await?;
6114 let entity: Option<GetMarginTradeCoeffV1Error> = serde_json::from_str(&content).ok();
6115 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6116 }
6117}
6118
6119pub async fn get_margin_transfer_v1(configuration: &configuration::Configuration, params: GetMarginTransferV1Params) -> Result<models::GetMarginTransferV1Resp, Error<GetMarginTransferV1Error>> {
6121
6122 let uri_str = format!("{}/sapi/v1/margin/transfer", configuration.base_path);
6123 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6124
6125 let mut query_params: Vec<(String, String)> = Vec::new();
6127
6128 if let Some(ref param_value) = params.asset {
6129 query_params.push(("asset".to_string(), param_value.to_string()));
6130 }
6131 if let Some(ref param_value) = params.r#type {
6132 query_params.push(("type".to_string(), param_value.to_string()));
6133 }
6134 if let Some(ref param_value) = params.start_time {
6135 query_params.push(("startTime".to_string(), param_value.to_string()));
6136 }
6137 if let Some(ref param_value) = params.end_time {
6138 query_params.push(("endTime".to_string(), param_value.to_string()));
6139 }
6140 if let Some(ref param_value) = params.current {
6141 query_params.push(("current".to_string(), param_value.to_string()));
6142 }
6143 if let Some(ref param_value) = params.size {
6144 query_params.push(("size".to_string(), param_value.to_string()));
6145 }
6146 if let Some(ref param_value) = params.isolated_symbol {
6147 query_params.push(("isolatedSymbol".to_string(), param_value.to_string()));
6148 }
6149 if let Some(ref param_value) = params.recv_window {
6150 query_params.push(("recvWindow".to_string(), param_value.to_string()));
6151 }
6152 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6153
6154 let mut header_params = std::collections::HashMap::new();
6156
6157 if let Some(ref binance_auth) = configuration.binance_auth {
6159 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6161
6162 let body_string: Option<Vec<u8>> = None;
6164
6165 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6167 Ok(sig) => sig,
6168 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6169 };
6170
6171 query_params.push(("signature".to_string(), signature));
6173 }
6174
6175 if !query_params.is_empty() {
6177 req_builder = req_builder.query(&query_params);
6178 }
6179
6180
6181 if let Some(ref user_agent) = configuration.user_agent {
6183 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6184 }
6185
6186 for (header_name, header_value) in header_params {
6188 req_builder = req_builder.header(&header_name, &header_value);
6189 }
6190
6191
6192 let req = req_builder.build()?;
6193 let resp = configuration.client.execute(req).await?;
6194
6195 let status = resp.status();
6196 let content_type = resp
6197 .headers()
6198 .get("content-type")
6199 .and_then(|v| v.to_str().ok())
6200 .unwrap_or("application/octet-stream");
6201 let content_type = super::ContentType::from(content_type);
6202
6203 if !status.is_client_error() && !status.is_server_error() {
6204 let content = resp.text().await?;
6205 match content_type {
6206 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6207 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginTransferV1Resp`"))),
6208 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::GetMarginTransferV1Resp`")))),
6209 }
6210 } else {
6211 let content = resp.text().await?;
6212 let entity: Option<GetMarginTransferV1Error> = serde_json::from_str(&content).ok();
6213 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6214 }
6215}
6216
6217pub async fn update_margin_api_key_ip_v1(configuration: &configuration::Configuration, params: UpdateMarginApiKeyIpV1Params) -> Result<serde_json::Value, Error<UpdateMarginApiKeyIpV1Error>> {
6219
6220 let uri_str = format!("{}/sapi/v1/margin/apiKey/ip", configuration.base_path);
6221 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6222
6223 let mut query_params: Vec<(String, String)> = Vec::new();
6225
6226
6227 let mut header_params = std::collections::HashMap::new();
6229
6230 if let Some(ref binance_auth) = configuration.binance_auth {
6232 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6234
6235 let body_string: Option<Vec<u8>> = None;
6237
6238 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6240 Ok(sig) => sig,
6241 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6242 };
6243
6244 query_params.push(("signature".to_string(), signature));
6246 }
6247
6248 if !query_params.is_empty() {
6250 req_builder = req_builder.query(&query_params);
6251 }
6252
6253
6254 if let Some(ref user_agent) = configuration.user_agent {
6256 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6257 }
6258
6259 for (header_name, header_value) in header_params {
6261 req_builder = req_builder.header(&header_name, &header_value);
6262 }
6263
6264 let mut multipart_form_params = std::collections::HashMap::new();
6265 multipart_form_params.insert("apiKey", params.api_key.to_string());
6266 multipart_form_params.insert("ip", params.ip.to_string());
6267 if let Some(param_value) = params.recv_window {
6268 multipart_form_params.insert("recvWindow", param_value.to_string());
6269 }
6270 if let Some(param_value) = params.symbol {
6271 multipart_form_params.insert("symbol", param_value.to_string());
6272 }
6273 multipart_form_params.insert("timestamp", params.timestamp.to_string());
6274 req_builder = req_builder.form(&multipart_form_params);
6275
6276 let req = req_builder.build()?;
6277 let resp = configuration.client.execute(req).await?;
6278
6279 let status = resp.status();
6280 let content_type = resp
6281 .headers()
6282 .get("content-type")
6283 .and_then(|v| v.to_str().ok())
6284 .unwrap_or("application/octet-stream");
6285 let content_type = super::ContentType::from(content_type);
6286
6287 if !status.is_client_error() && !status.is_server_error() {
6288 let content = resp.text().await?;
6289 match content_type {
6290 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6291 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
6292 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`")))),
6293 }
6294 } else {
6295 let content = resp.text().await?;
6296 let entity: Option<UpdateMarginApiKeyIpV1Error> = serde_json::from_str(&content).ok();
6297 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6298 }
6299}
6300
6301pub async fn update_margin_listen_key_v1(configuration: &configuration::Configuration, params: UpdateMarginListenKeyV1Params) -> Result<serde_json::Value, Error<UpdateMarginListenKeyV1Error>> {
6303
6304 let uri_str = format!("{}/sapi/v1/margin/listen-key", configuration.base_path);
6305 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6306
6307 let mut query_params: Vec<(String, String)> = Vec::new();
6309
6310
6311 let mut header_params = std::collections::HashMap::new();
6313
6314 if let Some(ref binance_auth) = configuration.binance_auth {
6316 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6318
6319 let body_string: Option<Vec<u8>> = None;
6321
6322 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6324 Ok(sig) => sig,
6325 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6326 };
6327
6328 query_params.push(("signature".to_string(), signature));
6330 }
6331
6332 if !query_params.is_empty() {
6334 req_builder = req_builder.query(&query_params);
6335 }
6336
6337
6338 if let Some(ref user_agent) = configuration.user_agent {
6340 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6341 }
6342
6343 for (header_name, header_value) in header_params {
6345 req_builder = req_builder.header(&header_name, &header_value);
6346 }
6347
6348 let mut multipart_form_params = std::collections::HashMap::new();
6349 multipart_form_params.insert("listenKey", params.listen_key.to_string());
6350 req_builder = req_builder.form(&multipart_form_params);
6351
6352 let req = req_builder.build()?;
6353 let resp = configuration.client.execute(req).await?;
6354
6355 let status = resp.status();
6356 let content_type = resp
6357 .headers()
6358 .get("content-type")
6359 .and_then(|v| v.to_str().ok())
6360 .unwrap_or("application/octet-stream");
6361 let content_type = super::ContentType::from(content_type);
6362
6363 if !status.is_client_error() && !status.is_server_error() {
6364 let content = resp.text().await?;
6365 match content_type {
6366 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6367 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
6368 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`")))),
6369 }
6370 } else {
6371 let content = resp.text().await?;
6372 let entity: Option<UpdateMarginListenKeyV1Error> = serde_json::from_str(&content).ok();
6373 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6374 }
6375}
6376
6377pub async fn update_user_data_stream_isolated_v1(configuration: &configuration::Configuration, params: UpdateUserDataStreamIsolatedV1Params) -> Result<serde_json::Value, Error<UpdateUserDataStreamIsolatedV1Error>> {
6379
6380 let uri_str = format!("{}/sapi/v1/userDataStream/isolated", configuration.base_path);
6381 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6382
6383 let mut query_params: Vec<(String, String)> = Vec::new();
6385
6386
6387 let mut header_params = std::collections::HashMap::new();
6389
6390 if let Some(ref binance_auth) = configuration.binance_auth {
6392 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6394
6395 let body_string: Option<Vec<u8>> = None;
6397
6398 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6400 Ok(sig) => sig,
6401 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6402 };
6403
6404 query_params.push(("signature".to_string(), signature));
6406 }
6407
6408 if !query_params.is_empty() {
6410 req_builder = req_builder.query(&query_params);
6411 }
6412
6413
6414 if let Some(ref user_agent) = configuration.user_agent {
6416 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6417 }
6418
6419 for (header_name, header_value) in header_params {
6421 req_builder = req_builder.header(&header_name, &header_value);
6422 }
6423
6424 let mut multipart_form_params = std::collections::HashMap::new();
6425 multipart_form_params.insert("listenKey", params.listen_key.to_string());
6426 multipart_form_params.insert("symbol", params.symbol.to_string());
6427 req_builder = req_builder.form(&multipart_form_params);
6428
6429 let req = req_builder.build()?;
6430 let resp = configuration.client.execute(req).await?;
6431
6432 let status = resp.status();
6433 let content_type = resp
6434 .headers()
6435 .get("content-type")
6436 .and_then(|v| v.to_str().ok())
6437 .unwrap_or("application/octet-stream");
6438 let content_type = super::ContentType::from(content_type);
6439
6440 if !status.is_client_error() && !status.is_server_error() {
6441 let content = resp.text().await?;
6442 match content_type {
6443 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6444 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
6445 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`")))),
6446 }
6447 } else {
6448 let content = resp.text().await?;
6449 let entity: Option<UpdateUserDataStreamIsolatedV1Error> = serde_json::from_str(&content).ok();
6450 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6451 }
6452}
6453
6454pub async fn update_user_data_stream_v1(configuration: &configuration::Configuration, params: UpdateUserDataStreamV1Params) -> Result<serde_json::Value, Error<UpdateUserDataStreamV1Error>> {
6456
6457 let uri_str = format!("{}/sapi/v1/userDataStream", configuration.base_path);
6458 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6459
6460 let mut query_params: Vec<(String, String)> = Vec::new();
6462
6463
6464 let mut header_params = std::collections::HashMap::new();
6466
6467 if let Some(ref binance_auth) = configuration.binance_auth {
6469 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6471
6472 let body_string: Option<Vec<u8>> = None;
6474
6475 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6477 Ok(sig) => sig,
6478 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6479 };
6480
6481 query_params.push(("signature".to_string(), signature));
6483 }
6484
6485 if !query_params.is_empty() {
6487 req_builder = req_builder.query(&query_params);
6488 }
6489
6490
6491 if let Some(ref user_agent) = configuration.user_agent {
6493 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6494 }
6495
6496 for (header_name, header_value) in header_params {
6498 req_builder = req_builder.header(&header_name, &header_value);
6499 }
6500
6501 let mut multipart_form_params = std::collections::HashMap::new();
6502 multipart_form_params.insert("listenKey", params.listen_key.to_string());
6503 req_builder = req_builder.form(&multipart_form_params);
6504
6505 let req = req_builder.build()?;
6506 let resp = configuration.client.execute(req).await?;
6507
6508 let status = resp.status();
6509 let content_type = resp
6510 .headers()
6511 .get("content-type")
6512 .and_then(|v| v.to_str().ok())
6513 .unwrap_or("application/octet-stream");
6514 let content_type = super::ContentType::from(content_type);
6515
6516 if !status.is_client_error() && !status.is_server_error() {
6517 let content = resp.text().await?;
6518 match content_type {
6519 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6520 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
6521 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`")))),
6522 }
6523 } else {
6524 let content = resp.text().await?;
6525 let entity: Option<UpdateUserDataStreamV1Error> = serde_json::from_str(&content).ok();
6526 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6527 }
6528}
6529