1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::derivatives::pmargin::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct PmarginCreateCmConditionalOrderV1Params {
20 pub side: String,
21 pub strategy_type: String,
22 pub symbol: String,
23 pub timestamp: i64,
24 pub activation_price: Option<String>,
25 pub callback_rate: Option<String>,
26 pub new_client_strategy_id: Option<String>,
27 pub position_side: Option<String>,
28 pub price: Option<String>,
29 pub price_protect: Option<String>,
30 pub quantity: Option<String>,
31 pub recv_window: Option<i64>,
32 pub reduce_only: Option<String>,
33 pub stop_price: Option<String>,
34 pub time_in_force: Option<String>,
35 pub working_type: Option<String>
36}
37
38#[derive(Clone, Debug, Default)]
40pub struct PmarginCreateCmOrderV1Params {
41 pub side: String,
42 pub symbol: String,
43 pub timestamp: i64,
44 pub r#type: String,
45 pub new_client_order_id: Option<String>,
46 pub new_order_resp_type: Option<String>,
47 pub position_side: Option<String>,
48 pub price: Option<String>,
49 pub price_match: Option<String>,
50 pub quantity: Option<String>,
51 pub recv_window: Option<i64>,
52 pub reduce_only: Option<String>,
53 pub time_in_force: Option<String>
54}
55
56#[derive(Clone, Debug, Default)]
58pub struct PmarginCreateMarginLoanV1Params {
59 pub amount: String,
60 pub asset: String,
61 pub timestamp: i64,
62 pub recv_window: Option<i64>
63}
64
65#[derive(Clone, Debug, Default)]
67pub struct PmarginCreateMarginOrderOcoV1Params {
68 pub price: String,
69 pub quantity: String,
70 pub side: String,
71 pub stop_price: String,
72 pub symbol: String,
73 pub timestamp: i64,
74 pub limit_client_order_id: Option<String>,
75 pub limit_iceberg_qty: Option<String>,
76 pub list_client_order_id: Option<String>,
77 pub new_order_resp_type: Option<String>,
78 pub recv_window: Option<i64>,
79 pub side_effect_type: Option<String>,
80 pub stop_client_order_id: Option<String>,
81 pub stop_iceberg_qty: Option<String>,
82 pub stop_limit_price: Option<String>,
83 pub stop_limit_time_in_force: Option<String>
84}
85
86#[derive(Clone, Debug, Default)]
88pub struct PmarginCreateMarginOrderV1Params {
89 pub side: String,
90 pub symbol: String,
91 pub timestamp: i64,
92 pub r#type: String,
93 pub auto_repay_at_cancel: Option<bool>,
94 pub iceberg_qty: Option<String>,
95 pub new_client_order_id: Option<String>,
96 pub new_order_resp_type: Option<String>,
97 pub price: Option<String>,
98 pub quantity: Option<String>,
99 pub quote_order_qty: Option<String>,
100 pub recv_window: Option<i64>,
101 pub self_trade_prevention_mode: Option<String>,
102 pub side_effect_type: Option<String>,
103 pub stop_price: Option<String>,
104 pub time_in_force: Option<String>
105}
106
107#[derive(Clone, Debug, Default)]
109pub struct PmarginCreateMarginRepayDebtV1Params {
110 pub asset: String,
111 pub timestamp: i64,
112 pub amount: Option<String>,
113 pub recv_window: Option<i64>,
114 pub specify_repay_assets: Option<String>
115}
116
117#[derive(Clone, Debug, Default)]
119pub struct PmarginCreateRepayLoanV1Params {
120 pub amount: String,
121 pub asset: String,
122 pub timestamp: i64,
123 pub recv_window: Option<i64>
124}
125
126#[derive(Clone, Debug, Default)]
128pub struct PmarginCreateUmConditionalOrderV1Params {
129 pub side: String,
130 pub strategy_type: String,
131 pub symbol: String,
132 pub timestamp: i64,
133 pub activation_price: Option<String>,
134 pub callback_rate: Option<String>,
135 pub good_till_date: Option<i64>,
136 pub new_client_strategy_id: Option<String>,
137 pub position_side: Option<String>,
138 pub price: Option<String>,
139 pub price_match: Option<String>,
140 pub price_protect: Option<String>,
141 pub quantity: Option<String>,
142 pub recv_window: Option<i64>,
143 pub reduce_only: Option<String>,
144 pub self_trade_prevention_mode: Option<String>,
145 pub stop_price: Option<String>,
146 pub time_in_force: Option<String>,
147 pub working_type: Option<String>
148}
149
150#[derive(Clone, Debug, Default)]
152pub struct PmarginCreateUmFeeBurnV1Params {
153 pub fee_burn: String,
154 pub timestamp: i64,
155 pub recv_window: Option<i64>
156}
157
158#[derive(Clone, Debug, Default)]
160pub struct PmarginCreateUmOrderV1Params {
161 pub side: String,
162 pub symbol: String,
163 pub timestamp: i64,
164 pub r#type: String,
165 pub good_till_date: Option<i64>,
166 pub new_client_order_id: Option<String>,
167 pub new_order_resp_type: Option<String>,
168 pub position_side: Option<String>,
169 pub price: Option<String>,
170 pub price_match: Option<String>,
171 pub quantity: Option<String>,
172 pub recv_window: Option<i64>,
173 pub reduce_only: Option<String>,
174 pub self_trade_prevention_mode: Option<String>,
175 pub time_in_force: Option<String>
176}
177
178#[derive(Clone, Debug, Default)]
180pub struct PmarginDeleteCmAllOpenOrdersV1Params {
181 pub symbol: String,
182 pub timestamp: i64,
183 pub recv_window: Option<i64>
184}
185
186#[derive(Clone, Debug, Default)]
188pub struct PmarginDeleteCmConditionalAllOpenOrdersV1Params {
189 pub symbol: String,
190 pub timestamp: i64,
191 pub recv_window: Option<i64>
192}
193
194#[derive(Clone, Debug, Default)]
196pub struct PmarginDeleteCmConditionalOrderV1Params {
197 pub symbol: String,
198 pub timestamp: i64,
199 pub strategy_id: Option<i64>,
200 pub new_client_strategy_id: Option<String>,
201 pub recv_window: Option<i64>
202}
203
204#[derive(Clone, Debug, Default)]
206pub struct PmarginDeleteCmOrderV1Params {
207 pub symbol: String,
208 pub timestamp: i64,
209 pub order_id: Option<i64>,
210 pub orig_client_order_id: Option<String>,
211 pub recv_window: Option<i64>
212}
213
214#[derive(Clone, Debug, Default)]
216pub struct PmarginDeleteMarginAllOpenOrdersV1Params {
217 pub symbol: String,
218 pub timestamp: i64,
219 pub recv_window: Option<i64>
221}
222
223#[derive(Clone, Debug, Default)]
225pub struct PmarginDeleteMarginOrderListV1Params {
226 pub symbol: String,
227 pub timestamp: i64,
228 pub order_list_id: Option<i64>,
230 pub list_client_order_id: Option<String>,
232 pub new_client_order_id: Option<String>,
234 pub recv_window: Option<i64>
236}
237
238#[derive(Clone, Debug, Default)]
240pub struct PmarginDeleteMarginOrderV1Params {
241 pub symbol: String,
242 pub timestamp: i64,
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 PmarginDeleteUmAllOpenOrdersV1Params {
254 pub symbol: String,
255 pub timestamp: i64,
256 pub recv_window: Option<i64>
257}
258
259#[derive(Clone, Debug, Default)]
261pub struct PmarginDeleteUmConditionalAllOpenOrdersV1Params {
262 pub symbol: String,
263 pub timestamp: i64,
264 pub recv_window: Option<i64>
265}
266
267#[derive(Clone, Debug, Default)]
269pub struct PmarginDeleteUmConditionalOrderV1Params {
270 pub symbol: String,
271 pub timestamp: i64,
272 pub strategy_id: Option<i64>,
273 pub new_client_strategy_id: Option<String>,
274 pub recv_window: Option<i64>
275}
276
277#[derive(Clone, Debug, Default)]
279pub struct PmarginDeleteUmOrderV1Params {
280 pub symbol: String,
281 pub timestamp: i64,
282 pub order_id: Option<i64>,
283 pub orig_client_order_id: Option<String>,
284 pub recv_window: Option<i64>
285}
286
287#[derive(Clone, Debug, Default)]
289pub struct PmarginGetCmAllOrdersV1Params {
290 pub symbol: String,
291 pub timestamp: i64,
292 pub pair: Option<String>,
293 pub order_id: Option<i64>,
294 pub start_time: Option<i64>,
295 pub end_time: Option<i64>,
296 pub limit: Option<i32>,
298 pub recv_window: Option<i64>
299}
300
301#[derive(Clone, Debug, Default)]
303pub struct PmarginGetCmConditionalAllOrdersV1Params {
304 pub timestamp: i64,
305 pub symbol: Option<String>,
306 pub strategy_id: Option<i64>,
307 pub start_time: Option<i64>,
308 pub end_time: Option<i64>,
309 pub limit: Option<i32>,
311 pub recv_window: Option<i64>
312}
313
314#[derive(Clone, Debug, Default)]
316pub struct PmarginGetCmConditionalOpenOrderV1Params {
317 pub symbol: String,
318 pub timestamp: i64,
319 pub strategy_id: Option<i64>,
320 pub new_client_strategy_id: Option<String>,
321 pub recv_window: Option<i64>
322}
323
324#[derive(Clone, Debug, Default)]
326pub struct PmarginGetCmConditionalOpenOrdersV1Params {
327 pub timestamp: i64,
328 pub symbol: Option<String>,
329 pub recv_window: Option<i64>
330}
331
332#[derive(Clone, Debug, Default)]
334pub struct PmarginGetCmConditionalOrderHistoryV1Params {
335 pub symbol: String,
336 pub timestamp: i64,
337 pub strategy_id: Option<i64>,
338 pub new_client_strategy_id: Option<String>,
339 pub recv_window: Option<i64>
340}
341
342#[derive(Clone, Debug, Default)]
344pub struct PmarginGetCmForceOrdersV1Params {
345 pub timestamp: i64,
346 pub symbol: Option<String>,
347 pub auto_close_type: Option<String>,
349 pub start_time: Option<i64>,
350 pub end_time: Option<i64>,
351 pub limit: Option<i32>,
353 pub recv_window: Option<i64>
355}
356
357#[derive(Clone, Debug, Default)]
359pub struct PmarginGetCmOpenOrderV1Params {
360 pub symbol: String,
361 pub timestamp: i64,
362 pub order_id: Option<i64>,
363 pub orig_client_order_id: Option<String>,
364 pub recv_window: Option<i64>
365}
366
367#[derive(Clone, Debug, Default)]
369pub struct PmarginGetCmOpenOrdersV1Params {
370 pub timestamp: i64,
371 pub symbol: Option<String>,
372 pub pair: Option<String>,
373 pub recv_window: Option<i64>
374}
375
376#[derive(Clone, Debug, Default)]
378pub struct PmarginGetCmOrderAmendmentV1Params {
379 pub symbol: String,
380 pub timestamp: i64,
381 pub order_id: Option<i64>,
382 pub orig_client_order_id: Option<String>,
383 pub start_time: Option<i64>,
385 pub end_time: Option<i64>,
387 pub limit: Option<i32>,
389 pub recv_window: Option<i64>
390}
391
392#[derive(Clone, Debug, Default)]
394pub struct PmarginGetCmOrderV1Params {
395 pub symbol: String,
396 pub timestamp: i64,
397 pub order_id: Option<i64>,
398 pub orig_client_order_id: Option<String>,
399 pub recv_window: Option<i64>
400}
401
402#[derive(Clone, Debug, Default)]
404pub struct PmarginGetCmUserTradesV1Params {
405 pub timestamp: i64,
406 pub symbol: Option<String>,
407 pub pair: Option<String>,
408 pub start_time: Option<i64>,
409 pub end_time: Option<i64>,
410 pub from_id: Option<i64>,
412 pub limit: Option<i32>,
414 pub recv_window: Option<i64>
415}
416
417#[derive(Clone, Debug, Default)]
419pub struct PmarginGetMarginAllOrderListV1Params {
420 pub timestamp: i64,
421 pub from_id: Option<i64>,
423 pub start_time: Option<i64>,
424 pub end_time: Option<i64>,
425 pub limit: Option<i32>,
427 pub recv_window: Option<i64>
429}
430
431#[derive(Clone, Debug, Default)]
433pub struct PmarginGetMarginAllOrdersV1Params {
434 pub symbol: String,
435 pub timestamp: i64,
436 pub order_id: Option<i64>,
437 pub start_time: Option<i64>,
438 pub end_time: Option<i64>,
439 pub limit: Option<i32>,
441 pub recv_window: Option<i64>
443}
444
445#[derive(Clone, Debug, Default)]
447pub struct PmarginGetMarginForceOrdersV1Params {
448 pub timestamp: i64,
449 pub start_time: Option<i64>,
450 pub end_time: Option<i64>,
451 pub current: Option<i64>,
453 pub size: Option<i64>,
455 pub recv_window: Option<i64>
457}
458
459#[derive(Clone, Debug, Default)]
461pub struct PmarginGetMarginMyTradesV1Params {
462 pub symbol: String,
463 pub timestamp: i64,
464 pub order_id: Option<i64>,
465 pub start_time: Option<i64>,
466 pub end_time: Option<i64>,
467 pub from_id: Option<i64>,
469 pub limit: Option<i32>,
471 pub recv_window: Option<i64>
473}
474
475#[derive(Clone, Debug, Default)]
477pub struct PmarginGetMarginOpenOrderListV1Params {
478 pub timestamp: i64,
479 pub recv_window: Option<i64>
481}
482
483#[derive(Clone, Debug, Default)]
485pub struct PmarginGetMarginOpenOrdersV1Params {
486 pub symbol: String,
487 pub timestamp: i64,
488 pub recv_window: Option<i64>
490}
491
492#[derive(Clone, Debug, Default)]
494pub struct PmarginGetMarginOrderListV1Params {
495 pub timestamp: i64,
496 pub order_list_id: Option<i64>,
498 pub orig_client_order_id: Option<String>,
500 pub recv_window: Option<i64>
502}
503
504#[derive(Clone, Debug, Default)]
506pub struct PmarginGetMarginOrderV1Params {
507 pub symbol: String,
508 pub timestamp: i64,
509 pub order_id: Option<i64>,
510 pub orig_client_order_id: Option<String>,
511 pub recv_window: Option<i64>
513}
514
515#[derive(Clone, Debug, Default)]
517pub struct PmarginGetUmAdlQuantileV1Params {
518 pub timestamp: i64,
519 pub symbol: Option<String>,
520 pub recv_window: Option<i64>
521}
522
523#[derive(Clone, Debug, Default)]
525pub struct PmarginGetUmAllOrdersV1Params {
526 pub symbol: String,
527 pub timestamp: i64,
528 pub order_id: Option<i64>,
529 pub start_time: Option<i64>,
530 pub end_time: Option<i64>,
531 pub limit: Option<i32>,
533 pub recv_window: Option<i64>
534}
535
536#[derive(Clone, Debug, Default)]
538pub struct PmarginGetUmConditionalAllOrdersV1Params {
539 pub timestamp: i64,
540 pub symbol: Option<String>,
541 pub strategy_id: Option<i64>,
542 pub start_time: Option<i64>,
543 pub end_time: Option<i64>,
544 pub limit: Option<i32>,
546 pub recv_window: Option<i64>
547}
548
549#[derive(Clone, Debug, Default)]
551pub struct PmarginGetUmConditionalOpenOrderV1Params {
552 pub symbol: String,
553 pub timestamp: i64,
554 pub strategy_id: Option<i64>,
555 pub new_client_strategy_id: Option<String>,
556 pub recv_window: Option<i64>
557}
558
559#[derive(Clone, Debug, Default)]
561pub struct PmarginGetUmConditionalOrderHistoryV1Params {
562 pub symbol: String,
563 pub timestamp: i64,
564 pub strategy_id: Option<i64>,
565 pub new_client_strategy_id: Option<String>,
566 pub recv_window: Option<i64>
567}
568
569#[derive(Clone, Debug, Default)]
571pub struct PmarginGetUmFeeBurnV1Params {
572 pub timestamp: i64,
573 pub recv_window: Option<i64>
574}
575
576#[derive(Clone, Debug, Default)]
578pub struct PmarginGetUmForceOrdersV1Params {
579 pub timestamp: i64,
580 pub symbol: Option<String>,
581 pub auto_close_type: Option<String>,
583 pub start_time: Option<i64>,
584 pub end_time: Option<i64>,
585 pub limit: Option<i32>,
587 pub recv_window: Option<i64>
589}
590
591#[derive(Clone, Debug, Default)]
593pub struct PmarginGetUmOpenOrderV1Params {
594 pub symbol: String,
595 pub timestamp: i64,
596 pub order_id: Option<i64>,
597 pub orig_client_order_id: Option<String>,
598 pub recv_window: Option<i64>
599}
600
601#[derive(Clone, Debug, Default)]
603pub struct PmarginGetUmOpenOrdersV1Params {
604 pub timestamp: i64,
605 pub symbol: Option<String>,
606 pub recv_window: Option<i64>
607}
608
609#[derive(Clone, Debug, Default)]
611pub struct PmarginGetUmOrderAmendmentV1Params {
612 pub symbol: String,
613 pub timestamp: i64,
614 pub order_id: Option<i64>,
615 pub orig_client_order_id: Option<String>,
616 pub start_time: Option<i64>,
618 pub end_time: Option<i64>,
620 pub limit: Option<i32>,
622 pub recv_window: Option<i64>
623}
624
625#[derive(Clone, Debug, Default)]
627pub struct PmarginGetUmOrderV1Params {
628 pub symbol: String,
629 pub timestamp: i64,
630 pub order_id: Option<i64>,
631 pub orig_client_order_id: Option<String>,
632 pub recv_window: Option<i64>
633}
634
635#[derive(Clone, Debug, Default)]
637pub struct PmarginGetUmUserTradesV1Params {
638 pub symbol: String,
639 pub timestamp: i64,
640 pub start_time: Option<i64>,
641 pub end_time: Option<i64>,
642 pub from_id: Option<i64>,
644 pub limit: Option<i32>,
646 pub recv_window: Option<i64>
647}
648
649#[derive(Clone, Debug, Default)]
651pub struct PmarginUpdateCmOrderV1Params {
652 pub price: String,
653 pub quantity: String,
654 pub side: String,
655 pub symbol: String,
656 pub timestamp: i64,
657 pub order_id: Option<i64>,
658 pub orig_client_order_id: Option<String>,
659 pub price_match: Option<String>,
660 pub recv_window: Option<i64>
661}
662
663#[derive(Clone, Debug, Default)]
665pub struct PmarginUpdateUmOrderV1Params {
666 pub price: String,
667 pub quantity: String,
668 pub side: String,
669 pub symbol: String,
670 pub timestamp: i64,
671 pub order_id: Option<i64>,
672 pub orig_client_order_id: Option<String>,
673 pub price_match: Option<String>,
674 pub recv_window: Option<i64>
675}
676
677
678#[derive(Debug, Clone, Serialize, Deserialize)]
680#[serde(untagged)]
681pub enum PmarginCreateCmConditionalOrderV1Error {
682 Status4XX(models::ApiError),
683 Status5XX(models::ApiError),
684 UnknownValue(serde_json::Value),
685}
686
687#[derive(Debug, Clone, Serialize, Deserialize)]
689#[serde(untagged)]
690pub enum PmarginCreateCmOrderV1Error {
691 Status4XX(models::ApiError),
692 Status5XX(models::ApiError),
693 UnknownValue(serde_json::Value),
694}
695
696#[derive(Debug, Clone, Serialize, Deserialize)]
698#[serde(untagged)]
699pub enum PmarginCreateMarginLoanV1Error {
700 Status4XX(models::ApiError),
701 Status5XX(models::ApiError),
702 UnknownValue(serde_json::Value),
703}
704
705#[derive(Debug, Clone, Serialize, Deserialize)]
707#[serde(untagged)]
708pub enum PmarginCreateMarginOrderOcoV1Error {
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 PmarginCreateMarginOrderV1Error {
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 PmarginCreateMarginRepayDebtV1Error {
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 PmarginCreateRepayLoanV1Error {
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 PmarginCreateUmConditionalOrderV1Error {
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 PmarginCreateUmFeeBurnV1Error {
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 PmarginCreateUmOrderV1Error {
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 PmarginDeleteCmAllOpenOrdersV1Error {
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 PmarginDeleteCmConditionalAllOpenOrdersV1Error {
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 PmarginDeleteCmConditionalOrderV1Error {
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 PmarginDeleteCmOrderV1Error {
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 PmarginDeleteMarginAllOpenOrdersV1Error {
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 PmarginDeleteMarginOrderListV1Error {
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 PmarginDeleteMarginOrderV1Error {
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 PmarginDeleteUmAllOpenOrdersV1Error {
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 PmarginDeleteUmConditionalAllOpenOrdersV1Error {
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 PmarginDeleteUmConditionalOrderV1Error {
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 PmarginDeleteUmOrderV1Error {
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 PmarginGetCmAdlQuantileV1Error {
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 PmarginGetCmAllOrdersV1Error {
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 PmarginGetCmConditionalAllOrdersV1Error {
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 PmarginGetCmConditionalOpenOrderV1Error {
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 PmarginGetCmConditionalOpenOrdersV1Error {
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 PmarginGetCmConditionalOrderHistoryV1Error {
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 PmarginGetCmForceOrdersV1Error {
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 PmarginGetCmOpenOrderV1Error {
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 PmarginGetCmOpenOrdersV1Error {
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 PmarginGetCmOrderAmendmentV1Error {
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 PmarginGetCmOrderV1Error {
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 PmarginGetCmUserTradesV1Error {
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 PmarginGetMarginAllOrderListV1Error {
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 PmarginGetMarginAllOrdersV1Error {
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 PmarginGetMarginForceOrdersV1Error {
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 PmarginGetMarginMyTradesV1Error {
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 PmarginGetMarginOpenOrderListV1Error {
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 PmarginGetMarginOpenOrdersV1Error {
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 PmarginGetMarginOrderListV1Error {
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 PmarginGetMarginOrderV1Error {
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 PmarginGetUmAdlQuantileV1Error {
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 PmarginGetUmAllOrdersV1Error {
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 PmarginGetUmConditionalAllOrdersV1Error {
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 PmarginGetUmConditionalOpenOrderV1Error {
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 PmarginGetUmConditionalOpenOrdersV1Error {
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 PmarginGetUmConditionalOrderHistoryV1Error {
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 PmarginGetUmFeeBurnV1Error {
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 PmarginGetUmForceOrdersV1Error {
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 PmarginGetUmOpenOrderV1Error {
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 PmarginGetUmOpenOrdersV1Error {
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 PmarginGetUmOrderAmendmentV1Error {
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 PmarginGetUmOrderV1Error {
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 PmarginGetUmUserTradesV1Error {
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 PmarginUpdateCmOrderV1Error {
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 PmarginUpdateUmOrderV1Error {
1177 Status4XX(models::ApiError),
1178 Status5XX(models::ApiError),
1179 UnknownValue(serde_json::Value),
1180}
1181
1182
1183pub async fn pmargin_create_cm_conditional_order_v1(configuration: &configuration::Configuration, params: PmarginCreateCmConditionalOrderV1Params) -> Result<models::PmarginCreateCmConditionalOrderV1Resp, Error<PmarginCreateCmConditionalOrderV1Error>> {
1185
1186 let uri_str = format!("{}/papi/v1/cm/conditional/order", configuration.base_path);
1187 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1188
1189 let mut query_params: Vec<(String, String)> = Vec::new();
1191
1192
1193 let mut header_params = std::collections::HashMap::new();
1195
1196 if let Some(ref binance_auth) = configuration.binance_auth {
1198 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1200
1201 let body_string: Option<Vec<u8>> = None;
1203
1204 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1206 Ok(sig) => sig,
1207 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1208 };
1209
1210 query_params.push(("signature".to_string(), signature));
1212 }
1213
1214 if !query_params.is_empty() {
1216 req_builder = req_builder.query(&query_params);
1217 }
1218
1219
1220 if let Some(ref user_agent) = configuration.user_agent {
1222 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1223 }
1224
1225 for (header_name, header_value) in header_params {
1227 req_builder = req_builder.header(&header_name, &header_value);
1228 }
1229
1230 let mut multipart_form_params = std::collections::HashMap::new();
1231 if let Some(param_value) = params.activation_price {
1232 multipart_form_params.insert("activationPrice", param_value.to_string());
1233 }
1234 if let Some(param_value) = params.callback_rate {
1235 multipart_form_params.insert("callbackRate", param_value.to_string());
1236 }
1237 if let Some(param_value) = params.new_client_strategy_id {
1238 multipart_form_params.insert("newClientStrategyId", param_value.to_string());
1239 }
1240 if let Some(param_value) = params.position_side {
1241 multipart_form_params.insert("positionSide", param_value.to_string());
1242 }
1243 if let Some(param_value) = params.price {
1244 multipart_form_params.insert("price", param_value.to_string());
1245 }
1246 if let Some(param_value) = params.price_protect {
1247 multipart_form_params.insert("priceProtect", param_value.to_string());
1248 }
1249 if let Some(param_value) = params.quantity {
1250 multipart_form_params.insert("quantity", param_value.to_string());
1251 }
1252 if let Some(param_value) = params.recv_window {
1253 multipart_form_params.insert("recvWindow", param_value.to_string());
1254 }
1255 if let Some(param_value) = params.reduce_only {
1256 multipart_form_params.insert("reduceOnly", param_value.to_string());
1257 }
1258 multipart_form_params.insert("side", params.side.to_string());
1259 if let Some(param_value) = params.stop_price {
1260 multipart_form_params.insert("stopPrice", param_value.to_string());
1261 }
1262 multipart_form_params.insert("strategyType", params.strategy_type.to_string());
1263 multipart_form_params.insert("symbol", params.symbol.to_string());
1264 if let Some(param_value) = params.time_in_force {
1265 multipart_form_params.insert("timeInForce", param_value.to_string());
1266 }
1267 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1268 if let Some(param_value) = params.working_type {
1269 multipart_form_params.insert("workingType", param_value.to_string());
1270 }
1271 req_builder = req_builder.form(&multipart_form_params);
1272
1273 let req = req_builder.build()?;
1274 let resp = configuration.client.execute(req).await?;
1275
1276 let status = resp.status();
1277 let content_type = resp
1278 .headers()
1279 .get("content-type")
1280 .and_then(|v| v.to_str().ok())
1281 .unwrap_or("application/octet-stream");
1282 let content_type = super::ContentType::from(content_type);
1283
1284 if !status.is_client_error() && !status.is_server_error() {
1285 let content = resp.text().await?;
1286 match content_type {
1287 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1288 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateCmConditionalOrderV1Resp`"))),
1289 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::PmarginCreateCmConditionalOrderV1Resp`")))),
1290 }
1291 } else {
1292 let content = resp.text().await?;
1293 let entity: Option<PmarginCreateCmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
1294 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1295 }
1296}
1297
1298pub async fn pmargin_create_cm_order_v1(configuration: &configuration::Configuration, params: PmarginCreateCmOrderV1Params) -> Result<models::PmarginCreateCmOrderV1Resp, Error<PmarginCreateCmOrderV1Error>> {
1300
1301 let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
1302 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1303
1304 let mut query_params: Vec<(String, String)> = Vec::new();
1306
1307
1308 let mut header_params = std::collections::HashMap::new();
1310
1311 if let Some(ref binance_auth) = configuration.binance_auth {
1313 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1315
1316 let body_string: Option<Vec<u8>> = None;
1318
1319 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1321 Ok(sig) => sig,
1322 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1323 };
1324
1325 query_params.push(("signature".to_string(), signature));
1327 }
1328
1329 if !query_params.is_empty() {
1331 req_builder = req_builder.query(&query_params);
1332 }
1333
1334
1335 if let Some(ref user_agent) = configuration.user_agent {
1337 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1338 }
1339
1340 for (header_name, header_value) in header_params {
1342 req_builder = req_builder.header(&header_name, &header_value);
1343 }
1344
1345 let mut multipart_form_params = std::collections::HashMap::new();
1346 if let Some(param_value) = params.new_client_order_id {
1347 multipart_form_params.insert("newClientOrderId", param_value.to_string());
1348 }
1349 if let Some(param_value) = params.new_order_resp_type {
1350 multipart_form_params.insert("newOrderRespType", param_value.to_string());
1351 }
1352 if let Some(param_value) = params.position_side {
1353 multipart_form_params.insert("positionSide", param_value.to_string());
1354 }
1355 if let Some(param_value) = params.price {
1356 multipart_form_params.insert("price", param_value.to_string());
1357 }
1358 if let Some(param_value) = params.price_match {
1359 multipart_form_params.insert("priceMatch", param_value.to_string());
1360 }
1361 if let Some(param_value) = params.quantity {
1362 multipart_form_params.insert("quantity", param_value.to_string());
1363 }
1364 if let Some(param_value) = params.recv_window {
1365 multipart_form_params.insert("recvWindow", param_value.to_string());
1366 }
1367 if let Some(param_value) = params.reduce_only {
1368 multipart_form_params.insert("reduceOnly", param_value.to_string());
1369 }
1370 multipart_form_params.insert("side", params.side.to_string());
1371 multipart_form_params.insert("symbol", params.symbol.to_string());
1372 if let Some(param_value) = params.time_in_force {
1373 multipart_form_params.insert("timeInForce", param_value.to_string());
1374 }
1375 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1376 multipart_form_params.insert("type", params.r#type.to_string());
1377 req_builder = req_builder.form(&multipart_form_params);
1378
1379 let req = req_builder.build()?;
1380 let resp = configuration.client.execute(req).await?;
1381
1382 let status = resp.status();
1383 let content_type = resp
1384 .headers()
1385 .get("content-type")
1386 .and_then(|v| v.to_str().ok())
1387 .unwrap_or("application/octet-stream");
1388 let content_type = super::ContentType::from(content_type);
1389
1390 if !status.is_client_error() && !status.is_server_error() {
1391 let content = resp.text().await?;
1392 match content_type {
1393 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1394 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateCmOrderV1Resp`"))),
1395 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::PmarginCreateCmOrderV1Resp`")))),
1396 }
1397 } else {
1398 let content = resp.text().await?;
1399 let entity: Option<PmarginCreateCmOrderV1Error> = serde_json::from_str(&content).ok();
1400 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1401 }
1402}
1403
1404pub async fn pmargin_create_margin_loan_v1(configuration: &configuration::Configuration, params: PmarginCreateMarginLoanV1Params) -> Result<models::PmarginCreateMarginLoanV1Resp, Error<PmarginCreateMarginLoanV1Error>> {
1406
1407 let uri_str = format!("{}/papi/v1/marginLoan", configuration.base_path);
1408 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1409
1410 let mut query_params: Vec<(String, String)> = Vec::new();
1412
1413
1414 let mut header_params = std::collections::HashMap::new();
1416
1417 if let Some(ref binance_auth) = configuration.binance_auth {
1419 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1421
1422 let body_string: Option<Vec<u8>> = None;
1424
1425 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1427 Ok(sig) => sig,
1428 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1429 };
1430
1431 query_params.push(("signature".to_string(), signature));
1433 }
1434
1435 if !query_params.is_empty() {
1437 req_builder = req_builder.query(&query_params);
1438 }
1439
1440
1441 if let Some(ref user_agent) = configuration.user_agent {
1443 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1444 }
1445
1446 for (header_name, header_value) in header_params {
1448 req_builder = req_builder.header(&header_name, &header_value);
1449 }
1450
1451 let mut multipart_form_params = std::collections::HashMap::new();
1452 multipart_form_params.insert("amount", params.amount.to_string());
1453 multipart_form_params.insert("asset", params.asset.to_string());
1454 if let Some(param_value) = params.recv_window {
1455 multipart_form_params.insert("recvWindow", param_value.to_string());
1456 }
1457 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1458 req_builder = req_builder.form(&multipart_form_params);
1459
1460 let req = req_builder.build()?;
1461 let resp = configuration.client.execute(req).await?;
1462
1463 let status = resp.status();
1464 let content_type = resp
1465 .headers()
1466 .get("content-type")
1467 .and_then(|v| v.to_str().ok())
1468 .unwrap_or("application/octet-stream");
1469 let content_type = super::ContentType::from(content_type);
1470
1471 if !status.is_client_error() && !status.is_server_error() {
1472 let content = resp.text().await?;
1473 match content_type {
1474 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1475 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateMarginLoanV1Resp`"))),
1476 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::PmarginCreateMarginLoanV1Resp`")))),
1477 }
1478 } else {
1479 let content = resp.text().await?;
1480 let entity: Option<PmarginCreateMarginLoanV1Error> = serde_json::from_str(&content).ok();
1481 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1482 }
1483}
1484
1485pub async fn pmargin_create_margin_order_oco_v1(configuration: &configuration::Configuration, params: PmarginCreateMarginOrderOcoV1Params) -> Result<models::PmarginCreateMarginOrderOcoV1Resp, Error<PmarginCreateMarginOrderOcoV1Error>> {
1487
1488 let uri_str = format!("{}/papi/v1/margin/order/oco", configuration.base_path);
1489 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1490
1491 let mut query_params: Vec<(String, String)> = Vec::new();
1493
1494
1495 let mut header_params = std::collections::HashMap::new();
1497
1498 if let Some(ref binance_auth) = configuration.binance_auth {
1500 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1502
1503 let body_string: Option<Vec<u8>> = None;
1505
1506 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1508 Ok(sig) => sig,
1509 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1510 };
1511
1512 query_params.push(("signature".to_string(), signature));
1514 }
1515
1516 if !query_params.is_empty() {
1518 req_builder = req_builder.query(&query_params);
1519 }
1520
1521
1522 if let Some(ref user_agent) = configuration.user_agent {
1524 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1525 }
1526
1527 for (header_name, header_value) in header_params {
1529 req_builder = req_builder.header(&header_name, &header_value);
1530 }
1531
1532 let mut multipart_form_params = std::collections::HashMap::new();
1533 if let Some(param_value) = params.limit_client_order_id {
1534 multipart_form_params.insert("limitClientOrderId", param_value.to_string());
1535 }
1536 if let Some(param_value) = params.limit_iceberg_qty {
1537 multipart_form_params.insert("limitIcebergQty", param_value.to_string());
1538 }
1539 if let Some(param_value) = params.list_client_order_id {
1540 multipart_form_params.insert("listClientOrderId", param_value.to_string());
1541 }
1542 if let Some(param_value) = params.new_order_resp_type {
1543 multipart_form_params.insert("newOrderRespType", param_value.to_string());
1544 }
1545 multipart_form_params.insert("price", params.price.to_string());
1546 multipart_form_params.insert("quantity", params.quantity.to_string());
1547 if let Some(param_value) = params.recv_window {
1548 multipart_form_params.insert("recvWindow", param_value.to_string());
1549 }
1550 multipart_form_params.insert("side", params.side.to_string());
1551 if let Some(param_value) = params.side_effect_type {
1552 multipart_form_params.insert("sideEffectType", param_value.to_string());
1553 }
1554 if let Some(param_value) = params.stop_client_order_id {
1555 multipart_form_params.insert("stopClientOrderId", param_value.to_string());
1556 }
1557 if let Some(param_value) = params.stop_iceberg_qty {
1558 multipart_form_params.insert("stopIcebergQty", param_value.to_string());
1559 }
1560 if let Some(param_value) = params.stop_limit_price {
1561 multipart_form_params.insert("stopLimitPrice", param_value.to_string());
1562 }
1563 if let Some(param_value) = params.stop_limit_time_in_force {
1564 multipart_form_params.insert("stopLimitTimeInForce", param_value.to_string());
1565 }
1566 multipart_form_params.insert("stopPrice", params.stop_price.to_string());
1567 multipart_form_params.insert("symbol", params.symbol.to_string());
1568 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1569 req_builder = req_builder.form(&multipart_form_params);
1570
1571 let req = req_builder.build()?;
1572 let resp = configuration.client.execute(req).await?;
1573
1574 let status = resp.status();
1575 let content_type = resp
1576 .headers()
1577 .get("content-type")
1578 .and_then(|v| v.to_str().ok())
1579 .unwrap_or("application/octet-stream");
1580 let content_type = super::ContentType::from(content_type);
1581
1582 if !status.is_client_error() && !status.is_server_error() {
1583 let content = resp.text().await?;
1584 match content_type {
1585 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1586 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateMarginOrderOcoV1Resp`"))),
1587 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::PmarginCreateMarginOrderOcoV1Resp`")))),
1588 }
1589 } else {
1590 let content = resp.text().await?;
1591 let entity: Option<PmarginCreateMarginOrderOcoV1Error> = serde_json::from_str(&content).ok();
1592 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1593 }
1594}
1595
1596pub async fn pmargin_create_margin_order_v1(configuration: &configuration::Configuration, params: PmarginCreateMarginOrderV1Params) -> Result<models::PmarginCreateMarginOrderV1Resp, Error<PmarginCreateMarginOrderV1Error>> {
1598
1599 let uri_str = format!("{}/papi/v1/margin/order", configuration.base_path);
1600 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1601
1602 let mut query_params: Vec<(String, String)> = Vec::new();
1604
1605
1606 let mut header_params = std::collections::HashMap::new();
1608
1609 if let Some(ref binance_auth) = configuration.binance_auth {
1611 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1613
1614 let body_string: Option<Vec<u8>> = None;
1616
1617 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1619 Ok(sig) => sig,
1620 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1621 };
1622
1623 query_params.push(("signature".to_string(), signature));
1625 }
1626
1627 if !query_params.is_empty() {
1629 req_builder = req_builder.query(&query_params);
1630 }
1631
1632
1633 if let Some(ref user_agent) = configuration.user_agent {
1635 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1636 }
1637
1638 for (header_name, header_value) in header_params {
1640 req_builder = req_builder.header(&header_name, &header_value);
1641 }
1642
1643 let mut multipart_form_params = std::collections::HashMap::new();
1644 if let Some(param_value) = params.auto_repay_at_cancel {
1645 multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
1646 }
1647 if let Some(param_value) = params.iceberg_qty {
1648 multipart_form_params.insert("icebergQty", param_value.to_string());
1649 }
1650 if let Some(param_value) = params.new_client_order_id {
1651 multipart_form_params.insert("newClientOrderId", param_value.to_string());
1652 }
1653 if let Some(param_value) = params.new_order_resp_type {
1654 multipart_form_params.insert("newOrderRespType", param_value.to_string());
1655 }
1656 if let Some(param_value) = params.price {
1657 multipart_form_params.insert("price", param_value.to_string());
1658 }
1659 if let Some(param_value) = params.quantity {
1660 multipart_form_params.insert("quantity", param_value.to_string());
1661 }
1662 if let Some(param_value) = params.quote_order_qty {
1663 multipart_form_params.insert("quoteOrderQty", param_value.to_string());
1664 }
1665 if let Some(param_value) = params.recv_window {
1666 multipart_form_params.insert("recvWindow", param_value.to_string());
1667 }
1668 if let Some(param_value) = params.self_trade_prevention_mode {
1669 multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1670 }
1671 multipart_form_params.insert("side", params.side.to_string());
1672 if let Some(param_value) = params.side_effect_type {
1673 multipart_form_params.insert("sideEffectType", param_value.to_string());
1674 }
1675 if let Some(param_value) = params.stop_price {
1676 multipart_form_params.insert("stopPrice", param_value.to_string());
1677 }
1678 multipart_form_params.insert("symbol", params.symbol.to_string());
1679 if let Some(param_value) = params.time_in_force {
1680 multipart_form_params.insert("timeInForce", param_value.to_string());
1681 }
1682 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1683 multipart_form_params.insert("type", params.r#type.to_string());
1684 req_builder = req_builder.form(&multipart_form_params);
1685
1686 let req = req_builder.build()?;
1687 let resp = configuration.client.execute(req).await?;
1688
1689 let status = resp.status();
1690 let content_type = resp
1691 .headers()
1692 .get("content-type")
1693 .and_then(|v| v.to_str().ok())
1694 .unwrap_or("application/octet-stream");
1695 let content_type = super::ContentType::from(content_type);
1696
1697 if !status.is_client_error() && !status.is_server_error() {
1698 let content = resp.text().await?;
1699 match content_type {
1700 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1701 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateMarginOrderV1Resp`"))),
1702 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::PmarginCreateMarginOrderV1Resp`")))),
1703 }
1704 } else {
1705 let content = resp.text().await?;
1706 let entity: Option<PmarginCreateMarginOrderV1Error> = serde_json::from_str(&content).ok();
1707 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1708 }
1709}
1710
1711pub async fn pmargin_create_margin_repay_debt_v1(configuration: &configuration::Configuration, params: PmarginCreateMarginRepayDebtV1Params) -> Result<models::PmarginCreateMarginRepayDebtV1Resp, Error<PmarginCreateMarginRepayDebtV1Error>> {
1713
1714 let uri_str = format!("{}/papi/v1/margin/repay-debt", configuration.base_path);
1715 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1716
1717 let mut query_params: Vec<(String, String)> = Vec::new();
1719
1720
1721 let mut header_params = std::collections::HashMap::new();
1723
1724 if let Some(ref binance_auth) = configuration.binance_auth {
1726 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1728
1729 let body_string: Option<Vec<u8>> = None;
1731
1732 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1734 Ok(sig) => sig,
1735 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1736 };
1737
1738 query_params.push(("signature".to_string(), signature));
1740 }
1741
1742 if !query_params.is_empty() {
1744 req_builder = req_builder.query(&query_params);
1745 }
1746
1747
1748 if let Some(ref user_agent) = configuration.user_agent {
1750 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1751 }
1752
1753 for (header_name, header_value) in header_params {
1755 req_builder = req_builder.header(&header_name, &header_value);
1756 }
1757
1758 let mut multipart_form_params = std::collections::HashMap::new();
1759 if let Some(param_value) = params.amount {
1760 multipart_form_params.insert("amount", param_value.to_string());
1761 }
1762 multipart_form_params.insert("asset", params.asset.to_string());
1763 if let Some(param_value) = params.recv_window {
1764 multipart_form_params.insert("recvWindow", param_value.to_string());
1765 }
1766 if let Some(param_value) = params.specify_repay_assets {
1767 multipart_form_params.insert("specifyRepayAssets", param_value.to_string());
1768 }
1769 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1770 req_builder = req_builder.form(&multipart_form_params);
1771
1772 let req = req_builder.build()?;
1773 let resp = configuration.client.execute(req).await?;
1774
1775 let status = resp.status();
1776 let content_type = resp
1777 .headers()
1778 .get("content-type")
1779 .and_then(|v| v.to_str().ok())
1780 .unwrap_or("application/octet-stream");
1781 let content_type = super::ContentType::from(content_type);
1782
1783 if !status.is_client_error() && !status.is_server_error() {
1784 let content = resp.text().await?;
1785 match content_type {
1786 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1787 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateMarginRepayDebtV1Resp`"))),
1788 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::PmarginCreateMarginRepayDebtV1Resp`")))),
1789 }
1790 } else {
1791 let content = resp.text().await?;
1792 let entity: Option<PmarginCreateMarginRepayDebtV1Error> = serde_json::from_str(&content).ok();
1793 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1794 }
1795}
1796
1797pub async fn pmargin_create_repay_loan_v1(configuration: &configuration::Configuration, params: PmarginCreateRepayLoanV1Params) -> Result<models::PmarginCreateRepayLoanV1Resp, Error<PmarginCreateRepayLoanV1Error>> {
1799
1800 let uri_str = format!("{}/papi/v1/repayLoan", configuration.base_path);
1801 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1802
1803 let mut query_params: Vec<(String, String)> = Vec::new();
1805
1806
1807 let mut header_params = std::collections::HashMap::new();
1809
1810 if let Some(ref binance_auth) = configuration.binance_auth {
1812 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1814
1815 let body_string: Option<Vec<u8>> = None;
1817
1818 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1820 Ok(sig) => sig,
1821 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1822 };
1823
1824 query_params.push(("signature".to_string(), signature));
1826 }
1827
1828 if !query_params.is_empty() {
1830 req_builder = req_builder.query(&query_params);
1831 }
1832
1833
1834 if let Some(ref user_agent) = configuration.user_agent {
1836 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1837 }
1838
1839 for (header_name, header_value) in header_params {
1841 req_builder = req_builder.header(&header_name, &header_value);
1842 }
1843
1844 let mut multipart_form_params = std::collections::HashMap::new();
1845 multipart_form_params.insert("amount", params.amount.to_string());
1846 multipart_form_params.insert("asset", params.asset.to_string());
1847 if let Some(param_value) = params.recv_window {
1848 multipart_form_params.insert("recvWindow", param_value.to_string());
1849 }
1850 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1851 req_builder = req_builder.form(&multipart_form_params);
1852
1853 let req = req_builder.build()?;
1854 let resp = configuration.client.execute(req).await?;
1855
1856 let status = resp.status();
1857 let content_type = resp
1858 .headers()
1859 .get("content-type")
1860 .and_then(|v| v.to_str().ok())
1861 .unwrap_or("application/octet-stream");
1862 let content_type = super::ContentType::from(content_type);
1863
1864 if !status.is_client_error() && !status.is_server_error() {
1865 let content = resp.text().await?;
1866 match content_type {
1867 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1868 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateRepayLoanV1Resp`"))),
1869 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::PmarginCreateRepayLoanV1Resp`")))),
1870 }
1871 } else {
1872 let content = resp.text().await?;
1873 let entity: Option<PmarginCreateRepayLoanV1Error> = serde_json::from_str(&content).ok();
1874 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1875 }
1876}
1877
1878pub async fn pmargin_create_um_conditional_order_v1(configuration: &configuration::Configuration, params: PmarginCreateUmConditionalOrderV1Params) -> Result<models::PmarginCreateUmConditionalOrderV1Resp, Error<PmarginCreateUmConditionalOrderV1Error>> {
1880
1881 let uri_str = format!("{}/papi/v1/um/conditional/order", configuration.base_path);
1882 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1883
1884 let mut query_params: Vec<(String, String)> = Vec::new();
1886
1887
1888 let mut header_params = std::collections::HashMap::new();
1890
1891 if let Some(ref binance_auth) = configuration.binance_auth {
1893 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1895
1896 let body_string: Option<Vec<u8>> = None;
1898
1899 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1901 Ok(sig) => sig,
1902 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1903 };
1904
1905 query_params.push(("signature".to_string(), signature));
1907 }
1908
1909 if !query_params.is_empty() {
1911 req_builder = req_builder.query(&query_params);
1912 }
1913
1914
1915 if let Some(ref user_agent) = configuration.user_agent {
1917 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1918 }
1919
1920 for (header_name, header_value) in header_params {
1922 req_builder = req_builder.header(&header_name, &header_value);
1923 }
1924
1925 let mut multipart_form_params = std::collections::HashMap::new();
1926 if let Some(param_value) = params.activation_price {
1927 multipart_form_params.insert("activationPrice", param_value.to_string());
1928 }
1929 if let Some(param_value) = params.callback_rate {
1930 multipart_form_params.insert("callbackRate", param_value.to_string());
1931 }
1932 if let Some(param_value) = params.good_till_date {
1933 multipart_form_params.insert("goodTillDate", param_value.to_string());
1934 }
1935 if let Some(param_value) = params.new_client_strategy_id {
1936 multipart_form_params.insert("newClientStrategyId", param_value.to_string());
1937 }
1938 if let Some(param_value) = params.position_side {
1939 multipart_form_params.insert("positionSide", param_value.to_string());
1940 }
1941 if let Some(param_value) = params.price {
1942 multipart_form_params.insert("price", param_value.to_string());
1943 }
1944 if let Some(param_value) = params.price_match {
1945 multipart_form_params.insert("priceMatch", param_value.to_string());
1946 }
1947 if let Some(param_value) = params.price_protect {
1948 multipart_form_params.insert("priceProtect", param_value.to_string());
1949 }
1950 if let Some(param_value) = params.quantity {
1951 multipart_form_params.insert("quantity", param_value.to_string());
1952 }
1953 if let Some(param_value) = params.recv_window {
1954 multipart_form_params.insert("recvWindow", param_value.to_string());
1955 }
1956 if let Some(param_value) = params.reduce_only {
1957 multipart_form_params.insert("reduceOnly", param_value.to_string());
1958 }
1959 if let Some(param_value) = params.self_trade_prevention_mode {
1960 multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1961 }
1962 multipart_form_params.insert("side", params.side.to_string());
1963 if let Some(param_value) = params.stop_price {
1964 multipart_form_params.insert("stopPrice", param_value.to_string());
1965 }
1966 multipart_form_params.insert("strategyType", params.strategy_type.to_string());
1967 multipart_form_params.insert("symbol", params.symbol.to_string());
1968 if let Some(param_value) = params.time_in_force {
1969 multipart_form_params.insert("timeInForce", param_value.to_string());
1970 }
1971 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1972 if let Some(param_value) = params.working_type {
1973 multipart_form_params.insert("workingType", param_value.to_string());
1974 }
1975 req_builder = req_builder.form(&multipart_form_params);
1976
1977 let req = req_builder.build()?;
1978 let resp = configuration.client.execute(req).await?;
1979
1980 let status = resp.status();
1981 let content_type = resp
1982 .headers()
1983 .get("content-type")
1984 .and_then(|v| v.to_str().ok())
1985 .unwrap_or("application/octet-stream");
1986 let content_type = super::ContentType::from(content_type);
1987
1988 if !status.is_client_error() && !status.is_server_error() {
1989 let content = resp.text().await?;
1990 match content_type {
1991 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1992 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateUmConditionalOrderV1Resp`"))),
1993 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::PmarginCreateUmConditionalOrderV1Resp`")))),
1994 }
1995 } else {
1996 let content = resp.text().await?;
1997 let entity: Option<PmarginCreateUmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
1998 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1999 }
2000}
2001
2002pub async fn pmargin_create_um_fee_burn_v1(configuration: &configuration::Configuration, params: PmarginCreateUmFeeBurnV1Params) -> Result<models::PmarginCreateUmFeeBurnV1Resp, Error<PmarginCreateUmFeeBurnV1Error>> {
2004
2005 let uri_str = format!("{}/papi/v1/um/feeBurn", configuration.base_path);
2006 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2007
2008 let mut query_params: Vec<(String, String)> = Vec::new();
2010
2011
2012 let mut header_params = std::collections::HashMap::new();
2014
2015 if let Some(ref binance_auth) = configuration.binance_auth {
2017 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2019
2020 let body_string: Option<Vec<u8>> = None;
2022
2023 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2025 Ok(sig) => sig,
2026 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2027 };
2028
2029 query_params.push(("signature".to_string(), signature));
2031 }
2032
2033 if !query_params.is_empty() {
2035 req_builder = req_builder.query(&query_params);
2036 }
2037
2038
2039 if let Some(ref user_agent) = configuration.user_agent {
2041 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2042 }
2043
2044 for (header_name, header_value) in header_params {
2046 req_builder = req_builder.header(&header_name, &header_value);
2047 }
2048
2049 let mut multipart_form_params = std::collections::HashMap::new();
2050 multipart_form_params.insert("feeBurn", params.fee_burn.to_string());
2051 if let Some(param_value) = params.recv_window {
2052 multipart_form_params.insert("recvWindow", param_value.to_string());
2053 }
2054 multipart_form_params.insert("timestamp", params.timestamp.to_string());
2055 req_builder = req_builder.form(&multipart_form_params);
2056
2057 let req = req_builder.build()?;
2058 let resp = configuration.client.execute(req).await?;
2059
2060 let status = resp.status();
2061 let content_type = resp
2062 .headers()
2063 .get("content-type")
2064 .and_then(|v| v.to_str().ok())
2065 .unwrap_or("application/octet-stream");
2066 let content_type = super::ContentType::from(content_type);
2067
2068 if !status.is_client_error() && !status.is_server_error() {
2069 let content = resp.text().await?;
2070 match content_type {
2071 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2072 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateUmFeeBurnV1Resp`"))),
2073 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::PmarginCreateUmFeeBurnV1Resp`")))),
2074 }
2075 } else {
2076 let content = resp.text().await?;
2077 let entity: Option<PmarginCreateUmFeeBurnV1Error> = serde_json::from_str(&content).ok();
2078 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2079 }
2080}
2081
2082pub async fn pmargin_create_um_order_v1(configuration: &configuration::Configuration, params: PmarginCreateUmOrderV1Params) -> Result<models::PmarginCreateUmOrderV1Resp, Error<PmarginCreateUmOrderV1Error>> {
2084
2085 let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
2086 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2087
2088 let mut query_params: Vec<(String, String)> = Vec::new();
2090
2091
2092 let mut header_params = std::collections::HashMap::new();
2094
2095 if let Some(ref binance_auth) = configuration.binance_auth {
2097 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2099
2100 let body_string: Option<Vec<u8>> = None;
2102
2103 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2105 Ok(sig) => sig,
2106 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2107 };
2108
2109 query_params.push(("signature".to_string(), signature));
2111 }
2112
2113 if !query_params.is_empty() {
2115 req_builder = req_builder.query(&query_params);
2116 }
2117
2118
2119 if let Some(ref user_agent) = configuration.user_agent {
2121 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2122 }
2123
2124 for (header_name, header_value) in header_params {
2126 req_builder = req_builder.header(&header_name, &header_value);
2127 }
2128
2129 let mut multipart_form_params = std::collections::HashMap::new();
2130 if let Some(param_value) = params.good_till_date {
2131 multipart_form_params.insert("goodTillDate", param_value.to_string());
2132 }
2133 if let Some(param_value) = params.new_client_order_id {
2134 multipart_form_params.insert("newClientOrderId", param_value.to_string());
2135 }
2136 if let Some(param_value) = params.new_order_resp_type {
2137 multipart_form_params.insert("newOrderRespType", param_value.to_string());
2138 }
2139 if let Some(param_value) = params.position_side {
2140 multipart_form_params.insert("positionSide", param_value.to_string());
2141 }
2142 if let Some(param_value) = params.price {
2143 multipart_form_params.insert("price", param_value.to_string());
2144 }
2145 if let Some(param_value) = params.price_match {
2146 multipart_form_params.insert("priceMatch", param_value.to_string());
2147 }
2148 if let Some(param_value) = params.quantity {
2149 multipart_form_params.insert("quantity", param_value.to_string());
2150 }
2151 if let Some(param_value) = params.recv_window {
2152 multipart_form_params.insert("recvWindow", param_value.to_string());
2153 }
2154 if let Some(param_value) = params.reduce_only {
2155 multipart_form_params.insert("reduceOnly", param_value.to_string());
2156 }
2157 if let Some(param_value) = params.self_trade_prevention_mode {
2158 multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
2159 }
2160 multipart_form_params.insert("side", params.side.to_string());
2161 multipart_form_params.insert("symbol", params.symbol.to_string());
2162 if let Some(param_value) = params.time_in_force {
2163 multipart_form_params.insert("timeInForce", param_value.to_string());
2164 }
2165 multipart_form_params.insert("timestamp", params.timestamp.to_string());
2166 multipart_form_params.insert("type", params.r#type.to_string());
2167 req_builder = req_builder.form(&multipart_form_params);
2168
2169 let req = req_builder.build()?;
2170 let resp = configuration.client.execute(req).await?;
2171
2172 let status = resp.status();
2173 let content_type = resp
2174 .headers()
2175 .get("content-type")
2176 .and_then(|v| v.to_str().ok())
2177 .unwrap_or("application/octet-stream");
2178 let content_type = super::ContentType::from(content_type);
2179
2180 if !status.is_client_error() && !status.is_server_error() {
2181 let content = resp.text().await?;
2182 match content_type {
2183 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2184 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginCreateUmOrderV1Resp`"))),
2185 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::PmarginCreateUmOrderV1Resp`")))),
2186 }
2187 } else {
2188 let content = resp.text().await?;
2189 let entity: Option<PmarginCreateUmOrderV1Error> = serde_json::from_str(&content).ok();
2190 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2191 }
2192}
2193
2194pub async fn pmargin_delete_cm_all_open_orders_v1(configuration: &configuration::Configuration, params: PmarginDeleteCmAllOpenOrdersV1Params) -> Result<models::PmarginDeleteCmAllOpenOrdersV1Resp, Error<PmarginDeleteCmAllOpenOrdersV1Error>> {
2196
2197 let uri_str = format!("{}/papi/v1/cm/allOpenOrders", configuration.base_path);
2198 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2199
2200 let mut query_params: Vec<(String, String)> = Vec::new();
2202
2203 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2204 if let Some(ref param_value) = params.recv_window {
2205 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2206 }
2207 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2208
2209 let mut header_params = std::collections::HashMap::new();
2211
2212 if let Some(ref binance_auth) = configuration.binance_auth {
2214 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2216
2217 let body_string: Option<Vec<u8>> = None;
2219
2220 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2222 Ok(sig) => sig,
2223 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2224 };
2225
2226 query_params.push(("signature".to_string(), signature));
2228 }
2229
2230 if !query_params.is_empty() {
2232 req_builder = req_builder.query(&query_params);
2233 }
2234
2235
2236 if let Some(ref user_agent) = configuration.user_agent {
2238 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2239 }
2240
2241 for (header_name, header_value) in header_params {
2243 req_builder = req_builder.header(&header_name, &header_value);
2244 }
2245
2246
2247 let req = req_builder.build()?;
2248 let resp = configuration.client.execute(req).await?;
2249
2250 let status = resp.status();
2251 let content_type = resp
2252 .headers()
2253 .get("content-type")
2254 .and_then(|v| v.to_str().ok())
2255 .unwrap_or("application/octet-stream");
2256 let content_type = super::ContentType::from(content_type);
2257
2258 if !status.is_client_error() && !status.is_server_error() {
2259 let content = resp.text().await?;
2260 match content_type {
2261 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2262 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteCmAllOpenOrdersV1Resp`"))),
2263 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::PmarginDeleteCmAllOpenOrdersV1Resp`")))),
2264 }
2265 } else {
2266 let content = resp.text().await?;
2267 let entity: Option<PmarginDeleteCmAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
2268 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2269 }
2270}
2271
2272pub async fn pmargin_delete_cm_conditional_all_open_orders_v1(configuration: &configuration::Configuration, params: PmarginDeleteCmConditionalAllOpenOrdersV1Params) -> Result<models::PmarginDeleteCmConditionalAllOpenOrdersV1Resp, Error<PmarginDeleteCmConditionalAllOpenOrdersV1Error>> {
2274
2275 let uri_str = format!("{}/papi/v1/cm/conditional/allOpenOrders", configuration.base_path);
2276 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2277
2278 let mut query_params: Vec<(String, String)> = Vec::new();
2280
2281 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2282 if let Some(ref param_value) = params.recv_window {
2283 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2284 }
2285 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2286
2287 let mut header_params = std::collections::HashMap::new();
2289
2290 if let Some(ref binance_auth) = configuration.binance_auth {
2292 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2294
2295 let body_string: Option<Vec<u8>> = None;
2297
2298 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2300 Ok(sig) => sig,
2301 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2302 };
2303
2304 query_params.push(("signature".to_string(), signature));
2306 }
2307
2308 if !query_params.is_empty() {
2310 req_builder = req_builder.query(&query_params);
2311 }
2312
2313
2314 if let Some(ref user_agent) = configuration.user_agent {
2316 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2317 }
2318
2319 for (header_name, header_value) in header_params {
2321 req_builder = req_builder.header(&header_name, &header_value);
2322 }
2323
2324
2325 let req = req_builder.build()?;
2326 let resp = configuration.client.execute(req).await?;
2327
2328 let status = resp.status();
2329 let content_type = resp
2330 .headers()
2331 .get("content-type")
2332 .and_then(|v| v.to_str().ok())
2333 .unwrap_or("application/octet-stream");
2334 let content_type = super::ContentType::from(content_type);
2335
2336 if !status.is_client_error() && !status.is_server_error() {
2337 let content = resp.text().await?;
2338 match content_type {
2339 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2340 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteCmConditionalAllOpenOrdersV1Resp`"))),
2341 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::PmarginDeleteCmConditionalAllOpenOrdersV1Resp`")))),
2342 }
2343 } else {
2344 let content = resp.text().await?;
2345 let entity: Option<PmarginDeleteCmConditionalAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
2346 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2347 }
2348}
2349
2350pub async fn pmargin_delete_cm_conditional_order_v1(configuration: &configuration::Configuration, params: PmarginDeleteCmConditionalOrderV1Params) -> Result<models::PmarginDeleteCmConditionalOrderV1Resp, Error<PmarginDeleteCmConditionalOrderV1Error>> {
2352
2353 let uri_str = format!("{}/papi/v1/cm/conditional/order", configuration.base_path);
2354 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2355
2356 let mut query_params: Vec<(String, String)> = Vec::new();
2358
2359 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2360 if let Some(ref param_value) = params.strategy_id {
2361 query_params.push(("strategyId".to_string(), param_value.to_string()));
2362 }
2363 if let Some(ref param_value) = params.new_client_strategy_id {
2364 query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
2365 }
2366 if let Some(ref param_value) = params.recv_window {
2367 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2368 }
2369 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2370
2371 let mut header_params = std::collections::HashMap::new();
2373
2374 if let Some(ref binance_auth) = configuration.binance_auth {
2376 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2378
2379 let body_string: Option<Vec<u8>> = None;
2381
2382 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2384 Ok(sig) => sig,
2385 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2386 };
2387
2388 query_params.push(("signature".to_string(), signature));
2390 }
2391
2392 if !query_params.is_empty() {
2394 req_builder = req_builder.query(&query_params);
2395 }
2396
2397
2398 if let Some(ref user_agent) = configuration.user_agent {
2400 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2401 }
2402
2403 for (header_name, header_value) in header_params {
2405 req_builder = req_builder.header(&header_name, &header_value);
2406 }
2407
2408
2409 let req = req_builder.build()?;
2410 let resp = configuration.client.execute(req).await?;
2411
2412 let status = resp.status();
2413 let content_type = resp
2414 .headers()
2415 .get("content-type")
2416 .and_then(|v| v.to_str().ok())
2417 .unwrap_or("application/octet-stream");
2418 let content_type = super::ContentType::from(content_type);
2419
2420 if !status.is_client_error() && !status.is_server_error() {
2421 let content = resp.text().await?;
2422 match content_type {
2423 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2424 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteCmConditionalOrderV1Resp`"))),
2425 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::PmarginDeleteCmConditionalOrderV1Resp`")))),
2426 }
2427 } else {
2428 let content = resp.text().await?;
2429 let entity: Option<PmarginDeleteCmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
2430 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2431 }
2432}
2433
2434pub async fn pmargin_delete_cm_order_v1(configuration: &configuration::Configuration, params: PmarginDeleteCmOrderV1Params) -> Result<models::PmarginDeleteCmOrderV1Resp, Error<PmarginDeleteCmOrderV1Error>> {
2436
2437 let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
2438 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2439
2440 let mut query_params: Vec<(String, String)> = Vec::new();
2442
2443 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2444 if let Some(ref param_value) = params.order_id {
2445 query_params.push(("orderId".to_string(), param_value.to_string()));
2446 }
2447 if let Some(ref param_value) = params.orig_client_order_id {
2448 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2449 }
2450 if let Some(ref param_value) = params.recv_window {
2451 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2452 }
2453 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2454
2455 let mut header_params = std::collections::HashMap::new();
2457
2458 if let Some(ref binance_auth) = configuration.binance_auth {
2460 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2462
2463 let body_string: Option<Vec<u8>> = None;
2465
2466 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2468 Ok(sig) => sig,
2469 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2470 };
2471
2472 query_params.push(("signature".to_string(), signature));
2474 }
2475
2476 if !query_params.is_empty() {
2478 req_builder = req_builder.query(&query_params);
2479 }
2480
2481
2482 if let Some(ref user_agent) = configuration.user_agent {
2484 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2485 }
2486
2487 for (header_name, header_value) in header_params {
2489 req_builder = req_builder.header(&header_name, &header_value);
2490 }
2491
2492
2493 let req = req_builder.build()?;
2494 let resp = configuration.client.execute(req).await?;
2495
2496 let status = resp.status();
2497 let content_type = resp
2498 .headers()
2499 .get("content-type")
2500 .and_then(|v| v.to_str().ok())
2501 .unwrap_or("application/octet-stream");
2502 let content_type = super::ContentType::from(content_type);
2503
2504 if !status.is_client_error() && !status.is_server_error() {
2505 let content = resp.text().await?;
2506 match content_type {
2507 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2508 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteCmOrderV1Resp`"))),
2509 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::PmarginDeleteCmOrderV1Resp`")))),
2510 }
2511 } else {
2512 let content = resp.text().await?;
2513 let entity: Option<PmarginDeleteCmOrderV1Error> = serde_json::from_str(&content).ok();
2514 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2515 }
2516}
2517
2518pub async fn pmargin_delete_margin_all_open_orders_v1(configuration: &configuration::Configuration, params: PmarginDeleteMarginAllOpenOrdersV1Params) -> Result<Vec<models::PmarginDeleteMarginAllOpenOrdersV1RespInner>, Error<PmarginDeleteMarginAllOpenOrdersV1Error>> {
2520
2521 let uri_str = format!("{}/papi/v1/margin/allOpenOrders", configuration.base_path);
2522 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2523
2524 let mut query_params: Vec<(String, String)> = Vec::new();
2526
2527 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2528 if let Some(ref param_value) = params.recv_window {
2529 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2530 }
2531 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2532
2533 let mut header_params = std::collections::HashMap::new();
2535
2536 if let Some(ref binance_auth) = configuration.binance_auth {
2538 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2540
2541 let body_string: Option<Vec<u8>> = None;
2543
2544 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2546 Ok(sig) => sig,
2547 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2548 };
2549
2550 query_params.push(("signature".to_string(), signature));
2552 }
2553
2554 if !query_params.is_empty() {
2556 req_builder = req_builder.query(&query_params);
2557 }
2558
2559
2560 if let Some(ref user_agent) = configuration.user_agent {
2562 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2563 }
2564
2565 for (header_name, header_value) in header_params {
2567 req_builder = req_builder.header(&header_name, &header_value);
2568 }
2569
2570
2571 let req = req_builder.build()?;
2572 let resp = configuration.client.execute(req).await?;
2573
2574 let status = resp.status();
2575 let content_type = resp
2576 .headers()
2577 .get("content-type")
2578 .and_then(|v| v.to_str().ok())
2579 .unwrap_or("application/octet-stream");
2580 let content_type = super::ContentType::from(content_type);
2581
2582 if !status.is_client_error() && !status.is_server_error() {
2583 let content = resp.text().await?;
2584 match content_type {
2585 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2586 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginDeleteMarginAllOpenOrdersV1RespInner>`"))),
2587 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::PmarginDeleteMarginAllOpenOrdersV1RespInner>`")))),
2588 }
2589 } else {
2590 let content = resp.text().await?;
2591 let entity: Option<PmarginDeleteMarginAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
2592 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2593 }
2594}
2595
2596pub async fn pmargin_delete_margin_order_list_v1(configuration: &configuration::Configuration, params: PmarginDeleteMarginOrderListV1Params) -> Result<models::PmarginDeleteMarginOrderListV1Resp, Error<PmarginDeleteMarginOrderListV1Error>> {
2598
2599 let uri_str = format!("{}/papi/v1/margin/orderList", configuration.base_path);
2600 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2601
2602 let mut query_params: Vec<(String, String)> = Vec::new();
2604
2605 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2606 if let Some(ref param_value) = params.order_list_id {
2607 query_params.push(("orderListId".to_string(), param_value.to_string()));
2608 }
2609 if let Some(ref param_value) = params.list_client_order_id {
2610 query_params.push(("listClientOrderId".to_string(), param_value.to_string()));
2611 }
2612 if let Some(ref param_value) = params.new_client_order_id {
2613 query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
2614 }
2615 if let Some(ref param_value) = params.recv_window {
2616 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2617 }
2618 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2619
2620 let mut header_params = std::collections::HashMap::new();
2622
2623 if let Some(ref binance_auth) = configuration.binance_auth {
2625 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2627
2628 let body_string: Option<Vec<u8>> = None;
2630
2631 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2633 Ok(sig) => sig,
2634 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2635 };
2636
2637 query_params.push(("signature".to_string(), signature));
2639 }
2640
2641 if !query_params.is_empty() {
2643 req_builder = req_builder.query(&query_params);
2644 }
2645
2646
2647 if let Some(ref user_agent) = configuration.user_agent {
2649 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2650 }
2651
2652 for (header_name, header_value) in header_params {
2654 req_builder = req_builder.header(&header_name, &header_value);
2655 }
2656
2657
2658 let req = req_builder.build()?;
2659 let resp = configuration.client.execute(req).await?;
2660
2661 let status = resp.status();
2662 let content_type = resp
2663 .headers()
2664 .get("content-type")
2665 .and_then(|v| v.to_str().ok())
2666 .unwrap_or("application/octet-stream");
2667 let content_type = super::ContentType::from(content_type);
2668
2669 if !status.is_client_error() && !status.is_server_error() {
2670 let content = resp.text().await?;
2671 match content_type {
2672 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2673 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteMarginOrderListV1Resp`"))),
2674 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::PmarginDeleteMarginOrderListV1Resp`")))),
2675 }
2676 } else {
2677 let content = resp.text().await?;
2678 let entity: Option<PmarginDeleteMarginOrderListV1Error> = serde_json::from_str(&content).ok();
2679 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2680 }
2681}
2682
2683pub async fn pmargin_delete_margin_order_v1(configuration: &configuration::Configuration, params: PmarginDeleteMarginOrderV1Params) -> Result<models::PmarginDeleteMarginOrderV1Resp, Error<PmarginDeleteMarginOrderV1Error>> {
2685
2686 let uri_str = format!("{}/papi/v1/margin/order", configuration.base_path);
2687 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2688
2689 let mut query_params: Vec<(String, String)> = Vec::new();
2691
2692 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2693 if let Some(ref param_value) = params.order_id {
2694 query_params.push(("orderId".to_string(), param_value.to_string()));
2695 }
2696 if let Some(ref param_value) = params.orig_client_order_id {
2697 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2698 }
2699 if let Some(ref param_value) = params.new_client_order_id {
2700 query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
2701 }
2702 if let Some(ref param_value) = params.recv_window {
2703 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2704 }
2705 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2706
2707 let mut header_params = std::collections::HashMap::new();
2709
2710 if let Some(ref binance_auth) = configuration.binance_auth {
2712 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2714
2715 let body_string: Option<Vec<u8>> = None;
2717
2718 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2720 Ok(sig) => sig,
2721 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2722 };
2723
2724 query_params.push(("signature".to_string(), signature));
2726 }
2727
2728 if !query_params.is_empty() {
2730 req_builder = req_builder.query(&query_params);
2731 }
2732
2733
2734 if let Some(ref user_agent) = configuration.user_agent {
2736 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2737 }
2738
2739 for (header_name, header_value) in header_params {
2741 req_builder = req_builder.header(&header_name, &header_value);
2742 }
2743
2744
2745 let req = req_builder.build()?;
2746 let resp = configuration.client.execute(req).await?;
2747
2748 let status = resp.status();
2749 let content_type = resp
2750 .headers()
2751 .get("content-type")
2752 .and_then(|v| v.to_str().ok())
2753 .unwrap_or("application/octet-stream");
2754 let content_type = super::ContentType::from(content_type);
2755
2756 if !status.is_client_error() && !status.is_server_error() {
2757 let content = resp.text().await?;
2758 match content_type {
2759 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2760 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteMarginOrderV1Resp`"))),
2761 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::PmarginDeleteMarginOrderV1Resp`")))),
2762 }
2763 } else {
2764 let content = resp.text().await?;
2765 let entity: Option<PmarginDeleteMarginOrderV1Error> = serde_json::from_str(&content).ok();
2766 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2767 }
2768}
2769
2770pub async fn pmargin_delete_um_all_open_orders_v1(configuration: &configuration::Configuration, params: PmarginDeleteUmAllOpenOrdersV1Params) -> Result<models::PmarginDeleteUmAllOpenOrdersV1Resp, Error<PmarginDeleteUmAllOpenOrdersV1Error>> {
2772
2773 let uri_str = format!("{}/papi/v1/um/allOpenOrders", configuration.base_path);
2774 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2775
2776 let mut query_params: Vec<(String, String)> = Vec::new();
2778
2779 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2780 if let Some(ref param_value) = params.recv_window {
2781 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2782 }
2783 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2784
2785 let mut header_params = std::collections::HashMap::new();
2787
2788 if let Some(ref binance_auth) = configuration.binance_auth {
2790 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2792
2793 let body_string: Option<Vec<u8>> = None;
2795
2796 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2798 Ok(sig) => sig,
2799 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2800 };
2801
2802 query_params.push(("signature".to_string(), signature));
2804 }
2805
2806 if !query_params.is_empty() {
2808 req_builder = req_builder.query(&query_params);
2809 }
2810
2811
2812 if let Some(ref user_agent) = configuration.user_agent {
2814 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2815 }
2816
2817 for (header_name, header_value) in header_params {
2819 req_builder = req_builder.header(&header_name, &header_value);
2820 }
2821
2822
2823 let req = req_builder.build()?;
2824 let resp = configuration.client.execute(req).await?;
2825
2826 let status = resp.status();
2827 let content_type = resp
2828 .headers()
2829 .get("content-type")
2830 .and_then(|v| v.to_str().ok())
2831 .unwrap_or("application/octet-stream");
2832 let content_type = super::ContentType::from(content_type);
2833
2834 if !status.is_client_error() && !status.is_server_error() {
2835 let content = resp.text().await?;
2836 match content_type {
2837 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2838 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteUmAllOpenOrdersV1Resp`"))),
2839 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::PmarginDeleteUmAllOpenOrdersV1Resp`")))),
2840 }
2841 } else {
2842 let content = resp.text().await?;
2843 let entity: Option<PmarginDeleteUmAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
2844 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2845 }
2846}
2847
2848pub async fn pmargin_delete_um_conditional_all_open_orders_v1(configuration: &configuration::Configuration, params: PmarginDeleteUmConditionalAllOpenOrdersV1Params) -> Result<models::PmarginDeleteUmConditionalAllOpenOrdersV1Resp, Error<PmarginDeleteUmConditionalAllOpenOrdersV1Error>> {
2850
2851 let uri_str = format!("{}/papi/v1/um/conditional/allOpenOrders", configuration.base_path);
2852 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2853
2854 let mut query_params: Vec<(String, String)> = Vec::new();
2856
2857 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2858 if let Some(ref param_value) = params.recv_window {
2859 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2860 }
2861 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2862
2863 let mut header_params = std::collections::HashMap::new();
2865
2866 if let Some(ref binance_auth) = configuration.binance_auth {
2868 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2870
2871 let body_string: Option<Vec<u8>> = None;
2873
2874 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2876 Ok(sig) => sig,
2877 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2878 };
2879
2880 query_params.push(("signature".to_string(), signature));
2882 }
2883
2884 if !query_params.is_empty() {
2886 req_builder = req_builder.query(&query_params);
2887 }
2888
2889
2890 if let Some(ref user_agent) = configuration.user_agent {
2892 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2893 }
2894
2895 for (header_name, header_value) in header_params {
2897 req_builder = req_builder.header(&header_name, &header_value);
2898 }
2899
2900
2901 let req = req_builder.build()?;
2902 let resp = configuration.client.execute(req).await?;
2903
2904 let status = resp.status();
2905 let content_type = resp
2906 .headers()
2907 .get("content-type")
2908 .and_then(|v| v.to_str().ok())
2909 .unwrap_or("application/octet-stream");
2910 let content_type = super::ContentType::from(content_type);
2911
2912 if !status.is_client_error() && !status.is_server_error() {
2913 let content = resp.text().await?;
2914 match content_type {
2915 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2916 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteUmConditionalAllOpenOrdersV1Resp`"))),
2917 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::PmarginDeleteUmConditionalAllOpenOrdersV1Resp`")))),
2918 }
2919 } else {
2920 let content = resp.text().await?;
2921 let entity: Option<PmarginDeleteUmConditionalAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
2922 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2923 }
2924}
2925
2926pub async fn pmargin_delete_um_conditional_order_v1(configuration: &configuration::Configuration, params: PmarginDeleteUmConditionalOrderV1Params) -> Result<models::PmarginDeleteUmConditionalOrderV1Resp, Error<PmarginDeleteUmConditionalOrderV1Error>> {
2928
2929 let uri_str = format!("{}/papi/v1/um/conditional/order", configuration.base_path);
2930 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2931
2932 let mut query_params: Vec<(String, String)> = Vec::new();
2934
2935 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2936 if let Some(ref param_value) = params.strategy_id {
2937 query_params.push(("strategyId".to_string(), param_value.to_string()));
2938 }
2939 if let Some(ref param_value) = params.new_client_strategy_id {
2940 query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
2941 }
2942 if let Some(ref param_value) = params.recv_window {
2943 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2944 }
2945 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2946
2947 let mut header_params = std::collections::HashMap::new();
2949
2950 if let Some(ref binance_auth) = configuration.binance_auth {
2952 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2954
2955 let body_string: Option<Vec<u8>> = None;
2957
2958 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2960 Ok(sig) => sig,
2961 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2962 };
2963
2964 query_params.push(("signature".to_string(), signature));
2966 }
2967
2968 if !query_params.is_empty() {
2970 req_builder = req_builder.query(&query_params);
2971 }
2972
2973
2974 if let Some(ref user_agent) = configuration.user_agent {
2976 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2977 }
2978
2979 for (header_name, header_value) in header_params {
2981 req_builder = req_builder.header(&header_name, &header_value);
2982 }
2983
2984
2985 let req = req_builder.build()?;
2986 let resp = configuration.client.execute(req).await?;
2987
2988 let status = resp.status();
2989 let content_type = resp
2990 .headers()
2991 .get("content-type")
2992 .and_then(|v| v.to_str().ok())
2993 .unwrap_or("application/octet-stream");
2994 let content_type = super::ContentType::from(content_type);
2995
2996 if !status.is_client_error() && !status.is_server_error() {
2997 let content = resp.text().await?;
2998 match content_type {
2999 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3000 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteUmConditionalOrderV1Resp`"))),
3001 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::PmarginDeleteUmConditionalOrderV1Resp`")))),
3002 }
3003 } else {
3004 let content = resp.text().await?;
3005 let entity: Option<PmarginDeleteUmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
3006 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3007 }
3008}
3009
3010pub async fn pmargin_delete_um_order_v1(configuration: &configuration::Configuration, params: PmarginDeleteUmOrderV1Params) -> Result<models::PmarginDeleteUmOrderV1Resp, Error<PmarginDeleteUmOrderV1Error>> {
3012
3013 let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
3014 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
3015
3016 let mut query_params: Vec<(String, String)> = Vec::new();
3018
3019 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3020 if let Some(ref param_value) = params.order_id {
3021 query_params.push(("orderId".to_string(), param_value.to_string()));
3022 }
3023 if let Some(ref param_value) = params.orig_client_order_id {
3024 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
3025 }
3026 if let Some(ref param_value) = params.recv_window {
3027 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3028 }
3029 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3030
3031 let mut header_params = std::collections::HashMap::new();
3033
3034 if let Some(ref binance_auth) = configuration.binance_auth {
3036 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3038
3039 let body_string: Option<Vec<u8>> = None;
3041
3042 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3044 Ok(sig) => sig,
3045 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3046 };
3047
3048 query_params.push(("signature".to_string(), signature));
3050 }
3051
3052 if !query_params.is_empty() {
3054 req_builder = req_builder.query(&query_params);
3055 }
3056
3057
3058 if let Some(ref user_agent) = configuration.user_agent {
3060 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3061 }
3062
3063 for (header_name, header_value) in header_params {
3065 req_builder = req_builder.header(&header_name, &header_value);
3066 }
3067
3068
3069 let req = req_builder.build()?;
3070 let resp = configuration.client.execute(req).await?;
3071
3072 let status = resp.status();
3073 let content_type = resp
3074 .headers()
3075 .get("content-type")
3076 .and_then(|v| v.to_str().ok())
3077 .unwrap_or("application/octet-stream");
3078 let content_type = super::ContentType::from(content_type);
3079
3080 if !status.is_client_error() && !status.is_server_error() {
3081 let content = resp.text().await?;
3082 match content_type {
3083 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3084 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginDeleteUmOrderV1Resp`"))),
3085 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::PmarginDeleteUmOrderV1Resp`")))),
3086 }
3087 } else {
3088 let content = resp.text().await?;
3089 let entity: Option<PmarginDeleteUmOrderV1Error> = serde_json::from_str(&content).ok();
3090 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3091 }
3092}
3093
3094pub async fn pmargin_get_cm_adl_quantile_v1(configuration: &configuration::Configuration) -> Result<Vec<models::PmarginGetCmAdlQuantileV1RespItem>, Error<PmarginGetCmAdlQuantileV1Error>> {
3096
3097 let uri_str = format!("{}/papi/v1/cm/adlQuantile", configuration.base_path);
3098 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3099
3100 let mut query_params: Vec<(String, String)> = Vec::new();
3102
3103
3104 let mut header_params = std::collections::HashMap::new();
3106
3107 if let Some(ref binance_auth) = configuration.binance_auth {
3109 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3111
3112 let body_string: Option<Vec<u8>> = None;
3114
3115 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3117 Ok(sig) => sig,
3118 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3119 };
3120
3121 query_params.push(("signature".to_string(), signature));
3123 }
3124
3125 if !query_params.is_empty() {
3127 req_builder = req_builder.query(&query_params);
3128 }
3129
3130
3131 if let Some(ref user_agent) = configuration.user_agent {
3133 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3134 }
3135
3136 for (header_name, header_value) in header_params {
3138 req_builder = req_builder.header(&header_name, &header_value);
3139 }
3140
3141
3142 let req = req_builder.build()?;
3143 let resp = configuration.client.execute(req).await?;
3144
3145 let status = resp.status();
3146 let content_type = resp
3147 .headers()
3148 .get("content-type")
3149 .and_then(|v| v.to_str().ok())
3150 .unwrap_or("application/octet-stream");
3151 let content_type = super::ContentType::from(content_type);
3152
3153 if !status.is_client_error() && !status.is_server_error() {
3154 let content = resp.text().await?;
3155 match content_type {
3156 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3157 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmAdlQuantileV1RespItem>`"))),
3158 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::PmarginGetCmAdlQuantileV1RespItem>`")))),
3159 }
3160 } else {
3161 let content = resp.text().await?;
3162 let entity: Option<PmarginGetCmAdlQuantileV1Error> = serde_json::from_str(&content).ok();
3163 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3164 }
3165}
3166
3167pub async fn pmargin_get_cm_all_orders_v1(configuration: &configuration::Configuration, params: PmarginGetCmAllOrdersV1Params) -> Result<Vec<models::PmarginGetCmAllOrdersV1RespItem>, Error<PmarginGetCmAllOrdersV1Error>> {
3169
3170 let uri_str = format!("{}/papi/v1/cm/allOrders", configuration.base_path);
3171 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3172
3173 let mut query_params: Vec<(String, String)> = Vec::new();
3175
3176 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3177 if let Some(ref param_value) = params.pair {
3178 query_params.push(("pair".to_string(), param_value.to_string()));
3179 }
3180 if let Some(ref param_value) = params.order_id {
3181 query_params.push(("orderId".to_string(), param_value.to_string()));
3182 }
3183 if let Some(ref param_value) = params.start_time {
3184 query_params.push(("startTime".to_string(), param_value.to_string()));
3185 }
3186 if let Some(ref param_value) = params.end_time {
3187 query_params.push(("endTime".to_string(), param_value.to_string()));
3188 }
3189 if let Some(ref param_value) = params.limit {
3190 query_params.push(("limit".to_string(), param_value.to_string()));
3191 }
3192 if let Some(ref param_value) = params.recv_window {
3193 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3194 }
3195 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3196
3197 let mut header_params = std::collections::HashMap::new();
3199
3200 if let Some(ref binance_auth) = configuration.binance_auth {
3202 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3204
3205 let body_string: Option<Vec<u8>> = None;
3207
3208 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3210 Ok(sig) => sig,
3211 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3212 };
3213
3214 query_params.push(("signature".to_string(), signature));
3216 }
3217
3218 if !query_params.is_empty() {
3220 req_builder = req_builder.query(&query_params);
3221 }
3222
3223
3224 if let Some(ref user_agent) = configuration.user_agent {
3226 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3227 }
3228
3229 for (header_name, header_value) in header_params {
3231 req_builder = req_builder.header(&header_name, &header_value);
3232 }
3233
3234
3235 let req = req_builder.build()?;
3236 let resp = configuration.client.execute(req).await?;
3237
3238 let status = resp.status();
3239 let content_type = resp
3240 .headers()
3241 .get("content-type")
3242 .and_then(|v| v.to_str().ok())
3243 .unwrap_or("application/octet-stream");
3244 let content_type = super::ContentType::from(content_type);
3245
3246 if !status.is_client_error() && !status.is_server_error() {
3247 let content = resp.text().await?;
3248 match content_type {
3249 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3250 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmAllOrdersV1RespItem>`"))),
3251 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::PmarginGetCmAllOrdersV1RespItem>`")))),
3252 }
3253 } else {
3254 let content = resp.text().await?;
3255 let entity: Option<PmarginGetCmAllOrdersV1Error> = serde_json::from_str(&content).ok();
3256 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3257 }
3258}
3259
3260pub async fn pmargin_get_cm_conditional_all_orders_v1(configuration: &configuration::Configuration, params: PmarginGetCmConditionalAllOrdersV1Params) -> Result<Vec<models::PmarginGetCmConditionalAllOrdersV1RespItem>, Error<PmarginGetCmConditionalAllOrdersV1Error>> {
3262
3263 let uri_str = format!("{}/papi/v1/cm/conditional/allOrders", configuration.base_path);
3264 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3265
3266 let mut query_params: Vec<(String, String)> = Vec::new();
3268
3269 if let Some(ref param_value) = params.symbol {
3270 query_params.push(("symbol".to_string(), param_value.to_string()));
3271 }
3272 if let Some(ref param_value) = params.strategy_id {
3273 query_params.push(("strategyId".to_string(), param_value.to_string()));
3274 }
3275 if let Some(ref param_value) = params.start_time {
3276 query_params.push(("startTime".to_string(), param_value.to_string()));
3277 }
3278 if let Some(ref param_value) = params.end_time {
3279 query_params.push(("endTime".to_string(), param_value.to_string()));
3280 }
3281 if let Some(ref param_value) = params.limit {
3282 query_params.push(("limit".to_string(), param_value.to_string()));
3283 }
3284 if let Some(ref param_value) = params.recv_window {
3285 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3286 }
3287 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3288
3289 let mut header_params = std::collections::HashMap::new();
3291
3292 if let Some(ref binance_auth) = configuration.binance_auth {
3294 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3296
3297 let body_string: Option<Vec<u8>> = None;
3299
3300 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3302 Ok(sig) => sig,
3303 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3304 };
3305
3306 query_params.push(("signature".to_string(), signature));
3308 }
3309
3310 if !query_params.is_empty() {
3312 req_builder = req_builder.query(&query_params);
3313 }
3314
3315
3316 if let Some(ref user_agent) = configuration.user_agent {
3318 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3319 }
3320
3321 for (header_name, header_value) in header_params {
3323 req_builder = req_builder.header(&header_name, &header_value);
3324 }
3325
3326
3327 let req = req_builder.build()?;
3328 let resp = configuration.client.execute(req).await?;
3329
3330 let status = resp.status();
3331 let content_type = resp
3332 .headers()
3333 .get("content-type")
3334 .and_then(|v| v.to_str().ok())
3335 .unwrap_or("application/octet-stream");
3336 let content_type = super::ContentType::from(content_type);
3337
3338 if !status.is_client_error() && !status.is_server_error() {
3339 let content = resp.text().await?;
3340 match content_type {
3341 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3342 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmConditionalAllOrdersV1RespItem>`"))),
3343 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::PmarginGetCmConditionalAllOrdersV1RespItem>`")))),
3344 }
3345 } else {
3346 let content = resp.text().await?;
3347 let entity: Option<PmarginGetCmConditionalAllOrdersV1Error> = serde_json::from_str(&content).ok();
3348 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3349 }
3350}
3351
3352pub async fn pmargin_get_cm_conditional_open_order_v1(configuration: &configuration::Configuration, params: PmarginGetCmConditionalOpenOrderV1Params) -> Result<models::PmarginGetCmConditionalOpenOrderV1Resp, Error<PmarginGetCmConditionalOpenOrderV1Error>> {
3354
3355 let uri_str = format!("{}/papi/v1/cm/conditional/openOrder", configuration.base_path);
3356 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3357
3358 let mut query_params: Vec<(String, String)> = Vec::new();
3360
3361 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3362 if let Some(ref param_value) = params.strategy_id {
3363 query_params.push(("strategyId".to_string(), param_value.to_string()));
3364 }
3365 if let Some(ref param_value) = params.new_client_strategy_id {
3366 query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
3367 }
3368 if let Some(ref param_value) = params.recv_window {
3369 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3370 }
3371 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3372
3373 let mut header_params = std::collections::HashMap::new();
3375
3376 if let Some(ref binance_auth) = configuration.binance_auth {
3378 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3380
3381 let body_string: Option<Vec<u8>> = None;
3383
3384 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3386 Ok(sig) => sig,
3387 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3388 };
3389
3390 query_params.push(("signature".to_string(), signature));
3392 }
3393
3394 if !query_params.is_empty() {
3396 req_builder = req_builder.query(&query_params);
3397 }
3398
3399
3400 if let Some(ref user_agent) = configuration.user_agent {
3402 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3403 }
3404
3405 for (header_name, header_value) in header_params {
3407 req_builder = req_builder.header(&header_name, &header_value);
3408 }
3409
3410
3411 let req = req_builder.build()?;
3412 let resp = configuration.client.execute(req).await?;
3413
3414 let status = resp.status();
3415 let content_type = resp
3416 .headers()
3417 .get("content-type")
3418 .and_then(|v| v.to_str().ok())
3419 .unwrap_or("application/octet-stream");
3420 let content_type = super::ContentType::from(content_type);
3421
3422 if !status.is_client_error() && !status.is_server_error() {
3423 let content = resp.text().await?;
3424 match content_type {
3425 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3426 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetCmConditionalOpenOrderV1Resp`"))),
3427 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::PmarginGetCmConditionalOpenOrderV1Resp`")))),
3428 }
3429 } else {
3430 let content = resp.text().await?;
3431 let entity: Option<PmarginGetCmConditionalOpenOrderV1Error> = serde_json::from_str(&content).ok();
3432 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3433 }
3434}
3435
3436pub async fn pmargin_get_cm_conditional_open_orders_v1(configuration: &configuration::Configuration, params: PmarginGetCmConditionalOpenOrdersV1Params) -> Result<Vec<models::PmarginGetCmConditionalOpenOrdersV1RespItem>, Error<PmarginGetCmConditionalOpenOrdersV1Error>> {
3438
3439 let uri_str = format!("{}/papi/v1/cm/conditional/openOrders", configuration.base_path);
3440 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3441
3442 let mut query_params: Vec<(String, String)> = Vec::new();
3444
3445 if let Some(ref param_value) = params.symbol {
3446 query_params.push(("symbol".to_string(), param_value.to_string()));
3447 }
3448 if let Some(ref param_value) = params.recv_window {
3449 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3450 }
3451 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3452
3453 let mut header_params = std::collections::HashMap::new();
3455
3456 if let Some(ref binance_auth) = configuration.binance_auth {
3458 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3460
3461 let body_string: Option<Vec<u8>> = None;
3463
3464 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3466 Ok(sig) => sig,
3467 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3468 };
3469
3470 query_params.push(("signature".to_string(), signature));
3472 }
3473
3474 if !query_params.is_empty() {
3476 req_builder = req_builder.query(&query_params);
3477 }
3478
3479
3480 if let Some(ref user_agent) = configuration.user_agent {
3482 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3483 }
3484
3485 for (header_name, header_value) in header_params {
3487 req_builder = req_builder.header(&header_name, &header_value);
3488 }
3489
3490
3491 let req = req_builder.build()?;
3492 let resp = configuration.client.execute(req).await?;
3493
3494 let status = resp.status();
3495 let content_type = resp
3496 .headers()
3497 .get("content-type")
3498 .and_then(|v| v.to_str().ok())
3499 .unwrap_or("application/octet-stream");
3500 let content_type = super::ContentType::from(content_type);
3501
3502 if !status.is_client_error() && !status.is_server_error() {
3503 let content = resp.text().await?;
3504 match content_type {
3505 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3506 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmConditionalOpenOrdersV1RespItem>`"))),
3507 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::PmarginGetCmConditionalOpenOrdersV1RespItem>`")))),
3508 }
3509 } else {
3510 let content = resp.text().await?;
3511 let entity: Option<PmarginGetCmConditionalOpenOrdersV1Error> = serde_json::from_str(&content).ok();
3512 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3513 }
3514}
3515
3516pub async fn pmargin_get_cm_conditional_order_history_v1(configuration: &configuration::Configuration, params: PmarginGetCmConditionalOrderHistoryV1Params) -> Result<models::PmarginGetCmConditionalOrderHistoryV1Resp, Error<PmarginGetCmConditionalOrderHistoryV1Error>> {
3518
3519 let uri_str = format!("{}/papi/v1/cm/conditional/orderHistory", configuration.base_path);
3520 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3521
3522 let mut query_params: Vec<(String, String)> = Vec::new();
3524
3525 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3526 if let Some(ref param_value) = params.strategy_id {
3527 query_params.push(("strategyId".to_string(), param_value.to_string()));
3528 }
3529 if let Some(ref param_value) = params.new_client_strategy_id {
3530 query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
3531 }
3532 if let Some(ref param_value) = params.recv_window {
3533 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3534 }
3535 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3536
3537 let mut header_params = std::collections::HashMap::new();
3539
3540 if let Some(ref binance_auth) = configuration.binance_auth {
3542 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3544
3545 let body_string: Option<Vec<u8>> = None;
3547
3548 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3550 Ok(sig) => sig,
3551 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3552 };
3553
3554 query_params.push(("signature".to_string(), signature));
3556 }
3557
3558 if !query_params.is_empty() {
3560 req_builder = req_builder.query(&query_params);
3561 }
3562
3563
3564 if let Some(ref user_agent) = configuration.user_agent {
3566 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3567 }
3568
3569 for (header_name, header_value) in header_params {
3571 req_builder = req_builder.header(&header_name, &header_value);
3572 }
3573
3574
3575 let req = req_builder.build()?;
3576 let resp = configuration.client.execute(req).await?;
3577
3578 let status = resp.status();
3579 let content_type = resp
3580 .headers()
3581 .get("content-type")
3582 .and_then(|v| v.to_str().ok())
3583 .unwrap_or("application/octet-stream");
3584 let content_type = super::ContentType::from(content_type);
3585
3586 if !status.is_client_error() && !status.is_server_error() {
3587 let content = resp.text().await?;
3588 match content_type {
3589 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3590 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetCmConditionalOrderHistoryV1Resp`"))),
3591 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::PmarginGetCmConditionalOrderHistoryV1Resp`")))),
3592 }
3593 } else {
3594 let content = resp.text().await?;
3595 let entity: Option<PmarginGetCmConditionalOrderHistoryV1Error> = serde_json::from_str(&content).ok();
3596 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3597 }
3598}
3599
3600pub async fn pmargin_get_cm_force_orders_v1(configuration: &configuration::Configuration, params: PmarginGetCmForceOrdersV1Params) -> Result<Vec<models::PmarginGetCmForceOrdersV1RespItem>, Error<PmarginGetCmForceOrdersV1Error>> {
3602
3603 let uri_str = format!("{}/papi/v1/cm/forceOrders", configuration.base_path);
3604 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3605
3606 let mut query_params: Vec<(String, String)> = Vec::new();
3608
3609 if let Some(ref param_value) = params.symbol {
3610 query_params.push(("symbol".to_string(), param_value.to_string()));
3611 }
3612 if let Some(ref param_value) = params.auto_close_type {
3613 query_params.push(("autoCloseType".to_string(), param_value.to_string()));
3614 }
3615 if let Some(ref param_value) = params.start_time {
3616 query_params.push(("startTime".to_string(), param_value.to_string()));
3617 }
3618 if let Some(ref param_value) = params.end_time {
3619 query_params.push(("endTime".to_string(), param_value.to_string()));
3620 }
3621 if let Some(ref param_value) = params.limit {
3622 query_params.push(("limit".to_string(), param_value.to_string()));
3623 }
3624 if let Some(ref param_value) = params.recv_window {
3625 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3626 }
3627 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3628
3629 let mut header_params = std::collections::HashMap::new();
3631
3632 if let Some(ref binance_auth) = configuration.binance_auth {
3634 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3636
3637 let body_string: Option<Vec<u8>> = None;
3639
3640 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3642 Ok(sig) => sig,
3643 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3644 };
3645
3646 query_params.push(("signature".to_string(), signature));
3648 }
3649
3650 if !query_params.is_empty() {
3652 req_builder = req_builder.query(&query_params);
3653 }
3654
3655
3656 if let Some(ref user_agent) = configuration.user_agent {
3658 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3659 }
3660
3661 for (header_name, header_value) in header_params {
3663 req_builder = req_builder.header(&header_name, &header_value);
3664 }
3665
3666
3667 let req = req_builder.build()?;
3668 let resp = configuration.client.execute(req).await?;
3669
3670 let status = resp.status();
3671 let content_type = resp
3672 .headers()
3673 .get("content-type")
3674 .and_then(|v| v.to_str().ok())
3675 .unwrap_or("application/octet-stream");
3676 let content_type = super::ContentType::from(content_type);
3677
3678 if !status.is_client_error() && !status.is_server_error() {
3679 let content = resp.text().await?;
3680 match content_type {
3681 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3682 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmForceOrdersV1RespItem>`"))),
3683 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::PmarginGetCmForceOrdersV1RespItem>`")))),
3684 }
3685 } else {
3686 let content = resp.text().await?;
3687 let entity: Option<PmarginGetCmForceOrdersV1Error> = serde_json::from_str(&content).ok();
3688 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3689 }
3690}
3691
3692pub async fn pmargin_get_cm_open_order_v1(configuration: &configuration::Configuration, params: PmarginGetCmOpenOrderV1Params) -> Result<models::PmarginGetCmOpenOrderV1Resp, Error<PmarginGetCmOpenOrderV1Error>> {
3694
3695 let uri_str = format!("{}/papi/v1/cm/openOrder", configuration.base_path);
3696 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3697
3698 let mut query_params: Vec<(String, String)> = Vec::new();
3700
3701 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3702 if let Some(ref param_value) = params.order_id {
3703 query_params.push(("orderId".to_string(), param_value.to_string()));
3704 }
3705 if let Some(ref param_value) = params.orig_client_order_id {
3706 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
3707 }
3708 if let Some(ref param_value) = params.recv_window {
3709 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3710 }
3711 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3712
3713 let mut header_params = std::collections::HashMap::new();
3715
3716 if let Some(ref binance_auth) = configuration.binance_auth {
3718 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3720
3721 let body_string: Option<Vec<u8>> = None;
3723
3724 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3726 Ok(sig) => sig,
3727 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3728 };
3729
3730 query_params.push(("signature".to_string(), signature));
3732 }
3733
3734 if !query_params.is_empty() {
3736 req_builder = req_builder.query(&query_params);
3737 }
3738
3739
3740 if let Some(ref user_agent) = configuration.user_agent {
3742 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3743 }
3744
3745 for (header_name, header_value) in header_params {
3747 req_builder = req_builder.header(&header_name, &header_value);
3748 }
3749
3750
3751 let req = req_builder.build()?;
3752 let resp = configuration.client.execute(req).await?;
3753
3754 let status = resp.status();
3755 let content_type = resp
3756 .headers()
3757 .get("content-type")
3758 .and_then(|v| v.to_str().ok())
3759 .unwrap_or("application/octet-stream");
3760 let content_type = super::ContentType::from(content_type);
3761
3762 if !status.is_client_error() && !status.is_server_error() {
3763 let content = resp.text().await?;
3764 match content_type {
3765 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3766 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetCmOpenOrderV1Resp`"))),
3767 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::PmarginGetCmOpenOrderV1Resp`")))),
3768 }
3769 } else {
3770 let content = resp.text().await?;
3771 let entity: Option<PmarginGetCmOpenOrderV1Error> = serde_json::from_str(&content).ok();
3772 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3773 }
3774}
3775
3776pub async fn pmargin_get_cm_open_orders_v1(configuration: &configuration::Configuration, params: PmarginGetCmOpenOrdersV1Params) -> Result<Vec<models::PmarginGetCmOpenOrdersV1RespItem>, Error<PmarginGetCmOpenOrdersV1Error>> {
3778
3779 let uri_str = format!("{}/papi/v1/cm/openOrders", configuration.base_path);
3780 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3781
3782 let mut query_params: Vec<(String, String)> = Vec::new();
3784
3785 if let Some(ref param_value) = params.symbol {
3786 query_params.push(("symbol".to_string(), param_value.to_string()));
3787 }
3788 if let Some(ref param_value) = params.pair {
3789 query_params.push(("pair".to_string(), param_value.to_string()));
3790 }
3791 if let Some(ref param_value) = params.recv_window {
3792 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3793 }
3794 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3795
3796 let mut header_params = std::collections::HashMap::new();
3798
3799 if let Some(ref binance_auth) = configuration.binance_auth {
3801 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3803
3804 let body_string: Option<Vec<u8>> = None;
3806
3807 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3809 Ok(sig) => sig,
3810 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3811 };
3812
3813 query_params.push(("signature".to_string(), signature));
3815 }
3816
3817 if !query_params.is_empty() {
3819 req_builder = req_builder.query(&query_params);
3820 }
3821
3822
3823 if let Some(ref user_agent) = configuration.user_agent {
3825 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3826 }
3827
3828 for (header_name, header_value) in header_params {
3830 req_builder = req_builder.header(&header_name, &header_value);
3831 }
3832
3833
3834 let req = req_builder.build()?;
3835 let resp = configuration.client.execute(req).await?;
3836
3837 let status = resp.status();
3838 let content_type = resp
3839 .headers()
3840 .get("content-type")
3841 .and_then(|v| v.to_str().ok())
3842 .unwrap_or("application/octet-stream");
3843 let content_type = super::ContentType::from(content_type);
3844
3845 if !status.is_client_error() && !status.is_server_error() {
3846 let content = resp.text().await?;
3847 match content_type {
3848 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3849 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmOpenOrdersV1RespItem>`"))),
3850 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::PmarginGetCmOpenOrdersV1RespItem>`")))),
3851 }
3852 } else {
3853 let content = resp.text().await?;
3854 let entity: Option<PmarginGetCmOpenOrdersV1Error> = serde_json::from_str(&content).ok();
3855 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3856 }
3857}
3858
3859pub async fn pmargin_get_cm_order_amendment_v1(configuration: &configuration::Configuration, params: PmarginGetCmOrderAmendmentV1Params) -> Result<Vec<models::PmarginGetCmOrderAmendmentV1RespItem>, Error<PmarginGetCmOrderAmendmentV1Error>> {
3861
3862 let uri_str = format!("{}/papi/v1/cm/orderAmendment", configuration.base_path);
3863 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3864
3865 let mut query_params: Vec<(String, String)> = Vec::new();
3867
3868 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3869 if let Some(ref param_value) = params.order_id {
3870 query_params.push(("orderId".to_string(), param_value.to_string()));
3871 }
3872 if let Some(ref param_value) = params.orig_client_order_id {
3873 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
3874 }
3875 if let Some(ref param_value) = params.start_time {
3876 query_params.push(("startTime".to_string(), param_value.to_string()));
3877 }
3878 if let Some(ref param_value) = params.end_time {
3879 query_params.push(("endTime".to_string(), param_value.to_string()));
3880 }
3881 if let Some(ref param_value) = params.limit {
3882 query_params.push(("limit".to_string(), param_value.to_string()));
3883 }
3884 if let Some(ref param_value) = params.recv_window {
3885 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3886 }
3887 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3888
3889 let mut header_params = std::collections::HashMap::new();
3891
3892 if let Some(ref binance_auth) = configuration.binance_auth {
3894 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3896
3897 let body_string: Option<Vec<u8>> = None;
3899
3900 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3902 Ok(sig) => sig,
3903 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3904 };
3905
3906 query_params.push(("signature".to_string(), signature));
3908 }
3909
3910 if !query_params.is_empty() {
3912 req_builder = req_builder.query(&query_params);
3913 }
3914
3915
3916 if let Some(ref user_agent) = configuration.user_agent {
3918 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3919 }
3920
3921 for (header_name, header_value) in header_params {
3923 req_builder = req_builder.header(&header_name, &header_value);
3924 }
3925
3926
3927 let req = req_builder.build()?;
3928 let resp = configuration.client.execute(req).await?;
3929
3930 let status = resp.status();
3931 let content_type = resp
3932 .headers()
3933 .get("content-type")
3934 .and_then(|v| v.to_str().ok())
3935 .unwrap_or("application/octet-stream");
3936 let content_type = super::ContentType::from(content_type);
3937
3938 if !status.is_client_error() && !status.is_server_error() {
3939 let content = resp.text().await?;
3940 match content_type {
3941 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3942 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmOrderAmendmentV1RespItem>`"))),
3943 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::PmarginGetCmOrderAmendmentV1RespItem>`")))),
3944 }
3945 } else {
3946 let content = resp.text().await?;
3947 let entity: Option<PmarginGetCmOrderAmendmentV1Error> = serde_json::from_str(&content).ok();
3948 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3949 }
3950}
3951
3952pub async fn pmargin_get_cm_order_v1(configuration: &configuration::Configuration, params: PmarginGetCmOrderV1Params) -> Result<models::PmarginGetCmOrderV1Resp, Error<PmarginGetCmOrderV1Error>> {
3954
3955 let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
3956 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3957
3958 let mut query_params: Vec<(String, String)> = Vec::new();
3960
3961 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3962 if let Some(ref param_value) = params.order_id {
3963 query_params.push(("orderId".to_string(), param_value.to_string()));
3964 }
3965 if let Some(ref param_value) = params.orig_client_order_id {
3966 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
3967 }
3968 if let Some(ref param_value) = params.recv_window {
3969 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3970 }
3971 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3972
3973 let mut header_params = std::collections::HashMap::new();
3975
3976 if let Some(ref binance_auth) = configuration.binance_auth {
3978 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3980
3981 let body_string: Option<Vec<u8>> = None;
3983
3984 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3986 Ok(sig) => sig,
3987 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3988 };
3989
3990 query_params.push(("signature".to_string(), signature));
3992 }
3993
3994 if !query_params.is_empty() {
3996 req_builder = req_builder.query(&query_params);
3997 }
3998
3999
4000 if let Some(ref user_agent) = configuration.user_agent {
4002 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4003 }
4004
4005 for (header_name, header_value) in header_params {
4007 req_builder = req_builder.header(&header_name, &header_value);
4008 }
4009
4010
4011 let req = req_builder.build()?;
4012 let resp = configuration.client.execute(req).await?;
4013
4014 let status = resp.status();
4015 let content_type = resp
4016 .headers()
4017 .get("content-type")
4018 .and_then(|v| v.to_str().ok())
4019 .unwrap_or("application/octet-stream");
4020 let content_type = super::ContentType::from(content_type);
4021
4022 if !status.is_client_error() && !status.is_server_error() {
4023 let content = resp.text().await?;
4024 match content_type {
4025 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4026 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetCmOrderV1Resp`"))),
4027 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::PmarginGetCmOrderV1Resp`")))),
4028 }
4029 } else {
4030 let content = resp.text().await?;
4031 let entity: Option<PmarginGetCmOrderV1Error> = serde_json::from_str(&content).ok();
4032 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4033 }
4034}
4035
4036pub async fn pmargin_get_cm_user_trades_v1(configuration: &configuration::Configuration, params: PmarginGetCmUserTradesV1Params) -> Result<Vec<models::PmarginGetCmUserTradesV1RespItem>, Error<PmarginGetCmUserTradesV1Error>> {
4038
4039 let uri_str = format!("{}/papi/v1/cm/userTrades", configuration.base_path);
4040 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4041
4042 let mut query_params: Vec<(String, String)> = Vec::new();
4044
4045 if let Some(ref param_value) = params.symbol {
4046 query_params.push(("symbol".to_string(), param_value.to_string()));
4047 }
4048 if let Some(ref param_value) = params.pair {
4049 query_params.push(("pair".to_string(), param_value.to_string()));
4050 }
4051 if let Some(ref param_value) = params.start_time {
4052 query_params.push(("startTime".to_string(), param_value.to_string()));
4053 }
4054 if let Some(ref param_value) = params.end_time {
4055 query_params.push(("endTime".to_string(), param_value.to_string()));
4056 }
4057 if let Some(ref param_value) = params.from_id {
4058 query_params.push(("fromId".to_string(), param_value.to_string()));
4059 }
4060 if let Some(ref param_value) = params.limit {
4061 query_params.push(("limit".to_string(), param_value.to_string()));
4062 }
4063 if let Some(ref param_value) = params.recv_window {
4064 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4065 }
4066 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4067
4068 let mut header_params = std::collections::HashMap::new();
4070
4071 if let Some(ref binance_auth) = configuration.binance_auth {
4073 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4075
4076 let body_string: Option<Vec<u8>> = None;
4078
4079 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4081 Ok(sig) => sig,
4082 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4083 };
4084
4085 query_params.push(("signature".to_string(), signature));
4087 }
4088
4089 if !query_params.is_empty() {
4091 req_builder = req_builder.query(&query_params);
4092 }
4093
4094
4095 if let Some(ref user_agent) = configuration.user_agent {
4097 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4098 }
4099
4100 for (header_name, header_value) in header_params {
4102 req_builder = req_builder.header(&header_name, &header_value);
4103 }
4104
4105
4106 let req = req_builder.build()?;
4107 let resp = configuration.client.execute(req).await?;
4108
4109 let status = resp.status();
4110 let content_type = resp
4111 .headers()
4112 .get("content-type")
4113 .and_then(|v| v.to_str().ok())
4114 .unwrap_or("application/octet-stream");
4115 let content_type = super::ContentType::from(content_type);
4116
4117 if !status.is_client_error() && !status.is_server_error() {
4118 let content = resp.text().await?;
4119 match content_type {
4120 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4121 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetCmUserTradesV1RespItem>`"))),
4122 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::PmarginGetCmUserTradesV1RespItem>`")))),
4123 }
4124 } else {
4125 let content = resp.text().await?;
4126 let entity: Option<PmarginGetCmUserTradesV1Error> = serde_json::from_str(&content).ok();
4127 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4128 }
4129}
4130
4131pub async fn pmargin_get_margin_all_order_list_v1(configuration: &configuration::Configuration, params: PmarginGetMarginAllOrderListV1Params) -> Result<Vec<models::PmarginGetMarginAllOrderListV1RespItem>, Error<PmarginGetMarginAllOrderListV1Error>> {
4133
4134 let uri_str = format!("{}/papi/v1/margin/allOrderList", configuration.base_path);
4135 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4136
4137 let mut query_params: Vec<(String, String)> = Vec::new();
4139
4140 if let Some(ref param_value) = params.from_id {
4141 query_params.push(("fromId".to_string(), param_value.to_string()));
4142 }
4143 if let Some(ref param_value) = params.start_time {
4144 query_params.push(("startTime".to_string(), param_value.to_string()));
4145 }
4146 if let Some(ref param_value) = params.end_time {
4147 query_params.push(("endTime".to_string(), param_value.to_string()));
4148 }
4149 if let Some(ref param_value) = params.limit {
4150 query_params.push(("limit".to_string(), param_value.to_string()));
4151 }
4152 if let Some(ref param_value) = params.recv_window {
4153 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4154 }
4155 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4156
4157 let mut header_params = std::collections::HashMap::new();
4159
4160 if let Some(ref binance_auth) = configuration.binance_auth {
4162 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4164
4165 let body_string: Option<Vec<u8>> = None;
4167
4168 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4170 Ok(sig) => sig,
4171 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4172 };
4173
4174 query_params.push(("signature".to_string(), signature));
4176 }
4177
4178 if !query_params.is_empty() {
4180 req_builder = req_builder.query(&query_params);
4181 }
4182
4183
4184 if let Some(ref user_agent) = configuration.user_agent {
4186 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4187 }
4188
4189 for (header_name, header_value) in header_params {
4191 req_builder = req_builder.header(&header_name, &header_value);
4192 }
4193
4194
4195 let req = req_builder.build()?;
4196 let resp = configuration.client.execute(req).await?;
4197
4198 let status = resp.status();
4199 let content_type = resp
4200 .headers()
4201 .get("content-type")
4202 .and_then(|v| v.to_str().ok())
4203 .unwrap_or("application/octet-stream");
4204 let content_type = super::ContentType::from(content_type);
4205
4206 if !status.is_client_error() && !status.is_server_error() {
4207 let content = resp.text().await?;
4208 match content_type {
4209 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4210 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetMarginAllOrderListV1RespItem>`"))),
4211 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::PmarginGetMarginAllOrderListV1RespItem>`")))),
4212 }
4213 } else {
4214 let content = resp.text().await?;
4215 let entity: Option<PmarginGetMarginAllOrderListV1Error> = serde_json::from_str(&content).ok();
4216 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4217 }
4218}
4219
4220pub async fn pmargin_get_margin_all_orders_v1(configuration: &configuration::Configuration, params: PmarginGetMarginAllOrdersV1Params) -> Result<Vec<models::PmarginGetMarginAllOrdersV1RespItem>, Error<PmarginGetMarginAllOrdersV1Error>> {
4222
4223 let uri_str = format!("{}/papi/v1/margin/allOrders", configuration.base_path);
4224 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4225
4226 let mut query_params: Vec<(String, String)> = Vec::new();
4228
4229 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4230 if let Some(ref param_value) = params.order_id {
4231 query_params.push(("orderId".to_string(), param_value.to_string()));
4232 }
4233 if let Some(ref param_value) = params.start_time {
4234 query_params.push(("startTime".to_string(), param_value.to_string()));
4235 }
4236 if let Some(ref param_value) = params.end_time {
4237 query_params.push(("endTime".to_string(), param_value.to_string()));
4238 }
4239 if let Some(ref param_value) = params.limit {
4240 query_params.push(("limit".to_string(), param_value.to_string()));
4241 }
4242 if let Some(ref param_value) = params.recv_window {
4243 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4244 }
4245 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4246
4247 let mut header_params = std::collections::HashMap::new();
4249
4250 if let Some(ref binance_auth) = configuration.binance_auth {
4252 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4254
4255 let body_string: Option<Vec<u8>> = None;
4257
4258 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4260 Ok(sig) => sig,
4261 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4262 };
4263
4264 query_params.push(("signature".to_string(), signature));
4266 }
4267
4268 if !query_params.is_empty() {
4270 req_builder = req_builder.query(&query_params);
4271 }
4272
4273
4274 if let Some(ref user_agent) = configuration.user_agent {
4276 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4277 }
4278
4279 for (header_name, header_value) in header_params {
4281 req_builder = req_builder.header(&header_name, &header_value);
4282 }
4283
4284
4285 let req = req_builder.build()?;
4286 let resp = configuration.client.execute(req).await?;
4287
4288 let status = resp.status();
4289 let content_type = resp
4290 .headers()
4291 .get("content-type")
4292 .and_then(|v| v.to_str().ok())
4293 .unwrap_or("application/octet-stream");
4294 let content_type = super::ContentType::from(content_type);
4295
4296 if !status.is_client_error() && !status.is_server_error() {
4297 let content = resp.text().await?;
4298 match content_type {
4299 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4300 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetMarginAllOrdersV1RespItem>`"))),
4301 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::PmarginGetMarginAllOrdersV1RespItem>`")))),
4302 }
4303 } else {
4304 let content = resp.text().await?;
4305 let entity: Option<PmarginGetMarginAllOrdersV1Error> = serde_json::from_str(&content).ok();
4306 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4307 }
4308}
4309
4310pub async fn pmargin_get_margin_force_orders_v1(configuration: &configuration::Configuration, params: PmarginGetMarginForceOrdersV1Params) -> Result<models::PmarginGetMarginForceOrdersV1Resp, Error<PmarginGetMarginForceOrdersV1Error>> {
4312
4313 let uri_str = format!("{}/papi/v1/margin/forceOrders", configuration.base_path);
4314 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4315
4316 let mut query_params: Vec<(String, String)> = Vec::new();
4318
4319 if let Some(ref param_value) = params.start_time {
4320 query_params.push(("startTime".to_string(), param_value.to_string()));
4321 }
4322 if let Some(ref param_value) = params.end_time {
4323 query_params.push(("endTime".to_string(), param_value.to_string()));
4324 }
4325 if let Some(ref param_value) = params.current {
4326 query_params.push(("current".to_string(), param_value.to_string()));
4327 }
4328 if let Some(ref param_value) = params.size {
4329 query_params.push(("size".to_string(), param_value.to_string()));
4330 }
4331 if let Some(ref param_value) = params.recv_window {
4332 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4333 }
4334 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4335
4336 let mut header_params = std::collections::HashMap::new();
4338
4339 if let Some(ref binance_auth) = configuration.binance_auth {
4341 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4343
4344 let body_string: Option<Vec<u8>> = None;
4346
4347 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4349 Ok(sig) => sig,
4350 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4351 };
4352
4353 query_params.push(("signature".to_string(), signature));
4355 }
4356
4357 if !query_params.is_empty() {
4359 req_builder = req_builder.query(&query_params);
4360 }
4361
4362
4363 if let Some(ref user_agent) = configuration.user_agent {
4365 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4366 }
4367
4368 for (header_name, header_value) in header_params {
4370 req_builder = req_builder.header(&header_name, &header_value);
4371 }
4372
4373
4374 let req = req_builder.build()?;
4375 let resp = configuration.client.execute(req).await?;
4376
4377 let status = resp.status();
4378 let content_type = resp
4379 .headers()
4380 .get("content-type")
4381 .and_then(|v| v.to_str().ok())
4382 .unwrap_or("application/octet-stream");
4383 let content_type = super::ContentType::from(content_type);
4384
4385 if !status.is_client_error() && !status.is_server_error() {
4386 let content = resp.text().await?;
4387 match content_type {
4388 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4389 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetMarginForceOrdersV1Resp`"))),
4390 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::PmarginGetMarginForceOrdersV1Resp`")))),
4391 }
4392 } else {
4393 let content = resp.text().await?;
4394 let entity: Option<PmarginGetMarginForceOrdersV1Error> = serde_json::from_str(&content).ok();
4395 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4396 }
4397}
4398
4399pub async fn pmargin_get_margin_my_trades_v1(configuration: &configuration::Configuration, params: PmarginGetMarginMyTradesV1Params) -> Result<Vec<models::PmarginGetMarginMyTradesV1RespItem>, Error<PmarginGetMarginMyTradesV1Error>> {
4401
4402 let uri_str = format!("{}/papi/v1/margin/myTrades", configuration.base_path);
4403 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4404
4405 let mut query_params: Vec<(String, String)> = Vec::new();
4407
4408 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4409 if let Some(ref param_value) = params.order_id {
4410 query_params.push(("orderId".to_string(), param_value.to_string()));
4411 }
4412 if let Some(ref param_value) = params.start_time {
4413 query_params.push(("startTime".to_string(), param_value.to_string()));
4414 }
4415 if let Some(ref param_value) = params.end_time {
4416 query_params.push(("endTime".to_string(), param_value.to_string()));
4417 }
4418 if let Some(ref param_value) = params.from_id {
4419 query_params.push(("fromId".to_string(), param_value.to_string()));
4420 }
4421 if let Some(ref param_value) = params.limit {
4422 query_params.push(("limit".to_string(), param_value.to_string()));
4423 }
4424 if let Some(ref param_value) = params.recv_window {
4425 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4426 }
4427 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4428
4429 let mut header_params = std::collections::HashMap::new();
4431
4432 if let Some(ref binance_auth) = configuration.binance_auth {
4434 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4436
4437 let body_string: Option<Vec<u8>> = None;
4439
4440 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4442 Ok(sig) => sig,
4443 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4444 };
4445
4446 query_params.push(("signature".to_string(), signature));
4448 }
4449
4450 if !query_params.is_empty() {
4452 req_builder = req_builder.query(&query_params);
4453 }
4454
4455
4456 if let Some(ref user_agent) = configuration.user_agent {
4458 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4459 }
4460
4461 for (header_name, header_value) in header_params {
4463 req_builder = req_builder.header(&header_name, &header_value);
4464 }
4465
4466
4467 let req = req_builder.build()?;
4468 let resp = configuration.client.execute(req).await?;
4469
4470 let status = resp.status();
4471 let content_type = resp
4472 .headers()
4473 .get("content-type")
4474 .and_then(|v| v.to_str().ok())
4475 .unwrap_or("application/octet-stream");
4476 let content_type = super::ContentType::from(content_type);
4477
4478 if !status.is_client_error() && !status.is_server_error() {
4479 let content = resp.text().await?;
4480 match content_type {
4481 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4482 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetMarginMyTradesV1RespItem>`"))),
4483 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::PmarginGetMarginMyTradesV1RespItem>`")))),
4484 }
4485 } else {
4486 let content = resp.text().await?;
4487 let entity: Option<PmarginGetMarginMyTradesV1Error> = serde_json::from_str(&content).ok();
4488 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4489 }
4490}
4491
4492pub async fn pmargin_get_margin_open_order_list_v1(configuration: &configuration::Configuration, params: PmarginGetMarginOpenOrderListV1Params) -> Result<Vec<models::PmarginGetMarginOpenOrderListV1RespItem>, Error<PmarginGetMarginOpenOrderListV1Error>> {
4494
4495 let uri_str = format!("{}/papi/v1/margin/openOrderList", configuration.base_path);
4496 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4497
4498 let mut query_params: Vec<(String, String)> = Vec::new();
4500
4501 if let Some(ref param_value) = params.recv_window {
4502 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4503 }
4504 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4505
4506 let mut header_params = std::collections::HashMap::new();
4508
4509 if let Some(ref binance_auth) = configuration.binance_auth {
4511 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4513
4514 let body_string: Option<Vec<u8>> = None;
4516
4517 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4519 Ok(sig) => sig,
4520 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4521 };
4522
4523 query_params.push(("signature".to_string(), signature));
4525 }
4526
4527 if !query_params.is_empty() {
4529 req_builder = req_builder.query(&query_params);
4530 }
4531
4532
4533 if let Some(ref user_agent) = configuration.user_agent {
4535 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4536 }
4537
4538 for (header_name, header_value) in header_params {
4540 req_builder = req_builder.header(&header_name, &header_value);
4541 }
4542
4543
4544 let req = req_builder.build()?;
4545 let resp = configuration.client.execute(req).await?;
4546
4547 let status = resp.status();
4548 let content_type = resp
4549 .headers()
4550 .get("content-type")
4551 .and_then(|v| v.to_str().ok())
4552 .unwrap_or("application/octet-stream");
4553 let content_type = super::ContentType::from(content_type);
4554
4555 if !status.is_client_error() && !status.is_server_error() {
4556 let content = resp.text().await?;
4557 match content_type {
4558 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4559 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetMarginOpenOrderListV1RespItem>`"))),
4560 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::PmarginGetMarginOpenOrderListV1RespItem>`")))),
4561 }
4562 } else {
4563 let content = resp.text().await?;
4564 let entity: Option<PmarginGetMarginOpenOrderListV1Error> = serde_json::from_str(&content).ok();
4565 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4566 }
4567}
4568
4569pub async fn pmargin_get_margin_open_orders_v1(configuration: &configuration::Configuration, params: PmarginGetMarginOpenOrdersV1Params) -> Result<Vec<models::PmarginGetMarginOpenOrdersV1RespItem>, Error<PmarginGetMarginOpenOrdersV1Error>> {
4571
4572 let uri_str = format!("{}/papi/v1/margin/openOrders", configuration.base_path);
4573 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4574
4575 let mut query_params: Vec<(String, String)> = Vec::new();
4577
4578 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4579 if let Some(ref param_value) = params.recv_window {
4580 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4581 }
4582 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4583
4584 let mut header_params = std::collections::HashMap::new();
4586
4587 if let Some(ref binance_auth) = configuration.binance_auth {
4589 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4591
4592 let body_string: Option<Vec<u8>> = None;
4594
4595 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4597 Ok(sig) => sig,
4598 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4599 };
4600
4601 query_params.push(("signature".to_string(), signature));
4603 }
4604
4605 if !query_params.is_empty() {
4607 req_builder = req_builder.query(&query_params);
4608 }
4609
4610
4611 if let Some(ref user_agent) = configuration.user_agent {
4613 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4614 }
4615
4616 for (header_name, header_value) in header_params {
4618 req_builder = req_builder.header(&header_name, &header_value);
4619 }
4620
4621
4622 let req = req_builder.build()?;
4623 let resp = configuration.client.execute(req).await?;
4624
4625 let status = resp.status();
4626 let content_type = resp
4627 .headers()
4628 .get("content-type")
4629 .and_then(|v| v.to_str().ok())
4630 .unwrap_or("application/octet-stream");
4631 let content_type = super::ContentType::from(content_type);
4632
4633 if !status.is_client_error() && !status.is_server_error() {
4634 let content = resp.text().await?;
4635 match content_type {
4636 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4637 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetMarginOpenOrdersV1RespItem>`"))),
4638 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::PmarginGetMarginOpenOrdersV1RespItem>`")))),
4639 }
4640 } else {
4641 let content = resp.text().await?;
4642 let entity: Option<PmarginGetMarginOpenOrdersV1Error> = serde_json::from_str(&content).ok();
4643 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4644 }
4645}
4646
4647pub async fn pmargin_get_margin_order_list_v1(configuration: &configuration::Configuration, params: PmarginGetMarginOrderListV1Params) -> Result<models::PmarginGetMarginOrderListV1Resp, Error<PmarginGetMarginOrderListV1Error>> {
4649
4650 let uri_str = format!("{}/papi/v1/margin/orderList", configuration.base_path);
4651 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4652
4653 let mut query_params: Vec<(String, String)> = Vec::new();
4655
4656 if let Some(ref param_value) = params.order_list_id {
4657 query_params.push(("orderListId".to_string(), param_value.to_string()));
4658 }
4659 if let Some(ref param_value) = params.orig_client_order_id {
4660 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
4661 }
4662 if let Some(ref param_value) = params.recv_window {
4663 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4664 }
4665 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4666
4667 let mut header_params = std::collections::HashMap::new();
4669
4670 if let Some(ref binance_auth) = configuration.binance_auth {
4672 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4674
4675 let body_string: Option<Vec<u8>> = None;
4677
4678 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4680 Ok(sig) => sig,
4681 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4682 };
4683
4684 query_params.push(("signature".to_string(), signature));
4686 }
4687
4688 if !query_params.is_empty() {
4690 req_builder = req_builder.query(&query_params);
4691 }
4692
4693
4694 if let Some(ref user_agent) = configuration.user_agent {
4696 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4697 }
4698
4699 for (header_name, header_value) in header_params {
4701 req_builder = req_builder.header(&header_name, &header_value);
4702 }
4703
4704
4705 let req = req_builder.build()?;
4706 let resp = configuration.client.execute(req).await?;
4707
4708 let status = resp.status();
4709 let content_type = resp
4710 .headers()
4711 .get("content-type")
4712 .and_then(|v| v.to_str().ok())
4713 .unwrap_or("application/octet-stream");
4714 let content_type = super::ContentType::from(content_type);
4715
4716 if !status.is_client_error() && !status.is_server_error() {
4717 let content = resp.text().await?;
4718 match content_type {
4719 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4720 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetMarginOrderListV1Resp`"))),
4721 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::PmarginGetMarginOrderListV1Resp`")))),
4722 }
4723 } else {
4724 let content = resp.text().await?;
4725 let entity: Option<PmarginGetMarginOrderListV1Error> = serde_json::from_str(&content).ok();
4726 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4727 }
4728}
4729
4730pub async fn pmargin_get_margin_order_v1(configuration: &configuration::Configuration, params: PmarginGetMarginOrderV1Params) -> Result<models::PmarginGetMarginOrderV1Resp, Error<PmarginGetMarginOrderV1Error>> {
4732
4733 let uri_str = format!("{}/papi/v1/margin/order", configuration.base_path);
4734 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4735
4736 let mut query_params: Vec<(String, String)> = Vec::new();
4738
4739 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4740 if let Some(ref param_value) = params.order_id {
4741 query_params.push(("orderId".to_string(), param_value.to_string()));
4742 }
4743 if let Some(ref param_value) = params.orig_client_order_id {
4744 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
4745 }
4746 if let Some(ref param_value) = params.recv_window {
4747 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4748 }
4749 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4750
4751 let mut header_params = std::collections::HashMap::new();
4753
4754 if let Some(ref binance_auth) = configuration.binance_auth {
4756 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4758
4759 let body_string: Option<Vec<u8>> = None;
4761
4762 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4764 Ok(sig) => sig,
4765 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4766 };
4767
4768 query_params.push(("signature".to_string(), signature));
4770 }
4771
4772 if !query_params.is_empty() {
4774 req_builder = req_builder.query(&query_params);
4775 }
4776
4777
4778 if let Some(ref user_agent) = configuration.user_agent {
4780 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4781 }
4782
4783 for (header_name, header_value) in header_params {
4785 req_builder = req_builder.header(&header_name, &header_value);
4786 }
4787
4788
4789 let req = req_builder.build()?;
4790 let resp = configuration.client.execute(req).await?;
4791
4792 let status = resp.status();
4793 let content_type = resp
4794 .headers()
4795 .get("content-type")
4796 .and_then(|v| v.to_str().ok())
4797 .unwrap_or("application/octet-stream");
4798 let content_type = super::ContentType::from(content_type);
4799
4800 if !status.is_client_error() && !status.is_server_error() {
4801 let content = resp.text().await?;
4802 match content_type {
4803 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4804 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetMarginOrderV1Resp`"))),
4805 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::PmarginGetMarginOrderV1Resp`")))),
4806 }
4807 } else {
4808 let content = resp.text().await?;
4809 let entity: Option<PmarginGetMarginOrderV1Error> = serde_json::from_str(&content).ok();
4810 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4811 }
4812}
4813
4814pub async fn pmargin_get_um_adl_quantile_v1(configuration: &configuration::Configuration, params: PmarginGetUmAdlQuantileV1Params) -> Result<Vec<models::PmarginGetUmAdlQuantileV1RespItem>, Error<PmarginGetUmAdlQuantileV1Error>> {
4816
4817 let uri_str = format!("{}/papi/v1/um/adlQuantile", configuration.base_path);
4818 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4819
4820 let mut query_params: Vec<(String, String)> = Vec::new();
4822
4823 if let Some(ref param_value) = params.symbol {
4824 query_params.push(("symbol".to_string(), param_value.to_string()));
4825 }
4826 if let Some(ref param_value) = params.recv_window {
4827 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4828 }
4829 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4830
4831 let mut header_params = std::collections::HashMap::new();
4833
4834 if let Some(ref binance_auth) = configuration.binance_auth {
4836 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4838
4839 let body_string: Option<Vec<u8>> = None;
4841
4842 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4844 Ok(sig) => sig,
4845 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4846 };
4847
4848 query_params.push(("signature".to_string(), signature));
4850 }
4851
4852 if !query_params.is_empty() {
4854 req_builder = req_builder.query(&query_params);
4855 }
4856
4857
4858 if let Some(ref user_agent) = configuration.user_agent {
4860 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4861 }
4862
4863 for (header_name, header_value) in header_params {
4865 req_builder = req_builder.header(&header_name, &header_value);
4866 }
4867
4868
4869 let req = req_builder.build()?;
4870 let resp = configuration.client.execute(req).await?;
4871
4872 let status = resp.status();
4873 let content_type = resp
4874 .headers()
4875 .get("content-type")
4876 .and_then(|v| v.to_str().ok())
4877 .unwrap_or("application/octet-stream");
4878 let content_type = super::ContentType::from(content_type);
4879
4880 if !status.is_client_error() && !status.is_server_error() {
4881 let content = resp.text().await?;
4882 match content_type {
4883 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4884 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmAdlQuantileV1RespItem>`"))),
4885 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::PmarginGetUmAdlQuantileV1RespItem>`")))),
4886 }
4887 } else {
4888 let content = resp.text().await?;
4889 let entity: Option<PmarginGetUmAdlQuantileV1Error> = serde_json::from_str(&content).ok();
4890 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4891 }
4892}
4893
4894pub async fn pmargin_get_um_all_orders_v1(configuration: &configuration::Configuration, params: PmarginGetUmAllOrdersV1Params) -> Result<Vec<models::PmarginGetUmAllOrdersV1RespItem>, Error<PmarginGetUmAllOrdersV1Error>> {
4896
4897 let uri_str = format!("{}/papi/v1/um/allOrders", configuration.base_path);
4898 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4899
4900 let mut query_params: Vec<(String, String)> = Vec::new();
4902
4903 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4904 if let Some(ref param_value) = params.order_id {
4905 query_params.push(("orderId".to_string(), param_value.to_string()));
4906 }
4907 if let Some(ref param_value) = params.start_time {
4908 query_params.push(("startTime".to_string(), param_value.to_string()));
4909 }
4910 if let Some(ref param_value) = params.end_time {
4911 query_params.push(("endTime".to_string(), param_value.to_string()));
4912 }
4913 if let Some(ref param_value) = params.limit {
4914 query_params.push(("limit".to_string(), param_value.to_string()));
4915 }
4916 if let Some(ref param_value) = params.recv_window {
4917 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4918 }
4919 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4920
4921 let mut header_params = std::collections::HashMap::new();
4923
4924 if let Some(ref binance_auth) = configuration.binance_auth {
4926 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4928
4929 let body_string: Option<Vec<u8>> = None;
4931
4932 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4934 Ok(sig) => sig,
4935 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4936 };
4937
4938 query_params.push(("signature".to_string(), signature));
4940 }
4941
4942 if !query_params.is_empty() {
4944 req_builder = req_builder.query(&query_params);
4945 }
4946
4947
4948 if let Some(ref user_agent) = configuration.user_agent {
4950 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4951 }
4952
4953 for (header_name, header_value) in header_params {
4955 req_builder = req_builder.header(&header_name, &header_value);
4956 }
4957
4958
4959 let req = req_builder.build()?;
4960 let resp = configuration.client.execute(req).await?;
4961
4962 let status = resp.status();
4963 let content_type = resp
4964 .headers()
4965 .get("content-type")
4966 .and_then(|v| v.to_str().ok())
4967 .unwrap_or("application/octet-stream");
4968 let content_type = super::ContentType::from(content_type);
4969
4970 if !status.is_client_error() && !status.is_server_error() {
4971 let content = resp.text().await?;
4972 match content_type {
4973 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4974 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmAllOrdersV1RespItem>`"))),
4975 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::PmarginGetUmAllOrdersV1RespItem>`")))),
4976 }
4977 } else {
4978 let content = resp.text().await?;
4979 let entity: Option<PmarginGetUmAllOrdersV1Error> = serde_json::from_str(&content).ok();
4980 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4981 }
4982}
4983
4984pub async fn pmargin_get_um_conditional_all_orders_v1(configuration: &configuration::Configuration, params: PmarginGetUmConditionalAllOrdersV1Params) -> Result<Vec<models::PmarginGetUmConditionalAllOrdersV1RespItem>, Error<PmarginGetUmConditionalAllOrdersV1Error>> {
4986
4987 let uri_str = format!("{}/papi/v1/um/conditional/allOrders", configuration.base_path);
4988 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4989
4990 let mut query_params: Vec<(String, String)> = Vec::new();
4992
4993 if let Some(ref param_value) = params.symbol {
4994 query_params.push(("symbol".to_string(), param_value.to_string()));
4995 }
4996 if let Some(ref param_value) = params.strategy_id {
4997 query_params.push(("strategyId".to_string(), param_value.to_string()));
4998 }
4999 if let Some(ref param_value) = params.start_time {
5000 query_params.push(("startTime".to_string(), param_value.to_string()));
5001 }
5002 if let Some(ref param_value) = params.end_time {
5003 query_params.push(("endTime".to_string(), param_value.to_string()));
5004 }
5005 if let Some(ref param_value) = params.limit {
5006 query_params.push(("limit".to_string(), param_value.to_string()));
5007 }
5008 if let Some(ref param_value) = params.recv_window {
5009 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5010 }
5011 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5012
5013 let mut header_params = std::collections::HashMap::new();
5015
5016 if let Some(ref binance_auth) = configuration.binance_auth {
5018 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5020
5021 let body_string: Option<Vec<u8>> = None;
5023
5024 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5026 Ok(sig) => sig,
5027 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5028 };
5029
5030 query_params.push(("signature".to_string(), signature));
5032 }
5033
5034 if !query_params.is_empty() {
5036 req_builder = req_builder.query(&query_params);
5037 }
5038
5039
5040 if let Some(ref user_agent) = configuration.user_agent {
5042 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5043 }
5044
5045 for (header_name, header_value) in header_params {
5047 req_builder = req_builder.header(&header_name, &header_value);
5048 }
5049
5050
5051 let req = req_builder.build()?;
5052 let resp = configuration.client.execute(req).await?;
5053
5054 let status = resp.status();
5055 let content_type = resp
5056 .headers()
5057 .get("content-type")
5058 .and_then(|v| v.to_str().ok())
5059 .unwrap_or("application/octet-stream");
5060 let content_type = super::ContentType::from(content_type);
5061
5062 if !status.is_client_error() && !status.is_server_error() {
5063 let content = resp.text().await?;
5064 match content_type {
5065 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5066 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmConditionalAllOrdersV1RespItem>`"))),
5067 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::PmarginGetUmConditionalAllOrdersV1RespItem>`")))),
5068 }
5069 } else {
5070 let content = resp.text().await?;
5071 let entity: Option<PmarginGetUmConditionalAllOrdersV1Error> = serde_json::from_str(&content).ok();
5072 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5073 }
5074}
5075
5076pub async fn pmargin_get_um_conditional_open_order_v1(configuration: &configuration::Configuration, params: PmarginGetUmConditionalOpenOrderV1Params) -> Result<models::PmarginGetUmConditionalOpenOrderV1Resp, Error<PmarginGetUmConditionalOpenOrderV1Error>> {
5078
5079 let uri_str = format!("{}/papi/v1/um/conditional/openOrder", configuration.base_path);
5080 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5081
5082 let mut query_params: Vec<(String, String)> = Vec::new();
5084
5085 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5086 if let Some(ref param_value) = params.strategy_id {
5087 query_params.push(("strategyId".to_string(), param_value.to_string()));
5088 }
5089 if let Some(ref param_value) = params.new_client_strategy_id {
5090 query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
5091 }
5092 if let Some(ref param_value) = params.recv_window {
5093 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5094 }
5095 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5096
5097 let mut header_params = std::collections::HashMap::new();
5099
5100 if let Some(ref binance_auth) = configuration.binance_auth {
5102 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5104
5105 let body_string: Option<Vec<u8>> = None;
5107
5108 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5110 Ok(sig) => sig,
5111 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5112 };
5113
5114 query_params.push(("signature".to_string(), signature));
5116 }
5117
5118 if !query_params.is_empty() {
5120 req_builder = req_builder.query(&query_params);
5121 }
5122
5123
5124 if let Some(ref user_agent) = configuration.user_agent {
5126 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5127 }
5128
5129 for (header_name, header_value) in header_params {
5131 req_builder = req_builder.header(&header_name, &header_value);
5132 }
5133
5134
5135 let req = req_builder.build()?;
5136 let resp = configuration.client.execute(req).await?;
5137
5138 let status = resp.status();
5139 let content_type = resp
5140 .headers()
5141 .get("content-type")
5142 .and_then(|v| v.to_str().ok())
5143 .unwrap_or("application/octet-stream");
5144 let content_type = super::ContentType::from(content_type);
5145
5146 if !status.is_client_error() && !status.is_server_error() {
5147 let content = resp.text().await?;
5148 match content_type {
5149 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5150 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmConditionalOpenOrderV1Resp`"))),
5151 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::PmarginGetUmConditionalOpenOrderV1Resp`")))),
5152 }
5153 } else {
5154 let content = resp.text().await?;
5155 let entity: Option<PmarginGetUmConditionalOpenOrderV1Error> = serde_json::from_str(&content).ok();
5156 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5157 }
5158}
5159
5160pub async fn pmargin_get_um_conditional_open_orders_v1(configuration: &configuration::Configuration) -> Result<Vec<models::PmarginGetUmConditionalOpenOrdersV1RespItem>, Error<PmarginGetUmConditionalOpenOrdersV1Error>> {
5162
5163 let uri_str = format!("{}/papi/v1/um/conditional/openOrders", configuration.base_path);
5164 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5165
5166 let mut query_params: Vec<(String, String)> = Vec::new();
5168
5169
5170 let mut header_params = std::collections::HashMap::new();
5172
5173 if let Some(ref binance_auth) = configuration.binance_auth {
5175 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5177
5178 let body_string: Option<Vec<u8>> = None;
5180
5181 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5183 Ok(sig) => sig,
5184 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5185 };
5186
5187 query_params.push(("signature".to_string(), signature));
5189 }
5190
5191 if !query_params.is_empty() {
5193 req_builder = req_builder.query(&query_params);
5194 }
5195
5196
5197 if let Some(ref user_agent) = configuration.user_agent {
5199 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5200 }
5201
5202 for (header_name, header_value) in header_params {
5204 req_builder = req_builder.header(&header_name, &header_value);
5205 }
5206
5207
5208 let req = req_builder.build()?;
5209 let resp = configuration.client.execute(req).await?;
5210
5211 let status = resp.status();
5212 let content_type = resp
5213 .headers()
5214 .get("content-type")
5215 .and_then(|v| v.to_str().ok())
5216 .unwrap_or("application/octet-stream");
5217 let content_type = super::ContentType::from(content_type);
5218
5219 if !status.is_client_error() && !status.is_server_error() {
5220 let content = resp.text().await?;
5221 match content_type {
5222 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5223 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmConditionalOpenOrdersV1RespItem>`"))),
5224 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::PmarginGetUmConditionalOpenOrdersV1RespItem>`")))),
5225 }
5226 } else {
5227 let content = resp.text().await?;
5228 let entity: Option<PmarginGetUmConditionalOpenOrdersV1Error> = serde_json::from_str(&content).ok();
5229 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5230 }
5231}
5232
5233pub async fn pmargin_get_um_conditional_order_history_v1(configuration: &configuration::Configuration, params: PmarginGetUmConditionalOrderHistoryV1Params) -> Result<models::PmarginGetUmConditionalOrderHistoryV1Resp, Error<PmarginGetUmConditionalOrderHistoryV1Error>> {
5235
5236 let uri_str = format!("{}/papi/v1/um/conditional/orderHistory", configuration.base_path);
5237 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5238
5239 let mut query_params: Vec<(String, String)> = Vec::new();
5241
5242 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5243 if let Some(ref param_value) = params.strategy_id {
5244 query_params.push(("strategyId".to_string(), param_value.to_string()));
5245 }
5246 if let Some(ref param_value) = params.new_client_strategy_id {
5247 query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
5248 }
5249 if let Some(ref param_value) = params.recv_window {
5250 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5251 }
5252 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5253
5254 let mut header_params = std::collections::HashMap::new();
5256
5257 if let Some(ref binance_auth) = configuration.binance_auth {
5259 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5261
5262 let body_string: Option<Vec<u8>> = None;
5264
5265 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5267 Ok(sig) => sig,
5268 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5269 };
5270
5271 query_params.push(("signature".to_string(), signature));
5273 }
5274
5275 if !query_params.is_empty() {
5277 req_builder = req_builder.query(&query_params);
5278 }
5279
5280
5281 if let Some(ref user_agent) = configuration.user_agent {
5283 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5284 }
5285
5286 for (header_name, header_value) in header_params {
5288 req_builder = req_builder.header(&header_name, &header_value);
5289 }
5290
5291
5292 let req = req_builder.build()?;
5293 let resp = configuration.client.execute(req).await?;
5294
5295 let status = resp.status();
5296 let content_type = resp
5297 .headers()
5298 .get("content-type")
5299 .and_then(|v| v.to_str().ok())
5300 .unwrap_or("application/octet-stream");
5301 let content_type = super::ContentType::from(content_type);
5302
5303 if !status.is_client_error() && !status.is_server_error() {
5304 let content = resp.text().await?;
5305 match content_type {
5306 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5307 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmConditionalOrderHistoryV1Resp`"))),
5308 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::PmarginGetUmConditionalOrderHistoryV1Resp`")))),
5309 }
5310 } else {
5311 let content = resp.text().await?;
5312 let entity: Option<PmarginGetUmConditionalOrderHistoryV1Error> = serde_json::from_str(&content).ok();
5313 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5314 }
5315}
5316
5317pub async fn pmargin_get_um_fee_burn_v1(configuration: &configuration::Configuration, params: PmarginGetUmFeeBurnV1Params) -> Result<models::PmarginGetUmFeeBurnV1Resp, Error<PmarginGetUmFeeBurnV1Error>> {
5319
5320 let uri_str = format!("{}/papi/v1/um/feeBurn", configuration.base_path);
5321 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5322
5323 let mut query_params: Vec<(String, String)> = Vec::new();
5325
5326 if let Some(ref param_value) = params.recv_window {
5327 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5328 }
5329 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5330
5331 let mut header_params = std::collections::HashMap::new();
5333
5334 if let Some(ref binance_auth) = configuration.binance_auth {
5336 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5338
5339 let body_string: Option<Vec<u8>> = None;
5341
5342 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5344 Ok(sig) => sig,
5345 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5346 };
5347
5348 query_params.push(("signature".to_string(), signature));
5350 }
5351
5352 if !query_params.is_empty() {
5354 req_builder = req_builder.query(&query_params);
5355 }
5356
5357
5358 if let Some(ref user_agent) = configuration.user_agent {
5360 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5361 }
5362
5363 for (header_name, header_value) in header_params {
5365 req_builder = req_builder.header(&header_name, &header_value);
5366 }
5367
5368
5369 let req = req_builder.build()?;
5370 let resp = configuration.client.execute(req).await?;
5371
5372 let status = resp.status();
5373 let content_type = resp
5374 .headers()
5375 .get("content-type")
5376 .and_then(|v| v.to_str().ok())
5377 .unwrap_or("application/octet-stream");
5378 let content_type = super::ContentType::from(content_type);
5379
5380 if !status.is_client_error() && !status.is_server_error() {
5381 let content = resp.text().await?;
5382 match content_type {
5383 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5384 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmFeeBurnV1Resp`"))),
5385 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::PmarginGetUmFeeBurnV1Resp`")))),
5386 }
5387 } else {
5388 let content = resp.text().await?;
5389 let entity: Option<PmarginGetUmFeeBurnV1Error> = serde_json::from_str(&content).ok();
5390 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5391 }
5392}
5393
5394pub async fn pmargin_get_um_force_orders_v1(configuration: &configuration::Configuration, params: PmarginGetUmForceOrdersV1Params) -> Result<Vec<models::PmarginGetUmForceOrdersV1RespItem>, Error<PmarginGetUmForceOrdersV1Error>> {
5396
5397 let uri_str = format!("{}/papi/v1/um/forceOrders", configuration.base_path);
5398 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5399
5400 let mut query_params: Vec<(String, String)> = Vec::new();
5402
5403 if let Some(ref param_value) = params.symbol {
5404 query_params.push(("symbol".to_string(), param_value.to_string()));
5405 }
5406 if let Some(ref param_value) = params.auto_close_type {
5407 query_params.push(("autoCloseType".to_string(), param_value.to_string()));
5408 }
5409 if let Some(ref param_value) = params.start_time {
5410 query_params.push(("startTime".to_string(), param_value.to_string()));
5411 }
5412 if let Some(ref param_value) = params.end_time {
5413 query_params.push(("endTime".to_string(), param_value.to_string()));
5414 }
5415 if let Some(ref param_value) = params.limit {
5416 query_params.push(("limit".to_string(), param_value.to_string()));
5417 }
5418 if let Some(ref param_value) = params.recv_window {
5419 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5420 }
5421 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5422
5423 let mut header_params = std::collections::HashMap::new();
5425
5426 if let Some(ref binance_auth) = configuration.binance_auth {
5428 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5430
5431 let body_string: Option<Vec<u8>> = None;
5433
5434 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5436 Ok(sig) => sig,
5437 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5438 };
5439
5440 query_params.push(("signature".to_string(), signature));
5442 }
5443
5444 if !query_params.is_empty() {
5446 req_builder = req_builder.query(&query_params);
5447 }
5448
5449
5450 if let Some(ref user_agent) = configuration.user_agent {
5452 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5453 }
5454
5455 for (header_name, header_value) in header_params {
5457 req_builder = req_builder.header(&header_name, &header_value);
5458 }
5459
5460
5461 let req = req_builder.build()?;
5462 let resp = configuration.client.execute(req).await?;
5463
5464 let status = resp.status();
5465 let content_type = resp
5466 .headers()
5467 .get("content-type")
5468 .and_then(|v| v.to_str().ok())
5469 .unwrap_or("application/octet-stream");
5470 let content_type = super::ContentType::from(content_type);
5471
5472 if !status.is_client_error() && !status.is_server_error() {
5473 let content = resp.text().await?;
5474 match content_type {
5475 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5476 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmForceOrdersV1RespItem>`"))),
5477 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::PmarginGetUmForceOrdersV1RespItem>`")))),
5478 }
5479 } else {
5480 let content = resp.text().await?;
5481 let entity: Option<PmarginGetUmForceOrdersV1Error> = serde_json::from_str(&content).ok();
5482 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5483 }
5484}
5485
5486pub async fn pmargin_get_um_open_order_v1(configuration: &configuration::Configuration, params: PmarginGetUmOpenOrderV1Params) -> Result<models::PmarginGetUmOpenOrderV1Resp, Error<PmarginGetUmOpenOrderV1Error>> {
5488
5489 let uri_str = format!("{}/papi/v1/um/openOrder", configuration.base_path);
5490 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5491
5492 let mut query_params: Vec<(String, String)> = Vec::new();
5494
5495 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5496 if let Some(ref param_value) = params.order_id {
5497 query_params.push(("orderId".to_string(), param_value.to_string()));
5498 }
5499 if let Some(ref param_value) = params.orig_client_order_id {
5500 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
5501 }
5502 if let Some(ref param_value) = params.recv_window {
5503 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5504 }
5505 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5506
5507 let mut header_params = std::collections::HashMap::new();
5509
5510 if let Some(ref binance_auth) = configuration.binance_auth {
5512 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5514
5515 let body_string: Option<Vec<u8>> = None;
5517
5518 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5520 Ok(sig) => sig,
5521 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5522 };
5523
5524 query_params.push(("signature".to_string(), signature));
5526 }
5527
5528 if !query_params.is_empty() {
5530 req_builder = req_builder.query(&query_params);
5531 }
5532
5533
5534 if let Some(ref user_agent) = configuration.user_agent {
5536 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5537 }
5538
5539 for (header_name, header_value) in header_params {
5541 req_builder = req_builder.header(&header_name, &header_value);
5542 }
5543
5544
5545 let req = req_builder.build()?;
5546 let resp = configuration.client.execute(req).await?;
5547
5548 let status = resp.status();
5549 let content_type = resp
5550 .headers()
5551 .get("content-type")
5552 .and_then(|v| v.to_str().ok())
5553 .unwrap_or("application/octet-stream");
5554 let content_type = super::ContentType::from(content_type);
5555
5556 if !status.is_client_error() && !status.is_server_error() {
5557 let content = resp.text().await?;
5558 match content_type {
5559 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5560 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmOpenOrderV1Resp`"))),
5561 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::PmarginGetUmOpenOrderV1Resp`")))),
5562 }
5563 } else {
5564 let content = resp.text().await?;
5565 let entity: Option<PmarginGetUmOpenOrderV1Error> = serde_json::from_str(&content).ok();
5566 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5567 }
5568}
5569
5570pub async fn pmargin_get_um_open_orders_v1(configuration: &configuration::Configuration, params: PmarginGetUmOpenOrdersV1Params) -> Result<Vec<models::PmarginGetUmOpenOrdersV1RespItem>, Error<PmarginGetUmOpenOrdersV1Error>> {
5572
5573 let uri_str = format!("{}/papi/v1/um/openOrders", configuration.base_path);
5574 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5575
5576 let mut query_params: Vec<(String, String)> = Vec::new();
5578
5579 if let Some(ref param_value) = params.symbol {
5580 query_params.push(("symbol".to_string(), param_value.to_string()));
5581 }
5582 if let Some(ref param_value) = params.recv_window {
5583 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5584 }
5585 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5586
5587 let mut header_params = std::collections::HashMap::new();
5589
5590 if let Some(ref binance_auth) = configuration.binance_auth {
5592 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5594
5595 let body_string: Option<Vec<u8>> = None;
5597
5598 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5600 Ok(sig) => sig,
5601 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5602 };
5603
5604 query_params.push(("signature".to_string(), signature));
5606 }
5607
5608 if !query_params.is_empty() {
5610 req_builder = req_builder.query(&query_params);
5611 }
5612
5613
5614 if let Some(ref user_agent) = configuration.user_agent {
5616 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5617 }
5618
5619 for (header_name, header_value) in header_params {
5621 req_builder = req_builder.header(&header_name, &header_value);
5622 }
5623
5624
5625 let req = req_builder.build()?;
5626 let resp = configuration.client.execute(req).await?;
5627
5628 let status = resp.status();
5629 let content_type = resp
5630 .headers()
5631 .get("content-type")
5632 .and_then(|v| v.to_str().ok())
5633 .unwrap_or("application/octet-stream");
5634 let content_type = super::ContentType::from(content_type);
5635
5636 if !status.is_client_error() && !status.is_server_error() {
5637 let content = resp.text().await?;
5638 match content_type {
5639 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5640 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmOpenOrdersV1RespItem>`"))),
5641 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::PmarginGetUmOpenOrdersV1RespItem>`")))),
5642 }
5643 } else {
5644 let content = resp.text().await?;
5645 let entity: Option<PmarginGetUmOpenOrdersV1Error> = serde_json::from_str(&content).ok();
5646 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5647 }
5648}
5649
5650pub async fn pmargin_get_um_order_amendment_v1(configuration: &configuration::Configuration, params: PmarginGetUmOrderAmendmentV1Params) -> Result<Vec<models::PmarginGetUmOrderAmendmentV1RespItem>, Error<PmarginGetUmOrderAmendmentV1Error>> {
5652
5653 let uri_str = format!("{}/papi/v1/um/orderAmendment", configuration.base_path);
5654 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5655
5656 let mut query_params: Vec<(String, String)> = Vec::new();
5658
5659 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5660 if let Some(ref param_value) = params.order_id {
5661 query_params.push(("orderId".to_string(), param_value.to_string()));
5662 }
5663 if let Some(ref param_value) = params.orig_client_order_id {
5664 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
5665 }
5666 if let Some(ref param_value) = params.start_time {
5667 query_params.push(("startTime".to_string(), param_value.to_string()));
5668 }
5669 if let Some(ref param_value) = params.end_time {
5670 query_params.push(("endTime".to_string(), param_value.to_string()));
5671 }
5672 if let Some(ref param_value) = params.limit {
5673 query_params.push(("limit".to_string(), param_value.to_string()));
5674 }
5675 if let Some(ref param_value) = params.recv_window {
5676 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5677 }
5678 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5679
5680 let mut header_params = std::collections::HashMap::new();
5682
5683 if let Some(ref binance_auth) = configuration.binance_auth {
5685 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5687
5688 let body_string: Option<Vec<u8>> = None;
5690
5691 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5693 Ok(sig) => sig,
5694 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5695 };
5696
5697 query_params.push(("signature".to_string(), signature));
5699 }
5700
5701 if !query_params.is_empty() {
5703 req_builder = req_builder.query(&query_params);
5704 }
5705
5706
5707 if let Some(ref user_agent) = configuration.user_agent {
5709 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5710 }
5711
5712 for (header_name, header_value) in header_params {
5714 req_builder = req_builder.header(&header_name, &header_value);
5715 }
5716
5717
5718 let req = req_builder.build()?;
5719 let resp = configuration.client.execute(req).await?;
5720
5721 let status = resp.status();
5722 let content_type = resp
5723 .headers()
5724 .get("content-type")
5725 .and_then(|v| v.to_str().ok())
5726 .unwrap_or("application/octet-stream");
5727 let content_type = super::ContentType::from(content_type);
5728
5729 if !status.is_client_error() && !status.is_server_error() {
5730 let content = resp.text().await?;
5731 match content_type {
5732 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5733 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmOrderAmendmentV1RespItem>`"))),
5734 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::PmarginGetUmOrderAmendmentV1RespItem>`")))),
5735 }
5736 } else {
5737 let content = resp.text().await?;
5738 let entity: Option<PmarginGetUmOrderAmendmentV1Error> = serde_json::from_str(&content).ok();
5739 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5740 }
5741}
5742
5743pub async fn pmargin_get_um_order_v1(configuration: &configuration::Configuration, params: PmarginGetUmOrderV1Params) -> Result<models::PmarginGetUmOrderV1Resp, Error<PmarginGetUmOrderV1Error>> {
5745
5746 let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
5747 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5748
5749 let mut query_params: Vec<(String, String)> = Vec::new();
5751
5752 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5753 if let Some(ref param_value) = params.order_id {
5754 query_params.push(("orderId".to_string(), param_value.to_string()));
5755 }
5756 if let Some(ref param_value) = params.orig_client_order_id {
5757 query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
5758 }
5759 if let Some(ref param_value) = params.recv_window {
5760 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5761 }
5762 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5763
5764 let mut header_params = std::collections::HashMap::new();
5766
5767 if let Some(ref binance_auth) = configuration.binance_auth {
5769 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5771
5772 let body_string: Option<Vec<u8>> = None;
5774
5775 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5777 Ok(sig) => sig,
5778 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5779 };
5780
5781 query_params.push(("signature".to_string(), signature));
5783 }
5784
5785 if !query_params.is_empty() {
5787 req_builder = req_builder.query(&query_params);
5788 }
5789
5790
5791 if let Some(ref user_agent) = configuration.user_agent {
5793 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5794 }
5795
5796 for (header_name, header_value) in header_params {
5798 req_builder = req_builder.header(&header_name, &header_value);
5799 }
5800
5801
5802 let req = req_builder.build()?;
5803 let resp = configuration.client.execute(req).await?;
5804
5805 let status = resp.status();
5806 let content_type = resp
5807 .headers()
5808 .get("content-type")
5809 .and_then(|v| v.to_str().ok())
5810 .unwrap_or("application/octet-stream");
5811 let content_type = super::ContentType::from(content_type);
5812
5813 if !status.is_client_error() && !status.is_server_error() {
5814 let content = resp.text().await?;
5815 match content_type {
5816 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5817 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetUmOrderV1Resp`"))),
5818 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::PmarginGetUmOrderV1Resp`")))),
5819 }
5820 } else {
5821 let content = resp.text().await?;
5822 let entity: Option<PmarginGetUmOrderV1Error> = serde_json::from_str(&content).ok();
5823 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5824 }
5825}
5826
5827pub async fn pmargin_get_um_user_trades_v1(configuration: &configuration::Configuration, params: PmarginGetUmUserTradesV1Params) -> Result<Vec<models::PmarginGetUmUserTradesV1RespItem>, Error<PmarginGetUmUserTradesV1Error>> {
5829
5830 let uri_str = format!("{}/papi/v1/um/userTrades", configuration.base_path);
5831 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5832
5833 let mut query_params: Vec<(String, String)> = Vec::new();
5835
5836 query_params.push(("symbol".to_string(), params.symbol.to_string()));
5837 if let Some(ref param_value) = params.start_time {
5838 query_params.push(("startTime".to_string(), param_value.to_string()));
5839 }
5840 if let Some(ref param_value) = params.end_time {
5841 query_params.push(("endTime".to_string(), param_value.to_string()));
5842 }
5843 if let Some(ref param_value) = params.from_id {
5844 query_params.push(("fromId".to_string(), param_value.to_string()));
5845 }
5846 if let Some(ref param_value) = params.limit {
5847 query_params.push(("limit".to_string(), param_value.to_string()));
5848 }
5849 if let Some(ref param_value) = params.recv_window {
5850 query_params.push(("recvWindow".to_string(), param_value.to_string()));
5851 }
5852 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5853
5854 let mut header_params = std::collections::HashMap::new();
5856
5857 if let Some(ref binance_auth) = configuration.binance_auth {
5859 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5861
5862 let body_string: Option<Vec<u8>> = None;
5864
5865 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5867 Ok(sig) => sig,
5868 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5869 };
5870
5871 query_params.push(("signature".to_string(), signature));
5873 }
5874
5875 if !query_params.is_empty() {
5877 req_builder = req_builder.query(&query_params);
5878 }
5879
5880
5881 if let Some(ref user_agent) = configuration.user_agent {
5883 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5884 }
5885
5886 for (header_name, header_value) in header_params {
5888 req_builder = req_builder.header(&header_name, &header_value);
5889 }
5890
5891
5892 let req = req_builder.build()?;
5893 let resp = configuration.client.execute(req).await?;
5894
5895 let status = resp.status();
5896 let content_type = resp
5897 .headers()
5898 .get("content-type")
5899 .and_then(|v| v.to_str().ok())
5900 .unwrap_or("application/octet-stream");
5901 let content_type = super::ContentType::from(content_type);
5902
5903 if !status.is_client_error() && !status.is_server_error() {
5904 let content = resp.text().await?;
5905 match content_type {
5906 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5907 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PmarginGetUmUserTradesV1RespItem>`"))),
5908 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::PmarginGetUmUserTradesV1RespItem>`")))),
5909 }
5910 } else {
5911 let content = resp.text().await?;
5912 let entity: Option<PmarginGetUmUserTradesV1Error> = serde_json::from_str(&content).ok();
5913 Err(Error::ResponseError(ResponseContent { status, content, entity }))
5914 }
5915}
5916
5917pub async fn pmargin_update_cm_order_v1(configuration: &configuration::Configuration, params: PmarginUpdateCmOrderV1Params) -> Result<models::PmarginUpdateCmOrderV1Resp, Error<PmarginUpdateCmOrderV1Error>> {
5919
5920 let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
5921 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
5922
5923 let mut query_params: Vec<(String, String)> = Vec::new();
5925
5926
5927 let mut header_params = std::collections::HashMap::new();
5929
5930 if let Some(ref binance_auth) = configuration.binance_auth {
5932 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5934
5935 let body_string: Option<Vec<u8>> = None;
5937
5938 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5940 Ok(sig) => sig,
5941 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5942 };
5943
5944 query_params.push(("signature".to_string(), signature));
5946 }
5947
5948 if !query_params.is_empty() {
5950 req_builder = req_builder.query(&query_params);
5951 }
5952
5953
5954 if let Some(ref user_agent) = configuration.user_agent {
5956 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5957 }
5958
5959 for (header_name, header_value) in header_params {
5961 req_builder = req_builder.header(&header_name, &header_value);
5962 }
5963
5964 let mut multipart_form_params = std::collections::HashMap::new();
5965 if let Some(param_value) = params.order_id {
5966 multipart_form_params.insert("orderId", param_value.to_string());
5967 }
5968 if let Some(param_value) = params.orig_client_order_id {
5969 multipart_form_params.insert("origClientOrderId", param_value.to_string());
5970 }
5971 multipart_form_params.insert("price", params.price.to_string());
5972 if let Some(param_value) = params.price_match {
5973 multipart_form_params.insert("priceMatch", param_value.to_string());
5974 }
5975 multipart_form_params.insert("quantity", params.quantity.to_string());
5976 if let Some(param_value) = params.recv_window {
5977 multipart_form_params.insert("recvWindow", param_value.to_string());
5978 }
5979 multipart_form_params.insert("side", params.side.to_string());
5980 multipart_form_params.insert("symbol", params.symbol.to_string());
5981 multipart_form_params.insert("timestamp", params.timestamp.to_string());
5982 req_builder = req_builder.form(&multipart_form_params);
5983
5984 let req = req_builder.build()?;
5985 let resp = configuration.client.execute(req).await?;
5986
5987 let status = resp.status();
5988 let content_type = resp
5989 .headers()
5990 .get("content-type")
5991 .and_then(|v| v.to_str().ok())
5992 .unwrap_or("application/octet-stream");
5993 let content_type = super::ContentType::from(content_type);
5994
5995 if !status.is_client_error() && !status.is_server_error() {
5996 let content = resp.text().await?;
5997 match content_type {
5998 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5999 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginUpdateCmOrderV1Resp`"))),
6000 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::PmarginUpdateCmOrderV1Resp`")))),
6001 }
6002 } else {
6003 let content = resp.text().await?;
6004 let entity: Option<PmarginUpdateCmOrderV1Error> = serde_json::from_str(&content).ok();
6005 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6006 }
6007}
6008
6009pub async fn pmargin_update_um_order_v1(configuration: &configuration::Configuration, params: PmarginUpdateUmOrderV1Params) -> Result<models::PmarginUpdateUmOrderV1Resp, Error<PmarginUpdateUmOrderV1Error>> {
6011
6012 let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
6013 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
6014
6015 let mut query_params: Vec<(String, String)> = Vec::new();
6017
6018
6019 let mut header_params = std::collections::HashMap::new();
6021
6022 if let Some(ref binance_auth) = configuration.binance_auth {
6024 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6026
6027 let body_string: Option<Vec<u8>> = None;
6029
6030 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6032 Ok(sig) => sig,
6033 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6034 };
6035
6036 query_params.push(("signature".to_string(), signature));
6038 }
6039
6040 if !query_params.is_empty() {
6042 req_builder = req_builder.query(&query_params);
6043 }
6044
6045
6046 if let Some(ref user_agent) = configuration.user_agent {
6048 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6049 }
6050
6051 for (header_name, header_value) in header_params {
6053 req_builder = req_builder.header(&header_name, &header_value);
6054 }
6055
6056 let mut multipart_form_params = std::collections::HashMap::new();
6057 if let Some(param_value) = params.order_id {
6058 multipart_form_params.insert("orderId", param_value.to_string());
6059 }
6060 if let Some(param_value) = params.orig_client_order_id {
6061 multipart_form_params.insert("origClientOrderId", param_value.to_string());
6062 }
6063 multipart_form_params.insert("price", params.price.to_string());
6064 if let Some(param_value) = params.price_match {
6065 multipart_form_params.insert("priceMatch", param_value.to_string());
6066 }
6067 multipart_form_params.insert("quantity", params.quantity.to_string());
6068 if let Some(param_value) = params.recv_window {
6069 multipart_form_params.insert("recvWindow", param_value.to_string());
6070 }
6071 multipart_form_params.insert("side", params.side.to_string());
6072 multipart_form_params.insert("symbol", params.symbol.to_string());
6073 multipart_form_params.insert("timestamp", params.timestamp.to_string());
6074 req_builder = req_builder.form(&multipart_form_params);
6075
6076 let req = req_builder.build()?;
6077 let resp = configuration.client.execute(req).await?;
6078
6079 let status = resp.status();
6080 let content_type = resp
6081 .headers()
6082 .get("content-type")
6083 .and_then(|v| v.to_str().ok())
6084 .unwrap_or("application/octet-stream");
6085 let content_type = super::ContentType::from(content_type);
6086
6087 if !status.is_client_error() && !status.is_server_error() {
6088 let content = resp.text().await?;
6089 match content_type {
6090 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6091 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginUpdateUmOrderV1Resp`"))),
6092 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::PmarginUpdateUmOrderV1Resp`")))),
6093 }
6094 } else {
6095 let content = resp.text().await?;
6096 let entity: Option<PmarginUpdateUmOrderV1Error> = serde_json::from_str(&content).ok();
6097 Err(Error::ResponseError(ResponseContent { status, content, entity }))
6098 }
6099}
6100