binance/derivatives/pmargin/apis/
trade_api.rs

1/*
2 * Binance Portfolio Margin API
3 *
4 * OpenAPI specification for Binance exchange - Pmargin API
5 *
6 * The version of the OpenAPI document: 0.1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::derivatives::pmargin::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`pmargin_create_cm_conditional_order_v1`]
18#[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/// struct for passing parameters to the method [`pmargin_create_cm_order_v1`]
39#[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/// struct for passing parameters to the method [`pmargin_create_margin_loan_v1`]
57#[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/// struct for passing parameters to the method [`pmargin_create_margin_order_oco_v1`]
66#[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/// struct for passing parameters to the method [`pmargin_create_margin_order_v1`]
87#[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/// struct for passing parameters to the method [`pmargin_create_margin_repay_debt_v1`]
108#[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/// struct for passing parameters to the method [`pmargin_create_repay_loan_v1`]
118#[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/// struct for passing parameters to the method [`pmargin_create_um_conditional_order_v1`]
127#[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/// struct for passing parameters to the method [`pmargin_create_um_fee_burn_v1`]
151#[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/// struct for passing parameters to the method [`pmargin_create_um_order_v1`]
159#[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/// struct for passing parameters to the method [`pmargin_delete_cm_all_open_orders_v1`]
179#[derive(Clone, Debug, Default)]
180pub struct PmarginDeleteCmAllOpenOrdersV1Params {
181    pub symbol: String,
182    pub timestamp: i64,
183    pub recv_window: Option<i64>
184}
185
186/// struct for passing parameters to the method [`pmargin_delete_cm_conditional_all_open_orders_v1`]
187#[derive(Clone, Debug, Default)]
188pub struct PmarginDeleteCmConditionalAllOpenOrdersV1Params {
189    pub symbol: String,
190    pub timestamp: i64,
191    pub recv_window: Option<i64>
192}
193
194/// struct for passing parameters to the method [`pmargin_delete_cm_conditional_order_v1`]
195#[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/// struct for passing parameters to the method [`pmargin_delete_cm_order_v1`]
205#[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/// struct for passing parameters to the method [`pmargin_delete_margin_all_open_orders_v1`]
215#[derive(Clone, Debug, Default)]
216pub struct PmarginDeleteMarginAllOpenOrdersV1Params {
217    pub symbol: String,
218    pub timestamp: i64,
219    /// The value cannot be greater than 60000
220    pub recv_window: Option<i64>
221}
222
223/// struct for passing parameters to the method [`pmargin_delete_margin_order_list_v1`]
224#[derive(Clone, Debug, Default)]
225pub struct PmarginDeleteMarginOrderListV1Params {
226    pub symbol: String,
227    pub timestamp: i64,
228    /// Either `orderListId` or `listClientOrderId` must be provided
229    pub order_list_id: Option<i64>,
230    /// Either `orderListId` or `listClientOrderId` must be provided
231    pub list_client_order_id: Option<String>,
232    /// Used to uniquely identify this cancel. Automatically generated by default
233    pub new_client_order_id: Option<String>,
234    /// The value cannot be greater than 60000
235    pub recv_window: Option<i64>
236}
237
238/// struct for passing parameters to the method [`pmargin_delete_margin_order_v1`]
239#[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    /// Used to uniquely identify this cancel. Automatically generated by default.
246    pub new_client_order_id: Option<String>,
247    /// The value cannot be greater than `60000`
248    pub recv_window: Option<i64>
249}
250
251/// struct for passing parameters to the method [`pmargin_delete_um_all_open_orders_v1`]
252#[derive(Clone, Debug, Default)]
253pub struct PmarginDeleteUmAllOpenOrdersV1Params {
254    pub symbol: String,
255    pub timestamp: i64,
256    pub recv_window: Option<i64>
257}
258
259/// struct for passing parameters to the method [`pmargin_delete_um_conditional_all_open_orders_v1`]
260#[derive(Clone, Debug, Default)]
261pub struct PmarginDeleteUmConditionalAllOpenOrdersV1Params {
262    pub symbol: String,
263    pub timestamp: i64,
264    pub recv_window: Option<i64>
265}
266
267/// struct for passing parameters to the method [`pmargin_delete_um_conditional_order_v1`]
268#[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/// struct for passing parameters to the method [`pmargin_delete_um_order_v1`]
278#[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/// struct for passing parameters to the method [`pmargin_get_cm_all_orders_v1`]
288#[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    /// Default 50; max 100.
297    pub limit: Option<i32>,
298    pub recv_window: Option<i64>
299}
300
301/// struct for passing parameters to the method [`pmargin_get_cm_conditional_all_orders_v1`]
302#[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    /// Default 500; max 1000.
310    pub limit: Option<i32>,
311    pub recv_window: Option<i64>
312}
313
314/// struct for passing parameters to the method [`pmargin_get_cm_conditional_open_order_v1`]
315#[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/// struct for passing parameters to the method [`pmargin_get_cm_conditional_open_orders_v1`]
325#[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/// struct for passing parameters to the method [`pmargin_get_cm_conditional_order_history_v1`]
333#[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/// struct for passing parameters to the method [`pmargin_get_cm_force_orders_v1`]
343#[derive(Clone, Debug, Default)]
344pub struct PmarginGetCmForceOrdersV1Params {
345    pub timestamp: i64,
346    pub symbol: Option<String>,
347    /// &#34;LIQUIDATION&#34; for liquidation orders, &#34;ADL&#34; for ADL orders.
348    pub auto_close_type: Option<String>,
349    pub start_time: Option<i64>,
350    pub end_time: Option<i64>,
351    /// Default 50; max 100.
352    pub limit: Option<i32>,
353    /// The value cannot be greater than 60000
354    pub recv_window: Option<i64>
355}
356
357/// struct for passing parameters to the method [`pmargin_get_cm_open_order_v1`]
358#[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/// struct for passing parameters to the method [`pmargin_get_cm_open_orders_v1`]
368#[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/// struct for passing parameters to the method [`pmargin_get_cm_order_amendment_v1`]
377#[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    /// Timestamp in ms to get modification history from INCLUSIVE
384    pub start_time: Option<i64>,
385    /// Timestamp in ms to get modification history until INCLUSIVE
386    pub end_time: Option<i64>,
387    /// Default 50, max 100
388    pub limit: Option<i32>,
389    pub recv_window: Option<i64>
390}
391
392/// struct for passing parameters to the method [`pmargin_get_cm_order_v1`]
393#[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/// struct for passing parameters to the method [`pmargin_get_cm_user_trades_v1`]
403#[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    /// Trade id to fetch from. Default gets most recent trades.
411    pub from_id: Option<i64>,
412    /// Default 50; max 1000.
413    pub limit: Option<i32>,
414    pub recv_window: Option<i64>
415}
416
417/// struct for passing parameters to the method [`pmargin_get_margin_all_order_list_v1`]
418#[derive(Clone, Debug, Default)]
419pub struct PmarginGetMarginAllOrderListV1Params {
420    pub timestamp: i64,
421    /// If supplied, neither startTime or endTime can be provided
422    pub from_id: Option<i64>,
423    pub start_time: Option<i64>,
424    pub end_time: Option<i64>,
425    /// Default 500; max 500.
426    pub limit: Option<i32>,
427    /// The value cannot be greater than 60000
428    pub recv_window: Option<i64>
429}
430
431/// struct for passing parameters to the method [`pmargin_get_margin_all_orders_v1`]
432#[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    /// Default 500; max 500.
440    pub limit: Option<i32>,
441    /// The value cannot be greater than 60000
442    pub recv_window: Option<i64>
443}
444
445/// struct for passing parameters to the method [`pmargin_get_margin_force_orders_v1`]
446#[derive(Clone, Debug, Default)]
447pub struct PmarginGetMarginForceOrdersV1Params {
448    pub timestamp: i64,
449    pub start_time: Option<i64>,
450    pub end_time: Option<i64>,
451    /// Currently querying page. Start from 1. Default:1
452    pub current: Option<i64>,
453    /// Default:10 Max:100
454    pub size: Option<i64>,
455    /// The value cannot be greater than 60000
456    pub recv_window: Option<i64>
457}
458
459/// struct for passing parameters to the method [`pmargin_get_margin_my_trades_v1`]
460#[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    /// TradeId to fetch from. Default gets most recent trades.
468    pub from_id: Option<i64>,
469    /// Default 500; max 1000.
470    pub limit: Option<i32>,
471    /// The value cannot be greater than 60000
472    pub recv_window: Option<i64>
473}
474
475/// struct for passing parameters to the method [`pmargin_get_margin_open_order_list_v1`]
476#[derive(Clone, Debug, Default)]
477pub struct PmarginGetMarginOpenOrderListV1Params {
478    pub timestamp: i64,
479    /// The value cannot be greater than 60000
480    pub recv_window: Option<i64>
481}
482
483/// struct for passing parameters to the method [`pmargin_get_margin_open_orders_v1`]
484#[derive(Clone, Debug, Default)]
485pub struct PmarginGetMarginOpenOrdersV1Params {
486    pub symbol: String,
487    pub timestamp: i64,
488    /// The value cannot be greater than 60000
489    pub recv_window: Option<i64>
490}
491
492/// struct for passing parameters to the method [`pmargin_get_margin_order_list_v1`]
493#[derive(Clone, Debug, Default)]
494pub struct PmarginGetMarginOrderListV1Params {
495    pub timestamp: i64,
496    /// Either orderListId or origClientOrderId must be provided
497    pub order_list_id: Option<i64>,
498    /// Either orderListId or origClientOrderId must be provided
499    pub orig_client_order_id: Option<String>,
500    /// The value cannot be greater than 60000
501    pub recv_window: Option<i64>
502}
503
504/// struct for passing parameters to the method [`pmargin_get_margin_order_v1`]
505#[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    /// The value cannot be greater than 60000
512    pub recv_window: Option<i64>
513}
514
515/// struct for passing parameters to the method [`pmargin_get_um_adl_quantile_v1`]
516#[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/// struct for passing parameters to the method [`pmargin_get_um_all_orders_v1`]
524#[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    /// Default 500; max 1000.
532    pub limit: Option<i32>,
533    pub recv_window: Option<i64>
534}
535
536/// struct for passing parameters to the method [`pmargin_get_um_conditional_all_orders_v1`]
537#[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    /// Default 500; max 1000.
545    pub limit: Option<i32>,
546    pub recv_window: Option<i64>
547}
548
549/// struct for passing parameters to the method [`pmargin_get_um_conditional_open_order_v1`]
550#[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/// struct for passing parameters to the method [`pmargin_get_um_conditional_order_history_v1`]
560#[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/// struct for passing parameters to the method [`pmargin_get_um_fee_burn_v1`]
570#[derive(Clone, Debug, Default)]
571pub struct PmarginGetUmFeeBurnV1Params {
572    pub timestamp: i64,
573    pub recv_window: Option<i64>
574}
575
576/// struct for passing parameters to the method [`pmargin_get_um_force_orders_v1`]
577#[derive(Clone, Debug, Default)]
578pub struct PmarginGetUmForceOrdersV1Params {
579    pub timestamp: i64,
580    pub symbol: Option<String>,
581    /// `LIQUIDATION` for liquidation orders, `ADL` for ADL orders.
582    pub auto_close_type: Option<String>,
583    pub start_time: Option<i64>,
584    pub end_time: Option<i64>,
585    /// Default 50; max 100.
586    pub limit: Option<i32>,
587    /// The value cannot be greater than 60000
588    pub recv_window: Option<i64>
589}
590
591/// struct for passing parameters to the method [`pmargin_get_um_open_order_v1`]
592#[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/// struct for passing parameters to the method [`pmargin_get_um_open_orders_v1`]
602#[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/// struct for passing parameters to the method [`pmargin_get_um_order_amendment_v1`]
610#[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    /// Timestamp in ms to get modification history from INCLUSIVE
617    pub start_time: Option<i64>,
618    /// Timestamp in ms to get modification history until INCLUSIVE
619    pub end_time: Option<i64>,
620    /// Default 500, max 1000
621    pub limit: Option<i32>,
622    pub recv_window: Option<i64>
623}
624
625/// struct for passing parameters to the method [`pmargin_get_um_order_v1`]
626#[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/// struct for passing parameters to the method [`pmargin_get_um_user_trades_v1`]
636#[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    /// Trade id to fetch from. Default gets most recent trades.
643    pub from_id: Option<i64>,
644    /// Default 500; max 1000.
645    pub limit: Option<i32>,
646    pub recv_window: Option<i64>
647}
648
649/// struct for passing parameters to the method [`pmargin_update_cm_order_v1`]
650#[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/// struct for passing parameters to the method [`pmargin_update_um_order_v1`]
664#[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/// struct for typed errors of method [`pmargin_create_cm_conditional_order_v1`]
679#[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/// struct for typed errors of method [`pmargin_create_cm_order_v1`]
688#[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/// struct for typed errors of method [`pmargin_create_margin_loan_v1`]
697#[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/// struct for typed errors of method [`pmargin_create_margin_order_oco_v1`]
706#[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/// struct for typed errors of method [`pmargin_create_margin_order_v1`]
715#[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/// struct for typed errors of method [`pmargin_create_margin_repay_debt_v1`]
724#[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/// struct for typed errors of method [`pmargin_create_repay_loan_v1`]
733#[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/// struct for typed errors of method [`pmargin_create_um_conditional_order_v1`]
742#[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/// struct for typed errors of method [`pmargin_create_um_fee_burn_v1`]
751#[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/// struct for typed errors of method [`pmargin_create_um_order_v1`]
760#[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/// struct for typed errors of method [`pmargin_delete_cm_all_open_orders_v1`]
769#[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/// struct for typed errors of method [`pmargin_delete_cm_conditional_all_open_orders_v1`]
778#[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/// struct for typed errors of method [`pmargin_delete_cm_conditional_order_v1`]
787#[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/// struct for typed errors of method [`pmargin_delete_cm_order_v1`]
796#[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/// struct for typed errors of method [`pmargin_delete_margin_all_open_orders_v1`]
805#[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/// struct for typed errors of method [`pmargin_delete_margin_order_list_v1`]
814#[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/// struct for typed errors of method [`pmargin_delete_margin_order_v1`]
823#[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/// struct for typed errors of method [`pmargin_delete_um_all_open_orders_v1`]
832#[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/// struct for typed errors of method [`pmargin_delete_um_conditional_all_open_orders_v1`]
841#[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/// struct for typed errors of method [`pmargin_delete_um_conditional_order_v1`]
850#[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/// struct for typed errors of method [`pmargin_delete_um_order_v1`]
859#[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/// struct for typed errors of method [`pmargin_get_cm_adl_quantile_v1`]
868#[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/// struct for typed errors of method [`pmargin_get_cm_all_orders_v1`]
877#[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/// struct for typed errors of method [`pmargin_get_cm_conditional_all_orders_v1`]
886#[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/// struct for typed errors of method [`pmargin_get_cm_conditional_open_order_v1`]
895#[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/// struct for typed errors of method [`pmargin_get_cm_conditional_open_orders_v1`]
904#[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/// struct for typed errors of method [`pmargin_get_cm_conditional_order_history_v1`]
913#[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/// struct for typed errors of method [`pmargin_get_cm_force_orders_v1`]
922#[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/// struct for typed errors of method [`pmargin_get_cm_open_order_v1`]
931#[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/// struct for typed errors of method [`pmargin_get_cm_open_orders_v1`]
940#[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/// struct for typed errors of method [`pmargin_get_cm_order_amendment_v1`]
949#[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/// struct for typed errors of method [`pmargin_get_cm_order_v1`]
958#[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/// struct for typed errors of method [`pmargin_get_cm_user_trades_v1`]
967#[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/// struct for typed errors of method [`pmargin_get_margin_all_order_list_v1`]
976#[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/// struct for typed errors of method [`pmargin_get_margin_all_orders_v1`]
985#[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/// struct for typed errors of method [`pmargin_get_margin_force_orders_v1`]
994#[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/// struct for typed errors of method [`pmargin_get_margin_my_trades_v1`]
1003#[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/// struct for typed errors of method [`pmargin_get_margin_open_order_list_v1`]
1012#[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/// struct for typed errors of method [`pmargin_get_margin_open_orders_v1`]
1021#[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/// struct for typed errors of method [`pmargin_get_margin_order_list_v1`]
1030#[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/// struct for typed errors of method [`pmargin_get_margin_order_v1`]
1039#[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/// struct for typed errors of method [`pmargin_get_um_adl_quantile_v1`]
1048#[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/// struct for typed errors of method [`pmargin_get_um_all_orders_v1`]
1057#[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/// struct for typed errors of method [`pmargin_get_um_conditional_all_orders_v1`]
1066#[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/// struct for typed errors of method [`pmargin_get_um_conditional_open_order_v1`]
1075#[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/// struct for typed errors of method [`pmargin_get_um_conditional_open_orders_v1`]
1084#[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/// struct for typed errors of method [`pmargin_get_um_conditional_order_history_v1`]
1093#[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/// struct for typed errors of method [`pmargin_get_um_fee_burn_v1`]
1102#[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/// struct for typed errors of method [`pmargin_get_um_force_orders_v1`]
1111#[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/// struct for typed errors of method [`pmargin_get_um_open_order_v1`]
1120#[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/// struct for typed errors of method [`pmargin_get_um_open_orders_v1`]
1129#[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/// struct for typed errors of method [`pmargin_get_um_order_amendment_v1`]
1138#[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/// struct for typed errors of method [`pmargin_get_um_order_v1`]
1147#[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/// struct for typed errors of method [`pmargin_get_um_user_trades_v1`]
1156#[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/// struct for typed errors of method [`pmargin_update_cm_order_v1`]
1165#[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/// struct for typed errors of method [`pmargin_update_um_order_v1`]
1174#[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
1183/// New CM Conditional Order
1184pub 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    // Create a mutable vector for query parameters
1190    let mut query_params: Vec<(String, String)> = Vec::new();
1191
1192
1193    // Create header parameters collection
1194    let mut header_params = std::collections::HashMap::new();
1195
1196    // Handle Binance Auth first if configured
1197    if let Some(ref binance_auth) = configuration.binance_auth {
1198        // Add API key to headers
1199        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1200        
1201        // Generate request body for signing (if any)
1202        let body_string: Option<Vec<u8>> = None;
1203        
1204        // Sign the request
1205        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        // Add signature to query params
1211        query_params.push(("signature".to_string(), signature));
1212    }
1213
1214    // Apply all query parameters
1215    if !query_params.is_empty() {
1216        req_builder = req_builder.query(&query_params);
1217    }
1218
1219
1220    // Add user agent if configured
1221    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    // Apply all header parameters
1226    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
1298/// Place new CM order
1299pub 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    // Create a mutable vector for query parameters
1305    let mut query_params: Vec<(String, String)> = Vec::new();
1306
1307
1308    // Create header parameters collection
1309    let mut header_params = std::collections::HashMap::new();
1310
1311    // Handle Binance Auth first if configured
1312    if let Some(ref binance_auth) = configuration.binance_auth {
1313        // Add API key to headers
1314        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1315        
1316        // Generate request body for signing (if any)
1317        let body_string: Option<Vec<u8>> = None;
1318        
1319        // Sign the request
1320        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        // Add signature to query params
1326        query_params.push(("signature".to_string(), signature));
1327    }
1328
1329    // Apply all query parameters
1330    if !query_params.is_empty() {
1331        req_builder = req_builder.query(&query_params);
1332    }
1333
1334
1335    // Add user agent if configured
1336    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    // Apply all header parameters
1341    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
1404/// Apply for a margin loan.
1405pub 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    // Create a mutable vector for query parameters
1411    let mut query_params: Vec<(String, String)> = Vec::new();
1412
1413
1414    // Create header parameters collection
1415    let mut header_params = std::collections::HashMap::new();
1416
1417    // Handle Binance Auth first if configured
1418    if let Some(ref binance_auth) = configuration.binance_auth {
1419        // Add API key to headers
1420        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1421        
1422        // Generate request body for signing (if any)
1423        let body_string: Option<Vec<u8>> = None;
1424        
1425        // Sign the request
1426        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        // Add signature to query params
1432        query_params.push(("signature".to_string(), signature));
1433    }
1434
1435    // Apply all query parameters
1436    if !query_params.is_empty() {
1437        req_builder = req_builder.query(&query_params);
1438    }
1439
1440
1441    // Add user agent if configured
1442    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    // Apply all header parameters
1447    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
1485/// Send in a new OCO for a margin account
1486pub 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    // Create a mutable vector for query parameters
1492    let mut query_params: Vec<(String, String)> = Vec::new();
1493
1494
1495    // Create header parameters collection
1496    let mut header_params = std::collections::HashMap::new();
1497
1498    // Handle Binance Auth first if configured
1499    if let Some(ref binance_auth) = configuration.binance_auth {
1500        // Add API key to headers
1501        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1502        
1503        // Generate request body for signing (if any)
1504        let body_string: Option<Vec<u8>> = None;
1505        
1506        // Sign the request
1507        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        // Add signature to query params
1513        query_params.push(("signature".to_string(), signature));
1514    }
1515
1516    // Apply all query parameters
1517    if !query_params.is_empty() {
1518        req_builder = req_builder.query(&query_params);
1519    }
1520
1521
1522    // Add user agent if configured
1523    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    // Apply all header parameters
1528    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
1596/// New Margin Order
1597pub 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    // Create a mutable vector for query parameters
1603    let mut query_params: Vec<(String, String)> = Vec::new();
1604
1605
1606    // Create header parameters collection
1607    let mut header_params = std::collections::HashMap::new();
1608
1609    // Handle Binance Auth first if configured
1610    if let Some(ref binance_auth) = configuration.binance_auth {
1611        // Add API key to headers
1612        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1613        
1614        // Generate request body for signing (if any)
1615        let body_string: Option<Vec<u8>> = None;
1616        
1617        // Sign the request
1618        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        // Add signature to query params
1624        query_params.push(("signature".to_string(), signature));
1625    }
1626
1627    // Apply all query parameters
1628    if !query_params.is_empty() {
1629        req_builder = req_builder.query(&query_params);
1630    }
1631
1632
1633    // Add user agent if configured
1634    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    // Apply all header parameters
1639    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
1711/// Repay debt for a margin loan.
1712pub 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    // Create a mutable vector for query parameters
1718    let mut query_params: Vec<(String, String)> = Vec::new();
1719
1720
1721    // Create header parameters collection
1722    let mut header_params = std::collections::HashMap::new();
1723
1724    // Handle Binance Auth first if configured
1725    if let Some(ref binance_auth) = configuration.binance_auth {
1726        // Add API key to headers
1727        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1728        
1729        // Generate request body for signing (if any)
1730        let body_string: Option<Vec<u8>> = None;
1731        
1732        // Sign the request
1733        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        // Add signature to query params
1739        query_params.push(("signature".to_string(), signature));
1740    }
1741
1742    // Apply all query parameters
1743    if !query_params.is_empty() {
1744        req_builder = req_builder.query(&query_params);
1745    }
1746
1747
1748    // Add user agent if configured
1749    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    // Apply all header parameters
1754    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
1797/// Repay for a margin loan.
1798pub 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    // Create a mutable vector for query parameters
1804    let mut query_params: Vec<(String, String)> = Vec::new();
1805
1806
1807    // Create header parameters collection
1808    let mut header_params = std::collections::HashMap::new();
1809
1810    // Handle Binance Auth first if configured
1811    if let Some(ref binance_auth) = configuration.binance_auth {
1812        // Add API key to headers
1813        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1814        
1815        // Generate request body for signing (if any)
1816        let body_string: Option<Vec<u8>> = None;
1817        
1818        // Sign the request
1819        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        // Add signature to query params
1825        query_params.push(("signature".to_string(), signature));
1826    }
1827
1828    // Apply all query parameters
1829    if !query_params.is_empty() {
1830        req_builder = req_builder.query(&query_params);
1831    }
1832
1833
1834    // Add user agent if configured
1835    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    // Apply all header parameters
1840    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
1878/// Place new UM conditional order
1879pub 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    // Create a mutable vector for query parameters
1885    let mut query_params: Vec<(String, String)> = Vec::new();
1886
1887
1888    // Create header parameters collection
1889    let mut header_params = std::collections::HashMap::new();
1890
1891    // Handle Binance Auth first if configured
1892    if let Some(ref binance_auth) = configuration.binance_auth {
1893        // Add API key to headers
1894        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1895        
1896        // Generate request body for signing (if any)
1897        let body_string: Option<Vec<u8>> = None;
1898        
1899        // Sign the request
1900        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        // Add signature to query params
1906        query_params.push(("signature".to_string(), signature));
1907    }
1908
1909    // Apply all query parameters
1910    if !query_params.is_empty() {
1911        req_builder = req_builder.query(&query_params);
1912    }
1913
1914
1915    // Add user agent if configured
1916    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    // Apply all header parameters
1921    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
2002/// Change user's BNB Fee Discount for UM Futures (Fee Discount On or Fee Discount Off ) on EVERY symbol
2003pub 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    // Create a mutable vector for query parameters
2009    let mut query_params: Vec<(String, String)> = Vec::new();
2010
2011
2012    // Create header parameters collection
2013    let mut header_params = std::collections::HashMap::new();
2014
2015    // Handle Binance Auth first if configured
2016    if let Some(ref binance_auth) = configuration.binance_auth {
2017        // Add API key to headers
2018        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2019        
2020        // Generate request body for signing (if any)
2021        let body_string: Option<Vec<u8>> = None;
2022        
2023        // Sign the request
2024        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        // Add signature to query params
2030        query_params.push(("signature".to_string(), signature));
2031    }
2032
2033    // Apply all query parameters
2034    if !query_params.is_empty() {
2035        req_builder = req_builder.query(&query_params);
2036    }
2037
2038
2039    // Add user agent if configured
2040    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    // Apply all header parameters
2045    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
2082/// Place new UM order
2083pub 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    // Create a mutable vector for query parameters
2089    let mut query_params: Vec<(String, String)> = Vec::new();
2090
2091
2092    // Create header parameters collection
2093    let mut header_params = std::collections::HashMap::new();
2094
2095    // Handle Binance Auth first if configured
2096    if let Some(ref binance_auth) = configuration.binance_auth {
2097        // Add API key to headers
2098        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2099        
2100        // Generate request body for signing (if any)
2101        let body_string: Option<Vec<u8>> = None;
2102        
2103        // Sign the request
2104        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        // Add signature to query params
2110        query_params.push(("signature".to_string(), signature));
2111    }
2112
2113    // Apply all query parameters
2114    if !query_params.is_empty() {
2115        req_builder = req_builder.query(&query_params);
2116    }
2117
2118
2119    // Add user agent if configured
2120    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    // Apply all header parameters
2125    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
2194/// Cancel all active LIMIT orders on specific symbol
2195pub 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    // Create a mutable vector for query parameters
2201    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    // Create header parameters collection
2210    let mut header_params = std::collections::HashMap::new();
2211
2212    // Handle Binance Auth first if configured
2213    if let Some(ref binance_auth) = configuration.binance_auth {
2214        // Add API key to headers
2215        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2216        
2217        // Generate request body for signing (if any)
2218        let body_string: Option<Vec<u8>> = None;
2219        
2220        // Sign the request
2221        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        // Add signature to query params
2227        query_params.push(("signature".to_string(), signature));
2228    }
2229
2230    // Apply all query parameters
2231    if !query_params.is_empty() {
2232        req_builder = req_builder.query(&query_params);
2233    }
2234
2235
2236    // Add user agent if configured
2237    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    // Apply all header parameters
2242    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
2272/// Cancel All CM Open Conditional Orders
2273pub 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    // Create a mutable vector for query parameters
2279    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    // Create header parameters collection
2288    let mut header_params = std::collections::HashMap::new();
2289
2290    // Handle Binance Auth first if configured
2291    if let Some(ref binance_auth) = configuration.binance_auth {
2292        // Add API key to headers
2293        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2294        
2295        // Generate request body for signing (if any)
2296        let body_string: Option<Vec<u8>> = None;
2297        
2298        // Sign the request
2299        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        // Add signature to query params
2305        query_params.push(("signature".to_string(), signature));
2306    }
2307
2308    // Apply all query parameters
2309    if !query_params.is_empty() {
2310        req_builder = req_builder.query(&query_params);
2311    }
2312
2313
2314    // Add user agent if configured
2315    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    // Apply all header parameters
2320    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
2350/// Cancel CM Conditional Order
2351pub 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    // Create a mutable vector for query parameters
2357    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    // Create header parameters collection
2372    let mut header_params = std::collections::HashMap::new();
2373
2374    // Handle Binance Auth first if configured
2375    if let Some(ref binance_auth) = configuration.binance_auth {
2376        // Add API key to headers
2377        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2378        
2379        // Generate request body for signing (if any)
2380        let body_string: Option<Vec<u8>> = None;
2381        
2382        // Sign the request
2383        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        // Add signature to query params
2389        query_params.push(("signature".to_string(), signature));
2390    }
2391
2392    // Apply all query parameters
2393    if !query_params.is_empty() {
2394        req_builder = req_builder.query(&query_params);
2395    }
2396
2397
2398    // Add user agent if configured
2399    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    // Apply all header parameters
2404    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
2434/// Cancel an active LIMIT order
2435pub 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    // Create a mutable vector for query parameters
2441    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    // Create header parameters collection
2456    let mut header_params = std::collections::HashMap::new();
2457
2458    // Handle Binance Auth first if configured
2459    if let Some(ref binance_auth) = configuration.binance_auth {
2460        // Add API key to headers
2461        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2462        
2463        // Generate request body for signing (if any)
2464        let body_string: Option<Vec<u8>> = None;
2465        
2466        // Sign the request
2467        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        // Add signature to query params
2473        query_params.push(("signature".to_string(), signature));
2474    }
2475
2476    // Apply all query parameters
2477    if !query_params.is_empty() {
2478        req_builder = req_builder.query(&query_params);
2479    }
2480
2481
2482    // Add user agent if configured
2483    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    // Apply all header parameters
2488    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
2518/// Cancel Margin Account All Open Orders on a Symbol
2519pub 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    // Create a mutable vector for query parameters
2525    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    // Create header parameters collection
2534    let mut header_params = std::collections::HashMap::new();
2535
2536    // Handle Binance Auth first if configured
2537    if let Some(ref binance_auth) = configuration.binance_auth {
2538        // Add API key to headers
2539        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2540        
2541        // Generate request body for signing (if any)
2542        let body_string: Option<Vec<u8>> = None;
2543        
2544        // Sign the request
2545        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        // Add signature to query params
2551        query_params.push(("signature".to_string(), signature));
2552    }
2553
2554    // Apply all query parameters
2555    if !query_params.is_empty() {
2556        req_builder = req_builder.query(&query_params);
2557    }
2558
2559
2560    // Add user agent if configured
2561    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    // Apply all header parameters
2566    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&lt;models::PmarginDeleteMarginAllOpenOrdersV1RespInner&gt;`"))),
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&lt;models::PmarginDeleteMarginAllOpenOrdersV1RespInner&gt;`")))),
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
2596/// Cancel Margin Account OCO Orders
2597pub 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    // Create a mutable vector for query parameters
2603    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    // Create header parameters collection
2621    let mut header_params = std::collections::HashMap::new();
2622
2623    // Handle Binance Auth first if configured
2624    if let Some(ref binance_auth) = configuration.binance_auth {
2625        // Add API key to headers
2626        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2627        
2628        // Generate request body for signing (if any)
2629        let body_string: Option<Vec<u8>> = None;
2630        
2631        // Sign the request
2632        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        // Add signature to query params
2638        query_params.push(("signature".to_string(), signature));
2639    }
2640
2641    // Apply all query parameters
2642    if !query_params.is_empty() {
2643        req_builder = req_builder.query(&query_params);
2644    }
2645
2646
2647    // Add user agent if configured
2648    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    // Apply all header parameters
2653    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
2683/// Cancel Margin Account Order
2684pub 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    // Create a mutable vector for query parameters
2690    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    // Create header parameters collection
2708    let mut header_params = std::collections::HashMap::new();
2709
2710    // Handle Binance Auth first if configured
2711    if let Some(ref binance_auth) = configuration.binance_auth {
2712        // Add API key to headers
2713        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2714        
2715        // Generate request body for signing (if any)
2716        let body_string: Option<Vec<u8>> = None;
2717        
2718        // Sign the request
2719        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        // Add signature to query params
2725        query_params.push(("signature".to_string(), signature));
2726    }
2727
2728    // Apply all query parameters
2729    if !query_params.is_empty() {
2730        req_builder = req_builder.query(&query_params);
2731    }
2732
2733
2734    // Add user agent if configured
2735    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    // Apply all header parameters
2740    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
2770/// Cancel all active LIMIT orders on specific symbol
2771pub 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    // Create a mutable vector for query parameters
2777    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    // Create header parameters collection
2786    let mut header_params = std::collections::HashMap::new();
2787
2788    // Handle Binance Auth first if configured
2789    if let Some(ref binance_auth) = configuration.binance_auth {
2790        // Add API key to headers
2791        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2792        
2793        // Generate request body for signing (if any)
2794        let body_string: Option<Vec<u8>> = None;
2795        
2796        // Sign the request
2797        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        // Add signature to query params
2803        query_params.push(("signature".to_string(), signature));
2804    }
2805
2806    // Apply all query parameters
2807    if !query_params.is_empty() {
2808        req_builder = req_builder.query(&query_params);
2809    }
2810
2811
2812    // Add user agent if configured
2813    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    // Apply all header parameters
2818    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
2848/// Cancel All UM Open Conditional Orders
2849pub 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    // Create a mutable vector for query parameters
2855    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    // Create header parameters collection
2864    let mut header_params = std::collections::HashMap::new();
2865
2866    // Handle Binance Auth first if configured
2867    if let Some(ref binance_auth) = configuration.binance_auth {
2868        // Add API key to headers
2869        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2870        
2871        // Generate request body for signing (if any)
2872        let body_string: Option<Vec<u8>> = None;
2873        
2874        // Sign the request
2875        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        // Add signature to query params
2881        query_params.push(("signature".to_string(), signature));
2882    }
2883
2884    // Apply all query parameters
2885    if !query_params.is_empty() {
2886        req_builder = req_builder.query(&query_params);
2887    }
2888
2889
2890    // Add user agent if configured
2891    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    // Apply all header parameters
2896    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
2926/// Cancel UM Conditional Order
2927pub 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    // Create a mutable vector for query parameters
2933    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    // Create header parameters collection
2948    let mut header_params = std::collections::HashMap::new();
2949
2950    // Handle Binance Auth first if configured
2951    if let Some(ref binance_auth) = configuration.binance_auth {
2952        // Add API key to headers
2953        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2954        
2955        // Generate request body for signing (if any)
2956        let body_string: Option<Vec<u8>> = None;
2957        
2958        // Sign the request
2959        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        // Add signature to query params
2965        query_params.push(("signature".to_string(), signature));
2966    }
2967
2968    // Apply all query parameters
2969    if !query_params.is_empty() {
2970        req_builder = req_builder.query(&query_params);
2971    }
2972
2973
2974    // Add user agent if configured
2975    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    // Apply all header parameters
2980    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
3010/// Cancel an active UM LIMIT order
3011pub 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    // Create a mutable vector for query parameters
3017    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    // Create header parameters collection
3032    let mut header_params = std::collections::HashMap::new();
3033
3034    // Handle Binance Auth first if configured
3035    if let Some(ref binance_auth) = configuration.binance_auth {
3036        // Add API key to headers
3037        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3038        
3039        // Generate request body for signing (if any)
3040        let body_string: Option<Vec<u8>> = None;
3041        
3042        // Sign the request
3043        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        // Add signature to query params
3049        query_params.push(("signature".to_string(), signature));
3050    }
3051
3052    // Apply all query parameters
3053    if !query_params.is_empty() {
3054        req_builder = req_builder.query(&query_params);
3055    }
3056
3057
3058    // Add user agent if configured
3059    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    // Apply all header parameters
3064    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
3094/// Query CM Position ADL Quantile Estimation
3095pub 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    // Create a mutable vector for query parameters
3101    let mut query_params: Vec<(String, String)> = Vec::new();
3102
3103
3104    // Create header parameters collection
3105    let mut header_params = std::collections::HashMap::new();
3106
3107    // Handle Binance Auth first if configured
3108    if let Some(ref binance_auth) = configuration.binance_auth {
3109        // Add API key to headers
3110        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3111        
3112        // Generate request body for signing (if any)
3113        let body_string: Option<Vec<u8>> = None;
3114        
3115        // Sign the request
3116        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        // Add signature to query params
3122        query_params.push(("signature".to_string(), signature));
3123    }
3124
3125    // Apply all query parameters
3126    if !query_params.is_empty() {
3127        req_builder = req_builder.query(&query_params);
3128    }
3129
3130
3131    // Add user agent if configured
3132    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    // Apply all header parameters
3137    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&lt;models::PmarginGetCmAdlQuantileV1RespItem&gt;`"))),
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&lt;models::PmarginGetCmAdlQuantileV1RespItem&gt;`")))),
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
3167/// Get all account CM orders; active, canceled, or filled.
3168pub 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    // Create a mutable vector for query parameters
3174    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    // Create header parameters collection
3198    let mut header_params = std::collections::HashMap::new();
3199
3200    // Handle Binance Auth first if configured
3201    if let Some(ref binance_auth) = configuration.binance_auth {
3202        // Add API key to headers
3203        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3204        
3205        // Generate request body for signing (if any)
3206        let body_string: Option<Vec<u8>> = None;
3207        
3208        // Sign the request
3209        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        // Add signature to query params
3215        query_params.push(("signature".to_string(), signature));
3216    }
3217
3218    // Apply all query parameters
3219    if !query_params.is_empty() {
3220        req_builder = req_builder.query(&query_params);
3221    }
3222
3223
3224    // Add user agent if configured
3225    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    // Apply all header parameters
3230    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&lt;models::PmarginGetCmAllOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetCmAllOrdersV1RespItem&gt;`")))),
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
3260/// Query All CM Conditional Orders
3261pub 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    // Create a mutable vector for query parameters
3267    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    // Create header parameters collection
3290    let mut header_params = std::collections::HashMap::new();
3291
3292    // Handle Binance Auth first if configured
3293    if let Some(ref binance_auth) = configuration.binance_auth {
3294        // Add API key to headers
3295        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3296        
3297        // Generate request body for signing (if any)
3298        let body_string: Option<Vec<u8>> = None;
3299        
3300        // Sign the request
3301        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        // Add signature to query params
3307        query_params.push(("signature".to_string(), signature));
3308    }
3309
3310    // Apply all query parameters
3311    if !query_params.is_empty() {
3312        req_builder = req_builder.query(&query_params);
3313    }
3314
3315
3316    // Add user agent if configured
3317    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    // Apply all header parameters
3322    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&lt;models::PmarginGetCmConditionalAllOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetCmConditionalAllOrdersV1RespItem&gt;`")))),
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
3352/// Query Current CM Open Conditional Order
3353pub 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    // Create a mutable vector for query parameters
3359    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    // Create header parameters collection
3374    let mut header_params = std::collections::HashMap::new();
3375
3376    // Handle Binance Auth first if configured
3377    if let Some(ref binance_auth) = configuration.binance_auth {
3378        // Add API key to headers
3379        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3380        
3381        // Generate request body for signing (if any)
3382        let body_string: Option<Vec<u8>> = None;
3383        
3384        // Sign the request
3385        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        // Add signature to query params
3391        query_params.push(("signature".to_string(), signature));
3392    }
3393
3394    // Apply all query parameters
3395    if !query_params.is_empty() {
3396        req_builder = req_builder.query(&query_params);
3397    }
3398
3399
3400    // Add user agent if configured
3401    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    // Apply all header parameters
3406    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
3436/// Get all open conditional orders on a symbol. Careful when accessing this with no symbol.
3437pub 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    // Create a mutable vector for query parameters
3443    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    // Create header parameters collection
3454    let mut header_params = std::collections::HashMap::new();
3455
3456    // Handle Binance Auth first if configured
3457    if let Some(ref binance_auth) = configuration.binance_auth {
3458        // Add API key to headers
3459        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3460        
3461        // Generate request body for signing (if any)
3462        let body_string: Option<Vec<u8>> = None;
3463        
3464        // Sign the request
3465        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        // Add signature to query params
3471        query_params.push(("signature".to_string(), signature));
3472    }
3473
3474    // Apply all query parameters
3475    if !query_params.is_empty() {
3476        req_builder = req_builder.query(&query_params);
3477    }
3478
3479
3480    // Add user agent if configured
3481    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    // Apply all header parameters
3486    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&lt;models::PmarginGetCmConditionalOpenOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetCmConditionalOpenOrdersV1RespItem&gt;`")))),
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
3516/// Query CM Conditional Order History
3517pub 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    // Create a mutable vector for query parameters
3523    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    // Create header parameters collection
3538    let mut header_params = std::collections::HashMap::new();
3539
3540    // Handle Binance Auth first if configured
3541    if let Some(ref binance_auth) = configuration.binance_auth {
3542        // Add API key to headers
3543        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3544        
3545        // Generate request body for signing (if any)
3546        let body_string: Option<Vec<u8>> = None;
3547        
3548        // Sign the request
3549        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        // Add signature to query params
3555        query_params.push(("signature".to_string(), signature));
3556    }
3557
3558    // Apply all query parameters
3559    if !query_params.is_empty() {
3560        req_builder = req_builder.query(&query_params);
3561    }
3562
3563
3564    // Add user agent if configured
3565    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    // Apply all header parameters
3570    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
3600/// Query User's CM Force Orders
3601pub 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    // Create a mutable vector for query parameters
3607    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    // Create header parameters collection
3630    let mut header_params = std::collections::HashMap::new();
3631
3632    // Handle Binance Auth first if configured
3633    if let Some(ref binance_auth) = configuration.binance_auth {
3634        // Add API key to headers
3635        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3636        
3637        // Generate request body for signing (if any)
3638        let body_string: Option<Vec<u8>> = None;
3639        
3640        // Sign the request
3641        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        // Add signature to query params
3647        query_params.push(("signature".to_string(), signature));
3648    }
3649
3650    // Apply all query parameters
3651    if !query_params.is_empty() {
3652        req_builder = req_builder.query(&query_params);
3653    }
3654
3655
3656    // Add user agent if configured
3657    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    // Apply all header parameters
3662    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&lt;models::PmarginGetCmForceOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetCmForceOrdersV1RespItem&gt;`")))),
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
3692/// Query current CM open order
3693pub 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    // Create a mutable vector for query parameters
3699    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    // Create header parameters collection
3714    let mut header_params = std::collections::HashMap::new();
3715
3716    // Handle Binance Auth first if configured
3717    if let Some(ref binance_auth) = configuration.binance_auth {
3718        // Add API key to headers
3719        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3720        
3721        // Generate request body for signing (if any)
3722        let body_string: Option<Vec<u8>> = None;
3723        
3724        // Sign the request
3725        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        // Add signature to query params
3731        query_params.push(("signature".to_string(), signature));
3732    }
3733
3734    // Apply all query parameters
3735    if !query_params.is_empty() {
3736        req_builder = req_builder.query(&query_params);
3737    }
3738
3739
3740    // Add user agent if configured
3741    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    // Apply all header parameters
3746    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
3776/// Get all open orders on a symbol.
3777pub 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    // Create a mutable vector for query parameters
3783    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    // Create header parameters collection
3797    let mut header_params = std::collections::HashMap::new();
3798
3799    // Handle Binance Auth first if configured
3800    if let Some(ref binance_auth) = configuration.binance_auth {
3801        // Add API key to headers
3802        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3803        
3804        // Generate request body for signing (if any)
3805        let body_string: Option<Vec<u8>> = None;
3806        
3807        // Sign the request
3808        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        // Add signature to query params
3814        query_params.push(("signature".to_string(), signature));
3815    }
3816
3817    // Apply all query parameters
3818    if !query_params.is_empty() {
3819        req_builder = req_builder.query(&query_params);
3820    }
3821
3822
3823    // Add user agent if configured
3824    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    // Apply all header parameters
3829    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&lt;models::PmarginGetCmOpenOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetCmOpenOrdersV1RespItem&gt;`")))),
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
3859/// Get order modification history
3860pub 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    // Create a mutable vector for query parameters
3866    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    // Create header parameters collection
3890    let mut header_params = std::collections::HashMap::new();
3891
3892    // Handle Binance Auth first if configured
3893    if let Some(ref binance_auth) = configuration.binance_auth {
3894        // Add API key to headers
3895        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3896        
3897        // Generate request body for signing (if any)
3898        let body_string: Option<Vec<u8>> = None;
3899        
3900        // Sign the request
3901        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        // Add signature to query params
3907        query_params.push(("signature".to_string(), signature));
3908    }
3909
3910    // Apply all query parameters
3911    if !query_params.is_empty() {
3912        req_builder = req_builder.query(&query_params);
3913    }
3914
3915
3916    // Add user agent if configured
3917    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    // Apply all header parameters
3922    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&lt;models::PmarginGetCmOrderAmendmentV1RespItem&gt;`"))),
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&lt;models::PmarginGetCmOrderAmendmentV1RespItem&gt;`")))),
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
3952/// Check an CM order's status.
3953pub 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    // Create a mutable vector for query parameters
3959    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    // Create header parameters collection
3974    let mut header_params = std::collections::HashMap::new();
3975
3976    // Handle Binance Auth first if configured
3977    if let Some(ref binance_auth) = configuration.binance_auth {
3978        // Add API key to headers
3979        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3980        
3981        // Generate request body for signing (if any)
3982        let body_string: Option<Vec<u8>> = None;
3983        
3984        // Sign the request
3985        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        // Add signature to query params
3991        query_params.push(("signature".to_string(), signature));
3992    }
3993
3994    // Apply all query parameters
3995    if !query_params.is_empty() {
3996        req_builder = req_builder.query(&query_params);
3997    }
3998
3999
4000    // Add user agent if configured
4001    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    // Apply all header parameters
4006    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
4036/// Get trades for a specific account and CM symbol.
4037pub 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    // Create a mutable vector for query parameters
4043    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    // Create header parameters collection
4069    let mut header_params = std::collections::HashMap::new();
4070
4071    // Handle Binance Auth first if configured
4072    if let Some(ref binance_auth) = configuration.binance_auth {
4073        // Add API key to headers
4074        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4075        
4076        // Generate request body for signing (if any)
4077        let body_string: Option<Vec<u8>> = None;
4078        
4079        // Sign the request
4080        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        // Add signature to query params
4086        query_params.push(("signature".to_string(), signature));
4087    }
4088
4089    // Apply all query parameters
4090    if !query_params.is_empty() {
4091        req_builder = req_builder.query(&query_params);
4092    }
4093
4094
4095    // Add user agent if configured
4096    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    // Apply all header parameters
4101    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&lt;models::PmarginGetCmUserTradesV1RespItem&gt;`"))),
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&lt;models::PmarginGetCmUserTradesV1RespItem&gt;`")))),
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
4131/// Query all OCO for a specific margin account based on provided optional parameters
4132pub 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    // Create a mutable vector for query parameters
4138    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    // Create header parameters collection
4158    let mut header_params = std::collections::HashMap::new();
4159
4160    // Handle Binance Auth first if configured
4161    if let Some(ref binance_auth) = configuration.binance_auth {
4162        // Add API key to headers
4163        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4164        
4165        // Generate request body for signing (if any)
4166        let body_string: Option<Vec<u8>> = None;
4167        
4168        // Sign the request
4169        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        // Add signature to query params
4175        query_params.push(("signature".to_string(), signature));
4176    }
4177
4178    // Apply all query parameters
4179    if !query_params.is_empty() {
4180        req_builder = req_builder.query(&query_params);
4181    }
4182
4183
4184    // Add user agent if configured
4185    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    // Apply all header parameters
4190    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&lt;models::PmarginGetMarginAllOrderListV1RespItem&gt;`"))),
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&lt;models::PmarginGetMarginAllOrderListV1RespItem&gt;`")))),
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
4220/// Query All Margin Account Orders
4221pub 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    // Create a mutable vector for query parameters
4227    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    // Create header parameters collection
4248    let mut header_params = std::collections::HashMap::new();
4249
4250    // Handle Binance Auth first if configured
4251    if let Some(ref binance_auth) = configuration.binance_auth {
4252        // Add API key to headers
4253        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4254        
4255        // Generate request body for signing (if any)
4256        let body_string: Option<Vec<u8>> = None;
4257        
4258        // Sign the request
4259        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        // Add signature to query params
4265        query_params.push(("signature".to_string(), signature));
4266    }
4267
4268    // Apply all query parameters
4269    if !query_params.is_empty() {
4270        req_builder = req_builder.query(&query_params);
4271    }
4272
4273
4274    // Add user agent if configured
4275    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    // Apply all header parameters
4280    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&lt;models::PmarginGetMarginAllOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetMarginAllOrdersV1RespItem&gt;`")))),
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
4310/// Query user's margin force orders
4311pub 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    // Create a mutable vector for query parameters
4317    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    // Create header parameters collection
4337    let mut header_params = std::collections::HashMap::new();
4338
4339    // Handle Binance Auth first if configured
4340    if let Some(ref binance_auth) = configuration.binance_auth {
4341        // Add API key to headers
4342        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4343        
4344        // Generate request body for signing (if any)
4345        let body_string: Option<Vec<u8>> = None;
4346        
4347        // Sign the request
4348        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        // Add signature to query params
4354        query_params.push(("signature".to_string(), signature));
4355    }
4356
4357    // Apply all query parameters
4358    if !query_params.is_empty() {
4359        req_builder = req_builder.query(&query_params);
4360    }
4361
4362
4363    // Add user agent if configured
4364    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    // Apply all header parameters
4369    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
4399/// Margin Account Trade List
4400pub 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    // Create a mutable vector for query parameters
4406    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    // Create header parameters collection
4430    let mut header_params = std::collections::HashMap::new();
4431
4432    // Handle Binance Auth first if configured
4433    if let Some(ref binance_auth) = configuration.binance_auth {
4434        // Add API key to headers
4435        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4436        
4437        // Generate request body for signing (if any)
4438        let body_string: Option<Vec<u8>> = None;
4439        
4440        // Sign the request
4441        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        // Add signature to query params
4447        query_params.push(("signature".to_string(), signature));
4448    }
4449
4450    // Apply all query parameters
4451    if !query_params.is_empty() {
4452        req_builder = req_builder.query(&query_params);
4453    }
4454
4455
4456    // Add user agent if configured
4457    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    // Apply all header parameters
4462    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&lt;models::PmarginGetMarginMyTradesV1RespItem&gt;`"))),
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&lt;models::PmarginGetMarginMyTradesV1RespItem&gt;`")))),
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
4492/// Query Margin Account's Open OCO
4493pub 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    // Create a mutable vector for query parameters
4499    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    // Create header parameters collection
4507    let mut header_params = std::collections::HashMap::new();
4508
4509    // Handle Binance Auth first if configured
4510    if let Some(ref binance_auth) = configuration.binance_auth {
4511        // Add API key to headers
4512        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4513        
4514        // Generate request body for signing (if any)
4515        let body_string: Option<Vec<u8>> = None;
4516        
4517        // Sign the request
4518        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        // Add signature to query params
4524        query_params.push(("signature".to_string(), signature));
4525    }
4526
4527    // Apply all query parameters
4528    if !query_params.is_empty() {
4529        req_builder = req_builder.query(&query_params);
4530    }
4531
4532
4533    // Add user agent if configured
4534    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    // Apply all header parameters
4539    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&lt;models::PmarginGetMarginOpenOrderListV1RespItem&gt;`"))),
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&lt;models::PmarginGetMarginOpenOrderListV1RespItem&gt;`")))),
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
4569/// Query Current Margin Open Order
4570pub 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    // Create a mutable vector for query parameters
4576    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    // Create header parameters collection
4585    let mut header_params = std::collections::HashMap::new();
4586
4587    // Handle Binance Auth first if configured
4588    if let Some(ref binance_auth) = configuration.binance_auth {
4589        // Add API key to headers
4590        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4591        
4592        // Generate request body for signing (if any)
4593        let body_string: Option<Vec<u8>> = None;
4594        
4595        // Sign the request
4596        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        // Add signature to query params
4602        query_params.push(("signature".to_string(), signature));
4603    }
4604
4605    // Apply all query parameters
4606    if !query_params.is_empty() {
4607        req_builder = req_builder.query(&query_params);
4608    }
4609
4610
4611    // Add user agent if configured
4612    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    // Apply all header parameters
4617    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&lt;models::PmarginGetMarginOpenOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetMarginOpenOrdersV1RespItem&gt;`")))),
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
4647/// Retrieves a specific OCO based on provided optional parameters
4648pub 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    // Create a mutable vector for query parameters
4654    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    // Create header parameters collection
4668    let mut header_params = std::collections::HashMap::new();
4669
4670    // Handle Binance Auth first if configured
4671    if let Some(ref binance_auth) = configuration.binance_auth {
4672        // Add API key to headers
4673        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4674        
4675        // Generate request body for signing (if any)
4676        let body_string: Option<Vec<u8>> = None;
4677        
4678        // Sign the request
4679        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        // Add signature to query params
4685        query_params.push(("signature".to_string(), signature));
4686    }
4687
4688    // Apply all query parameters
4689    if !query_params.is_empty() {
4690        req_builder = req_builder.query(&query_params);
4691    }
4692
4693
4694    // Add user agent if configured
4695    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    // Apply all header parameters
4700    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
4730/// Query Margin Account Order
4731pub 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    // Create a mutable vector for query parameters
4737    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    // Create header parameters collection
4752    let mut header_params = std::collections::HashMap::new();
4753
4754    // Handle Binance Auth first if configured
4755    if let Some(ref binance_auth) = configuration.binance_auth {
4756        // Add API key to headers
4757        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4758        
4759        // Generate request body for signing (if any)
4760        let body_string: Option<Vec<u8>> = None;
4761        
4762        // Sign the request
4763        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        // Add signature to query params
4769        query_params.push(("signature".to_string(), signature));
4770    }
4771
4772    // Apply all query parameters
4773    if !query_params.is_empty() {
4774        req_builder = req_builder.query(&query_params);
4775    }
4776
4777
4778    // Add user agent if configured
4779    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    // Apply all header parameters
4784    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
4814/// Query UM Position ADL Quantile Estimation
4815pub 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    // Create a mutable vector for query parameters
4821    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    // Create header parameters collection
4832    let mut header_params = std::collections::HashMap::new();
4833
4834    // Handle Binance Auth first if configured
4835    if let Some(ref binance_auth) = configuration.binance_auth {
4836        // Add API key to headers
4837        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4838        
4839        // Generate request body for signing (if any)
4840        let body_string: Option<Vec<u8>> = None;
4841        
4842        // Sign the request
4843        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        // Add signature to query params
4849        query_params.push(("signature".to_string(), signature));
4850    }
4851
4852    // Apply all query parameters
4853    if !query_params.is_empty() {
4854        req_builder = req_builder.query(&query_params);
4855    }
4856
4857
4858    // Add user agent if configured
4859    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    // Apply all header parameters
4864    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&lt;models::PmarginGetUmAdlQuantileV1RespItem&gt;`"))),
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&lt;models::PmarginGetUmAdlQuantileV1RespItem&gt;`")))),
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
4894/// Get all account UM orders; active, canceled, or filled.
4895pub 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    // Create a mutable vector for query parameters
4901    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    // Create header parameters collection
4922    let mut header_params = std::collections::HashMap::new();
4923
4924    // Handle Binance Auth first if configured
4925    if let Some(ref binance_auth) = configuration.binance_auth {
4926        // Add API key to headers
4927        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4928        
4929        // Generate request body for signing (if any)
4930        let body_string: Option<Vec<u8>> = None;
4931        
4932        // Sign the request
4933        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        // Add signature to query params
4939        query_params.push(("signature".to_string(), signature));
4940    }
4941
4942    // Apply all query parameters
4943    if !query_params.is_empty() {
4944        req_builder = req_builder.query(&query_params);
4945    }
4946
4947
4948    // Add user agent if configured
4949    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    // Apply all header parameters
4954    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&lt;models::PmarginGetUmAllOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetUmAllOrdersV1RespItem&gt;`")))),
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
4984/// Query All UM Conditional Orders
4985pub 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    // Create a mutable vector for query parameters
4991    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    // Create header parameters collection
5014    let mut header_params = std::collections::HashMap::new();
5015
5016    // Handle Binance Auth first if configured
5017    if let Some(ref binance_auth) = configuration.binance_auth {
5018        // Add API key to headers
5019        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5020        
5021        // Generate request body for signing (if any)
5022        let body_string: Option<Vec<u8>> = None;
5023        
5024        // Sign the request
5025        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        // Add signature to query params
5031        query_params.push(("signature".to_string(), signature));
5032    }
5033
5034    // Apply all query parameters
5035    if !query_params.is_empty() {
5036        req_builder = req_builder.query(&query_params);
5037    }
5038
5039
5040    // Add user agent if configured
5041    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    // Apply all header parameters
5046    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&lt;models::PmarginGetUmConditionalAllOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetUmConditionalAllOrdersV1RespItem&gt;`")))),
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
5076/// Query Current UM Open Conditional Order
5077pub 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    // Create a mutable vector for query parameters
5083    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    // Create header parameters collection
5098    let mut header_params = std::collections::HashMap::new();
5099
5100    // Handle Binance Auth first if configured
5101    if let Some(ref binance_auth) = configuration.binance_auth {
5102        // Add API key to headers
5103        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5104        
5105        // Generate request body for signing (if any)
5106        let body_string: Option<Vec<u8>> = None;
5107        
5108        // Sign the request
5109        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        // Add signature to query params
5115        query_params.push(("signature".to_string(), signature));
5116    }
5117
5118    // Apply all query parameters
5119    if !query_params.is_empty() {
5120        req_builder = req_builder.query(&query_params);
5121    }
5122
5123
5124    // Add user agent if configured
5125    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    // Apply all header parameters
5130    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
5160/// Get all open conditional orders on a symbol.
5161pub 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    // Create a mutable vector for query parameters
5167    let mut query_params: Vec<(String, String)> = Vec::new();
5168
5169
5170    // Create header parameters collection
5171    let mut header_params = std::collections::HashMap::new();
5172
5173    // Handle Binance Auth first if configured
5174    if let Some(ref binance_auth) = configuration.binance_auth {
5175        // Add API key to headers
5176        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5177        
5178        // Generate request body for signing (if any)
5179        let body_string: Option<Vec<u8>> = None;
5180        
5181        // Sign the request
5182        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        // Add signature to query params
5188        query_params.push(("signature".to_string(), signature));
5189    }
5190
5191    // Apply all query parameters
5192    if !query_params.is_empty() {
5193        req_builder = req_builder.query(&query_params);
5194    }
5195
5196
5197    // Add user agent if configured
5198    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    // Apply all header parameters
5203    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&lt;models::PmarginGetUmConditionalOpenOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetUmConditionalOpenOrdersV1RespItem&gt;`")))),
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
5233/// Query UM Conditional Order History
5234pub 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    // Create a mutable vector for query parameters
5240    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    // Create header parameters collection
5255    let mut header_params = std::collections::HashMap::new();
5256
5257    // Handle Binance Auth first if configured
5258    if let Some(ref binance_auth) = configuration.binance_auth {
5259        // Add API key to headers
5260        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5261        
5262        // Generate request body for signing (if any)
5263        let body_string: Option<Vec<u8>> = None;
5264        
5265        // Sign the request
5266        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        // Add signature to query params
5272        query_params.push(("signature".to_string(), signature));
5273    }
5274
5275    // Apply all query parameters
5276    if !query_params.is_empty() {
5277        req_builder = req_builder.query(&query_params);
5278    }
5279
5280
5281    // Add user agent if configured
5282    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    // Apply all header parameters
5287    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
5317/// Get user's BNB Fee Discount for UM Futures (Fee Discount On or Fee Discount Off )
5318pub 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    // Create a mutable vector for query parameters
5324    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    // Create header parameters collection
5332    let mut header_params = std::collections::HashMap::new();
5333
5334    // Handle Binance Auth first if configured
5335    if let Some(ref binance_auth) = configuration.binance_auth {
5336        // Add API key to headers
5337        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5338        
5339        // Generate request body for signing (if any)
5340        let body_string: Option<Vec<u8>> = None;
5341        
5342        // Sign the request
5343        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        // Add signature to query params
5349        query_params.push(("signature".to_string(), signature));
5350    }
5351
5352    // Apply all query parameters
5353    if !query_params.is_empty() {
5354        req_builder = req_builder.query(&query_params);
5355    }
5356
5357
5358    // Add user agent if configured
5359    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    // Apply all header parameters
5364    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
5394/// Query User's UM Force Orders
5395pub 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    // Create a mutable vector for query parameters
5401    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    // Create header parameters collection
5424    let mut header_params = std::collections::HashMap::new();
5425
5426    // Handle Binance Auth first if configured
5427    if let Some(ref binance_auth) = configuration.binance_auth {
5428        // Add API key to headers
5429        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5430        
5431        // Generate request body for signing (if any)
5432        let body_string: Option<Vec<u8>> = None;
5433        
5434        // Sign the request
5435        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        // Add signature to query params
5441        query_params.push(("signature".to_string(), signature));
5442    }
5443
5444    // Apply all query parameters
5445    if !query_params.is_empty() {
5446        req_builder = req_builder.query(&query_params);
5447    }
5448
5449
5450    // Add user agent if configured
5451    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    // Apply all header parameters
5456    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&lt;models::PmarginGetUmForceOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetUmForceOrdersV1RespItem&gt;`")))),
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
5486/// Query current UM open order
5487pub 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    // Create a mutable vector for query parameters
5493    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    // Create header parameters collection
5508    let mut header_params = std::collections::HashMap::new();
5509
5510    // Handle Binance Auth first if configured
5511    if let Some(ref binance_auth) = configuration.binance_auth {
5512        // Add API key to headers
5513        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5514        
5515        // Generate request body for signing (if any)
5516        let body_string: Option<Vec<u8>> = None;
5517        
5518        // Sign the request
5519        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        // Add signature to query params
5525        query_params.push(("signature".to_string(), signature));
5526    }
5527
5528    // Apply all query parameters
5529    if !query_params.is_empty() {
5530        req_builder = req_builder.query(&query_params);
5531    }
5532
5533
5534    // Add user agent if configured
5535    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    // Apply all header parameters
5540    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
5570/// Get all open orders on a symbol.
5571pub 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    // Create a mutable vector for query parameters
5577    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    // Create header parameters collection
5588    let mut header_params = std::collections::HashMap::new();
5589
5590    // Handle Binance Auth first if configured
5591    if let Some(ref binance_auth) = configuration.binance_auth {
5592        // Add API key to headers
5593        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5594        
5595        // Generate request body for signing (if any)
5596        let body_string: Option<Vec<u8>> = None;
5597        
5598        // Sign the request
5599        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        // Add signature to query params
5605        query_params.push(("signature".to_string(), signature));
5606    }
5607
5608    // Apply all query parameters
5609    if !query_params.is_empty() {
5610        req_builder = req_builder.query(&query_params);
5611    }
5612
5613
5614    // Add user agent if configured
5615    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    // Apply all header parameters
5620    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&lt;models::PmarginGetUmOpenOrdersV1RespItem&gt;`"))),
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&lt;models::PmarginGetUmOpenOrdersV1RespItem&gt;`")))),
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
5650/// Get order modification history
5651pub 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    // Create a mutable vector for query parameters
5657    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    // Create header parameters collection
5681    let mut header_params = std::collections::HashMap::new();
5682
5683    // Handle Binance Auth first if configured
5684    if let Some(ref binance_auth) = configuration.binance_auth {
5685        // Add API key to headers
5686        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5687        
5688        // Generate request body for signing (if any)
5689        let body_string: Option<Vec<u8>> = None;
5690        
5691        // Sign the request
5692        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        // Add signature to query params
5698        query_params.push(("signature".to_string(), signature));
5699    }
5700
5701    // Apply all query parameters
5702    if !query_params.is_empty() {
5703        req_builder = req_builder.query(&query_params);
5704    }
5705
5706
5707    // Add user agent if configured
5708    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    // Apply all header parameters
5713    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&lt;models::PmarginGetUmOrderAmendmentV1RespItem&gt;`"))),
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&lt;models::PmarginGetUmOrderAmendmentV1RespItem&gt;`")))),
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
5743/// Check an UM order's status.
5744pub 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    // Create a mutable vector for query parameters
5750    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    // Create header parameters collection
5765    let mut header_params = std::collections::HashMap::new();
5766
5767    // Handle Binance Auth first if configured
5768    if let Some(ref binance_auth) = configuration.binance_auth {
5769        // Add API key to headers
5770        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5771        
5772        // Generate request body for signing (if any)
5773        let body_string: Option<Vec<u8>> = None;
5774        
5775        // Sign the request
5776        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        // Add signature to query params
5782        query_params.push(("signature".to_string(), signature));
5783    }
5784
5785    // Apply all query parameters
5786    if !query_params.is_empty() {
5787        req_builder = req_builder.query(&query_params);
5788    }
5789
5790
5791    // Add user agent if configured
5792    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    // Apply all header parameters
5797    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
5827/// Get trades for a specific account and UM symbol.
5828pub 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    // Create a mutable vector for query parameters
5834    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    // Create header parameters collection
5855    let mut header_params = std::collections::HashMap::new();
5856
5857    // Handle Binance Auth first if configured
5858    if let Some(ref binance_auth) = configuration.binance_auth {
5859        // Add API key to headers
5860        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5861        
5862        // Generate request body for signing (if any)
5863        let body_string: Option<Vec<u8>> = None;
5864        
5865        // Sign the request
5866        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        // Add signature to query params
5872        query_params.push(("signature".to_string(), signature));
5873    }
5874
5875    // Apply all query parameters
5876    if !query_params.is_empty() {
5877        req_builder = req_builder.query(&query_params);
5878    }
5879
5880
5881    // Add user agent if configured
5882    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    // Apply all header parameters
5887    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&lt;models::PmarginGetUmUserTradesV1RespItem&gt;`"))),
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&lt;models::PmarginGetUmUserTradesV1RespItem&gt;`")))),
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
5917/// Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
5918pub 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    // Create a mutable vector for query parameters
5924    let mut query_params: Vec<(String, String)> = Vec::new();
5925
5926
5927    // Create header parameters collection
5928    let mut header_params = std::collections::HashMap::new();
5929
5930    // Handle Binance Auth first if configured
5931    if let Some(ref binance_auth) = configuration.binance_auth {
5932        // Add API key to headers
5933        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5934        
5935        // Generate request body for signing (if any)
5936        let body_string: Option<Vec<u8>> = None;
5937        
5938        // Sign the request
5939        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        // Add signature to query params
5945        query_params.push(("signature".to_string(), signature));
5946    }
5947
5948    // Apply all query parameters
5949    if !query_params.is_empty() {
5950        req_builder = req_builder.query(&query_params);
5951    }
5952
5953
5954    // Add user agent if configured
5955    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    // Apply all header parameters
5960    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
6009/// Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
6010pub 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    // Create a mutable vector for query parameters
6016    let mut query_params: Vec<(String, String)> = Vec::new();
6017
6018
6019    // Create header parameters collection
6020    let mut header_params = std::collections::HashMap::new();
6021
6022    // Handle Binance Auth first if configured
6023    if let Some(ref binance_auth) = configuration.binance_auth {
6024        // Add API key to headers
6025        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6026        
6027        // Generate request body for signing (if any)
6028        let body_string: Option<Vec<u8>> = None;
6029        
6030        // Sign the request
6031        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        // Add signature to query params
6037        query_params.push(("signature".to_string(), signature));
6038    }
6039
6040    // Apply all query parameters
6041    if !query_params.is_empty() {
6042        req_builder = req_builder.query(&query_params);
6043    }
6044
6045
6046    // Add user agent if configured
6047    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    // Apply all header parameters
6052    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