binance/pmargin/apis/
portfolio_margin_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.2.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::pmargin::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`create_asset_collection_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateAssetCollectionV1Params {
20    pub asset: String,
21    pub timestamp: i64,
22    pub recv_window: Option<i64>
23}
24
25/// struct for passing parameters to the method [`create_auto_collection_v1`]
26#[derive(Clone, Debug, Default)]
27pub struct CreateAutoCollectionV1Params {
28    pub timestamp: i64,
29    pub recv_window: Option<i64>
30}
31
32/// struct for passing parameters to the method [`create_bnb_transfer_v1`]
33#[derive(Clone, Debug, Default)]
34pub struct CreateBnbTransferV1Params {
35    pub amount: String,
36    pub timestamp: i64,
37    pub transfer_side: String,
38    pub recv_window: Option<i64>
39}
40
41/// struct for passing parameters to the method [`create_cm_conditional_order_v1`]
42#[derive(Clone, Debug, Default)]
43pub struct CreateCmConditionalOrderV1Params {
44    pub side: String,
45    pub strategy_type: String,
46    pub symbol: String,
47    pub timestamp: i64,
48    pub activation_price: Option<String>,
49    pub callback_rate: Option<String>,
50    pub new_client_strategy_id: Option<String>,
51    pub position_side: Option<String>,
52    pub price: Option<String>,
53    pub price_protect: Option<String>,
54    pub quantity: Option<String>,
55    pub recv_window: Option<i64>,
56    pub reduce_only: Option<String>,
57    pub stop_price: Option<String>,
58    pub time_in_force: Option<String>,
59    pub working_type: Option<String>
60}
61
62/// struct for passing parameters to the method [`create_cm_leverage_v1`]
63#[derive(Clone, Debug, Default)]
64pub struct CreateCmLeverageV1Params {
65    pub leverage: i32,
66    pub symbol: String,
67    pub timestamp: i64,
68    pub recv_window: Option<i64>
69}
70
71/// struct for passing parameters to the method [`create_cm_order_v1`]
72#[derive(Clone, Debug, Default)]
73pub struct CreateCmOrderV1Params {
74    pub side: String,
75    pub symbol: String,
76    pub timestamp: i64,
77    pub r#type: String,
78    pub new_client_order_id: Option<String>,
79    pub new_order_resp_type: Option<String>,
80    pub position_side: Option<String>,
81    pub price: Option<String>,
82    pub price_match: Option<String>,
83    pub quantity: Option<String>,
84    pub recv_window: Option<i64>,
85    pub reduce_only: Option<String>,
86    pub time_in_force: Option<String>
87}
88
89/// struct for passing parameters to the method [`create_cm_position_side_dual_v1`]
90#[derive(Clone, Debug, Default)]
91pub struct CreateCmPositionSideDualV1Params {
92    pub dual_side_position: String,
93    pub timestamp: i64,
94    pub recv_window: Option<i64>
95}
96
97/// struct for passing parameters to the method [`create_margin_loan_v1`]
98#[derive(Clone, Debug, Default)]
99pub struct CreateMarginLoanV1Params {
100    pub amount: String,
101    pub asset: String,
102    pub timestamp: i64,
103    pub recv_window: Option<i64>
104}
105
106/// struct for passing parameters to the method [`create_margin_order_oco_v1`]
107#[derive(Clone, Debug, Default)]
108pub struct CreateMarginOrderOcoV1Params {
109    pub price: String,
110    pub quantity: String,
111    pub side: String,
112    pub stop_price: String,
113    pub symbol: String,
114    pub timestamp: i64,
115    pub limit_client_order_id: Option<String>,
116    pub limit_iceberg_qty: Option<String>,
117    pub list_client_order_id: Option<String>,
118    pub new_order_resp_type: Option<String>,
119    pub recv_window: Option<i64>,
120    pub side_effect_type: Option<String>,
121    pub stop_client_order_id: Option<String>,
122    pub stop_iceberg_qty: Option<String>,
123    pub stop_limit_price: Option<String>,
124    pub stop_limit_time_in_force: Option<String>
125}
126
127/// struct for passing parameters to the method [`create_margin_order_v1`]
128#[derive(Clone, Debug, Default)]
129pub struct CreateMarginOrderV1Params {
130    pub side: String,
131    pub symbol: String,
132    pub timestamp: i64,
133    pub r#type: String,
134    pub auto_repay_at_cancel: Option<bool>,
135    pub iceberg_qty: Option<String>,
136    pub new_client_order_id: Option<String>,
137    pub new_order_resp_type: Option<String>,
138    pub price: Option<String>,
139    pub quantity: Option<String>,
140    pub quote_order_qty: Option<String>,
141    pub recv_window: Option<i64>,
142    pub self_trade_prevention_mode: Option<String>,
143    pub side_effect_type: Option<String>,
144    pub stop_price: Option<String>,
145    pub time_in_force: Option<String>
146}
147
148/// struct for passing parameters to the method [`create_margin_repay_debt_v1`]
149#[derive(Clone, Debug, Default)]
150pub struct CreateMarginRepayDebtV1Params {
151    pub asset: String,
152    pub timestamp: i64,
153    pub amount: Option<String>,
154    pub recv_window: Option<i64>,
155    pub specify_repay_assets: Option<String>
156}
157
158/// struct for passing parameters to the method [`create_repay_futures_negative_balance_v1`]
159#[derive(Clone, Debug, Default)]
160pub struct CreateRepayFuturesNegativeBalanceV1Params {
161    pub timestamp: i64,
162    pub recv_window: Option<i64>
163}
164
165/// struct for passing parameters to the method [`create_repay_futures_switch_v1`]
166#[derive(Clone, Debug, Default)]
167pub struct CreateRepayFuturesSwitchV1Params {
168    pub auto_repay: String,
169    pub timestamp: i64,
170    pub recv_window: Option<i64>
171}
172
173/// struct for passing parameters to the method [`create_repay_loan_v1`]
174#[derive(Clone, Debug, Default)]
175pub struct CreateRepayLoanV1Params {
176    pub amount: String,
177    pub asset: String,
178    pub timestamp: i64,
179    pub recv_window: Option<i64>
180}
181
182/// struct for passing parameters to the method [`create_um_conditional_order_v1`]
183#[derive(Clone, Debug, Default)]
184pub struct CreateUmConditionalOrderV1Params {
185    pub side: String,
186    pub strategy_type: String,
187    pub symbol: String,
188    pub timestamp: i64,
189    pub activation_price: Option<String>,
190    pub callback_rate: Option<String>,
191    pub good_till_date: Option<i64>,
192    pub new_client_strategy_id: Option<String>,
193    pub position_side: Option<String>,
194    pub price: Option<String>,
195    pub price_match: Option<String>,
196    pub price_protect: Option<String>,
197    pub quantity: Option<String>,
198    pub recv_window: Option<i64>,
199    pub reduce_only: Option<String>,
200    pub self_trade_prevention_mode: Option<String>,
201    pub stop_price: Option<String>,
202    pub time_in_force: Option<String>,
203    pub working_type: Option<String>
204}
205
206/// struct for passing parameters to the method [`create_um_fee_burn_v1`]
207#[derive(Clone, Debug, Default)]
208pub struct CreateUmFeeBurnV1Params {
209    pub fee_burn: String,
210    pub timestamp: i64,
211    pub recv_window: Option<i64>
212}
213
214/// struct for passing parameters to the method [`create_um_leverage_v1`]
215#[derive(Clone, Debug, Default)]
216pub struct CreateUmLeverageV1Params {
217    pub leverage: i32,
218    pub symbol: String,
219    pub timestamp: i64,
220    pub recv_window: Option<i64>
221}
222
223/// struct for passing parameters to the method [`create_um_order_v1`]
224#[derive(Clone, Debug, Default)]
225pub struct CreateUmOrderV1Params {
226    pub side: String,
227    pub symbol: String,
228    pub timestamp: i64,
229    pub r#type: String,
230    pub good_till_date: Option<i64>,
231    pub new_client_order_id: Option<String>,
232    pub new_order_resp_type: Option<String>,
233    pub position_side: Option<String>,
234    pub price: Option<String>,
235    pub price_match: Option<String>,
236    pub quantity: Option<String>,
237    pub recv_window: Option<i64>,
238    pub reduce_only: Option<String>,
239    pub self_trade_prevention_mode: Option<String>,
240    pub time_in_force: Option<String>
241}
242
243/// struct for passing parameters to the method [`create_um_position_side_dual_v1`]
244#[derive(Clone, Debug, Default)]
245pub struct CreateUmPositionSideDualV1Params {
246    pub dual_side_position: String,
247    pub timestamp: i64,
248    pub recv_window: Option<i64>
249}
250
251/// struct for passing parameters to the method [`delete_cm_all_open_orders_v1`]
252#[derive(Clone, Debug, Default)]
253pub struct DeleteCmAllOpenOrdersV1Params {
254    pub symbol: String,
255    pub timestamp: i64,
256    pub recv_window: Option<i64>
257}
258
259/// struct for passing parameters to the method [`delete_cm_conditional_all_open_orders_v1`]
260#[derive(Clone, Debug, Default)]
261pub struct DeleteCmConditionalAllOpenOrdersV1Params {
262    pub symbol: String,
263    pub timestamp: i64,
264    pub recv_window: Option<i64>
265}
266
267/// struct for passing parameters to the method [`delete_cm_conditional_order_v1`]
268#[derive(Clone, Debug, Default)]
269pub struct DeleteCmConditionalOrderV1Params {
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 [`delete_cm_order_v1`]
278#[derive(Clone, Debug, Default)]
279pub struct DeleteCmOrderV1Params {
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 [`delete_margin_all_open_orders_v1`]
288#[derive(Clone, Debug, Default)]
289pub struct DeleteMarginAllOpenOrdersV1Params {
290    pub symbol: String,
291    pub timestamp: i64,
292    /// The value cannot be greater than 60000
293    pub recv_window: Option<i64>
294}
295
296/// struct for passing parameters to the method [`delete_margin_order_list_v1`]
297#[derive(Clone, Debug, Default)]
298pub struct DeleteMarginOrderListV1Params {
299    pub symbol: String,
300    pub timestamp: i64,
301    /// Either `orderListId` or `listClientOrderId` must be provided
302    pub order_list_id: Option<i64>,
303    /// Either `orderListId` or `listClientOrderId` must be provided
304    pub list_client_order_id: Option<String>,
305    /// Used to uniquely identify this cancel. Automatically generated by default
306    pub new_client_order_id: Option<String>,
307    /// The value cannot be greater than 60000
308    pub recv_window: Option<i64>
309}
310
311/// struct for passing parameters to the method [`delete_margin_order_v1`]
312#[derive(Clone, Debug, Default)]
313pub struct DeleteMarginOrderV1Params {
314    pub symbol: String,
315    pub timestamp: i64,
316    pub order_id: Option<i64>,
317    pub orig_client_order_id: Option<String>,
318    /// Used to uniquely identify this cancel. Automatically generated by default.
319    pub new_client_order_id: Option<String>,
320    /// The value cannot be greater than `60000`
321    pub recv_window: Option<i64>
322}
323
324/// struct for passing parameters to the method [`delete_um_all_open_orders_v1`]
325#[derive(Clone, Debug, Default)]
326pub struct DeleteUmAllOpenOrdersV1Params {
327    pub symbol: String,
328    pub timestamp: i64,
329    pub recv_window: Option<i64>
330}
331
332/// struct for passing parameters to the method [`delete_um_conditional_all_open_orders_v1`]
333#[derive(Clone, Debug, Default)]
334pub struct DeleteUmConditionalAllOpenOrdersV1Params {
335    pub symbol: String,
336    pub timestamp: i64,
337    pub recv_window: Option<i64>
338}
339
340/// struct for passing parameters to the method [`delete_um_conditional_order_v1`]
341#[derive(Clone, Debug, Default)]
342pub struct DeleteUmConditionalOrderV1Params {
343    pub symbol: String,
344    pub timestamp: i64,
345    pub strategy_id: Option<i64>,
346    pub new_client_strategy_id: Option<String>,
347    pub recv_window: Option<i64>
348}
349
350/// struct for passing parameters to the method [`delete_um_order_v1`]
351#[derive(Clone, Debug, Default)]
352pub struct DeleteUmOrderV1Params {
353    pub symbol: String,
354    pub timestamp: i64,
355    pub order_id: Option<i64>,
356    pub orig_client_order_id: Option<String>,
357    pub recv_window: Option<i64>
358}
359
360/// struct for passing parameters to the method [`get_account_v1`]
361#[derive(Clone, Debug, Default)]
362pub struct GetAccountV1Params {
363    pub timestamp: i64,
364    pub recv_window: Option<i64>
365}
366
367/// struct for passing parameters to the method [`get_balance_v1`]
368#[derive(Clone, Debug, Default)]
369pub struct GetBalanceV1Params {
370    pub timestamp: i64,
371    pub asset: Option<String>,
372    pub recv_window: Option<i64>
373}
374
375/// struct for passing parameters to the method [`get_cm_account_v1`]
376#[derive(Clone, Debug, Default)]
377pub struct GetCmAccountV1Params {
378    pub timestamp: i64,
379    pub recv_window: Option<i64>
380}
381
382/// struct for passing parameters to the method [`get_cm_all_orders_v1`]
383#[derive(Clone, Debug, Default)]
384pub struct GetCmAllOrdersV1Params {
385    pub symbol: String,
386    pub timestamp: i64,
387    pub pair: Option<String>,
388    pub order_id: Option<i64>,
389    pub start_time: Option<i64>,
390    pub end_time: Option<i64>,
391    /// Default 50; max 100.
392    pub limit: Option<i32>,
393    pub recv_window: Option<i64>
394}
395
396/// struct for passing parameters to the method [`get_cm_commission_rate_v1`]
397#[derive(Clone, Debug, Default)]
398pub struct GetCmCommissionRateV1Params {
399    pub symbol: String,
400    pub timestamp: i64,
401    pub recv_window: Option<i64>
402}
403
404/// struct for passing parameters to the method [`get_cm_conditional_all_orders_v1`]
405#[derive(Clone, Debug, Default)]
406pub struct GetCmConditionalAllOrdersV1Params {
407    pub timestamp: i64,
408    pub symbol: Option<String>,
409    pub strategy_id: Option<i64>,
410    pub start_time: Option<i64>,
411    pub end_time: Option<i64>,
412    /// Default 500; max 1000.
413    pub limit: Option<i32>,
414    pub recv_window: Option<i64>
415}
416
417/// struct for passing parameters to the method [`get_cm_conditional_open_order_v1`]
418#[derive(Clone, Debug, Default)]
419pub struct GetCmConditionalOpenOrderV1Params {
420    pub symbol: String,
421    pub timestamp: i64,
422    pub strategy_id: Option<i64>,
423    pub new_client_strategy_id: Option<String>,
424    pub recv_window: Option<i64>
425}
426
427/// struct for passing parameters to the method [`get_cm_conditional_open_orders_v1`]
428#[derive(Clone, Debug, Default)]
429pub struct GetCmConditionalOpenOrdersV1Params {
430    pub timestamp: i64,
431    pub symbol: Option<String>,
432    pub recv_window: Option<i64>
433}
434
435/// struct for passing parameters to the method [`get_cm_conditional_order_history_v1`]
436#[derive(Clone, Debug, Default)]
437pub struct GetCmConditionalOrderHistoryV1Params {
438    pub symbol: String,
439    pub timestamp: i64,
440    pub strategy_id: Option<i64>,
441    pub new_client_strategy_id: Option<String>,
442    pub recv_window: Option<i64>
443}
444
445/// struct for passing parameters to the method [`get_cm_force_orders_v1`]
446#[derive(Clone, Debug, Default)]
447pub struct GetCmForceOrdersV1Params {
448    pub timestamp: i64,
449    pub symbol: Option<String>,
450    /// &#34;LIQUIDATION&#34; for liquidation orders, &#34;ADL&#34; for ADL orders.
451    pub auto_close_type: Option<String>,
452    pub start_time: Option<i64>,
453    pub end_time: Option<i64>,
454    /// Default 50; max 100.
455    pub limit: Option<i32>,
456    /// The value cannot be greater than 60000
457    pub recv_window: Option<i64>
458}
459
460/// struct for passing parameters to the method [`get_cm_income_v1`]
461#[derive(Clone, Debug, Default)]
462pub struct GetCmIncomeV1Params {
463    pub timestamp: i64,
464    pub symbol: Option<String>,
465    /// &#34;TRANSFER&#34;,&#34;WELCOME_BONUS&#34;, &#34;FUNDING_FEE&#34;, &#34;REALIZED_PNL&#34;, &#34;COMMISSION&#34;, &#34;INSURANCE_CLEAR&#34;, and &#34;DELIVERED_SETTELMENT&#34;
466    pub income_type: Option<String>,
467    /// Timestamp in ms to get funding from INCLUSIVE.
468    pub start_time: Option<i64>,
469    /// Timestamp in ms to get funding until INCLUSIVE.
470    pub end_time: Option<i64>,
471    pub page: Option<i32>,
472    /// Default 100; max 1000
473    pub limit: Option<i32>,
474    pub recv_window: Option<i64>
475}
476
477/// struct for passing parameters to the method [`get_cm_leverage_bracket_v1`]
478#[derive(Clone, Debug, Default)]
479pub struct GetCmLeverageBracketV1Params {
480    pub timestamp: i64,
481    pub symbol: Option<String>,
482    pub recv_window: Option<i64>
483}
484
485/// struct for passing parameters to the method [`get_cm_open_order_v1`]
486#[derive(Clone, Debug, Default)]
487pub struct GetCmOpenOrderV1Params {
488    pub symbol: String,
489    pub timestamp: i64,
490    pub order_id: Option<i64>,
491    pub orig_client_order_id: Option<String>,
492    pub recv_window: Option<i64>
493}
494
495/// struct for passing parameters to the method [`get_cm_open_orders_v1`]
496#[derive(Clone, Debug, Default)]
497pub struct GetCmOpenOrdersV1Params {
498    pub timestamp: i64,
499    pub symbol: Option<String>,
500    pub pair: Option<String>,
501    pub recv_window: Option<i64>
502}
503
504/// struct for passing parameters to the method [`get_cm_order_amendment_v1`]
505#[derive(Clone, Debug, Default)]
506pub struct GetCmOrderAmendmentV1Params {
507    pub symbol: String,
508    pub timestamp: i64,
509    pub order_id: Option<i64>,
510    pub orig_client_order_id: Option<String>,
511    /// Timestamp in ms to get modification history from INCLUSIVE
512    pub start_time: Option<i64>,
513    /// Timestamp in ms to get modification history until INCLUSIVE
514    pub end_time: Option<i64>,
515    /// Default 50, max 100
516    pub limit: Option<i32>,
517    pub recv_window: Option<i64>
518}
519
520/// struct for passing parameters to the method [`get_cm_order_v1`]
521#[derive(Clone, Debug, Default)]
522pub struct GetCmOrderV1Params {
523    pub symbol: String,
524    pub timestamp: i64,
525    pub order_id: Option<i64>,
526    pub orig_client_order_id: Option<String>,
527    pub recv_window: Option<i64>
528}
529
530/// struct for passing parameters to the method [`get_cm_position_risk_v1`]
531#[derive(Clone, Debug, Default)]
532pub struct GetCmPositionRiskV1Params {
533    pub timestamp: i64,
534    pub margin_asset: Option<String>,
535    pub pair: Option<String>,
536    pub recv_window: Option<i64>
537}
538
539/// struct for passing parameters to the method [`get_cm_position_side_dual_v1`]
540#[derive(Clone, Debug, Default)]
541pub struct GetCmPositionSideDualV1Params {
542    pub timestamp: i64,
543    pub recv_window: Option<i64>
544}
545
546/// struct for passing parameters to the method [`get_cm_user_trades_v1`]
547#[derive(Clone, Debug, Default)]
548pub struct GetCmUserTradesV1Params {
549    pub timestamp: i64,
550    pub symbol: Option<String>,
551    pub pair: Option<String>,
552    pub start_time: Option<i64>,
553    pub end_time: Option<i64>,
554    /// Trade id to fetch from. Default gets most recent trades.
555    pub from_id: Option<i64>,
556    /// Default 50; max 1000.
557    pub limit: Option<i32>,
558    pub recv_window: Option<i64>
559}
560
561/// struct for passing parameters to the method [`get_margin_all_order_list_v1`]
562#[derive(Clone, Debug, Default)]
563pub struct GetMarginAllOrderListV1Params {
564    pub timestamp: i64,
565    /// If supplied, neither startTime or endTime can be provided
566    pub from_id: Option<i64>,
567    pub start_time: Option<i64>,
568    pub end_time: Option<i64>,
569    /// Default 500; max 500.
570    pub limit: Option<i32>,
571    /// The value cannot be greater than 60000
572    pub recv_window: Option<i64>
573}
574
575/// struct for passing parameters to the method [`get_margin_all_orders_v1`]
576#[derive(Clone, Debug, Default)]
577pub struct GetMarginAllOrdersV1Params {
578    pub symbol: String,
579    pub timestamp: i64,
580    pub order_id: Option<i64>,
581    pub start_time: Option<i64>,
582    pub end_time: Option<i64>,
583    /// Default 500; max 500.
584    pub limit: Option<i32>,
585    /// The value cannot be greater than 60000
586    pub recv_window: Option<i64>
587}
588
589/// struct for passing parameters to the method [`get_margin_force_orders_v1`]
590#[derive(Clone, Debug, Default)]
591pub struct GetMarginForceOrdersV1Params {
592    pub timestamp: i64,
593    pub start_time: Option<i64>,
594    pub end_time: Option<i64>,
595    /// Currently querying page. Start from 1. Default:1
596    pub current: Option<i64>,
597    /// Default:10 Max:100
598    pub size: Option<i64>,
599    /// The value cannot be greater than 60000
600    pub recv_window: Option<i64>
601}
602
603/// struct for passing parameters to the method [`get_margin_margin_interest_history_v1`]
604#[derive(Clone, Debug, Default)]
605pub struct GetMarginMarginInterestHistoryV1Params {
606    pub timestamp: i64,
607    pub asset: Option<String>,
608    pub start_time: Option<i64>,
609    pub end_time: Option<i64>,
610    /// Currently querying page. Start from 1. Default:1
611    pub current: Option<i64>,
612    /// Default:10 Max:100
613    pub size: Option<i64>,
614    /// Default: `false`. Set to `true` for archived data from 6 months ago
615    pub archived: Option<String>,
616    /// The value cannot be greater than `60000`
617    pub recv_window: Option<i64>
618}
619
620/// struct for passing parameters to the method [`get_margin_margin_loan_v1`]
621#[derive(Clone, Debug, Default)]
622pub struct GetMarginMarginLoanV1Params {
623    pub asset: String,
624    pub timestamp: i64,
625    /// the `tranId` in `POST/papi/v1/marginLoan`
626    pub tx_id: Option<i64>,
627    pub start_time: Option<i64>,
628    pub end_time: Option<i64>,
629    /// Currently querying page. Start from 1. Default:1
630    pub current: Option<i64>,
631    /// Default:10 Max:100
632    pub size: Option<i64>,
633    /// Default: `false`. Set to `true` for archived data from 6 months ago
634    pub archived: Option<String>,
635    /// The value cannot be greater than 60000
636    pub recv_window: Option<i64>
637}
638
639/// struct for passing parameters to the method [`get_margin_max_borrowable_v1`]
640#[derive(Clone, Debug, Default)]
641pub struct GetMarginMaxBorrowableV1Params {
642    pub asset: String,
643    pub timestamp: i64,
644    /// The value cannot be greater than `60000`
645    pub recv_window: Option<i64>
646}
647
648/// struct for passing parameters to the method [`get_margin_max_withdraw_v1`]
649#[derive(Clone, Debug, Default)]
650pub struct GetMarginMaxWithdrawV1Params {
651    pub asset: String,
652    pub timestamp: i64,
653    /// The value cannot be greater than `60000`
654    pub recv_window: Option<i64>
655}
656
657/// struct for passing parameters to the method [`get_margin_my_trades_v1`]
658#[derive(Clone, Debug, Default)]
659pub struct GetMarginMyTradesV1Params {
660    pub symbol: String,
661    pub timestamp: i64,
662    pub order_id: Option<i64>,
663    pub start_time: Option<i64>,
664    pub end_time: Option<i64>,
665    /// TradeId to fetch from. Default gets most recent trades.
666    pub from_id: Option<i64>,
667    /// Default 500; max 1000.
668    pub limit: Option<i32>,
669    /// The value cannot be greater than 60000
670    pub recv_window: Option<i64>
671}
672
673/// struct for passing parameters to the method [`get_margin_open_order_list_v1`]
674#[derive(Clone, Debug, Default)]
675pub struct GetMarginOpenOrderListV1Params {
676    pub timestamp: i64,
677    /// The value cannot be greater than 60000
678    pub recv_window: Option<i64>
679}
680
681/// struct for passing parameters to the method [`get_margin_open_orders_v1`]
682#[derive(Clone, Debug, Default)]
683pub struct GetMarginOpenOrdersV1Params {
684    pub symbol: String,
685    pub timestamp: i64,
686    /// The value cannot be greater than 60000
687    pub recv_window: Option<i64>
688}
689
690/// struct for passing parameters to the method [`get_margin_order_list_v1`]
691#[derive(Clone, Debug, Default)]
692pub struct GetMarginOrderListV1Params {
693    pub timestamp: i64,
694    /// Either orderListId or origClientOrderId must be provided
695    pub order_list_id: Option<i64>,
696    /// Either orderListId or origClientOrderId must be provided
697    pub orig_client_order_id: Option<String>,
698    /// The value cannot be greater than 60000
699    pub recv_window: Option<i64>
700}
701
702/// struct for passing parameters to the method [`get_margin_order_v1`]
703#[derive(Clone, Debug, Default)]
704pub struct GetMarginOrderV1Params {
705    pub symbol: String,
706    pub timestamp: i64,
707    pub order_id: Option<i64>,
708    pub orig_client_order_id: Option<String>,
709    /// The value cannot be greater than 60000
710    pub recv_window: Option<i64>
711}
712
713/// struct for passing parameters to the method [`get_margin_repay_loan_v1`]
714#[derive(Clone, Debug, Default)]
715pub struct GetMarginRepayLoanV1Params {
716    pub asset: String,
717    pub timestamp: i64,
718    /// the tranId in `POST/papi/v1/repayLoan`
719    pub tx_id: Option<i64>,
720    pub start_time: Option<i64>,
721    pub end_time: Option<i64>,
722    /// Currently querying page. Start from 1. Default:1
723    pub current: Option<i64>,
724    /// Default:10 Max:100
725    pub size: Option<i64>,
726    /// Default: `false`. Set to `true` for archived data from 6 months ago
727    pub archived: Option<String>,
728    /// The value cannot be greater than 60000
729    pub recv_window: Option<i64>
730}
731
732/// struct for passing parameters to the method [`get_portfolio_interest_history_v1`]
733#[derive(Clone, Debug, Default)]
734pub struct GetPortfolioInterestHistoryV1Params {
735    pub timestamp: i64,
736    pub asset: Option<String>,
737    pub start_time: Option<i64>,
738    pub end_time: Option<i64>,
739    /// Default:10 Max:100
740    pub size: Option<i64>,
741    pub recv_window: Option<i64>
742}
743
744/// struct for passing parameters to the method [`get_portfolio_negative_balance_exchange_record_v1`]
745#[derive(Clone, Debug, Default)]
746pub struct GetPortfolioNegativeBalanceExchangeRecordV1Params {
747    pub start_time: i64,
748    pub end_time: i64,
749    pub timestamp: i64,
750    /// The value cannot be greater than 60000
751    pub recv_window: Option<i64>
752}
753
754/// struct for passing parameters to the method [`get_rate_limit_order_v1`]
755#[derive(Clone, Debug, Default)]
756pub struct GetRateLimitOrderV1Params {
757    pub timestamp: i64,
758    pub recv_window: Option<i64>
759}
760
761/// struct for passing parameters to the method [`get_repay_futures_switch_v1`]
762#[derive(Clone, Debug, Default)]
763pub struct GetRepayFuturesSwitchV1Params {
764    pub timestamp: i64,
765    pub recv_window: Option<i64>
766}
767
768/// struct for passing parameters to the method [`get_um_account_config_v1`]
769#[derive(Clone, Debug, Default)]
770pub struct GetUmAccountConfigV1Params {
771    pub timestamp: i64,
772    pub recv_window: Option<i64>
773}
774
775/// struct for passing parameters to the method [`get_um_account_v1`]
776#[derive(Clone, Debug, Default)]
777pub struct GetUmAccountV1Params {
778    pub timestamp: i64,
779    pub recv_window: Option<i64>
780}
781
782/// struct for passing parameters to the method [`get_um_account_v2`]
783#[derive(Clone, Debug, Default)]
784pub struct GetUmAccountV2Params {
785    pub timestamp: i64,
786    pub recv_window: Option<i64>
787}
788
789/// struct for passing parameters to the method [`get_um_adl_quantile_v1`]
790#[derive(Clone, Debug, Default)]
791pub struct GetUmAdlQuantileV1Params {
792    pub timestamp: i64,
793    pub symbol: Option<String>,
794    pub recv_window: Option<i64>
795}
796
797/// struct for passing parameters to the method [`get_um_all_orders_v1`]
798#[derive(Clone, Debug, Default)]
799pub struct GetUmAllOrdersV1Params {
800    pub symbol: String,
801    pub timestamp: i64,
802    pub order_id: Option<i64>,
803    pub start_time: Option<i64>,
804    pub end_time: Option<i64>,
805    /// Default 500; max 1000.
806    pub limit: Option<i32>,
807    pub recv_window: Option<i64>
808}
809
810/// struct for passing parameters to the method [`get_um_api_trading_status_v1`]
811#[derive(Clone, Debug, Default)]
812pub struct GetUmApiTradingStatusV1Params {
813    pub timestamp: i64,
814    pub symbol: Option<String>,
815    pub recv_window: Option<i64>
816}
817
818/// struct for passing parameters to the method [`get_um_commission_rate_v1`]
819#[derive(Clone, Debug, Default)]
820pub struct GetUmCommissionRateV1Params {
821    pub symbol: String,
822    pub timestamp: i64,
823    pub recv_window: Option<i64>
824}
825
826/// struct for passing parameters to the method [`get_um_conditional_all_orders_v1`]
827#[derive(Clone, Debug, Default)]
828pub struct GetUmConditionalAllOrdersV1Params {
829    pub timestamp: i64,
830    pub symbol: Option<String>,
831    pub strategy_id: Option<i64>,
832    pub start_time: Option<i64>,
833    pub end_time: Option<i64>,
834    /// Default 500; max 1000.
835    pub limit: Option<i32>,
836    pub recv_window: Option<i64>
837}
838
839/// struct for passing parameters to the method [`get_um_conditional_open_order_v1`]
840#[derive(Clone, Debug, Default)]
841pub struct GetUmConditionalOpenOrderV1Params {
842    pub symbol: String,
843    pub timestamp: i64,
844    pub strategy_id: Option<i64>,
845    pub new_client_strategy_id: Option<String>,
846    pub recv_window: Option<i64>
847}
848
849/// struct for passing parameters to the method [`get_um_conditional_order_history_v1`]
850#[derive(Clone, Debug, Default)]
851pub struct GetUmConditionalOrderHistoryV1Params {
852    pub symbol: String,
853    pub timestamp: i64,
854    pub strategy_id: Option<i64>,
855    pub new_client_strategy_id: Option<String>,
856    pub recv_window: Option<i64>
857}
858
859/// struct for passing parameters to the method [`get_um_fee_burn_v1`]
860#[derive(Clone, Debug, Default)]
861pub struct GetUmFeeBurnV1Params {
862    pub timestamp: i64,
863    pub recv_window: Option<i64>
864}
865
866/// struct for passing parameters to the method [`get_um_force_orders_v1`]
867#[derive(Clone, Debug, Default)]
868pub struct GetUmForceOrdersV1Params {
869    pub timestamp: i64,
870    pub symbol: Option<String>,
871    /// `LIQUIDATION` for liquidation orders, `ADL` for ADL orders.
872    pub auto_close_type: Option<String>,
873    pub start_time: Option<i64>,
874    pub end_time: Option<i64>,
875    /// Default 50; max 100.
876    pub limit: Option<i32>,
877    /// The value cannot be greater than 60000
878    pub recv_window: Option<i64>
879}
880
881/// struct for passing parameters to the method [`get_um_income_asyn_id_v1`]
882#[derive(Clone, Debug, Default)]
883pub struct GetUmIncomeAsynIdV1Params {
884    /// get by download id api
885    pub download_id: String,
886    pub timestamp: i64,
887    pub recv_window: Option<i64>
888}
889
890/// struct for passing parameters to the method [`get_um_income_asyn_v1`]
891#[derive(Clone, Debug, Default)]
892pub struct GetUmIncomeAsynV1Params {
893    /// Timestamp in ms
894    pub start_time: i64,
895    /// Timestamp in ms
896    pub end_time: i64,
897    pub timestamp: i64,
898    pub recv_window: Option<i64>
899}
900
901/// struct for passing parameters to the method [`get_um_income_v1`]
902#[derive(Clone, Debug, Default)]
903pub struct GetUmIncomeV1Params {
904    pub timestamp: i64,
905    pub symbol: Option<String>,
906    /// TRANSFER, WELCOME_BONUS, REALIZED_PNL, FUNDING_FEE, COMMISSION, INSURANCE_CLEAR, REFERRAL_KICKBACK, COMMISSION_REBATE, API_REBATE, CONTEST_REWARD, CROSS_COLLATERAL_TRANSFER, OPTIONS_PREMIUM_FEE, OPTIONS_SETTLE_PROFIT, INTERNAL_TRANSFER, AUTO_EXCHANGE, DELIVERED_SETTELMENT, COIN_SWAP_DEPOSIT, COIN_SWAP_WITHDRAW, POSITION_LIMIT_INCREASE_FEE
907    pub income_type: Option<String>,
908    /// Timestamp in ms to get funding from INCLUSIVE.
909    pub start_time: Option<i64>,
910    /// Timestamp in ms to get funding until INCLUSIVE.
911    pub end_time: Option<i64>,
912    pub page: Option<i32>,
913    /// Default 100; max 1000
914    pub limit: Option<i32>,
915    pub recv_window: Option<i64>
916}
917
918/// struct for passing parameters to the method [`get_um_leverage_bracket_v1`]
919#[derive(Clone, Debug, Default)]
920pub struct GetUmLeverageBracketV1Params {
921    pub timestamp: i64,
922    pub symbol: Option<String>,
923    pub recv_window: Option<i64>
924}
925
926/// struct for passing parameters to the method [`get_um_open_order_v1`]
927#[derive(Clone, Debug, Default)]
928pub struct GetUmOpenOrderV1Params {
929    pub symbol: String,
930    pub timestamp: i64,
931    pub order_id: Option<i64>,
932    pub orig_client_order_id: Option<String>,
933    pub recv_window: Option<i64>
934}
935
936/// struct for passing parameters to the method [`get_um_open_orders_v1`]
937#[derive(Clone, Debug, Default)]
938pub struct GetUmOpenOrdersV1Params {
939    pub timestamp: i64,
940    pub symbol: Option<String>,
941    pub recv_window: Option<i64>
942}
943
944/// struct for passing parameters to the method [`get_um_order_amendment_v1`]
945#[derive(Clone, Debug, Default)]
946pub struct GetUmOrderAmendmentV1Params {
947    pub symbol: String,
948    pub timestamp: i64,
949    pub order_id: Option<i64>,
950    pub orig_client_order_id: Option<String>,
951    /// Timestamp in ms to get modification history from INCLUSIVE
952    pub start_time: Option<i64>,
953    /// Timestamp in ms to get modification history until INCLUSIVE
954    pub end_time: Option<i64>,
955    /// Default 500, max 1000
956    pub limit: Option<i32>,
957    pub recv_window: Option<i64>
958}
959
960/// struct for passing parameters to the method [`get_um_order_asyn_id_v1`]
961#[derive(Clone, Debug, Default)]
962pub struct GetUmOrderAsynIdV1Params {
963    /// get by download id api
964    pub download_id: String,
965    pub timestamp: i64,
966    pub recv_window: Option<i64>
967}
968
969/// struct for passing parameters to the method [`get_um_order_asyn_v1`]
970#[derive(Clone, Debug, Default)]
971pub struct GetUmOrderAsynV1Params {
972    /// Timestamp in ms
973    pub start_time: i64,
974    /// Timestamp in ms
975    pub end_time: i64,
976    pub timestamp: i64,
977    pub recv_window: Option<i64>
978}
979
980/// struct for passing parameters to the method [`get_um_order_v1`]
981#[derive(Clone, Debug, Default)]
982pub struct GetUmOrderV1Params {
983    pub symbol: String,
984    pub timestamp: i64,
985    pub order_id: Option<i64>,
986    pub orig_client_order_id: Option<String>,
987    pub recv_window: Option<i64>
988}
989
990/// struct for passing parameters to the method [`get_um_position_side_dual_v1`]
991#[derive(Clone, Debug, Default)]
992pub struct GetUmPositionSideDualV1Params {
993    pub timestamp: i64,
994    pub recv_window: Option<i64>
995}
996
997/// struct for passing parameters to the method [`get_um_symbol_config_v1`]
998#[derive(Clone, Debug, Default)]
999pub struct GetUmSymbolConfigV1Params {
1000    pub timestamp: i64,
1001    pub symbol: Option<String>,
1002    pub recv_window: Option<i64>
1003}
1004
1005/// struct for passing parameters to the method [`get_um_trade_asyn_id_v1`]
1006#[derive(Clone, Debug, Default)]
1007pub struct GetUmTradeAsynIdV1Params {
1008    /// get by download id api
1009    pub download_id: String,
1010    pub timestamp: i64,
1011    pub recv_window: Option<i64>
1012}
1013
1014/// struct for passing parameters to the method [`get_um_trade_asyn_v1`]
1015#[derive(Clone, Debug, Default)]
1016pub struct GetUmTradeAsynV1Params {
1017    /// Timestamp in ms
1018    pub start_time: i64,
1019    /// Timestamp in ms
1020    pub end_time: i64,
1021    pub timestamp: i64,
1022    pub recv_window: Option<i64>
1023}
1024
1025/// struct for passing parameters to the method [`get_um_user_trades_v1`]
1026#[derive(Clone, Debug, Default)]
1027pub struct GetUmUserTradesV1Params {
1028    pub symbol: String,
1029    pub timestamp: i64,
1030    pub start_time: Option<i64>,
1031    pub end_time: Option<i64>,
1032    /// Trade id to fetch from. Default gets most recent trades.
1033    pub from_id: Option<i64>,
1034    /// Default 500; max 1000.
1035    pub limit: Option<i32>,
1036    pub recv_window: Option<i64>
1037}
1038
1039/// struct for passing parameters to the method [`update_cm_order_v1`]
1040#[derive(Clone, Debug, Default)]
1041pub struct UpdateCmOrderV1Params {
1042    pub price: String,
1043    pub quantity: String,
1044    pub side: String,
1045    pub symbol: String,
1046    pub timestamp: i64,
1047    pub order_id: Option<i64>,
1048    pub orig_client_order_id: Option<String>,
1049    pub price_match: Option<String>,
1050    pub recv_window: Option<i64>
1051}
1052
1053/// struct for passing parameters to the method [`update_um_order_v1`]
1054#[derive(Clone, Debug, Default)]
1055pub struct UpdateUmOrderV1Params {
1056    pub price: String,
1057    pub quantity: String,
1058    pub side: String,
1059    pub symbol: String,
1060    pub timestamp: i64,
1061    pub order_id: Option<i64>,
1062    pub orig_client_order_id: Option<String>,
1063    pub price_match: Option<String>,
1064    pub recv_window: Option<i64>
1065}
1066
1067
1068/// struct for typed errors of method [`create_asset_collection_v1`]
1069#[derive(Debug, Clone, Serialize, Deserialize)]
1070#[serde(untagged)]
1071pub enum CreateAssetCollectionV1Error {
1072    Status4XX(models::ApiError),
1073    Status5XX(models::ApiError),
1074    UnknownValue(serde_json::Value),
1075}
1076
1077/// struct for typed errors of method [`create_auto_collection_v1`]
1078#[derive(Debug, Clone, Serialize, Deserialize)]
1079#[serde(untagged)]
1080pub enum CreateAutoCollectionV1Error {
1081    Status4XX(models::ApiError),
1082    Status5XX(models::ApiError),
1083    UnknownValue(serde_json::Value),
1084}
1085
1086/// struct for typed errors of method [`create_bnb_transfer_v1`]
1087#[derive(Debug, Clone, Serialize, Deserialize)]
1088#[serde(untagged)]
1089pub enum CreateBnbTransferV1Error {
1090    Status4XX(models::ApiError),
1091    Status5XX(models::ApiError),
1092    UnknownValue(serde_json::Value),
1093}
1094
1095/// struct for typed errors of method [`create_cm_conditional_order_v1`]
1096#[derive(Debug, Clone, Serialize, Deserialize)]
1097#[serde(untagged)]
1098pub enum CreateCmConditionalOrderV1Error {
1099    Status4XX(models::ApiError),
1100    Status5XX(models::ApiError),
1101    UnknownValue(serde_json::Value),
1102}
1103
1104/// struct for typed errors of method [`create_cm_leverage_v1`]
1105#[derive(Debug, Clone, Serialize, Deserialize)]
1106#[serde(untagged)]
1107pub enum CreateCmLeverageV1Error {
1108    Status4XX(models::ApiError),
1109    Status5XX(models::ApiError),
1110    UnknownValue(serde_json::Value),
1111}
1112
1113/// struct for typed errors of method [`create_cm_order_v1`]
1114#[derive(Debug, Clone, Serialize, Deserialize)]
1115#[serde(untagged)]
1116pub enum CreateCmOrderV1Error {
1117    Status4XX(models::ApiError),
1118    Status5XX(models::ApiError),
1119    UnknownValue(serde_json::Value),
1120}
1121
1122/// struct for typed errors of method [`create_cm_position_side_dual_v1`]
1123#[derive(Debug, Clone, Serialize, Deserialize)]
1124#[serde(untagged)]
1125pub enum CreateCmPositionSideDualV1Error {
1126    Status4XX(models::ApiError),
1127    Status5XX(models::ApiError),
1128    UnknownValue(serde_json::Value),
1129}
1130
1131/// struct for typed errors of method [`create_listen_key_v1`]
1132#[derive(Debug, Clone, Serialize, Deserialize)]
1133#[serde(untagged)]
1134pub enum CreateListenKeyV1Error {
1135    Status4XX(models::ApiError),
1136    Status5XX(models::ApiError),
1137    UnknownValue(serde_json::Value),
1138}
1139
1140/// struct for typed errors of method [`create_margin_loan_v1`]
1141#[derive(Debug, Clone, Serialize, Deserialize)]
1142#[serde(untagged)]
1143pub enum CreateMarginLoanV1Error {
1144    Status4XX(models::ApiError),
1145    Status5XX(models::ApiError),
1146    UnknownValue(serde_json::Value),
1147}
1148
1149/// struct for typed errors of method [`create_margin_order_oco_v1`]
1150#[derive(Debug, Clone, Serialize, Deserialize)]
1151#[serde(untagged)]
1152pub enum CreateMarginOrderOcoV1Error {
1153    Status4XX(models::ApiError),
1154    Status5XX(models::ApiError),
1155    UnknownValue(serde_json::Value),
1156}
1157
1158/// struct for typed errors of method [`create_margin_order_v1`]
1159#[derive(Debug, Clone, Serialize, Deserialize)]
1160#[serde(untagged)]
1161pub enum CreateMarginOrderV1Error {
1162    Status4XX(models::ApiError),
1163    Status5XX(models::ApiError),
1164    UnknownValue(serde_json::Value),
1165}
1166
1167/// struct for typed errors of method [`create_margin_repay_debt_v1`]
1168#[derive(Debug, Clone, Serialize, Deserialize)]
1169#[serde(untagged)]
1170pub enum CreateMarginRepayDebtV1Error {
1171    Status4XX(models::ApiError),
1172    Status5XX(models::ApiError),
1173    UnknownValue(serde_json::Value),
1174}
1175
1176/// struct for typed errors of method [`create_repay_futures_negative_balance_v1`]
1177#[derive(Debug, Clone, Serialize, Deserialize)]
1178#[serde(untagged)]
1179pub enum CreateRepayFuturesNegativeBalanceV1Error {
1180    Status4XX(models::ApiError),
1181    Status5XX(models::ApiError),
1182    UnknownValue(serde_json::Value),
1183}
1184
1185/// struct for typed errors of method [`create_repay_futures_switch_v1`]
1186#[derive(Debug, Clone, Serialize, Deserialize)]
1187#[serde(untagged)]
1188pub enum CreateRepayFuturesSwitchV1Error {
1189    Status4XX(models::ApiError),
1190    Status5XX(models::ApiError),
1191    UnknownValue(serde_json::Value),
1192}
1193
1194/// struct for typed errors of method [`create_repay_loan_v1`]
1195#[derive(Debug, Clone, Serialize, Deserialize)]
1196#[serde(untagged)]
1197pub enum CreateRepayLoanV1Error {
1198    Status4XX(models::ApiError),
1199    Status5XX(models::ApiError),
1200    UnknownValue(serde_json::Value),
1201}
1202
1203/// struct for typed errors of method [`create_um_conditional_order_v1`]
1204#[derive(Debug, Clone, Serialize, Deserialize)]
1205#[serde(untagged)]
1206pub enum CreateUmConditionalOrderV1Error {
1207    Status4XX(models::ApiError),
1208    Status5XX(models::ApiError),
1209    UnknownValue(serde_json::Value),
1210}
1211
1212/// struct for typed errors of method [`create_um_fee_burn_v1`]
1213#[derive(Debug, Clone, Serialize, Deserialize)]
1214#[serde(untagged)]
1215pub enum CreateUmFeeBurnV1Error {
1216    Status4XX(models::ApiError),
1217    Status5XX(models::ApiError),
1218    UnknownValue(serde_json::Value),
1219}
1220
1221/// struct for typed errors of method [`create_um_leverage_v1`]
1222#[derive(Debug, Clone, Serialize, Deserialize)]
1223#[serde(untagged)]
1224pub enum CreateUmLeverageV1Error {
1225    Status4XX(models::ApiError),
1226    Status5XX(models::ApiError),
1227    UnknownValue(serde_json::Value),
1228}
1229
1230/// struct for typed errors of method [`create_um_order_v1`]
1231#[derive(Debug, Clone, Serialize, Deserialize)]
1232#[serde(untagged)]
1233pub enum CreateUmOrderV1Error {
1234    Status4XX(models::ApiError),
1235    Status5XX(models::ApiError),
1236    UnknownValue(serde_json::Value),
1237}
1238
1239/// struct for typed errors of method [`create_um_position_side_dual_v1`]
1240#[derive(Debug, Clone, Serialize, Deserialize)]
1241#[serde(untagged)]
1242pub enum CreateUmPositionSideDualV1Error {
1243    Status4XX(models::ApiError),
1244    Status5XX(models::ApiError),
1245    UnknownValue(serde_json::Value),
1246}
1247
1248/// struct for typed errors of method [`delete_cm_all_open_orders_v1`]
1249#[derive(Debug, Clone, Serialize, Deserialize)]
1250#[serde(untagged)]
1251pub enum DeleteCmAllOpenOrdersV1Error {
1252    Status4XX(models::ApiError),
1253    Status5XX(models::ApiError),
1254    UnknownValue(serde_json::Value),
1255}
1256
1257/// struct for typed errors of method [`delete_cm_conditional_all_open_orders_v1`]
1258#[derive(Debug, Clone, Serialize, Deserialize)]
1259#[serde(untagged)]
1260pub enum DeleteCmConditionalAllOpenOrdersV1Error {
1261    Status4XX(models::ApiError),
1262    Status5XX(models::ApiError),
1263    UnknownValue(serde_json::Value),
1264}
1265
1266/// struct for typed errors of method [`delete_cm_conditional_order_v1`]
1267#[derive(Debug, Clone, Serialize, Deserialize)]
1268#[serde(untagged)]
1269pub enum DeleteCmConditionalOrderV1Error {
1270    Status4XX(models::ApiError),
1271    Status5XX(models::ApiError),
1272    UnknownValue(serde_json::Value),
1273}
1274
1275/// struct for typed errors of method [`delete_cm_order_v1`]
1276#[derive(Debug, Clone, Serialize, Deserialize)]
1277#[serde(untagged)]
1278pub enum DeleteCmOrderV1Error {
1279    Status4XX(models::ApiError),
1280    Status5XX(models::ApiError),
1281    UnknownValue(serde_json::Value),
1282}
1283
1284/// struct for typed errors of method [`delete_listen_key_v1`]
1285#[derive(Debug, Clone, Serialize, Deserialize)]
1286#[serde(untagged)]
1287pub enum DeleteListenKeyV1Error {
1288    Status4XX(models::ApiError),
1289    Status5XX(models::ApiError),
1290    UnknownValue(serde_json::Value),
1291}
1292
1293/// struct for typed errors of method [`delete_margin_all_open_orders_v1`]
1294#[derive(Debug, Clone, Serialize, Deserialize)]
1295#[serde(untagged)]
1296pub enum DeleteMarginAllOpenOrdersV1Error {
1297    Status4XX(models::ApiError),
1298    Status5XX(models::ApiError),
1299    UnknownValue(serde_json::Value),
1300}
1301
1302/// struct for typed errors of method [`delete_margin_order_list_v1`]
1303#[derive(Debug, Clone, Serialize, Deserialize)]
1304#[serde(untagged)]
1305pub enum DeleteMarginOrderListV1Error {
1306    Status4XX(models::ApiError),
1307    Status5XX(models::ApiError),
1308    UnknownValue(serde_json::Value),
1309}
1310
1311/// struct for typed errors of method [`delete_margin_order_v1`]
1312#[derive(Debug, Clone, Serialize, Deserialize)]
1313#[serde(untagged)]
1314pub enum DeleteMarginOrderV1Error {
1315    Status4XX(models::ApiError),
1316    Status5XX(models::ApiError),
1317    UnknownValue(serde_json::Value),
1318}
1319
1320/// struct for typed errors of method [`delete_um_all_open_orders_v1`]
1321#[derive(Debug, Clone, Serialize, Deserialize)]
1322#[serde(untagged)]
1323pub enum DeleteUmAllOpenOrdersV1Error {
1324    Status4XX(models::ApiError),
1325    Status5XX(models::ApiError),
1326    UnknownValue(serde_json::Value),
1327}
1328
1329/// struct for typed errors of method [`delete_um_conditional_all_open_orders_v1`]
1330#[derive(Debug, Clone, Serialize, Deserialize)]
1331#[serde(untagged)]
1332pub enum DeleteUmConditionalAllOpenOrdersV1Error {
1333    Status4XX(models::ApiError),
1334    Status5XX(models::ApiError),
1335    UnknownValue(serde_json::Value),
1336}
1337
1338/// struct for typed errors of method [`delete_um_conditional_order_v1`]
1339#[derive(Debug, Clone, Serialize, Deserialize)]
1340#[serde(untagged)]
1341pub enum DeleteUmConditionalOrderV1Error {
1342    Status4XX(models::ApiError),
1343    Status5XX(models::ApiError),
1344    UnknownValue(serde_json::Value),
1345}
1346
1347/// struct for typed errors of method [`delete_um_order_v1`]
1348#[derive(Debug, Clone, Serialize, Deserialize)]
1349#[serde(untagged)]
1350pub enum DeleteUmOrderV1Error {
1351    Status4XX(models::ApiError),
1352    Status5XX(models::ApiError),
1353    UnknownValue(serde_json::Value),
1354}
1355
1356/// struct for typed errors of method [`get_account_v1`]
1357#[derive(Debug, Clone, Serialize, Deserialize)]
1358#[serde(untagged)]
1359pub enum GetAccountV1Error {
1360    Status4XX(models::ApiError),
1361    Status5XX(models::ApiError),
1362    UnknownValue(serde_json::Value),
1363}
1364
1365/// struct for typed errors of method [`get_balance_v1`]
1366#[derive(Debug, Clone, Serialize, Deserialize)]
1367#[serde(untagged)]
1368pub enum GetBalanceV1Error {
1369    Status4XX(models::ApiError),
1370    Status5XX(models::ApiError),
1371    UnknownValue(serde_json::Value),
1372}
1373
1374/// struct for typed errors of method [`get_cm_account_v1`]
1375#[derive(Debug, Clone, Serialize, Deserialize)]
1376#[serde(untagged)]
1377pub enum GetCmAccountV1Error {
1378    Status4XX(models::ApiError),
1379    Status5XX(models::ApiError),
1380    UnknownValue(serde_json::Value),
1381}
1382
1383/// struct for typed errors of method [`get_cm_adl_quantile_v1`]
1384#[derive(Debug, Clone, Serialize, Deserialize)]
1385#[serde(untagged)]
1386pub enum GetCmAdlQuantileV1Error {
1387    Status4XX(models::ApiError),
1388    Status5XX(models::ApiError),
1389    UnknownValue(serde_json::Value),
1390}
1391
1392/// struct for typed errors of method [`get_cm_all_orders_v1`]
1393#[derive(Debug, Clone, Serialize, Deserialize)]
1394#[serde(untagged)]
1395pub enum GetCmAllOrdersV1Error {
1396    Status4XX(models::ApiError),
1397    Status5XX(models::ApiError),
1398    UnknownValue(serde_json::Value),
1399}
1400
1401/// struct for typed errors of method [`get_cm_commission_rate_v1`]
1402#[derive(Debug, Clone, Serialize, Deserialize)]
1403#[serde(untagged)]
1404pub enum GetCmCommissionRateV1Error {
1405    Status4XX(models::ApiError),
1406    Status5XX(models::ApiError),
1407    UnknownValue(serde_json::Value),
1408}
1409
1410/// struct for typed errors of method [`get_cm_conditional_all_orders_v1`]
1411#[derive(Debug, Clone, Serialize, Deserialize)]
1412#[serde(untagged)]
1413pub enum GetCmConditionalAllOrdersV1Error {
1414    Status4XX(models::ApiError),
1415    Status5XX(models::ApiError),
1416    UnknownValue(serde_json::Value),
1417}
1418
1419/// struct for typed errors of method [`get_cm_conditional_open_order_v1`]
1420#[derive(Debug, Clone, Serialize, Deserialize)]
1421#[serde(untagged)]
1422pub enum GetCmConditionalOpenOrderV1Error {
1423    Status4XX(models::ApiError),
1424    Status5XX(models::ApiError),
1425    UnknownValue(serde_json::Value),
1426}
1427
1428/// struct for typed errors of method [`get_cm_conditional_open_orders_v1`]
1429#[derive(Debug, Clone, Serialize, Deserialize)]
1430#[serde(untagged)]
1431pub enum GetCmConditionalOpenOrdersV1Error {
1432    Status4XX(models::ApiError),
1433    Status5XX(models::ApiError),
1434    UnknownValue(serde_json::Value),
1435}
1436
1437/// struct for typed errors of method [`get_cm_conditional_order_history_v1`]
1438#[derive(Debug, Clone, Serialize, Deserialize)]
1439#[serde(untagged)]
1440pub enum GetCmConditionalOrderHistoryV1Error {
1441    Status4XX(models::ApiError),
1442    Status5XX(models::ApiError),
1443    UnknownValue(serde_json::Value),
1444}
1445
1446/// struct for typed errors of method [`get_cm_force_orders_v1`]
1447#[derive(Debug, Clone, Serialize, Deserialize)]
1448#[serde(untagged)]
1449pub enum GetCmForceOrdersV1Error {
1450    Status4XX(models::ApiError),
1451    Status5XX(models::ApiError),
1452    UnknownValue(serde_json::Value),
1453}
1454
1455/// struct for typed errors of method [`get_cm_income_v1`]
1456#[derive(Debug, Clone, Serialize, Deserialize)]
1457#[serde(untagged)]
1458pub enum GetCmIncomeV1Error {
1459    Status4XX(models::ApiError),
1460    Status5XX(models::ApiError),
1461    UnknownValue(serde_json::Value),
1462}
1463
1464/// struct for typed errors of method [`get_cm_leverage_bracket_v1`]
1465#[derive(Debug, Clone, Serialize, Deserialize)]
1466#[serde(untagged)]
1467pub enum GetCmLeverageBracketV1Error {
1468    Status4XX(models::ApiError),
1469    Status5XX(models::ApiError),
1470    UnknownValue(serde_json::Value),
1471}
1472
1473/// struct for typed errors of method [`get_cm_open_order_v1`]
1474#[derive(Debug, Clone, Serialize, Deserialize)]
1475#[serde(untagged)]
1476pub enum GetCmOpenOrderV1Error {
1477    Status4XX(models::ApiError),
1478    Status5XX(models::ApiError),
1479    UnknownValue(serde_json::Value),
1480}
1481
1482/// struct for typed errors of method [`get_cm_open_orders_v1`]
1483#[derive(Debug, Clone, Serialize, Deserialize)]
1484#[serde(untagged)]
1485pub enum GetCmOpenOrdersV1Error {
1486    Status4XX(models::ApiError),
1487    Status5XX(models::ApiError),
1488    UnknownValue(serde_json::Value),
1489}
1490
1491/// struct for typed errors of method [`get_cm_order_amendment_v1`]
1492#[derive(Debug, Clone, Serialize, Deserialize)]
1493#[serde(untagged)]
1494pub enum GetCmOrderAmendmentV1Error {
1495    Status4XX(models::ApiError),
1496    Status5XX(models::ApiError),
1497    UnknownValue(serde_json::Value),
1498}
1499
1500/// struct for typed errors of method [`get_cm_order_v1`]
1501#[derive(Debug, Clone, Serialize, Deserialize)]
1502#[serde(untagged)]
1503pub enum GetCmOrderV1Error {
1504    Status4XX(models::ApiError),
1505    Status5XX(models::ApiError),
1506    UnknownValue(serde_json::Value),
1507}
1508
1509/// struct for typed errors of method [`get_cm_position_risk_v1`]
1510#[derive(Debug, Clone, Serialize, Deserialize)]
1511#[serde(untagged)]
1512pub enum GetCmPositionRiskV1Error {
1513    Status4XX(models::ApiError),
1514    Status5XX(models::ApiError),
1515    UnknownValue(serde_json::Value),
1516}
1517
1518/// struct for typed errors of method [`get_cm_position_side_dual_v1`]
1519#[derive(Debug, Clone, Serialize, Deserialize)]
1520#[serde(untagged)]
1521pub enum GetCmPositionSideDualV1Error {
1522    Status4XX(models::ApiError),
1523    Status5XX(models::ApiError),
1524    UnknownValue(serde_json::Value),
1525}
1526
1527/// struct for typed errors of method [`get_cm_user_trades_v1`]
1528#[derive(Debug, Clone, Serialize, Deserialize)]
1529#[serde(untagged)]
1530pub enum GetCmUserTradesV1Error {
1531    Status4XX(models::ApiError),
1532    Status5XX(models::ApiError),
1533    UnknownValue(serde_json::Value),
1534}
1535
1536/// struct for typed errors of method [`get_margin_all_order_list_v1`]
1537#[derive(Debug, Clone, Serialize, Deserialize)]
1538#[serde(untagged)]
1539pub enum GetMarginAllOrderListV1Error {
1540    Status4XX(models::ApiError),
1541    Status5XX(models::ApiError),
1542    UnknownValue(serde_json::Value),
1543}
1544
1545/// struct for typed errors of method [`get_margin_all_orders_v1`]
1546#[derive(Debug, Clone, Serialize, Deserialize)]
1547#[serde(untagged)]
1548pub enum GetMarginAllOrdersV1Error {
1549    Status4XX(models::ApiError),
1550    Status5XX(models::ApiError),
1551    UnknownValue(serde_json::Value),
1552}
1553
1554/// struct for typed errors of method [`get_margin_force_orders_v1`]
1555#[derive(Debug, Clone, Serialize, Deserialize)]
1556#[serde(untagged)]
1557pub enum GetMarginForceOrdersV1Error {
1558    Status4XX(models::ApiError),
1559    Status5XX(models::ApiError),
1560    UnknownValue(serde_json::Value),
1561}
1562
1563/// struct for typed errors of method [`get_margin_margin_interest_history_v1`]
1564#[derive(Debug, Clone, Serialize, Deserialize)]
1565#[serde(untagged)]
1566pub enum GetMarginMarginInterestHistoryV1Error {
1567    Status4XX(models::ApiError),
1568    Status5XX(models::ApiError),
1569    UnknownValue(serde_json::Value),
1570}
1571
1572/// struct for typed errors of method [`get_margin_margin_loan_v1`]
1573#[derive(Debug, Clone, Serialize, Deserialize)]
1574#[serde(untagged)]
1575pub enum GetMarginMarginLoanV1Error {
1576    Status4XX(models::ApiError),
1577    Status5XX(models::ApiError),
1578    UnknownValue(serde_json::Value),
1579}
1580
1581/// struct for typed errors of method [`get_margin_max_borrowable_v1`]
1582#[derive(Debug, Clone, Serialize, Deserialize)]
1583#[serde(untagged)]
1584pub enum GetMarginMaxBorrowableV1Error {
1585    Status4XX(models::ApiError),
1586    Status5XX(models::ApiError),
1587    UnknownValue(serde_json::Value),
1588}
1589
1590/// struct for typed errors of method [`get_margin_max_withdraw_v1`]
1591#[derive(Debug, Clone, Serialize, Deserialize)]
1592#[serde(untagged)]
1593pub enum GetMarginMaxWithdrawV1Error {
1594    Status4XX(models::ApiError),
1595    Status5XX(models::ApiError),
1596    UnknownValue(serde_json::Value),
1597}
1598
1599/// struct for typed errors of method [`get_margin_my_trades_v1`]
1600#[derive(Debug, Clone, Serialize, Deserialize)]
1601#[serde(untagged)]
1602pub enum GetMarginMyTradesV1Error {
1603    Status4XX(models::ApiError),
1604    Status5XX(models::ApiError),
1605    UnknownValue(serde_json::Value),
1606}
1607
1608/// struct for typed errors of method [`get_margin_open_order_list_v1`]
1609#[derive(Debug, Clone, Serialize, Deserialize)]
1610#[serde(untagged)]
1611pub enum GetMarginOpenOrderListV1Error {
1612    Status4XX(models::ApiError),
1613    Status5XX(models::ApiError),
1614    UnknownValue(serde_json::Value),
1615}
1616
1617/// struct for typed errors of method [`get_margin_open_orders_v1`]
1618#[derive(Debug, Clone, Serialize, Deserialize)]
1619#[serde(untagged)]
1620pub enum GetMarginOpenOrdersV1Error {
1621    Status4XX(models::ApiError),
1622    Status5XX(models::ApiError),
1623    UnknownValue(serde_json::Value),
1624}
1625
1626/// struct for typed errors of method [`get_margin_order_list_v1`]
1627#[derive(Debug, Clone, Serialize, Deserialize)]
1628#[serde(untagged)]
1629pub enum GetMarginOrderListV1Error {
1630    Status4XX(models::ApiError),
1631    Status5XX(models::ApiError),
1632    UnknownValue(serde_json::Value),
1633}
1634
1635/// struct for typed errors of method [`get_margin_order_v1`]
1636#[derive(Debug, Clone, Serialize, Deserialize)]
1637#[serde(untagged)]
1638pub enum GetMarginOrderV1Error {
1639    Status4XX(models::ApiError),
1640    Status5XX(models::ApiError),
1641    UnknownValue(serde_json::Value),
1642}
1643
1644/// struct for typed errors of method [`get_margin_repay_loan_v1`]
1645#[derive(Debug, Clone, Serialize, Deserialize)]
1646#[serde(untagged)]
1647pub enum GetMarginRepayLoanV1Error {
1648    Status4XX(models::ApiError),
1649    Status5XX(models::ApiError),
1650    UnknownValue(serde_json::Value),
1651}
1652
1653/// struct for typed errors of method [`get_ping_v1`]
1654#[derive(Debug, Clone, Serialize, Deserialize)]
1655#[serde(untagged)]
1656pub enum GetPingV1Error {
1657    Status4XX(models::ApiError),
1658    Status5XX(models::ApiError),
1659    UnknownValue(serde_json::Value),
1660}
1661
1662/// struct for typed errors of method [`get_portfolio_interest_history_v1`]
1663#[derive(Debug, Clone, Serialize, Deserialize)]
1664#[serde(untagged)]
1665pub enum GetPortfolioInterestHistoryV1Error {
1666    Status4XX(models::ApiError),
1667    Status5XX(models::ApiError),
1668    UnknownValue(serde_json::Value),
1669}
1670
1671/// struct for typed errors of method [`get_portfolio_negative_balance_exchange_record_v1`]
1672#[derive(Debug, Clone, Serialize, Deserialize)]
1673#[serde(untagged)]
1674pub enum GetPortfolioNegativeBalanceExchangeRecordV1Error {
1675    Status4XX(models::ApiError),
1676    Status5XX(models::ApiError),
1677    UnknownValue(serde_json::Value),
1678}
1679
1680/// struct for typed errors of method [`get_rate_limit_order_v1`]
1681#[derive(Debug, Clone, Serialize, Deserialize)]
1682#[serde(untagged)]
1683pub enum GetRateLimitOrderV1Error {
1684    Status4XX(models::ApiError),
1685    Status5XX(models::ApiError),
1686    UnknownValue(serde_json::Value),
1687}
1688
1689/// struct for typed errors of method [`get_repay_futures_switch_v1`]
1690#[derive(Debug, Clone, Serialize, Deserialize)]
1691#[serde(untagged)]
1692pub enum GetRepayFuturesSwitchV1Error {
1693    Status4XX(models::ApiError),
1694    Status5XX(models::ApiError),
1695    UnknownValue(serde_json::Value),
1696}
1697
1698/// struct for typed errors of method [`get_um_account_config_v1`]
1699#[derive(Debug, Clone, Serialize, Deserialize)]
1700#[serde(untagged)]
1701pub enum GetUmAccountConfigV1Error {
1702    Status4XX(models::ApiError),
1703    Status5XX(models::ApiError),
1704    UnknownValue(serde_json::Value),
1705}
1706
1707/// struct for typed errors of method [`get_um_account_v1`]
1708#[derive(Debug, Clone, Serialize, Deserialize)]
1709#[serde(untagged)]
1710pub enum GetUmAccountV1Error {
1711    Status4XX(models::ApiError),
1712    Status5XX(models::ApiError),
1713    UnknownValue(serde_json::Value),
1714}
1715
1716/// struct for typed errors of method [`get_um_account_v2`]
1717#[derive(Debug, Clone, Serialize, Deserialize)]
1718#[serde(untagged)]
1719pub enum GetUmAccountV2Error {
1720    Status4XX(models::ApiError),
1721    Status5XX(models::ApiError),
1722    UnknownValue(serde_json::Value),
1723}
1724
1725/// struct for typed errors of method [`get_um_adl_quantile_v1`]
1726#[derive(Debug, Clone, Serialize, Deserialize)]
1727#[serde(untagged)]
1728pub enum GetUmAdlQuantileV1Error {
1729    Status4XX(models::ApiError),
1730    Status5XX(models::ApiError),
1731    UnknownValue(serde_json::Value),
1732}
1733
1734/// struct for typed errors of method [`get_um_all_orders_v1`]
1735#[derive(Debug, Clone, Serialize, Deserialize)]
1736#[serde(untagged)]
1737pub enum GetUmAllOrdersV1Error {
1738    Status4XX(models::ApiError),
1739    Status5XX(models::ApiError),
1740    UnknownValue(serde_json::Value),
1741}
1742
1743/// struct for typed errors of method [`get_um_api_trading_status_v1`]
1744#[derive(Debug, Clone, Serialize, Deserialize)]
1745#[serde(untagged)]
1746pub enum GetUmApiTradingStatusV1Error {
1747    Status4XX(models::ApiError),
1748    Status5XX(models::ApiError),
1749    UnknownValue(serde_json::Value),
1750}
1751
1752/// struct for typed errors of method [`get_um_commission_rate_v1`]
1753#[derive(Debug, Clone, Serialize, Deserialize)]
1754#[serde(untagged)]
1755pub enum GetUmCommissionRateV1Error {
1756    Status4XX(models::ApiError),
1757    Status5XX(models::ApiError),
1758    UnknownValue(serde_json::Value),
1759}
1760
1761/// struct for typed errors of method [`get_um_conditional_all_orders_v1`]
1762#[derive(Debug, Clone, Serialize, Deserialize)]
1763#[serde(untagged)]
1764pub enum GetUmConditionalAllOrdersV1Error {
1765    Status4XX(models::ApiError),
1766    Status5XX(models::ApiError),
1767    UnknownValue(serde_json::Value),
1768}
1769
1770/// struct for typed errors of method [`get_um_conditional_open_order_v1`]
1771#[derive(Debug, Clone, Serialize, Deserialize)]
1772#[serde(untagged)]
1773pub enum GetUmConditionalOpenOrderV1Error {
1774    Status4XX(models::ApiError),
1775    Status5XX(models::ApiError),
1776    UnknownValue(serde_json::Value),
1777}
1778
1779/// struct for typed errors of method [`get_um_conditional_open_orders_v1`]
1780#[derive(Debug, Clone, Serialize, Deserialize)]
1781#[serde(untagged)]
1782pub enum GetUmConditionalOpenOrdersV1Error {
1783    Status4XX(models::ApiError),
1784    Status5XX(models::ApiError),
1785    UnknownValue(serde_json::Value),
1786}
1787
1788/// struct for typed errors of method [`get_um_conditional_order_history_v1`]
1789#[derive(Debug, Clone, Serialize, Deserialize)]
1790#[serde(untagged)]
1791pub enum GetUmConditionalOrderHistoryV1Error {
1792    Status4XX(models::ApiError),
1793    Status5XX(models::ApiError),
1794    UnknownValue(serde_json::Value),
1795}
1796
1797/// struct for typed errors of method [`get_um_fee_burn_v1`]
1798#[derive(Debug, Clone, Serialize, Deserialize)]
1799#[serde(untagged)]
1800pub enum GetUmFeeBurnV1Error {
1801    Status4XX(models::ApiError),
1802    Status5XX(models::ApiError),
1803    UnknownValue(serde_json::Value),
1804}
1805
1806/// struct for typed errors of method [`get_um_force_orders_v1`]
1807#[derive(Debug, Clone, Serialize, Deserialize)]
1808#[serde(untagged)]
1809pub enum GetUmForceOrdersV1Error {
1810    Status4XX(models::ApiError),
1811    Status5XX(models::ApiError),
1812    UnknownValue(serde_json::Value),
1813}
1814
1815/// struct for typed errors of method [`get_um_income_asyn_id_v1`]
1816#[derive(Debug, Clone, Serialize, Deserialize)]
1817#[serde(untagged)]
1818pub enum GetUmIncomeAsynIdV1Error {
1819    Status4XX(models::ApiError),
1820    Status5XX(models::ApiError),
1821    UnknownValue(serde_json::Value),
1822}
1823
1824/// struct for typed errors of method [`get_um_income_asyn_v1`]
1825#[derive(Debug, Clone, Serialize, Deserialize)]
1826#[serde(untagged)]
1827pub enum GetUmIncomeAsynV1Error {
1828    Status4XX(models::ApiError),
1829    Status5XX(models::ApiError),
1830    UnknownValue(serde_json::Value),
1831}
1832
1833/// struct for typed errors of method [`get_um_income_v1`]
1834#[derive(Debug, Clone, Serialize, Deserialize)]
1835#[serde(untagged)]
1836pub enum GetUmIncomeV1Error {
1837    Status4XX(models::ApiError),
1838    Status5XX(models::ApiError),
1839    UnknownValue(serde_json::Value),
1840}
1841
1842/// struct for typed errors of method [`get_um_leverage_bracket_v1`]
1843#[derive(Debug, Clone, Serialize, Deserialize)]
1844#[serde(untagged)]
1845pub enum GetUmLeverageBracketV1Error {
1846    Status4XX(models::ApiError),
1847    Status5XX(models::ApiError),
1848    UnknownValue(serde_json::Value),
1849}
1850
1851/// struct for typed errors of method [`get_um_open_order_v1`]
1852#[derive(Debug, Clone, Serialize, Deserialize)]
1853#[serde(untagged)]
1854pub enum GetUmOpenOrderV1Error {
1855    Status4XX(models::ApiError),
1856    Status5XX(models::ApiError),
1857    UnknownValue(serde_json::Value),
1858}
1859
1860/// struct for typed errors of method [`get_um_open_orders_v1`]
1861#[derive(Debug, Clone, Serialize, Deserialize)]
1862#[serde(untagged)]
1863pub enum GetUmOpenOrdersV1Error {
1864    Status4XX(models::ApiError),
1865    Status5XX(models::ApiError),
1866    UnknownValue(serde_json::Value),
1867}
1868
1869/// struct for typed errors of method [`get_um_order_amendment_v1`]
1870#[derive(Debug, Clone, Serialize, Deserialize)]
1871#[serde(untagged)]
1872pub enum GetUmOrderAmendmentV1Error {
1873    Status4XX(models::ApiError),
1874    Status5XX(models::ApiError),
1875    UnknownValue(serde_json::Value),
1876}
1877
1878/// struct for typed errors of method [`get_um_order_asyn_id_v1`]
1879#[derive(Debug, Clone, Serialize, Deserialize)]
1880#[serde(untagged)]
1881pub enum GetUmOrderAsynIdV1Error {
1882    Status4XX(models::ApiError),
1883    Status5XX(models::ApiError),
1884    UnknownValue(serde_json::Value),
1885}
1886
1887/// struct for typed errors of method [`get_um_order_asyn_v1`]
1888#[derive(Debug, Clone, Serialize, Deserialize)]
1889#[serde(untagged)]
1890pub enum GetUmOrderAsynV1Error {
1891    Status4XX(models::ApiError),
1892    Status5XX(models::ApiError),
1893    UnknownValue(serde_json::Value),
1894}
1895
1896/// struct for typed errors of method [`get_um_order_v1`]
1897#[derive(Debug, Clone, Serialize, Deserialize)]
1898#[serde(untagged)]
1899pub enum GetUmOrderV1Error {
1900    Status4XX(models::ApiError),
1901    Status5XX(models::ApiError),
1902    UnknownValue(serde_json::Value),
1903}
1904
1905/// struct for typed errors of method [`get_um_position_risk_v1`]
1906#[derive(Debug, Clone, Serialize, Deserialize)]
1907#[serde(untagged)]
1908pub enum GetUmPositionRiskV1Error {
1909    Status4XX(models::ApiError),
1910    Status5XX(models::ApiError),
1911    UnknownValue(serde_json::Value),
1912}
1913
1914/// struct for typed errors of method [`get_um_position_side_dual_v1`]
1915#[derive(Debug, Clone, Serialize, Deserialize)]
1916#[serde(untagged)]
1917pub enum GetUmPositionSideDualV1Error {
1918    Status4XX(models::ApiError),
1919    Status5XX(models::ApiError),
1920    UnknownValue(serde_json::Value),
1921}
1922
1923/// struct for typed errors of method [`get_um_symbol_config_v1`]
1924#[derive(Debug, Clone, Serialize, Deserialize)]
1925#[serde(untagged)]
1926pub enum GetUmSymbolConfigV1Error {
1927    Status4XX(models::ApiError),
1928    Status5XX(models::ApiError),
1929    UnknownValue(serde_json::Value),
1930}
1931
1932/// struct for typed errors of method [`get_um_trade_asyn_id_v1`]
1933#[derive(Debug, Clone, Serialize, Deserialize)]
1934#[serde(untagged)]
1935pub enum GetUmTradeAsynIdV1Error {
1936    Status4XX(models::ApiError),
1937    Status5XX(models::ApiError),
1938    UnknownValue(serde_json::Value),
1939}
1940
1941/// struct for typed errors of method [`get_um_trade_asyn_v1`]
1942#[derive(Debug, Clone, Serialize, Deserialize)]
1943#[serde(untagged)]
1944pub enum GetUmTradeAsynV1Error {
1945    Status4XX(models::ApiError),
1946    Status5XX(models::ApiError),
1947    UnknownValue(serde_json::Value),
1948}
1949
1950/// struct for typed errors of method [`get_um_user_trades_v1`]
1951#[derive(Debug, Clone, Serialize, Deserialize)]
1952#[serde(untagged)]
1953pub enum GetUmUserTradesV1Error {
1954    Status4XX(models::ApiError),
1955    Status5XX(models::ApiError),
1956    UnknownValue(serde_json::Value),
1957}
1958
1959/// struct for typed errors of method [`update_cm_order_v1`]
1960#[derive(Debug, Clone, Serialize, Deserialize)]
1961#[serde(untagged)]
1962pub enum UpdateCmOrderV1Error {
1963    Status4XX(models::ApiError),
1964    Status5XX(models::ApiError),
1965    UnknownValue(serde_json::Value),
1966}
1967
1968/// struct for typed errors of method [`update_listen_key_v1`]
1969#[derive(Debug, Clone, Serialize, Deserialize)]
1970#[serde(untagged)]
1971pub enum UpdateListenKeyV1Error {
1972    Status4XX(models::ApiError),
1973    Status5XX(models::ApiError),
1974    UnknownValue(serde_json::Value),
1975}
1976
1977/// struct for typed errors of method [`update_um_order_v1`]
1978#[derive(Debug, Clone, Serialize, Deserialize)]
1979#[serde(untagged)]
1980pub enum UpdateUmOrderV1Error {
1981    Status4XX(models::ApiError),
1982    Status5XX(models::ApiError),
1983    UnknownValue(serde_json::Value),
1984}
1985
1986
1987/// Transfers specific asset from Futures Account to Margin account
1988pub async fn create_asset_collection_v1(configuration: &configuration::Configuration, params: CreateAssetCollectionV1Params) -> Result<models::CreateAssetCollectionV1Resp, Error<CreateAssetCollectionV1Error>> {
1989
1990    let uri_str = format!("{}/papi/v1/asset-collection", configuration.base_path);
1991    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1992
1993    // Create a mutable vector for query parameters
1994    let mut query_params: Vec<(String, String)> = Vec::new();
1995
1996
1997    // Create header parameters collection
1998    let mut header_params = std::collections::HashMap::new();
1999
2000    // Handle Binance Auth first if configured
2001    if let Some(ref binance_auth) = configuration.binance_auth {
2002        // Add API key to headers
2003        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2004        
2005        // Generate request body for signing (if any)
2006        let body_string: Option<Vec<u8>> = None;
2007        
2008        // Sign the request
2009        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2010            Ok(sig) => sig,
2011            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2012        };
2013        
2014        // Add signature to query params
2015        query_params.push(("signature".to_string(), signature));
2016    }
2017
2018    // Apply all query parameters
2019    if !query_params.is_empty() {
2020        req_builder = req_builder.query(&query_params);
2021    }
2022
2023
2024    // Add user agent if configured
2025    if let Some(ref user_agent) = configuration.user_agent {
2026        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2027    }
2028
2029    // Apply all header parameters
2030    for (header_name, header_value) in header_params {
2031        req_builder = req_builder.header(&header_name, &header_value);
2032    }
2033
2034    let mut multipart_form_params = std::collections::HashMap::new();
2035    multipart_form_params.insert("asset", params.asset.to_string());
2036    if let Some(param_value) = params.recv_window {
2037        multipart_form_params.insert("recvWindow", param_value.to_string());
2038    }
2039    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2040    req_builder = req_builder.form(&multipart_form_params);
2041
2042    let req = req_builder.build()?;
2043    let resp = configuration.client.execute(req).await?;
2044
2045    let status = resp.status();
2046    let content_type = resp
2047        .headers()
2048        .get("content-type")
2049        .and_then(|v| v.to_str().ok())
2050        .unwrap_or("application/octet-stream");
2051    let content_type = super::ContentType::from(content_type);
2052
2053    if !status.is_client_error() && !status.is_server_error() {
2054        let content = resp.text().await?;
2055        match content_type {
2056            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2057            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAssetCollectionV1Resp`"))),
2058            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::CreateAssetCollectionV1Resp`")))),
2059        }
2060    } else {
2061        let content = resp.text().await?;
2062        let entity: Option<CreateAssetCollectionV1Error> = serde_json::from_str(&content).ok();
2063        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2064    }
2065}
2066
2067/// Fund collection for Portfolio Margin
2068pub async fn create_auto_collection_v1(configuration: &configuration::Configuration, params: CreateAutoCollectionV1Params) -> Result<models::CreateAutoCollectionV1Resp, Error<CreateAutoCollectionV1Error>> {
2069
2070    let uri_str = format!("{}/papi/v1/auto-collection", configuration.base_path);
2071    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2072
2073    // Create a mutable vector for query parameters
2074    let mut query_params: Vec<(String, String)> = Vec::new();
2075
2076
2077    // Create header parameters collection
2078    let mut header_params = std::collections::HashMap::new();
2079
2080    // Handle Binance Auth first if configured
2081    if let Some(ref binance_auth) = configuration.binance_auth {
2082        // Add API key to headers
2083        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2084        
2085        // Generate request body for signing (if any)
2086        let body_string: Option<Vec<u8>> = None;
2087        
2088        // Sign the request
2089        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2090            Ok(sig) => sig,
2091            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2092        };
2093        
2094        // Add signature to query params
2095        query_params.push(("signature".to_string(), signature));
2096    }
2097
2098    // Apply all query parameters
2099    if !query_params.is_empty() {
2100        req_builder = req_builder.query(&query_params);
2101    }
2102
2103
2104    // Add user agent if configured
2105    if let Some(ref user_agent) = configuration.user_agent {
2106        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2107    }
2108
2109    // Apply all header parameters
2110    for (header_name, header_value) in header_params {
2111        req_builder = req_builder.header(&header_name, &header_value);
2112    }
2113
2114    let mut multipart_form_params = std::collections::HashMap::new();
2115    if let Some(param_value) = params.recv_window {
2116        multipart_form_params.insert("recvWindow", param_value.to_string());
2117    }
2118    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2119    req_builder = req_builder.form(&multipart_form_params);
2120
2121    let req = req_builder.build()?;
2122    let resp = configuration.client.execute(req).await?;
2123
2124    let status = resp.status();
2125    let content_type = resp
2126        .headers()
2127        .get("content-type")
2128        .and_then(|v| v.to_str().ok())
2129        .unwrap_or("application/octet-stream");
2130    let content_type = super::ContentType::from(content_type);
2131
2132    if !status.is_client_error() && !status.is_server_error() {
2133        let content = resp.text().await?;
2134        match content_type {
2135            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2136            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAutoCollectionV1Resp`"))),
2137            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::CreateAutoCollectionV1Resp`")))),
2138        }
2139    } else {
2140        let content = resp.text().await?;
2141        let entity: Option<CreateAutoCollectionV1Error> = serde_json::from_str(&content).ok();
2142        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2143    }
2144}
2145
2146/// Transfer BNB in and out of UM
2147pub async fn create_bnb_transfer_v1(configuration: &configuration::Configuration, params: CreateBnbTransferV1Params) -> Result<models::CreateBnbTransferV1Resp, Error<CreateBnbTransferV1Error>> {
2148
2149    let uri_str = format!("{}/papi/v1/bnb-transfer", configuration.base_path);
2150    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2151
2152    // Create a mutable vector for query parameters
2153    let mut query_params: Vec<(String, String)> = Vec::new();
2154
2155
2156    // Create header parameters collection
2157    let mut header_params = std::collections::HashMap::new();
2158
2159    // Handle Binance Auth first if configured
2160    if let Some(ref binance_auth) = configuration.binance_auth {
2161        // Add API key to headers
2162        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2163        
2164        // Generate request body for signing (if any)
2165        let body_string: Option<Vec<u8>> = None;
2166        
2167        // Sign the request
2168        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2169            Ok(sig) => sig,
2170            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2171        };
2172        
2173        // Add signature to query params
2174        query_params.push(("signature".to_string(), signature));
2175    }
2176
2177    // Apply all query parameters
2178    if !query_params.is_empty() {
2179        req_builder = req_builder.query(&query_params);
2180    }
2181
2182
2183    // Add user agent if configured
2184    if let Some(ref user_agent) = configuration.user_agent {
2185        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2186    }
2187
2188    // Apply all header parameters
2189    for (header_name, header_value) in header_params {
2190        req_builder = req_builder.header(&header_name, &header_value);
2191    }
2192
2193    let mut multipart_form_params = std::collections::HashMap::new();
2194    multipart_form_params.insert("amount", params.amount.to_string());
2195    if let Some(param_value) = params.recv_window {
2196        multipart_form_params.insert("recvWindow", param_value.to_string());
2197    }
2198    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2199    multipart_form_params.insert("transferSide", params.transfer_side.to_string());
2200    req_builder = req_builder.form(&multipart_form_params);
2201
2202    let req = req_builder.build()?;
2203    let resp = configuration.client.execute(req).await?;
2204
2205    let status = resp.status();
2206    let content_type = resp
2207        .headers()
2208        .get("content-type")
2209        .and_then(|v| v.to_str().ok())
2210        .unwrap_or("application/octet-stream");
2211    let content_type = super::ContentType::from(content_type);
2212
2213    if !status.is_client_error() && !status.is_server_error() {
2214        let content = resp.text().await?;
2215        match content_type {
2216            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2217            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateBnbTransferV1Resp`"))),
2218            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateBnbTransferV1Resp`")))),
2219        }
2220    } else {
2221        let content = resp.text().await?;
2222        let entity: Option<CreateBnbTransferV1Error> = serde_json::from_str(&content).ok();
2223        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2224    }
2225}
2226
2227/// New CM Conditional Order
2228pub async fn create_cm_conditional_order_v1(configuration: &configuration::Configuration, params: CreateCmConditionalOrderV1Params) -> Result<models::CreateCmConditionalOrderV1Resp, Error<CreateCmConditionalOrderV1Error>> {
2229
2230    let uri_str = format!("{}/papi/v1/cm/conditional/order", configuration.base_path);
2231    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2232
2233    // Create a mutable vector for query parameters
2234    let mut query_params: Vec<(String, String)> = Vec::new();
2235
2236
2237    // Create header parameters collection
2238    let mut header_params = std::collections::HashMap::new();
2239
2240    // Handle Binance Auth first if configured
2241    if let Some(ref binance_auth) = configuration.binance_auth {
2242        // Add API key to headers
2243        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2244        
2245        // Generate request body for signing (if any)
2246        let body_string: Option<Vec<u8>> = None;
2247        
2248        // Sign the request
2249        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2250            Ok(sig) => sig,
2251            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2252        };
2253        
2254        // Add signature to query params
2255        query_params.push(("signature".to_string(), signature));
2256    }
2257
2258    // Apply all query parameters
2259    if !query_params.is_empty() {
2260        req_builder = req_builder.query(&query_params);
2261    }
2262
2263
2264    // Add user agent if configured
2265    if let Some(ref user_agent) = configuration.user_agent {
2266        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2267    }
2268
2269    // Apply all header parameters
2270    for (header_name, header_value) in header_params {
2271        req_builder = req_builder.header(&header_name, &header_value);
2272    }
2273
2274    let mut multipart_form_params = std::collections::HashMap::new();
2275    if let Some(param_value) = params.activation_price {
2276        multipart_form_params.insert("activationPrice", param_value.to_string());
2277    }
2278    if let Some(param_value) = params.callback_rate {
2279        multipart_form_params.insert("callbackRate", param_value.to_string());
2280    }
2281    if let Some(param_value) = params.new_client_strategy_id {
2282        multipart_form_params.insert("newClientStrategyId", param_value.to_string());
2283    }
2284    if let Some(param_value) = params.position_side {
2285        multipart_form_params.insert("positionSide", param_value.to_string());
2286    }
2287    if let Some(param_value) = params.price {
2288        multipart_form_params.insert("price", param_value.to_string());
2289    }
2290    if let Some(param_value) = params.price_protect {
2291        multipart_form_params.insert("priceProtect", param_value.to_string());
2292    }
2293    if let Some(param_value) = params.quantity {
2294        multipart_form_params.insert("quantity", param_value.to_string());
2295    }
2296    if let Some(param_value) = params.recv_window {
2297        multipart_form_params.insert("recvWindow", param_value.to_string());
2298    }
2299    if let Some(param_value) = params.reduce_only {
2300        multipart_form_params.insert("reduceOnly", param_value.to_string());
2301    }
2302    multipart_form_params.insert("side", params.side.to_string());
2303    if let Some(param_value) = params.stop_price {
2304        multipart_form_params.insert("stopPrice", param_value.to_string());
2305    }
2306    multipart_form_params.insert("strategyType", params.strategy_type.to_string());
2307    multipart_form_params.insert("symbol", params.symbol.to_string());
2308    if let Some(param_value) = params.time_in_force {
2309        multipart_form_params.insert("timeInForce", param_value.to_string());
2310    }
2311    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2312    if let Some(param_value) = params.working_type {
2313        multipart_form_params.insert("workingType", param_value.to_string());
2314    }
2315    req_builder = req_builder.form(&multipart_form_params);
2316
2317    let req = req_builder.build()?;
2318    let resp = configuration.client.execute(req).await?;
2319
2320    let status = resp.status();
2321    let content_type = resp
2322        .headers()
2323        .get("content-type")
2324        .and_then(|v| v.to_str().ok())
2325        .unwrap_or("application/octet-stream");
2326    let content_type = super::ContentType::from(content_type);
2327
2328    if !status.is_client_error() && !status.is_server_error() {
2329        let content = resp.text().await?;
2330        match content_type {
2331            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2332            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCmConditionalOrderV1Resp`"))),
2333            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::CreateCmConditionalOrderV1Resp`")))),
2334        }
2335    } else {
2336        let content = resp.text().await?;
2337        let entity: Option<CreateCmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
2338        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2339    }
2340}
2341
2342/// Change user's initial leverage of specific symbol in CM.
2343pub async fn create_cm_leverage_v1(configuration: &configuration::Configuration, params: CreateCmLeverageV1Params) -> Result<models::CreateCmLeverageV1Resp, Error<CreateCmLeverageV1Error>> {
2344
2345    let uri_str = format!("{}/papi/v1/cm/leverage", configuration.base_path);
2346    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2347
2348    // Create a mutable vector for query parameters
2349    let mut query_params: Vec<(String, String)> = Vec::new();
2350
2351
2352    // Create header parameters collection
2353    let mut header_params = std::collections::HashMap::new();
2354
2355    // Handle Binance Auth first if configured
2356    if let Some(ref binance_auth) = configuration.binance_auth {
2357        // Add API key to headers
2358        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2359        
2360        // Generate request body for signing (if any)
2361        let body_string: Option<Vec<u8>> = None;
2362        
2363        // Sign the request
2364        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2365            Ok(sig) => sig,
2366            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2367        };
2368        
2369        // Add signature to query params
2370        query_params.push(("signature".to_string(), signature));
2371    }
2372
2373    // Apply all query parameters
2374    if !query_params.is_empty() {
2375        req_builder = req_builder.query(&query_params);
2376    }
2377
2378
2379    // Add user agent if configured
2380    if let Some(ref user_agent) = configuration.user_agent {
2381        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2382    }
2383
2384    // Apply all header parameters
2385    for (header_name, header_value) in header_params {
2386        req_builder = req_builder.header(&header_name, &header_value);
2387    }
2388
2389    let mut multipart_form_params = std::collections::HashMap::new();
2390    multipart_form_params.insert("leverage", params.leverage.to_string());
2391    if let Some(param_value) = params.recv_window {
2392        multipart_form_params.insert("recvWindow", param_value.to_string());
2393    }
2394    multipart_form_params.insert("symbol", params.symbol.to_string());
2395    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2396    req_builder = req_builder.form(&multipart_form_params);
2397
2398    let req = req_builder.build()?;
2399    let resp = configuration.client.execute(req).await?;
2400
2401    let status = resp.status();
2402    let content_type = resp
2403        .headers()
2404        .get("content-type")
2405        .and_then(|v| v.to_str().ok())
2406        .unwrap_or("application/octet-stream");
2407    let content_type = super::ContentType::from(content_type);
2408
2409    if !status.is_client_error() && !status.is_server_error() {
2410        let content = resp.text().await?;
2411        match content_type {
2412            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2413            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCmLeverageV1Resp`"))),
2414            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::CreateCmLeverageV1Resp`")))),
2415        }
2416    } else {
2417        let content = resp.text().await?;
2418        let entity: Option<CreateCmLeverageV1Error> = serde_json::from_str(&content).ok();
2419        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2420    }
2421}
2422
2423/// Place new CM order
2424pub async fn create_cm_order_v1(configuration: &configuration::Configuration, params: CreateCmOrderV1Params) -> Result<models::CreateCmOrderV1Resp, Error<CreateCmOrderV1Error>> {
2425
2426    let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
2427    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2428
2429    // Create a mutable vector for query parameters
2430    let mut query_params: Vec<(String, String)> = Vec::new();
2431
2432
2433    // Create header parameters collection
2434    let mut header_params = std::collections::HashMap::new();
2435
2436    // Handle Binance Auth first if configured
2437    if let Some(ref binance_auth) = configuration.binance_auth {
2438        // Add API key to headers
2439        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2440        
2441        // Generate request body for signing (if any)
2442        let body_string: Option<Vec<u8>> = None;
2443        
2444        // Sign the request
2445        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2446            Ok(sig) => sig,
2447            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2448        };
2449        
2450        // Add signature to query params
2451        query_params.push(("signature".to_string(), signature));
2452    }
2453
2454    // Apply all query parameters
2455    if !query_params.is_empty() {
2456        req_builder = req_builder.query(&query_params);
2457    }
2458
2459
2460    // Add user agent if configured
2461    if let Some(ref user_agent) = configuration.user_agent {
2462        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2463    }
2464
2465    // Apply all header parameters
2466    for (header_name, header_value) in header_params {
2467        req_builder = req_builder.header(&header_name, &header_value);
2468    }
2469
2470    let mut multipart_form_params = std::collections::HashMap::new();
2471    if let Some(param_value) = params.new_client_order_id {
2472        multipart_form_params.insert("newClientOrderId", param_value.to_string());
2473    }
2474    if let Some(param_value) = params.new_order_resp_type {
2475        multipart_form_params.insert("newOrderRespType", param_value.to_string());
2476    }
2477    if let Some(param_value) = params.position_side {
2478        multipart_form_params.insert("positionSide", param_value.to_string());
2479    }
2480    if let Some(param_value) = params.price {
2481        multipart_form_params.insert("price", param_value.to_string());
2482    }
2483    if let Some(param_value) = params.price_match {
2484        multipart_form_params.insert("priceMatch", param_value.to_string());
2485    }
2486    if let Some(param_value) = params.quantity {
2487        multipart_form_params.insert("quantity", param_value.to_string());
2488    }
2489    if let Some(param_value) = params.recv_window {
2490        multipart_form_params.insert("recvWindow", param_value.to_string());
2491    }
2492    if let Some(param_value) = params.reduce_only {
2493        multipart_form_params.insert("reduceOnly", param_value.to_string());
2494    }
2495    multipart_form_params.insert("side", params.side.to_string());
2496    multipart_form_params.insert("symbol", params.symbol.to_string());
2497    if let Some(param_value) = params.time_in_force {
2498        multipart_form_params.insert("timeInForce", param_value.to_string());
2499    }
2500    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2501    multipart_form_params.insert("type", params.r#type.to_string());
2502    req_builder = req_builder.form(&multipart_form_params);
2503
2504    let req = req_builder.build()?;
2505    let resp = configuration.client.execute(req).await?;
2506
2507    let status = resp.status();
2508    let content_type = resp
2509        .headers()
2510        .get("content-type")
2511        .and_then(|v| v.to_str().ok())
2512        .unwrap_or("application/octet-stream");
2513    let content_type = super::ContentType::from(content_type);
2514
2515    if !status.is_client_error() && !status.is_server_error() {
2516        let content = resp.text().await?;
2517        match content_type {
2518            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2519            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCmOrderV1Resp`"))),
2520            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::CreateCmOrderV1Resp`")))),
2521        }
2522    } else {
2523        let content = resp.text().await?;
2524        let entity: Option<CreateCmOrderV1Error> = serde_json::from_str(&content).ok();
2525        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2526    }
2527}
2528
2529/// Change user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in CM
2530pub async fn create_cm_position_side_dual_v1(configuration: &configuration::Configuration, params: CreateCmPositionSideDualV1Params) -> Result<models::CreateCmPositionSideDualV1Resp, Error<CreateCmPositionSideDualV1Error>> {
2531
2532    let uri_str = format!("{}/papi/v1/cm/positionSide/dual", configuration.base_path);
2533    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2534
2535    // Create a mutable vector for query parameters
2536    let mut query_params: Vec<(String, String)> = Vec::new();
2537
2538
2539    // Create header parameters collection
2540    let mut header_params = std::collections::HashMap::new();
2541
2542    // Handle Binance Auth first if configured
2543    if let Some(ref binance_auth) = configuration.binance_auth {
2544        // Add API key to headers
2545        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2546        
2547        // Generate request body for signing (if any)
2548        let body_string: Option<Vec<u8>> = None;
2549        
2550        // Sign the request
2551        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2552            Ok(sig) => sig,
2553            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2554        };
2555        
2556        // Add signature to query params
2557        query_params.push(("signature".to_string(), signature));
2558    }
2559
2560    // Apply all query parameters
2561    if !query_params.is_empty() {
2562        req_builder = req_builder.query(&query_params);
2563    }
2564
2565
2566    // Add user agent if configured
2567    if let Some(ref user_agent) = configuration.user_agent {
2568        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2569    }
2570
2571    // Apply all header parameters
2572    for (header_name, header_value) in header_params {
2573        req_builder = req_builder.header(&header_name, &header_value);
2574    }
2575
2576    let mut multipart_form_params = std::collections::HashMap::new();
2577    multipart_form_params.insert("dualSidePosition", params.dual_side_position.to_string());
2578    if let Some(param_value) = params.recv_window {
2579        multipart_form_params.insert("recvWindow", param_value.to_string());
2580    }
2581    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2582    req_builder = req_builder.form(&multipart_form_params);
2583
2584    let req = req_builder.build()?;
2585    let resp = configuration.client.execute(req).await?;
2586
2587    let status = resp.status();
2588    let content_type = resp
2589        .headers()
2590        .get("content-type")
2591        .and_then(|v| v.to_str().ok())
2592        .unwrap_or("application/octet-stream");
2593    let content_type = super::ContentType::from(content_type);
2594
2595    if !status.is_client_error() && !status.is_server_error() {
2596        let content = resp.text().await?;
2597        match content_type {
2598            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2599            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCmPositionSideDualV1Resp`"))),
2600            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::CreateCmPositionSideDualV1Resp`")))),
2601        }
2602    } else {
2603        let content = resp.text().await?;
2604        let entity: Option<CreateCmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
2605        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2606    }
2607}
2608
2609/// Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active listenKey, that listenKey will be returned and its validity will be extended for 60 minutes.
2610pub async fn create_listen_key_v1(configuration: &configuration::Configuration) -> Result<models::CreateListenKeyV1Resp, Error<CreateListenKeyV1Error>> {
2611
2612    let uri_str = format!("{}/papi/v1/listenKey", configuration.base_path);
2613    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2614
2615    // Create a mutable vector for query parameters
2616    let mut query_params: Vec<(String, String)> = Vec::new();
2617
2618
2619    // Create header parameters collection
2620    let mut header_params = std::collections::HashMap::new();
2621
2622    // Handle Binance Auth first if configured
2623    if let Some(ref binance_auth) = configuration.binance_auth {
2624        // Add API key to headers
2625        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2626        
2627        // Generate request body for signing (if any)
2628        let body_string: Option<Vec<u8>> = None;
2629        
2630        // Sign the request
2631        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2632            Ok(sig) => sig,
2633            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2634        };
2635        
2636        // Add signature to query params
2637        query_params.push(("signature".to_string(), signature));
2638    }
2639
2640    // Apply all query parameters
2641    if !query_params.is_empty() {
2642        req_builder = req_builder.query(&query_params);
2643    }
2644
2645
2646    // Add user agent if configured
2647    if let Some(ref user_agent) = configuration.user_agent {
2648        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2649    }
2650
2651    // Apply all header parameters
2652    for (header_name, header_value) in header_params {
2653        req_builder = req_builder.header(&header_name, &header_value);
2654    }
2655
2656
2657    let req = req_builder.build()?;
2658    let resp = configuration.client.execute(req).await?;
2659
2660    let status = resp.status();
2661    let content_type = resp
2662        .headers()
2663        .get("content-type")
2664        .and_then(|v| v.to_str().ok())
2665        .unwrap_or("application/octet-stream");
2666    let content_type = super::ContentType::from(content_type);
2667
2668    if !status.is_client_error() && !status.is_server_error() {
2669        let content = resp.text().await?;
2670        match content_type {
2671            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2672            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateListenKeyV1Resp`"))),
2673            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateListenKeyV1Resp`")))),
2674        }
2675    } else {
2676        let content = resp.text().await?;
2677        let entity: Option<CreateListenKeyV1Error> = serde_json::from_str(&content).ok();
2678        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2679    }
2680}
2681
2682/// Apply for a margin loan.
2683pub async fn create_margin_loan_v1(configuration: &configuration::Configuration, params: CreateMarginLoanV1Params) -> Result<models::CreateMarginLoanV1Resp, Error<CreateMarginLoanV1Error>> {
2684
2685    let uri_str = format!("{}/papi/v1/marginLoan", configuration.base_path);
2686    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2687
2688    // Create a mutable vector for query parameters
2689    let mut query_params: Vec<(String, String)> = Vec::new();
2690
2691
2692    // Create header parameters collection
2693    let mut header_params = std::collections::HashMap::new();
2694
2695    // Handle Binance Auth first if configured
2696    if let Some(ref binance_auth) = configuration.binance_auth {
2697        // Add API key to headers
2698        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2699        
2700        // Generate request body for signing (if any)
2701        let body_string: Option<Vec<u8>> = None;
2702        
2703        // Sign the request
2704        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2705            Ok(sig) => sig,
2706            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2707        };
2708        
2709        // Add signature to query params
2710        query_params.push(("signature".to_string(), signature));
2711    }
2712
2713    // Apply all query parameters
2714    if !query_params.is_empty() {
2715        req_builder = req_builder.query(&query_params);
2716    }
2717
2718
2719    // Add user agent if configured
2720    if let Some(ref user_agent) = configuration.user_agent {
2721        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2722    }
2723
2724    // Apply all header parameters
2725    for (header_name, header_value) in header_params {
2726        req_builder = req_builder.header(&header_name, &header_value);
2727    }
2728
2729    let mut multipart_form_params = std::collections::HashMap::new();
2730    multipart_form_params.insert("amount", params.amount.to_string());
2731    multipart_form_params.insert("asset", params.asset.to_string());
2732    if let Some(param_value) = params.recv_window {
2733        multipart_form_params.insert("recvWindow", param_value.to_string());
2734    }
2735    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2736    req_builder = req_builder.form(&multipart_form_params);
2737
2738    let req = req_builder.build()?;
2739    let resp = configuration.client.execute(req).await?;
2740
2741    let status = resp.status();
2742    let content_type = resp
2743        .headers()
2744        .get("content-type")
2745        .and_then(|v| v.to_str().ok())
2746        .unwrap_or("application/octet-stream");
2747    let content_type = super::ContentType::from(content_type);
2748
2749    if !status.is_client_error() && !status.is_server_error() {
2750        let content = resp.text().await?;
2751        match content_type {
2752            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2753            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginLoanV1Resp`"))),
2754            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::CreateMarginLoanV1Resp`")))),
2755        }
2756    } else {
2757        let content = resp.text().await?;
2758        let entity: Option<CreateMarginLoanV1Error> = serde_json::from_str(&content).ok();
2759        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2760    }
2761}
2762
2763/// Send in a new OCO for a margin account
2764pub async fn create_margin_order_oco_v1(configuration: &configuration::Configuration, params: CreateMarginOrderOcoV1Params) -> Result<models::CreateMarginOrderOcoV1Resp, Error<CreateMarginOrderOcoV1Error>> {
2765
2766    let uri_str = format!("{}/papi/v1/margin/order/oco", configuration.base_path);
2767    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2768
2769    // Create a mutable vector for query parameters
2770    let mut query_params: Vec<(String, String)> = Vec::new();
2771
2772
2773    // Create header parameters collection
2774    let mut header_params = std::collections::HashMap::new();
2775
2776    // Handle Binance Auth first if configured
2777    if let Some(ref binance_auth) = configuration.binance_auth {
2778        // Add API key to headers
2779        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2780        
2781        // Generate request body for signing (if any)
2782        let body_string: Option<Vec<u8>> = None;
2783        
2784        // Sign the request
2785        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2786            Ok(sig) => sig,
2787            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2788        };
2789        
2790        // Add signature to query params
2791        query_params.push(("signature".to_string(), signature));
2792    }
2793
2794    // Apply all query parameters
2795    if !query_params.is_empty() {
2796        req_builder = req_builder.query(&query_params);
2797    }
2798
2799
2800    // Add user agent if configured
2801    if let Some(ref user_agent) = configuration.user_agent {
2802        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2803    }
2804
2805    // Apply all header parameters
2806    for (header_name, header_value) in header_params {
2807        req_builder = req_builder.header(&header_name, &header_value);
2808    }
2809
2810    let mut multipart_form_params = std::collections::HashMap::new();
2811    if let Some(param_value) = params.limit_client_order_id {
2812        multipart_form_params.insert("limitClientOrderId", param_value.to_string());
2813    }
2814    if let Some(param_value) = params.limit_iceberg_qty {
2815        multipart_form_params.insert("limitIcebergQty", param_value.to_string());
2816    }
2817    if let Some(param_value) = params.list_client_order_id {
2818        multipart_form_params.insert("listClientOrderId", param_value.to_string());
2819    }
2820    if let Some(param_value) = params.new_order_resp_type {
2821        multipart_form_params.insert("newOrderRespType", param_value.to_string());
2822    }
2823    multipart_form_params.insert("price", params.price.to_string());
2824    multipart_form_params.insert("quantity", params.quantity.to_string());
2825    if let Some(param_value) = params.recv_window {
2826        multipart_form_params.insert("recvWindow", param_value.to_string());
2827    }
2828    multipart_form_params.insert("side", params.side.to_string());
2829    if let Some(param_value) = params.side_effect_type {
2830        multipart_form_params.insert("sideEffectType", param_value.to_string());
2831    }
2832    if let Some(param_value) = params.stop_client_order_id {
2833        multipart_form_params.insert("stopClientOrderId", param_value.to_string());
2834    }
2835    if let Some(param_value) = params.stop_iceberg_qty {
2836        multipart_form_params.insert("stopIcebergQty", param_value.to_string());
2837    }
2838    if let Some(param_value) = params.stop_limit_price {
2839        multipart_form_params.insert("stopLimitPrice", param_value.to_string());
2840    }
2841    if let Some(param_value) = params.stop_limit_time_in_force {
2842        multipart_form_params.insert("stopLimitTimeInForce", param_value.to_string());
2843    }
2844    multipart_form_params.insert("stopPrice", params.stop_price.to_string());
2845    multipart_form_params.insert("symbol", params.symbol.to_string());
2846    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2847    req_builder = req_builder.form(&multipart_form_params);
2848
2849    let req = req_builder.build()?;
2850    let resp = configuration.client.execute(req).await?;
2851
2852    let status = resp.status();
2853    let content_type = resp
2854        .headers()
2855        .get("content-type")
2856        .and_then(|v| v.to_str().ok())
2857        .unwrap_or("application/octet-stream");
2858    let content_type = super::ContentType::from(content_type);
2859
2860    if !status.is_client_error() && !status.is_server_error() {
2861        let content = resp.text().await?;
2862        match content_type {
2863            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2864            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginOrderOcoV1Resp`"))),
2865            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateMarginOrderOcoV1Resp`")))),
2866        }
2867    } else {
2868        let content = resp.text().await?;
2869        let entity: Option<CreateMarginOrderOcoV1Error> = serde_json::from_str(&content).ok();
2870        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2871    }
2872}
2873
2874/// New Margin Order
2875pub async fn create_margin_order_v1(configuration: &configuration::Configuration, params: CreateMarginOrderV1Params) -> Result<models::CreateMarginOrderV1Resp, Error<CreateMarginOrderV1Error>> {
2876
2877    let uri_str = format!("{}/papi/v1/margin/order", configuration.base_path);
2878    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2879
2880    // Create a mutable vector for query parameters
2881    let mut query_params: Vec<(String, String)> = Vec::new();
2882
2883
2884    // Create header parameters collection
2885    let mut header_params = std::collections::HashMap::new();
2886
2887    // Handle Binance Auth first if configured
2888    if let Some(ref binance_auth) = configuration.binance_auth {
2889        // Add API key to headers
2890        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2891        
2892        // Generate request body for signing (if any)
2893        let body_string: Option<Vec<u8>> = None;
2894        
2895        // Sign the request
2896        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2897            Ok(sig) => sig,
2898            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2899        };
2900        
2901        // Add signature to query params
2902        query_params.push(("signature".to_string(), signature));
2903    }
2904
2905    // Apply all query parameters
2906    if !query_params.is_empty() {
2907        req_builder = req_builder.query(&query_params);
2908    }
2909
2910
2911    // Add user agent if configured
2912    if let Some(ref user_agent) = configuration.user_agent {
2913        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2914    }
2915
2916    // Apply all header parameters
2917    for (header_name, header_value) in header_params {
2918        req_builder = req_builder.header(&header_name, &header_value);
2919    }
2920
2921    let mut multipart_form_params = std::collections::HashMap::new();
2922    if let Some(param_value) = params.auto_repay_at_cancel {
2923        multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
2924    }
2925    if let Some(param_value) = params.iceberg_qty {
2926        multipart_form_params.insert("icebergQty", param_value.to_string());
2927    }
2928    if let Some(param_value) = params.new_client_order_id {
2929        multipart_form_params.insert("newClientOrderId", param_value.to_string());
2930    }
2931    if let Some(param_value) = params.new_order_resp_type {
2932        multipart_form_params.insert("newOrderRespType", param_value.to_string());
2933    }
2934    if let Some(param_value) = params.price {
2935        multipart_form_params.insert("price", param_value.to_string());
2936    }
2937    if let Some(param_value) = params.quantity {
2938        multipart_form_params.insert("quantity", param_value.to_string());
2939    }
2940    if let Some(param_value) = params.quote_order_qty {
2941        multipart_form_params.insert("quoteOrderQty", param_value.to_string());
2942    }
2943    if let Some(param_value) = params.recv_window {
2944        multipart_form_params.insert("recvWindow", param_value.to_string());
2945    }
2946    if let Some(param_value) = params.self_trade_prevention_mode {
2947        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
2948    }
2949    multipart_form_params.insert("side", params.side.to_string());
2950    if let Some(param_value) = params.side_effect_type {
2951        multipart_form_params.insert("sideEffectType", param_value.to_string());
2952    }
2953    if let Some(param_value) = params.stop_price {
2954        multipart_form_params.insert("stopPrice", param_value.to_string());
2955    }
2956    multipart_form_params.insert("symbol", params.symbol.to_string());
2957    if let Some(param_value) = params.time_in_force {
2958        multipart_form_params.insert("timeInForce", param_value.to_string());
2959    }
2960    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2961    multipart_form_params.insert("type", params.r#type.to_string());
2962    req_builder = req_builder.form(&multipart_form_params);
2963
2964    let req = req_builder.build()?;
2965    let resp = configuration.client.execute(req).await?;
2966
2967    let status = resp.status();
2968    let content_type = resp
2969        .headers()
2970        .get("content-type")
2971        .and_then(|v| v.to_str().ok())
2972        .unwrap_or("application/octet-stream");
2973    let content_type = super::ContentType::from(content_type);
2974
2975    if !status.is_client_error() && !status.is_server_error() {
2976        let content = resp.text().await?;
2977        match content_type {
2978            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2979            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginOrderV1Resp`"))),
2980            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::CreateMarginOrderV1Resp`")))),
2981        }
2982    } else {
2983        let content = resp.text().await?;
2984        let entity: Option<CreateMarginOrderV1Error> = serde_json::from_str(&content).ok();
2985        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2986    }
2987}
2988
2989/// Repay debt for a margin loan.
2990pub async fn create_margin_repay_debt_v1(configuration: &configuration::Configuration, params: CreateMarginRepayDebtV1Params) -> Result<models::CreateMarginRepayDebtV1Resp, Error<CreateMarginRepayDebtV1Error>> {
2991
2992    let uri_str = format!("{}/papi/v1/margin/repay-debt", configuration.base_path);
2993    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2994
2995    // Create a mutable vector for query parameters
2996    let mut query_params: Vec<(String, String)> = Vec::new();
2997
2998
2999    // Create header parameters collection
3000    let mut header_params = std::collections::HashMap::new();
3001
3002    // Handle Binance Auth first if configured
3003    if let Some(ref binance_auth) = configuration.binance_auth {
3004        // Add API key to headers
3005        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3006        
3007        // Generate request body for signing (if any)
3008        let body_string: Option<Vec<u8>> = None;
3009        
3010        // Sign the request
3011        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3012            Ok(sig) => sig,
3013            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3014        };
3015        
3016        // Add signature to query params
3017        query_params.push(("signature".to_string(), signature));
3018    }
3019
3020    // Apply all query parameters
3021    if !query_params.is_empty() {
3022        req_builder = req_builder.query(&query_params);
3023    }
3024
3025
3026    // Add user agent if configured
3027    if let Some(ref user_agent) = configuration.user_agent {
3028        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3029    }
3030
3031    // Apply all header parameters
3032    for (header_name, header_value) in header_params {
3033        req_builder = req_builder.header(&header_name, &header_value);
3034    }
3035
3036    let mut multipart_form_params = std::collections::HashMap::new();
3037    if let Some(param_value) = params.amount {
3038        multipart_form_params.insert("amount", param_value.to_string());
3039    }
3040    multipart_form_params.insert("asset", params.asset.to_string());
3041    if let Some(param_value) = params.recv_window {
3042        multipart_form_params.insert("recvWindow", param_value.to_string());
3043    }
3044    if let Some(param_value) = params.specify_repay_assets {
3045        multipart_form_params.insert("specifyRepayAssets", param_value.to_string());
3046    }
3047    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3048    req_builder = req_builder.form(&multipart_form_params);
3049
3050    let req = req_builder.build()?;
3051    let resp = configuration.client.execute(req).await?;
3052
3053    let status = resp.status();
3054    let content_type = resp
3055        .headers()
3056        .get("content-type")
3057        .and_then(|v| v.to_str().ok())
3058        .unwrap_or("application/octet-stream");
3059    let content_type = super::ContentType::from(content_type);
3060
3061    if !status.is_client_error() && !status.is_server_error() {
3062        let content = resp.text().await?;
3063        match content_type {
3064            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3065            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMarginRepayDebtV1Resp`"))),
3066            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::CreateMarginRepayDebtV1Resp`")))),
3067        }
3068    } else {
3069        let content = resp.text().await?;
3070        let entity: Option<CreateMarginRepayDebtV1Error> = serde_json::from_str(&content).ok();
3071        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3072    }
3073}
3074
3075/// Repay futures Negative Balance
3076pub async fn create_repay_futures_negative_balance_v1(configuration: &configuration::Configuration, params: CreateRepayFuturesNegativeBalanceV1Params) -> Result<models::CreateRepayFuturesNegativeBalanceV1Resp, Error<CreateRepayFuturesNegativeBalanceV1Error>> {
3077
3078    let uri_str = format!("{}/papi/v1/repay-futures-negative-balance", configuration.base_path);
3079    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3080
3081    // Create a mutable vector for query parameters
3082    let mut query_params: Vec<(String, String)> = Vec::new();
3083
3084
3085    // Create header parameters collection
3086    let mut header_params = std::collections::HashMap::new();
3087
3088    // Handle Binance Auth first if configured
3089    if let Some(ref binance_auth) = configuration.binance_auth {
3090        // Add API key to headers
3091        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3092        
3093        // Generate request body for signing (if any)
3094        let body_string: Option<Vec<u8>> = None;
3095        
3096        // Sign the request
3097        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3098            Ok(sig) => sig,
3099            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3100        };
3101        
3102        // Add signature to query params
3103        query_params.push(("signature".to_string(), signature));
3104    }
3105
3106    // Apply all query parameters
3107    if !query_params.is_empty() {
3108        req_builder = req_builder.query(&query_params);
3109    }
3110
3111
3112    // Add user agent if configured
3113    if let Some(ref user_agent) = configuration.user_agent {
3114        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3115    }
3116
3117    // Apply all header parameters
3118    for (header_name, header_value) in header_params {
3119        req_builder = req_builder.header(&header_name, &header_value);
3120    }
3121
3122    let mut multipart_form_params = std::collections::HashMap::new();
3123    if let Some(param_value) = params.recv_window {
3124        multipart_form_params.insert("recvWindow", param_value.to_string());
3125    }
3126    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3127    req_builder = req_builder.form(&multipart_form_params);
3128
3129    let req = req_builder.build()?;
3130    let resp = configuration.client.execute(req).await?;
3131
3132    let status = resp.status();
3133    let content_type = resp
3134        .headers()
3135        .get("content-type")
3136        .and_then(|v| v.to_str().ok())
3137        .unwrap_or("application/octet-stream");
3138    let content_type = super::ContentType::from(content_type);
3139
3140    if !status.is_client_error() && !status.is_server_error() {
3141        let content = resp.text().await?;
3142        match content_type {
3143            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3144            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateRepayFuturesNegativeBalanceV1Resp`"))),
3145            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::CreateRepayFuturesNegativeBalanceV1Resp`")))),
3146        }
3147    } else {
3148        let content = resp.text().await?;
3149        let entity: Option<CreateRepayFuturesNegativeBalanceV1Error> = serde_json::from_str(&content).ok();
3150        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3151    }
3152}
3153
3154/// Change Auto-repay-futures Status
3155pub async fn create_repay_futures_switch_v1(configuration: &configuration::Configuration, params: CreateRepayFuturesSwitchV1Params) -> Result<models::CreateRepayFuturesSwitchV1Resp, Error<CreateRepayFuturesSwitchV1Error>> {
3156
3157    let uri_str = format!("{}/papi/v1/repay-futures-switch", configuration.base_path);
3158    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3159
3160    // Create a mutable vector for query parameters
3161    let mut query_params: Vec<(String, String)> = Vec::new();
3162
3163
3164    // Create header parameters collection
3165    let mut header_params = std::collections::HashMap::new();
3166
3167    // Handle Binance Auth first if configured
3168    if let Some(ref binance_auth) = configuration.binance_auth {
3169        // Add API key to headers
3170        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3171        
3172        // Generate request body for signing (if any)
3173        let body_string: Option<Vec<u8>> = None;
3174        
3175        // Sign the request
3176        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3177            Ok(sig) => sig,
3178            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3179        };
3180        
3181        // Add signature to query params
3182        query_params.push(("signature".to_string(), signature));
3183    }
3184
3185    // Apply all query parameters
3186    if !query_params.is_empty() {
3187        req_builder = req_builder.query(&query_params);
3188    }
3189
3190
3191    // Add user agent if configured
3192    if let Some(ref user_agent) = configuration.user_agent {
3193        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3194    }
3195
3196    // Apply all header parameters
3197    for (header_name, header_value) in header_params {
3198        req_builder = req_builder.header(&header_name, &header_value);
3199    }
3200
3201    let mut multipart_form_params = std::collections::HashMap::new();
3202    multipart_form_params.insert("autoRepay", params.auto_repay.to_string());
3203    if let Some(param_value) = params.recv_window {
3204        multipart_form_params.insert("recvWindow", param_value.to_string());
3205    }
3206    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3207    req_builder = req_builder.form(&multipart_form_params);
3208
3209    let req = req_builder.build()?;
3210    let resp = configuration.client.execute(req).await?;
3211
3212    let status = resp.status();
3213    let content_type = resp
3214        .headers()
3215        .get("content-type")
3216        .and_then(|v| v.to_str().ok())
3217        .unwrap_or("application/octet-stream");
3218    let content_type = super::ContentType::from(content_type);
3219
3220    if !status.is_client_error() && !status.is_server_error() {
3221        let content = resp.text().await?;
3222        match content_type {
3223            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3224            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateRepayFuturesSwitchV1Resp`"))),
3225            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::CreateRepayFuturesSwitchV1Resp`")))),
3226        }
3227    } else {
3228        let content = resp.text().await?;
3229        let entity: Option<CreateRepayFuturesSwitchV1Error> = serde_json::from_str(&content).ok();
3230        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3231    }
3232}
3233
3234/// Repay for a margin loan.
3235pub async fn create_repay_loan_v1(configuration: &configuration::Configuration, params: CreateRepayLoanV1Params) -> Result<models::CreateRepayLoanV1Resp, Error<CreateRepayLoanV1Error>> {
3236
3237    let uri_str = format!("{}/papi/v1/repayLoan", configuration.base_path);
3238    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3239
3240    // Create a mutable vector for query parameters
3241    let mut query_params: Vec<(String, String)> = Vec::new();
3242
3243
3244    // Create header parameters collection
3245    let mut header_params = std::collections::HashMap::new();
3246
3247    // Handle Binance Auth first if configured
3248    if let Some(ref binance_auth) = configuration.binance_auth {
3249        // Add API key to headers
3250        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3251        
3252        // Generate request body for signing (if any)
3253        let body_string: Option<Vec<u8>> = None;
3254        
3255        // Sign the request
3256        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3257            Ok(sig) => sig,
3258            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3259        };
3260        
3261        // Add signature to query params
3262        query_params.push(("signature".to_string(), signature));
3263    }
3264
3265    // Apply all query parameters
3266    if !query_params.is_empty() {
3267        req_builder = req_builder.query(&query_params);
3268    }
3269
3270
3271    // Add user agent if configured
3272    if let Some(ref user_agent) = configuration.user_agent {
3273        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3274    }
3275
3276    // Apply all header parameters
3277    for (header_name, header_value) in header_params {
3278        req_builder = req_builder.header(&header_name, &header_value);
3279    }
3280
3281    let mut multipart_form_params = std::collections::HashMap::new();
3282    multipart_form_params.insert("amount", params.amount.to_string());
3283    multipart_form_params.insert("asset", params.asset.to_string());
3284    if let Some(param_value) = params.recv_window {
3285        multipart_form_params.insert("recvWindow", param_value.to_string());
3286    }
3287    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3288    req_builder = req_builder.form(&multipart_form_params);
3289
3290    let req = req_builder.build()?;
3291    let resp = configuration.client.execute(req).await?;
3292
3293    let status = resp.status();
3294    let content_type = resp
3295        .headers()
3296        .get("content-type")
3297        .and_then(|v| v.to_str().ok())
3298        .unwrap_or("application/octet-stream");
3299    let content_type = super::ContentType::from(content_type);
3300
3301    if !status.is_client_error() && !status.is_server_error() {
3302        let content = resp.text().await?;
3303        match content_type {
3304            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3305            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateRepayLoanV1Resp`"))),
3306            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::CreateRepayLoanV1Resp`")))),
3307        }
3308    } else {
3309        let content = resp.text().await?;
3310        let entity: Option<CreateRepayLoanV1Error> = serde_json::from_str(&content).ok();
3311        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3312    }
3313}
3314
3315/// Place new UM conditional order
3316pub async fn create_um_conditional_order_v1(configuration: &configuration::Configuration, params: CreateUmConditionalOrderV1Params) -> Result<models::CreateUmConditionalOrderV1Resp, Error<CreateUmConditionalOrderV1Error>> {
3317
3318    let uri_str = format!("{}/papi/v1/um/conditional/order", configuration.base_path);
3319    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3320
3321    // Create a mutable vector for query parameters
3322    let mut query_params: Vec<(String, String)> = Vec::new();
3323
3324
3325    // Create header parameters collection
3326    let mut header_params = std::collections::HashMap::new();
3327
3328    // Handle Binance Auth first if configured
3329    if let Some(ref binance_auth) = configuration.binance_auth {
3330        // Add API key to headers
3331        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3332        
3333        // Generate request body for signing (if any)
3334        let body_string: Option<Vec<u8>> = None;
3335        
3336        // Sign the request
3337        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3338            Ok(sig) => sig,
3339            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3340        };
3341        
3342        // Add signature to query params
3343        query_params.push(("signature".to_string(), signature));
3344    }
3345
3346    // Apply all query parameters
3347    if !query_params.is_empty() {
3348        req_builder = req_builder.query(&query_params);
3349    }
3350
3351
3352    // Add user agent if configured
3353    if let Some(ref user_agent) = configuration.user_agent {
3354        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3355    }
3356
3357    // Apply all header parameters
3358    for (header_name, header_value) in header_params {
3359        req_builder = req_builder.header(&header_name, &header_value);
3360    }
3361
3362    let mut multipart_form_params = std::collections::HashMap::new();
3363    if let Some(param_value) = params.activation_price {
3364        multipart_form_params.insert("activationPrice", param_value.to_string());
3365    }
3366    if let Some(param_value) = params.callback_rate {
3367        multipart_form_params.insert("callbackRate", param_value.to_string());
3368    }
3369    if let Some(param_value) = params.good_till_date {
3370        multipart_form_params.insert("goodTillDate", param_value.to_string());
3371    }
3372    if let Some(param_value) = params.new_client_strategy_id {
3373        multipart_form_params.insert("newClientStrategyId", param_value.to_string());
3374    }
3375    if let Some(param_value) = params.position_side {
3376        multipart_form_params.insert("positionSide", param_value.to_string());
3377    }
3378    if let Some(param_value) = params.price {
3379        multipart_form_params.insert("price", param_value.to_string());
3380    }
3381    if let Some(param_value) = params.price_match {
3382        multipart_form_params.insert("priceMatch", param_value.to_string());
3383    }
3384    if let Some(param_value) = params.price_protect {
3385        multipart_form_params.insert("priceProtect", param_value.to_string());
3386    }
3387    if let Some(param_value) = params.quantity {
3388        multipart_form_params.insert("quantity", param_value.to_string());
3389    }
3390    if let Some(param_value) = params.recv_window {
3391        multipart_form_params.insert("recvWindow", param_value.to_string());
3392    }
3393    if let Some(param_value) = params.reduce_only {
3394        multipart_form_params.insert("reduceOnly", param_value.to_string());
3395    }
3396    if let Some(param_value) = params.self_trade_prevention_mode {
3397        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
3398    }
3399    multipart_form_params.insert("side", params.side.to_string());
3400    if let Some(param_value) = params.stop_price {
3401        multipart_form_params.insert("stopPrice", param_value.to_string());
3402    }
3403    multipart_form_params.insert("strategyType", params.strategy_type.to_string());
3404    multipart_form_params.insert("symbol", params.symbol.to_string());
3405    if let Some(param_value) = params.time_in_force {
3406        multipart_form_params.insert("timeInForce", param_value.to_string());
3407    }
3408    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3409    if let Some(param_value) = params.working_type {
3410        multipart_form_params.insert("workingType", param_value.to_string());
3411    }
3412    req_builder = req_builder.form(&multipart_form_params);
3413
3414    let req = req_builder.build()?;
3415    let resp = configuration.client.execute(req).await?;
3416
3417    let status = resp.status();
3418    let content_type = resp
3419        .headers()
3420        .get("content-type")
3421        .and_then(|v| v.to_str().ok())
3422        .unwrap_or("application/octet-stream");
3423    let content_type = super::ContentType::from(content_type);
3424
3425    if !status.is_client_error() && !status.is_server_error() {
3426        let content = resp.text().await?;
3427        match content_type {
3428            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3429            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateUmConditionalOrderV1Resp`"))),
3430            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::CreateUmConditionalOrderV1Resp`")))),
3431        }
3432    } else {
3433        let content = resp.text().await?;
3434        let entity: Option<CreateUmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
3435        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3436    }
3437}
3438
3439/// Change user's BNB Fee Discount for UM Futures (Fee Discount On or Fee Discount Off ) on EVERY symbol
3440pub async fn create_um_fee_burn_v1(configuration: &configuration::Configuration, params: CreateUmFeeBurnV1Params) -> Result<models::CreateUmFeeBurnV1Resp, Error<CreateUmFeeBurnV1Error>> {
3441
3442    let uri_str = format!("{}/papi/v1/um/feeBurn", configuration.base_path);
3443    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3444
3445    // Create a mutable vector for query parameters
3446    let mut query_params: Vec<(String, String)> = Vec::new();
3447
3448
3449    // Create header parameters collection
3450    let mut header_params = std::collections::HashMap::new();
3451
3452    // Handle Binance Auth first if configured
3453    if let Some(ref binance_auth) = configuration.binance_auth {
3454        // Add API key to headers
3455        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3456        
3457        // Generate request body for signing (if any)
3458        let body_string: Option<Vec<u8>> = None;
3459        
3460        // Sign the request
3461        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3462            Ok(sig) => sig,
3463            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3464        };
3465        
3466        // Add signature to query params
3467        query_params.push(("signature".to_string(), signature));
3468    }
3469
3470    // Apply all query parameters
3471    if !query_params.is_empty() {
3472        req_builder = req_builder.query(&query_params);
3473    }
3474
3475
3476    // Add user agent if configured
3477    if let Some(ref user_agent) = configuration.user_agent {
3478        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3479    }
3480
3481    // Apply all header parameters
3482    for (header_name, header_value) in header_params {
3483        req_builder = req_builder.header(&header_name, &header_value);
3484    }
3485
3486    let mut multipart_form_params = std::collections::HashMap::new();
3487    multipart_form_params.insert("feeBurn", params.fee_burn.to_string());
3488    if let Some(param_value) = params.recv_window {
3489        multipart_form_params.insert("recvWindow", param_value.to_string());
3490    }
3491    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3492    req_builder = req_builder.form(&multipart_form_params);
3493
3494    let req = req_builder.build()?;
3495    let resp = configuration.client.execute(req).await?;
3496
3497    let status = resp.status();
3498    let content_type = resp
3499        .headers()
3500        .get("content-type")
3501        .and_then(|v| v.to_str().ok())
3502        .unwrap_or("application/octet-stream");
3503    let content_type = super::ContentType::from(content_type);
3504
3505    if !status.is_client_error() && !status.is_server_error() {
3506        let content = resp.text().await?;
3507        match content_type {
3508            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3509            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateUmFeeBurnV1Resp`"))),
3510            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::CreateUmFeeBurnV1Resp`")))),
3511        }
3512    } else {
3513        let content = resp.text().await?;
3514        let entity: Option<CreateUmFeeBurnV1Error> = serde_json::from_str(&content).ok();
3515        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3516    }
3517}
3518
3519/// Change user's initial leverage of specific symbol in UM.
3520pub async fn create_um_leverage_v1(configuration: &configuration::Configuration, params: CreateUmLeverageV1Params) -> Result<models::CreateUmLeverageV1Resp, Error<CreateUmLeverageV1Error>> {
3521
3522    let uri_str = format!("{}/papi/v1/um/leverage", configuration.base_path);
3523    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3524
3525    // Create a mutable vector for query parameters
3526    let mut query_params: Vec<(String, String)> = Vec::new();
3527
3528
3529    // Create header parameters collection
3530    let mut header_params = std::collections::HashMap::new();
3531
3532    // Handle Binance Auth first if configured
3533    if let Some(ref binance_auth) = configuration.binance_auth {
3534        // Add API key to headers
3535        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3536        
3537        // Generate request body for signing (if any)
3538        let body_string: Option<Vec<u8>> = None;
3539        
3540        // Sign the request
3541        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3542            Ok(sig) => sig,
3543            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3544        };
3545        
3546        // Add signature to query params
3547        query_params.push(("signature".to_string(), signature));
3548    }
3549
3550    // Apply all query parameters
3551    if !query_params.is_empty() {
3552        req_builder = req_builder.query(&query_params);
3553    }
3554
3555
3556    // Add user agent if configured
3557    if let Some(ref user_agent) = configuration.user_agent {
3558        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3559    }
3560
3561    // Apply all header parameters
3562    for (header_name, header_value) in header_params {
3563        req_builder = req_builder.header(&header_name, &header_value);
3564    }
3565
3566    let mut multipart_form_params = std::collections::HashMap::new();
3567    multipart_form_params.insert("leverage", params.leverage.to_string());
3568    if let Some(param_value) = params.recv_window {
3569        multipart_form_params.insert("recvWindow", param_value.to_string());
3570    }
3571    multipart_form_params.insert("symbol", params.symbol.to_string());
3572    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3573    req_builder = req_builder.form(&multipart_form_params);
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::CreateUmLeverageV1Resp`"))),
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::CreateUmLeverageV1Resp`")))),
3592        }
3593    } else {
3594        let content = resp.text().await?;
3595        let entity: Option<CreateUmLeverageV1Error> = serde_json::from_str(&content).ok();
3596        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3597    }
3598}
3599
3600/// Place new UM order
3601pub async fn create_um_order_v1(configuration: &configuration::Configuration, params: CreateUmOrderV1Params) -> Result<models::CreateUmOrderV1Resp, Error<CreateUmOrderV1Error>> {
3602
3603    let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
3604    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3605
3606    // Create a mutable vector for query parameters
3607    let mut query_params: Vec<(String, String)> = Vec::new();
3608
3609
3610    // Create header parameters collection
3611    let mut header_params = std::collections::HashMap::new();
3612
3613    // Handle Binance Auth first if configured
3614    if let Some(ref binance_auth) = configuration.binance_auth {
3615        // Add API key to headers
3616        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3617        
3618        // Generate request body for signing (if any)
3619        let body_string: Option<Vec<u8>> = None;
3620        
3621        // Sign the request
3622        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3623            Ok(sig) => sig,
3624            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3625        };
3626        
3627        // Add signature to query params
3628        query_params.push(("signature".to_string(), signature));
3629    }
3630
3631    // Apply all query parameters
3632    if !query_params.is_empty() {
3633        req_builder = req_builder.query(&query_params);
3634    }
3635
3636
3637    // Add user agent if configured
3638    if let Some(ref user_agent) = configuration.user_agent {
3639        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3640    }
3641
3642    // Apply all header parameters
3643    for (header_name, header_value) in header_params {
3644        req_builder = req_builder.header(&header_name, &header_value);
3645    }
3646
3647    let mut multipart_form_params = std::collections::HashMap::new();
3648    if let Some(param_value) = params.good_till_date {
3649        multipart_form_params.insert("goodTillDate", param_value.to_string());
3650    }
3651    if let Some(param_value) = params.new_client_order_id {
3652        multipart_form_params.insert("newClientOrderId", param_value.to_string());
3653    }
3654    if let Some(param_value) = params.new_order_resp_type {
3655        multipart_form_params.insert("newOrderRespType", param_value.to_string());
3656    }
3657    if let Some(param_value) = params.position_side {
3658        multipart_form_params.insert("positionSide", param_value.to_string());
3659    }
3660    if let Some(param_value) = params.price {
3661        multipart_form_params.insert("price", param_value.to_string());
3662    }
3663    if let Some(param_value) = params.price_match {
3664        multipart_form_params.insert("priceMatch", param_value.to_string());
3665    }
3666    if let Some(param_value) = params.quantity {
3667        multipart_form_params.insert("quantity", param_value.to_string());
3668    }
3669    if let Some(param_value) = params.recv_window {
3670        multipart_form_params.insert("recvWindow", param_value.to_string());
3671    }
3672    if let Some(param_value) = params.reduce_only {
3673        multipart_form_params.insert("reduceOnly", param_value.to_string());
3674    }
3675    if let Some(param_value) = params.self_trade_prevention_mode {
3676        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
3677    }
3678    multipart_form_params.insert("side", params.side.to_string());
3679    multipart_form_params.insert("symbol", params.symbol.to_string());
3680    if let Some(param_value) = params.time_in_force {
3681        multipart_form_params.insert("timeInForce", param_value.to_string());
3682    }
3683    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3684    multipart_form_params.insert("type", params.r#type.to_string());
3685    req_builder = req_builder.form(&multipart_form_params);
3686
3687    let req = req_builder.build()?;
3688    let resp = configuration.client.execute(req).await?;
3689
3690    let status = resp.status();
3691    let content_type = resp
3692        .headers()
3693        .get("content-type")
3694        .and_then(|v| v.to_str().ok())
3695        .unwrap_or("application/octet-stream");
3696    let content_type = super::ContentType::from(content_type);
3697
3698    if !status.is_client_error() && !status.is_server_error() {
3699        let content = resp.text().await?;
3700        match content_type {
3701            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3702            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateUmOrderV1Resp`"))),
3703            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::CreateUmOrderV1Resp`")))),
3704        }
3705    } else {
3706        let content = resp.text().await?;
3707        let entity: Option<CreateUmOrderV1Error> = serde_json::from_str(&content).ok();
3708        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3709    }
3710}
3711
3712/// Change user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in UM
3713pub async fn create_um_position_side_dual_v1(configuration: &configuration::Configuration, params: CreateUmPositionSideDualV1Params) -> Result<models::CreateUmPositionSideDualV1Resp, Error<CreateUmPositionSideDualV1Error>> {
3714
3715    let uri_str = format!("{}/papi/v1/um/positionSide/dual", configuration.base_path);
3716    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
3717
3718    // Create a mutable vector for query parameters
3719    let mut query_params: Vec<(String, String)> = Vec::new();
3720
3721
3722    // Create header parameters collection
3723    let mut header_params = std::collections::HashMap::new();
3724
3725    // Handle Binance Auth first if configured
3726    if let Some(ref binance_auth) = configuration.binance_auth {
3727        // Add API key to headers
3728        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3729        
3730        // Generate request body for signing (if any)
3731        let body_string: Option<Vec<u8>> = None;
3732        
3733        // Sign the request
3734        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3735            Ok(sig) => sig,
3736            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3737        };
3738        
3739        // Add signature to query params
3740        query_params.push(("signature".to_string(), signature));
3741    }
3742
3743    // Apply all query parameters
3744    if !query_params.is_empty() {
3745        req_builder = req_builder.query(&query_params);
3746    }
3747
3748
3749    // Add user agent if configured
3750    if let Some(ref user_agent) = configuration.user_agent {
3751        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3752    }
3753
3754    // Apply all header parameters
3755    for (header_name, header_value) in header_params {
3756        req_builder = req_builder.header(&header_name, &header_value);
3757    }
3758
3759    let mut multipart_form_params = std::collections::HashMap::new();
3760    multipart_form_params.insert("dualSidePosition", params.dual_side_position.to_string());
3761    if let Some(param_value) = params.recv_window {
3762        multipart_form_params.insert("recvWindow", param_value.to_string());
3763    }
3764    multipart_form_params.insert("timestamp", params.timestamp.to_string());
3765    req_builder = req_builder.form(&multipart_form_params);
3766
3767    let req = req_builder.build()?;
3768    let resp = configuration.client.execute(req).await?;
3769
3770    let status = resp.status();
3771    let content_type = resp
3772        .headers()
3773        .get("content-type")
3774        .and_then(|v| v.to_str().ok())
3775        .unwrap_or("application/octet-stream");
3776    let content_type = super::ContentType::from(content_type);
3777
3778    if !status.is_client_error() && !status.is_server_error() {
3779        let content = resp.text().await?;
3780        match content_type {
3781            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3782            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateUmPositionSideDualV1Resp`"))),
3783            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::CreateUmPositionSideDualV1Resp`")))),
3784        }
3785    } else {
3786        let content = resp.text().await?;
3787        let entity: Option<CreateUmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
3788        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3789    }
3790}
3791
3792/// Cancel all active LIMIT orders on specific symbol
3793pub async fn delete_cm_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteCmAllOpenOrdersV1Params) -> Result<models::DeleteCmAllOpenOrdersV1Resp, Error<DeleteCmAllOpenOrdersV1Error>> {
3794
3795    let uri_str = format!("{}/papi/v1/cm/allOpenOrders", configuration.base_path);
3796    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
3797
3798    // Create a mutable vector for query parameters
3799    let mut query_params: Vec<(String, String)> = Vec::new();
3800
3801    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3802    if let Some(ref param_value) = params.recv_window {
3803        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3804    }
3805    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3806
3807    // Create header parameters collection
3808    let mut header_params = std::collections::HashMap::new();
3809
3810    // Handle Binance Auth first if configured
3811    if let Some(ref binance_auth) = configuration.binance_auth {
3812        // Add API key to headers
3813        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3814        
3815        // Generate request body for signing (if any)
3816        let body_string: Option<Vec<u8>> = None;
3817        
3818        // Sign the request
3819        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3820            Ok(sig) => sig,
3821            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3822        };
3823        
3824        // Add signature to query params
3825        query_params.push(("signature".to_string(), signature));
3826    }
3827
3828    // Apply all query parameters
3829    if !query_params.is_empty() {
3830        req_builder = req_builder.query(&query_params);
3831    }
3832
3833
3834    // Add user agent if configured
3835    if let Some(ref user_agent) = configuration.user_agent {
3836        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3837    }
3838
3839    // Apply all header parameters
3840    for (header_name, header_value) in header_params {
3841        req_builder = req_builder.header(&header_name, &header_value);
3842    }
3843
3844
3845    let req = req_builder.build()?;
3846    let resp = configuration.client.execute(req).await?;
3847
3848    let status = resp.status();
3849    let content_type = resp
3850        .headers()
3851        .get("content-type")
3852        .and_then(|v| v.to_str().ok())
3853        .unwrap_or("application/octet-stream");
3854    let content_type = super::ContentType::from(content_type);
3855
3856    if !status.is_client_error() && !status.is_server_error() {
3857        let content = resp.text().await?;
3858        match content_type {
3859            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3860            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteCmAllOpenOrdersV1Resp`"))),
3861            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteCmAllOpenOrdersV1Resp`")))),
3862        }
3863    } else {
3864        let content = resp.text().await?;
3865        let entity: Option<DeleteCmAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
3866        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3867    }
3868}
3869
3870/// Cancel All CM Open Conditional Orders
3871pub async fn delete_cm_conditional_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteCmConditionalAllOpenOrdersV1Params) -> Result<models::DeleteCmConditionalAllOpenOrdersV1Resp, Error<DeleteCmConditionalAllOpenOrdersV1Error>> {
3872
3873    let uri_str = format!("{}/papi/v1/cm/conditional/allOpenOrders", configuration.base_path);
3874    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
3875
3876    // Create a mutable vector for query parameters
3877    let mut query_params: Vec<(String, String)> = Vec::new();
3878
3879    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3880    if let Some(ref param_value) = params.recv_window {
3881        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3882    }
3883    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3884
3885    // Create header parameters collection
3886    let mut header_params = std::collections::HashMap::new();
3887
3888    // Handle Binance Auth first if configured
3889    if let Some(ref binance_auth) = configuration.binance_auth {
3890        // Add API key to headers
3891        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3892        
3893        // Generate request body for signing (if any)
3894        let body_string: Option<Vec<u8>> = None;
3895        
3896        // Sign the request
3897        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3898            Ok(sig) => sig,
3899            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3900        };
3901        
3902        // Add signature to query params
3903        query_params.push(("signature".to_string(), signature));
3904    }
3905
3906    // Apply all query parameters
3907    if !query_params.is_empty() {
3908        req_builder = req_builder.query(&query_params);
3909    }
3910
3911
3912    // Add user agent if configured
3913    if let Some(ref user_agent) = configuration.user_agent {
3914        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3915    }
3916
3917    // Apply all header parameters
3918    for (header_name, header_value) in header_params {
3919        req_builder = req_builder.header(&header_name, &header_value);
3920    }
3921
3922
3923    let req = req_builder.build()?;
3924    let resp = configuration.client.execute(req).await?;
3925
3926    let status = resp.status();
3927    let content_type = resp
3928        .headers()
3929        .get("content-type")
3930        .and_then(|v| v.to_str().ok())
3931        .unwrap_or("application/octet-stream");
3932    let content_type = super::ContentType::from(content_type);
3933
3934    if !status.is_client_error() && !status.is_server_error() {
3935        let content = resp.text().await?;
3936        match content_type {
3937            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3938            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteCmConditionalAllOpenOrdersV1Resp`"))),
3939            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteCmConditionalAllOpenOrdersV1Resp`")))),
3940        }
3941    } else {
3942        let content = resp.text().await?;
3943        let entity: Option<DeleteCmConditionalAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
3944        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3945    }
3946}
3947
3948/// Cancel CM Conditional Order
3949pub async fn delete_cm_conditional_order_v1(configuration: &configuration::Configuration, params: DeleteCmConditionalOrderV1Params) -> Result<models::DeleteCmConditionalOrderV1Resp, Error<DeleteCmConditionalOrderV1Error>> {
3950
3951    let uri_str = format!("{}/papi/v1/cm/conditional/order", configuration.base_path);
3952    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
3953
3954    // Create a mutable vector for query parameters
3955    let mut query_params: Vec<(String, String)> = Vec::new();
3956
3957    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3958    if let Some(ref param_value) = params.strategy_id {
3959        query_params.push(("strategyId".to_string(), param_value.to_string()));
3960    }
3961    if let Some(ref param_value) = params.new_client_strategy_id {
3962        query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
3963    }
3964    if let Some(ref param_value) = params.recv_window {
3965        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3966    }
3967    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3968
3969    // Create header parameters collection
3970    let mut header_params = std::collections::HashMap::new();
3971
3972    // Handle Binance Auth first if configured
3973    if let Some(ref binance_auth) = configuration.binance_auth {
3974        // Add API key to headers
3975        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3976        
3977        // Generate request body for signing (if any)
3978        let body_string: Option<Vec<u8>> = None;
3979        
3980        // Sign the request
3981        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3982            Ok(sig) => sig,
3983            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3984        };
3985        
3986        // Add signature to query params
3987        query_params.push(("signature".to_string(), signature));
3988    }
3989
3990    // Apply all query parameters
3991    if !query_params.is_empty() {
3992        req_builder = req_builder.query(&query_params);
3993    }
3994
3995
3996    // Add user agent if configured
3997    if let Some(ref user_agent) = configuration.user_agent {
3998        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3999    }
4000
4001    // Apply all header parameters
4002    for (header_name, header_value) in header_params {
4003        req_builder = req_builder.header(&header_name, &header_value);
4004    }
4005
4006
4007    let req = req_builder.build()?;
4008    let resp = configuration.client.execute(req).await?;
4009
4010    let status = resp.status();
4011    let content_type = resp
4012        .headers()
4013        .get("content-type")
4014        .and_then(|v| v.to_str().ok())
4015        .unwrap_or("application/octet-stream");
4016    let content_type = super::ContentType::from(content_type);
4017
4018    if !status.is_client_error() && !status.is_server_error() {
4019        let content = resp.text().await?;
4020        match content_type {
4021            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4022            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteCmConditionalOrderV1Resp`"))),
4023            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::DeleteCmConditionalOrderV1Resp`")))),
4024        }
4025    } else {
4026        let content = resp.text().await?;
4027        let entity: Option<DeleteCmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
4028        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4029    }
4030}
4031
4032/// Cancel an active LIMIT order
4033pub async fn delete_cm_order_v1(configuration: &configuration::Configuration, params: DeleteCmOrderV1Params) -> Result<models::DeleteCmOrderV1Resp, Error<DeleteCmOrderV1Error>> {
4034
4035    let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
4036    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4037
4038    // Create a mutable vector for query parameters
4039    let mut query_params: Vec<(String, String)> = Vec::new();
4040
4041    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4042    if let Some(ref param_value) = params.order_id {
4043        query_params.push(("orderId".to_string(), param_value.to_string()));
4044    }
4045    if let Some(ref param_value) = params.orig_client_order_id {
4046        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
4047    }
4048    if let Some(ref param_value) = params.recv_window {
4049        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4050    }
4051    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4052
4053    // Create header parameters collection
4054    let mut header_params = std::collections::HashMap::new();
4055
4056    // Handle Binance Auth first if configured
4057    if let Some(ref binance_auth) = configuration.binance_auth {
4058        // Add API key to headers
4059        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4060        
4061        // Generate request body for signing (if any)
4062        let body_string: Option<Vec<u8>> = None;
4063        
4064        // Sign the request
4065        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4066            Ok(sig) => sig,
4067            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4068        };
4069        
4070        // Add signature to query params
4071        query_params.push(("signature".to_string(), signature));
4072    }
4073
4074    // Apply all query parameters
4075    if !query_params.is_empty() {
4076        req_builder = req_builder.query(&query_params);
4077    }
4078
4079
4080    // Add user agent if configured
4081    if let Some(ref user_agent) = configuration.user_agent {
4082        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4083    }
4084
4085    // Apply all header parameters
4086    for (header_name, header_value) in header_params {
4087        req_builder = req_builder.header(&header_name, &header_value);
4088    }
4089
4090
4091    let req = req_builder.build()?;
4092    let resp = configuration.client.execute(req).await?;
4093
4094    let status = resp.status();
4095    let content_type = resp
4096        .headers()
4097        .get("content-type")
4098        .and_then(|v| v.to_str().ok())
4099        .unwrap_or("application/octet-stream");
4100    let content_type = super::ContentType::from(content_type);
4101
4102    if !status.is_client_error() && !status.is_server_error() {
4103        let content = resp.text().await?;
4104        match content_type {
4105            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4106            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteCmOrderV1Resp`"))),
4107            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::DeleteCmOrderV1Resp`")))),
4108        }
4109    } else {
4110        let content = resp.text().await?;
4111        let entity: Option<DeleteCmOrderV1Error> = serde_json::from_str(&content).ok();
4112        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4113    }
4114}
4115
4116/// Close out a user data stream.
4117pub async fn delete_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<DeleteListenKeyV1Error>> {
4118
4119    let uri_str = format!("{}/papi/v1/listenKey", configuration.base_path);
4120    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4121
4122    // Create a mutable vector for query parameters
4123    let mut query_params: Vec<(String, String)> = Vec::new();
4124
4125
4126    // Create header parameters collection
4127    let mut header_params = std::collections::HashMap::new();
4128
4129    // Handle Binance Auth first if configured
4130    if let Some(ref binance_auth) = configuration.binance_auth {
4131        // Add API key to headers
4132        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4133        
4134        // Generate request body for signing (if any)
4135        let body_string: Option<Vec<u8>> = None;
4136        
4137        // Sign the request
4138        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4139            Ok(sig) => sig,
4140            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4141        };
4142        
4143        // Add signature to query params
4144        query_params.push(("signature".to_string(), signature));
4145    }
4146
4147    // Apply all query parameters
4148    if !query_params.is_empty() {
4149        req_builder = req_builder.query(&query_params);
4150    }
4151
4152
4153    // Add user agent if configured
4154    if let Some(ref user_agent) = configuration.user_agent {
4155        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4156    }
4157
4158    // Apply all header parameters
4159    for (header_name, header_value) in header_params {
4160        req_builder = req_builder.header(&header_name, &header_value);
4161    }
4162
4163
4164    let req = req_builder.build()?;
4165    let resp = configuration.client.execute(req).await?;
4166
4167    let status = resp.status();
4168    let content_type = resp
4169        .headers()
4170        .get("content-type")
4171        .and_then(|v| v.to_str().ok())
4172        .unwrap_or("application/octet-stream");
4173    let content_type = super::ContentType::from(content_type);
4174
4175    if !status.is_client_error() && !status.is_server_error() {
4176        let content = resp.text().await?;
4177        match content_type {
4178            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4179            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
4180            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
4181        }
4182    } else {
4183        let content = resp.text().await?;
4184        let entity: Option<DeleteListenKeyV1Error> = serde_json::from_str(&content).ok();
4185        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4186    }
4187}
4188
4189/// Cancel Margin Account All Open Orders on a Symbol
4190pub async fn delete_margin_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteMarginAllOpenOrdersV1Params) -> Result<Vec<models::PmarginDeleteMarginAllOpenOrdersV1RespInner>, Error<DeleteMarginAllOpenOrdersV1Error>> {
4191
4192    let uri_str = format!("{}/papi/v1/margin/allOpenOrders", configuration.base_path);
4193    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4194
4195    // Create a mutable vector for query parameters
4196    let mut query_params: Vec<(String, String)> = Vec::new();
4197
4198    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4199    if let Some(ref param_value) = params.recv_window {
4200        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4201    }
4202    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4203
4204    // Create header parameters collection
4205    let mut header_params = std::collections::HashMap::new();
4206
4207    // Handle Binance Auth first if configured
4208    if let Some(ref binance_auth) = configuration.binance_auth {
4209        // Add API key to headers
4210        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4211        
4212        // Generate request body for signing (if any)
4213        let body_string: Option<Vec<u8>> = None;
4214        
4215        // Sign the request
4216        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4217            Ok(sig) => sig,
4218            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4219        };
4220        
4221        // Add signature to query params
4222        query_params.push(("signature".to_string(), signature));
4223    }
4224
4225    // Apply all query parameters
4226    if !query_params.is_empty() {
4227        req_builder = req_builder.query(&query_params);
4228    }
4229
4230
4231    // Add user agent if configured
4232    if let Some(ref user_agent) = configuration.user_agent {
4233        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4234    }
4235
4236    // Apply all header parameters
4237    for (header_name, header_value) in header_params {
4238        req_builder = req_builder.header(&header_name, &header_value);
4239    }
4240
4241
4242    let req = req_builder.build()?;
4243    let resp = configuration.client.execute(req).await?;
4244
4245    let status = resp.status();
4246    let content_type = resp
4247        .headers()
4248        .get("content-type")
4249        .and_then(|v| v.to_str().ok())
4250        .unwrap_or("application/octet-stream");
4251    let content_type = super::ContentType::from(content_type);
4252
4253    if !status.is_client_error() && !status.is_server_error() {
4254        let content = resp.text().await?;
4255        match content_type {
4256            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4257            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;`"))),
4258            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;`")))),
4259        }
4260    } else {
4261        let content = resp.text().await?;
4262        let entity: Option<DeleteMarginAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
4263        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4264    }
4265}
4266
4267/// Cancel Margin Account OCO Orders
4268pub async fn delete_margin_order_list_v1(configuration: &configuration::Configuration, params: DeleteMarginOrderListV1Params) -> Result<models::DeleteMarginOrderListV1Resp, Error<DeleteMarginOrderListV1Error>> {
4269
4270    let uri_str = format!("{}/papi/v1/margin/orderList", configuration.base_path);
4271    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4272
4273    // Create a mutable vector for query parameters
4274    let mut query_params: Vec<(String, String)> = Vec::new();
4275
4276    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4277    if let Some(ref param_value) = params.order_list_id {
4278        query_params.push(("orderListId".to_string(), param_value.to_string()));
4279    }
4280    if let Some(ref param_value) = params.list_client_order_id {
4281        query_params.push(("listClientOrderId".to_string(), param_value.to_string()));
4282    }
4283    if let Some(ref param_value) = params.new_client_order_id {
4284        query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
4285    }
4286    if let Some(ref param_value) = params.recv_window {
4287        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4288    }
4289    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4290
4291    // Create header parameters collection
4292    let mut header_params = std::collections::HashMap::new();
4293
4294    // Handle Binance Auth first if configured
4295    if let Some(ref binance_auth) = configuration.binance_auth {
4296        // Add API key to headers
4297        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4298        
4299        // Generate request body for signing (if any)
4300        let body_string: Option<Vec<u8>> = None;
4301        
4302        // Sign the request
4303        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4304            Ok(sig) => sig,
4305            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4306        };
4307        
4308        // Add signature to query params
4309        query_params.push(("signature".to_string(), signature));
4310    }
4311
4312    // Apply all query parameters
4313    if !query_params.is_empty() {
4314        req_builder = req_builder.query(&query_params);
4315    }
4316
4317
4318    // Add user agent if configured
4319    if let Some(ref user_agent) = configuration.user_agent {
4320        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4321    }
4322
4323    // Apply all header parameters
4324    for (header_name, header_value) in header_params {
4325        req_builder = req_builder.header(&header_name, &header_value);
4326    }
4327
4328
4329    let req = req_builder.build()?;
4330    let resp = configuration.client.execute(req).await?;
4331
4332    let status = resp.status();
4333    let content_type = resp
4334        .headers()
4335        .get("content-type")
4336        .and_then(|v| v.to_str().ok())
4337        .unwrap_or("application/octet-stream");
4338    let content_type = super::ContentType::from(content_type);
4339
4340    if !status.is_client_error() && !status.is_server_error() {
4341        let content = resp.text().await?;
4342        match content_type {
4343            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4344            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMarginOrderListV1Resp`"))),
4345            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteMarginOrderListV1Resp`")))),
4346        }
4347    } else {
4348        let content = resp.text().await?;
4349        let entity: Option<DeleteMarginOrderListV1Error> = serde_json::from_str(&content).ok();
4350        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4351    }
4352}
4353
4354/// Cancel Margin Account Order
4355pub async fn delete_margin_order_v1(configuration: &configuration::Configuration, params: DeleteMarginOrderV1Params) -> Result<models::DeleteMarginOrderV1Resp, Error<DeleteMarginOrderV1Error>> {
4356
4357    let uri_str = format!("{}/papi/v1/margin/order", configuration.base_path);
4358    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4359
4360    // Create a mutable vector for query parameters
4361    let mut query_params: Vec<(String, String)> = Vec::new();
4362
4363    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4364    if let Some(ref param_value) = params.order_id {
4365        query_params.push(("orderId".to_string(), param_value.to_string()));
4366    }
4367    if let Some(ref param_value) = params.orig_client_order_id {
4368        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
4369    }
4370    if let Some(ref param_value) = params.new_client_order_id {
4371        query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
4372    }
4373    if let Some(ref param_value) = params.recv_window {
4374        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4375    }
4376    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4377
4378    // Create header parameters collection
4379    let mut header_params = std::collections::HashMap::new();
4380
4381    // Handle Binance Auth first if configured
4382    if let Some(ref binance_auth) = configuration.binance_auth {
4383        // Add API key to headers
4384        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4385        
4386        // Generate request body for signing (if any)
4387        let body_string: Option<Vec<u8>> = None;
4388        
4389        // Sign the request
4390        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4391            Ok(sig) => sig,
4392            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4393        };
4394        
4395        // Add signature to query params
4396        query_params.push(("signature".to_string(), signature));
4397    }
4398
4399    // Apply all query parameters
4400    if !query_params.is_empty() {
4401        req_builder = req_builder.query(&query_params);
4402    }
4403
4404
4405    // Add user agent if configured
4406    if let Some(ref user_agent) = configuration.user_agent {
4407        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4408    }
4409
4410    // Apply all header parameters
4411    for (header_name, header_value) in header_params {
4412        req_builder = req_builder.header(&header_name, &header_value);
4413    }
4414
4415
4416    let req = req_builder.build()?;
4417    let resp = configuration.client.execute(req).await?;
4418
4419    let status = resp.status();
4420    let content_type = resp
4421        .headers()
4422        .get("content-type")
4423        .and_then(|v| v.to_str().ok())
4424        .unwrap_or("application/octet-stream");
4425    let content_type = super::ContentType::from(content_type);
4426
4427    if !status.is_client_error() && !status.is_server_error() {
4428        let content = resp.text().await?;
4429        match content_type {
4430            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4431            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMarginOrderV1Resp`"))),
4432            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteMarginOrderV1Resp`")))),
4433        }
4434    } else {
4435        let content = resp.text().await?;
4436        let entity: Option<DeleteMarginOrderV1Error> = serde_json::from_str(&content).ok();
4437        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4438    }
4439}
4440
4441/// Cancel all active LIMIT orders on specific symbol
4442pub async fn delete_um_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteUmAllOpenOrdersV1Params) -> Result<models::DeleteUmAllOpenOrdersV1Resp, Error<DeleteUmAllOpenOrdersV1Error>> {
4443
4444    let uri_str = format!("{}/papi/v1/um/allOpenOrders", configuration.base_path);
4445    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4446
4447    // Create a mutable vector for query parameters
4448    let mut query_params: Vec<(String, String)> = Vec::new();
4449
4450    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4451    if let Some(ref param_value) = params.recv_window {
4452        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4453    }
4454    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4455
4456    // Create header parameters collection
4457    let mut header_params = std::collections::HashMap::new();
4458
4459    // Handle Binance Auth first if configured
4460    if let Some(ref binance_auth) = configuration.binance_auth {
4461        // Add API key to headers
4462        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4463        
4464        // Generate request body for signing (if any)
4465        let body_string: Option<Vec<u8>> = None;
4466        
4467        // Sign the request
4468        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4469            Ok(sig) => sig,
4470            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4471        };
4472        
4473        // Add signature to query params
4474        query_params.push(("signature".to_string(), signature));
4475    }
4476
4477    // Apply all query parameters
4478    if !query_params.is_empty() {
4479        req_builder = req_builder.query(&query_params);
4480    }
4481
4482
4483    // Add user agent if configured
4484    if let Some(ref user_agent) = configuration.user_agent {
4485        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4486    }
4487
4488    // Apply all header parameters
4489    for (header_name, header_value) in header_params {
4490        req_builder = req_builder.header(&header_name, &header_value);
4491    }
4492
4493
4494    let req = req_builder.build()?;
4495    let resp = configuration.client.execute(req).await?;
4496
4497    let status = resp.status();
4498    let content_type = resp
4499        .headers()
4500        .get("content-type")
4501        .and_then(|v| v.to_str().ok())
4502        .unwrap_or("application/octet-stream");
4503    let content_type = super::ContentType::from(content_type);
4504
4505    if !status.is_client_error() && !status.is_server_error() {
4506        let content = resp.text().await?;
4507        match content_type {
4508            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4509            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteUmAllOpenOrdersV1Resp`"))),
4510            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::DeleteUmAllOpenOrdersV1Resp`")))),
4511        }
4512    } else {
4513        let content = resp.text().await?;
4514        let entity: Option<DeleteUmAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
4515        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4516    }
4517}
4518
4519/// Cancel All UM Open Conditional Orders
4520pub async fn delete_um_conditional_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteUmConditionalAllOpenOrdersV1Params) -> Result<models::DeleteUmConditionalAllOpenOrdersV1Resp, Error<DeleteUmConditionalAllOpenOrdersV1Error>> {
4521
4522    let uri_str = format!("{}/papi/v1/um/conditional/allOpenOrders", configuration.base_path);
4523    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4524
4525    // Create a mutable vector for query parameters
4526    let mut query_params: Vec<(String, String)> = Vec::new();
4527
4528    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4529    if let Some(ref param_value) = params.recv_window {
4530        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4531    }
4532    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4533
4534    // Create header parameters collection
4535    let mut header_params = std::collections::HashMap::new();
4536
4537    // Handle Binance Auth first if configured
4538    if let Some(ref binance_auth) = configuration.binance_auth {
4539        // Add API key to headers
4540        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4541        
4542        // Generate request body for signing (if any)
4543        let body_string: Option<Vec<u8>> = None;
4544        
4545        // Sign the request
4546        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4547            Ok(sig) => sig,
4548            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4549        };
4550        
4551        // Add signature to query params
4552        query_params.push(("signature".to_string(), signature));
4553    }
4554
4555    // Apply all query parameters
4556    if !query_params.is_empty() {
4557        req_builder = req_builder.query(&query_params);
4558    }
4559
4560
4561    // Add user agent if configured
4562    if let Some(ref user_agent) = configuration.user_agent {
4563        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4564    }
4565
4566    // Apply all header parameters
4567    for (header_name, header_value) in header_params {
4568        req_builder = req_builder.header(&header_name, &header_value);
4569    }
4570
4571
4572    let req = req_builder.build()?;
4573    let resp = configuration.client.execute(req).await?;
4574
4575    let status = resp.status();
4576    let content_type = resp
4577        .headers()
4578        .get("content-type")
4579        .and_then(|v| v.to_str().ok())
4580        .unwrap_or("application/octet-stream");
4581    let content_type = super::ContentType::from(content_type);
4582
4583    if !status.is_client_error() && !status.is_server_error() {
4584        let content = resp.text().await?;
4585        match content_type {
4586            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4587            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteUmConditionalAllOpenOrdersV1Resp`"))),
4588            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::DeleteUmConditionalAllOpenOrdersV1Resp`")))),
4589        }
4590    } else {
4591        let content = resp.text().await?;
4592        let entity: Option<DeleteUmConditionalAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
4593        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4594    }
4595}
4596
4597/// Cancel UM Conditional Order
4598pub async fn delete_um_conditional_order_v1(configuration: &configuration::Configuration, params: DeleteUmConditionalOrderV1Params) -> Result<models::DeleteUmConditionalOrderV1Resp, Error<DeleteUmConditionalOrderV1Error>> {
4599
4600    let uri_str = format!("{}/papi/v1/um/conditional/order", configuration.base_path);
4601    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4602
4603    // Create a mutable vector for query parameters
4604    let mut query_params: Vec<(String, String)> = Vec::new();
4605
4606    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4607    if let Some(ref param_value) = params.strategy_id {
4608        query_params.push(("strategyId".to_string(), param_value.to_string()));
4609    }
4610    if let Some(ref param_value) = params.new_client_strategy_id {
4611        query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
4612    }
4613    if let Some(ref param_value) = params.recv_window {
4614        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4615    }
4616    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4617
4618    // Create header parameters collection
4619    let mut header_params = std::collections::HashMap::new();
4620
4621    // Handle Binance Auth first if configured
4622    if let Some(ref binance_auth) = configuration.binance_auth {
4623        // Add API key to headers
4624        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4625        
4626        // Generate request body for signing (if any)
4627        let body_string: Option<Vec<u8>> = None;
4628        
4629        // Sign the request
4630        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4631            Ok(sig) => sig,
4632            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4633        };
4634        
4635        // Add signature to query params
4636        query_params.push(("signature".to_string(), signature));
4637    }
4638
4639    // Apply all query parameters
4640    if !query_params.is_empty() {
4641        req_builder = req_builder.query(&query_params);
4642    }
4643
4644
4645    // Add user agent if configured
4646    if let Some(ref user_agent) = configuration.user_agent {
4647        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4648    }
4649
4650    // Apply all header parameters
4651    for (header_name, header_value) in header_params {
4652        req_builder = req_builder.header(&header_name, &header_value);
4653    }
4654
4655
4656    let req = req_builder.build()?;
4657    let resp = configuration.client.execute(req).await?;
4658
4659    let status = resp.status();
4660    let content_type = resp
4661        .headers()
4662        .get("content-type")
4663        .and_then(|v| v.to_str().ok())
4664        .unwrap_or("application/octet-stream");
4665    let content_type = super::ContentType::from(content_type);
4666
4667    if !status.is_client_error() && !status.is_server_error() {
4668        let content = resp.text().await?;
4669        match content_type {
4670            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4671            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteUmConditionalOrderV1Resp`"))),
4672            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::DeleteUmConditionalOrderV1Resp`")))),
4673        }
4674    } else {
4675        let content = resp.text().await?;
4676        let entity: Option<DeleteUmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
4677        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4678    }
4679}
4680
4681/// Cancel an active UM LIMIT order
4682pub async fn delete_um_order_v1(configuration: &configuration::Configuration, params: DeleteUmOrderV1Params) -> Result<models::DeleteUmOrderV1Resp, Error<DeleteUmOrderV1Error>> {
4683
4684    let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
4685    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
4686
4687    // Create a mutable vector for query parameters
4688    let mut query_params: Vec<(String, String)> = Vec::new();
4689
4690    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4691    if let Some(ref param_value) = params.order_id {
4692        query_params.push(("orderId".to_string(), param_value.to_string()));
4693    }
4694    if let Some(ref param_value) = params.orig_client_order_id {
4695        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
4696    }
4697    if let Some(ref param_value) = params.recv_window {
4698        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4699    }
4700    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4701
4702    // Create header parameters collection
4703    let mut header_params = std::collections::HashMap::new();
4704
4705    // Handle Binance Auth first if configured
4706    if let Some(ref binance_auth) = configuration.binance_auth {
4707        // Add API key to headers
4708        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4709        
4710        // Generate request body for signing (if any)
4711        let body_string: Option<Vec<u8>> = None;
4712        
4713        // Sign the request
4714        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4715            Ok(sig) => sig,
4716            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4717        };
4718        
4719        // Add signature to query params
4720        query_params.push(("signature".to_string(), signature));
4721    }
4722
4723    // Apply all query parameters
4724    if !query_params.is_empty() {
4725        req_builder = req_builder.query(&query_params);
4726    }
4727
4728
4729    // Add user agent if configured
4730    if let Some(ref user_agent) = configuration.user_agent {
4731        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4732    }
4733
4734    // Apply all header parameters
4735    for (header_name, header_value) in header_params {
4736        req_builder = req_builder.header(&header_name, &header_value);
4737    }
4738
4739
4740    let req = req_builder.build()?;
4741    let resp = configuration.client.execute(req).await?;
4742
4743    let status = resp.status();
4744    let content_type = resp
4745        .headers()
4746        .get("content-type")
4747        .and_then(|v| v.to_str().ok())
4748        .unwrap_or("application/octet-stream");
4749    let content_type = super::ContentType::from(content_type);
4750
4751    if !status.is_client_error() && !status.is_server_error() {
4752        let content = resp.text().await?;
4753        match content_type {
4754            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4755            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteUmOrderV1Resp`"))),
4756            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::DeleteUmOrderV1Resp`")))),
4757        }
4758    } else {
4759        let content = resp.text().await?;
4760        let entity: Option<DeleteUmOrderV1Error> = serde_json::from_str(&content).ok();
4761        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4762    }
4763}
4764
4765/// Query account information
4766pub async fn get_account_v1(configuration: &configuration::Configuration, params: GetAccountV1Params) -> Result<models::GetAccountV1Resp, Error<GetAccountV1Error>> {
4767
4768    let uri_str = format!("{}/papi/v1/account", configuration.base_path);
4769    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4770
4771    // Create a mutable vector for query parameters
4772    let mut query_params: Vec<(String, String)> = Vec::new();
4773
4774    if let Some(ref param_value) = params.recv_window {
4775        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4776    }
4777    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4778
4779    // Create header parameters collection
4780    let mut header_params = std::collections::HashMap::new();
4781
4782    // Handle Binance Auth first if configured
4783    if let Some(ref binance_auth) = configuration.binance_auth {
4784        // Add API key to headers
4785        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4786        
4787        // Generate request body for signing (if any)
4788        let body_string: Option<Vec<u8>> = None;
4789        
4790        // Sign the request
4791        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4792            Ok(sig) => sig,
4793            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4794        };
4795        
4796        // Add signature to query params
4797        query_params.push(("signature".to_string(), signature));
4798    }
4799
4800    // Apply all query parameters
4801    if !query_params.is_empty() {
4802        req_builder = req_builder.query(&query_params);
4803    }
4804
4805
4806    // Add user agent if configured
4807    if let Some(ref user_agent) = configuration.user_agent {
4808        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4809    }
4810
4811    // Apply all header parameters
4812    for (header_name, header_value) in header_params {
4813        req_builder = req_builder.header(&header_name, &header_value);
4814    }
4815
4816
4817    let req = req_builder.build()?;
4818    let resp = configuration.client.execute(req).await?;
4819
4820    let status = resp.status();
4821    let content_type = resp
4822        .headers()
4823        .get("content-type")
4824        .and_then(|v| v.to_str().ok())
4825        .unwrap_or("application/octet-stream");
4826    let content_type = super::ContentType::from(content_type);
4827
4828    if !status.is_client_error() && !status.is_server_error() {
4829        let content = resp.text().await?;
4830        match content_type {
4831            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4832            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountV1Resp`"))),
4833            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAccountV1Resp`")))),
4834        }
4835    } else {
4836        let content = resp.text().await?;
4837        let entity: Option<GetAccountV1Error> = serde_json::from_str(&content).ok();
4838        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4839    }
4840}
4841
4842/// Query account balance
4843pub async fn get_balance_v1(configuration: &configuration::Configuration, params: GetBalanceV1Params) -> Result<models::PmarginGetBalanceV1Resp, Error<GetBalanceV1Error>> {
4844
4845    let uri_str = format!("{}/papi/v1/balance", configuration.base_path);
4846    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4847
4848    // Create a mutable vector for query parameters
4849    let mut query_params: Vec<(String, String)> = Vec::new();
4850
4851    if let Some(ref param_value) = params.asset {
4852        query_params.push(("asset".to_string(), param_value.to_string()));
4853    }
4854    if let Some(ref param_value) = params.recv_window {
4855        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4856    }
4857    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4858
4859    // Create header parameters collection
4860    let mut header_params = std::collections::HashMap::new();
4861
4862    // Handle Binance Auth first if configured
4863    if let Some(ref binance_auth) = configuration.binance_auth {
4864        // Add API key to headers
4865        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4866        
4867        // Generate request body for signing (if any)
4868        let body_string: Option<Vec<u8>> = None;
4869        
4870        // Sign the request
4871        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4872            Ok(sig) => sig,
4873            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4874        };
4875        
4876        // Add signature to query params
4877        query_params.push(("signature".to_string(), signature));
4878    }
4879
4880    // Apply all query parameters
4881    if !query_params.is_empty() {
4882        req_builder = req_builder.query(&query_params);
4883    }
4884
4885
4886    // Add user agent if configured
4887    if let Some(ref user_agent) = configuration.user_agent {
4888        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4889    }
4890
4891    // Apply all header parameters
4892    for (header_name, header_value) in header_params {
4893        req_builder = req_builder.header(&header_name, &header_value);
4894    }
4895
4896
4897    let req = req_builder.build()?;
4898    let resp = configuration.client.execute(req).await?;
4899
4900    let status = resp.status();
4901    let content_type = resp
4902        .headers()
4903        .get("content-type")
4904        .and_then(|v| v.to_str().ok())
4905        .unwrap_or("application/octet-stream");
4906    let content_type = super::ContentType::from(content_type);
4907
4908    if !status.is_client_error() && !status.is_server_error() {
4909        let content = resp.text().await?;
4910        match content_type {
4911            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4912            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PmarginGetBalanceV1Resp`"))),
4913            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PmarginGetBalanceV1Resp`")))),
4914        }
4915    } else {
4916        let content = resp.text().await?;
4917        let entity: Option<GetBalanceV1Error> = serde_json::from_str(&content).ok();
4918        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4919    }
4920}
4921
4922/// Get current CM account asset and position information.
4923pub async fn get_cm_account_v1(configuration: &configuration::Configuration, params: GetCmAccountV1Params) -> Result<models::GetCmAccountV1Resp, Error<GetCmAccountV1Error>> {
4924
4925    let uri_str = format!("{}/papi/v1/cm/account", configuration.base_path);
4926    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4927
4928    // Create a mutable vector for query parameters
4929    let mut query_params: Vec<(String, String)> = Vec::new();
4930
4931    if let Some(ref param_value) = params.recv_window {
4932        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4933    }
4934    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4935
4936    // Create header parameters collection
4937    let mut header_params = std::collections::HashMap::new();
4938
4939    // Handle Binance Auth first if configured
4940    if let Some(ref binance_auth) = configuration.binance_auth {
4941        // Add API key to headers
4942        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4943        
4944        // Generate request body for signing (if any)
4945        let body_string: Option<Vec<u8>> = None;
4946        
4947        // Sign the request
4948        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4949            Ok(sig) => sig,
4950            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4951        };
4952        
4953        // Add signature to query params
4954        query_params.push(("signature".to_string(), signature));
4955    }
4956
4957    // Apply all query parameters
4958    if !query_params.is_empty() {
4959        req_builder = req_builder.query(&query_params);
4960    }
4961
4962
4963    // Add user agent if configured
4964    if let Some(ref user_agent) = configuration.user_agent {
4965        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4966    }
4967
4968    // Apply all header parameters
4969    for (header_name, header_value) in header_params {
4970        req_builder = req_builder.header(&header_name, &header_value);
4971    }
4972
4973
4974    let req = req_builder.build()?;
4975    let resp = configuration.client.execute(req).await?;
4976
4977    let status = resp.status();
4978    let content_type = resp
4979        .headers()
4980        .get("content-type")
4981        .and_then(|v| v.to_str().ok())
4982        .unwrap_or("application/octet-stream");
4983    let content_type = super::ContentType::from(content_type);
4984
4985    if !status.is_client_error() && !status.is_server_error() {
4986        let content = resp.text().await?;
4987        match content_type {
4988            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4989            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCmAccountV1Resp`"))),
4990            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::GetCmAccountV1Resp`")))),
4991        }
4992    } else {
4993        let content = resp.text().await?;
4994        let entity: Option<GetCmAccountV1Error> = serde_json::from_str(&content).ok();
4995        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4996    }
4997}
4998
4999/// Query CM Position ADL Quantile Estimation
5000pub async fn get_cm_adl_quantile_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetCmAdlQuantileV1RespItem>, Error<GetCmAdlQuantileV1Error>> {
5001
5002    let uri_str = format!("{}/papi/v1/cm/adlQuantile", configuration.base_path);
5003    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5004
5005    // Create a mutable vector for query parameters
5006    let mut query_params: Vec<(String, String)> = Vec::new();
5007
5008
5009    // Create header parameters collection
5010    let mut header_params = std::collections::HashMap::new();
5011
5012    // Handle Binance Auth first if configured
5013    if let Some(ref binance_auth) = configuration.binance_auth {
5014        // Add API key to headers
5015        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5016        
5017        // Generate request body for signing (if any)
5018        let body_string: Option<Vec<u8>> = None;
5019        
5020        // Sign the request
5021        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5022            Ok(sig) => sig,
5023            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5024        };
5025        
5026        // Add signature to query params
5027        query_params.push(("signature".to_string(), signature));
5028    }
5029
5030    // Apply all query parameters
5031    if !query_params.is_empty() {
5032        req_builder = req_builder.query(&query_params);
5033    }
5034
5035
5036    // Add user agent if configured
5037    if let Some(ref user_agent) = configuration.user_agent {
5038        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5039    }
5040
5041    // Apply all header parameters
5042    for (header_name, header_value) in header_params {
5043        req_builder = req_builder.header(&header_name, &header_value);
5044    }
5045
5046
5047    let req = req_builder.build()?;
5048    let resp = configuration.client.execute(req).await?;
5049
5050    let status = resp.status();
5051    let content_type = resp
5052        .headers()
5053        .get("content-type")
5054        .and_then(|v| v.to_str().ok())
5055        .unwrap_or("application/octet-stream");
5056    let content_type = super::ContentType::from(content_type);
5057
5058    if !status.is_client_error() && !status.is_server_error() {
5059        let content = resp.text().await?;
5060        match content_type {
5061            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5062            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmAdlQuantileV1RespItem&gt;`"))),
5063            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::GetCmAdlQuantileV1RespItem&gt;`")))),
5064        }
5065    } else {
5066        let content = resp.text().await?;
5067        let entity: Option<GetCmAdlQuantileV1Error> = serde_json::from_str(&content).ok();
5068        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5069    }
5070}
5071
5072/// Get all account CM orders; active, canceled, or filled.
5073pub async fn get_cm_all_orders_v1(configuration: &configuration::Configuration, params: GetCmAllOrdersV1Params) -> Result<Vec<models::GetCmAllOrdersV1RespItem>, Error<GetCmAllOrdersV1Error>> {
5074
5075    let uri_str = format!("{}/papi/v1/cm/allOrders", configuration.base_path);
5076    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5077
5078    // Create a mutable vector for query parameters
5079    let mut query_params: Vec<(String, String)> = Vec::new();
5080
5081    query_params.push(("symbol".to_string(), params.symbol.to_string()));
5082    if let Some(ref param_value) = params.pair {
5083        query_params.push(("pair".to_string(), param_value.to_string()));
5084    }
5085    if let Some(ref param_value) = params.order_id {
5086        query_params.push(("orderId".to_string(), param_value.to_string()));
5087    }
5088    if let Some(ref param_value) = params.start_time {
5089        query_params.push(("startTime".to_string(), param_value.to_string()));
5090    }
5091    if let Some(ref param_value) = params.end_time {
5092        query_params.push(("endTime".to_string(), param_value.to_string()));
5093    }
5094    if let Some(ref param_value) = params.limit {
5095        query_params.push(("limit".to_string(), param_value.to_string()));
5096    }
5097    if let Some(ref param_value) = params.recv_window {
5098        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5099    }
5100    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5101
5102    // Create header parameters collection
5103    let mut header_params = std::collections::HashMap::new();
5104
5105    // Handle Binance Auth first if configured
5106    if let Some(ref binance_auth) = configuration.binance_auth {
5107        // Add API key to headers
5108        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5109        
5110        // Generate request body for signing (if any)
5111        let body_string: Option<Vec<u8>> = None;
5112        
5113        // Sign the request
5114        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5115            Ok(sig) => sig,
5116            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5117        };
5118        
5119        // Add signature to query params
5120        query_params.push(("signature".to_string(), signature));
5121    }
5122
5123    // Apply all query parameters
5124    if !query_params.is_empty() {
5125        req_builder = req_builder.query(&query_params);
5126    }
5127
5128
5129    // Add user agent if configured
5130    if let Some(ref user_agent) = configuration.user_agent {
5131        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5132    }
5133
5134    // Apply all header parameters
5135    for (header_name, header_value) in header_params {
5136        req_builder = req_builder.header(&header_name, &header_value);
5137    }
5138
5139
5140    let req = req_builder.build()?;
5141    let resp = configuration.client.execute(req).await?;
5142
5143    let status = resp.status();
5144    let content_type = resp
5145        .headers()
5146        .get("content-type")
5147        .and_then(|v| v.to_str().ok())
5148        .unwrap_or("application/octet-stream");
5149    let content_type = super::ContentType::from(content_type);
5150
5151    if !status.is_client_error() && !status.is_server_error() {
5152        let content = resp.text().await?;
5153        match content_type {
5154            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5155            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmAllOrdersV1RespItem&gt;`"))),
5156            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::GetCmAllOrdersV1RespItem&gt;`")))),
5157        }
5158    } else {
5159        let content = resp.text().await?;
5160        let entity: Option<GetCmAllOrdersV1Error> = serde_json::from_str(&content).ok();
5161        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5162    }
5163}
5164
5165/// Get User Commission Rate for CM
5166pub async fn get_cm_commission_rate_v1(configuration: &configuration::Configuration, params: GetCmCommissionRateV1Params) -> Result<models::GetCmCommissionRateV1Resp, Error<GetCmCommissionRateV1Error>> {
5167
5168    let uri_str = format!("{}/papi/v1/cm/commissionRate", configuration.base_path);
5169    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5170
5171    // Create a mutable vector for query parameters
5172    let mut query_params: Vec<(String, String)> = Vec::new();
5173
5174    query_params.push(("symbol".to_string(), params.symbol.to_string()));
5175    if let Some(ref param_value) = params.recv_window {
5176        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5177    }
5178    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5179
5180    // Create header parameters collection
5181    let mut header_params = std::collections::HashMap::new();
5182
5183    // Handle Binance Auth first if configured
5184    if let Some(ref binance_auth) = configuration.binance_auth {
5185        // Add API key to headers
5186        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5187        
5188        // Generate request body for signing (if any)
5189        let body_string: Option<Vec<u8>> = None;
5190        
5191        // Sign the request
5192        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5193            Ok(sig) => sig,
5194            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5195        };
5196        
5197        // Add signature to query params
5198        query_params.push(("signature".to_string(), signature));
5199    }
5200
5201    // Apply all query parameters
5202    if !query_params.is_empty() {
5203        req_builder = req_builder.query(&query_params);
5204    }
5205
5206
5207    // Add user agent if configured
5208    if let Some(ref user_agent) = configuration.user_agent {
5209        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5210    }
5211
5212    // Apply all header parameters
5213    for (header_name, header_value) in header_params {
5214        req_builder = req_builder.header(&header_name, &header_value);
5215    }
5216
5217
5218    let req = req_builder.build()?;
5219    let resp = configuration.client.execute(req).await?;
5220
5221    let status = resp.status();
5222    let content_type = resp
5223        .headers()
5224        .get("content-type")
5225        .and_then(|v| v.to_str().ok())
5226        .unwrap_or("application/octet-stream");
5227    let content_type = super::ContentType::from(content_type);
5228
5229    if !status.is_client_error() && !status.is_server_error() {
5230        let content = resp.text().await?;
5231        match content_type {
5232            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5233            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCmCommissionRateV1Resp`"))),
5234            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::GetCmCommissionRateV1Resp`")))),
5235        }
5236    } else {
5237        let content = resp.text().await?;
5238        let entity: Option<GetCmCommissionRateV1Error> = serde_json::from_str(&content).ok();
5239        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5240    }
5241}
5242
5243/// Query All CM Conditional Orders
5244pub async fn get_cm_conditional_all_orders_v1(configuration: &configuration::Configuration, params: GetCmConditionalAllOrdersV1Params) -> Result<Vec<models::GetCmConditionalAllOrdersV1RespItem>, Error<GetCmConditionalAllOrdersV1Error>> {
5245
5246    let uri_str = format!("{}/papi/v1/cm/conditional/allOrders", configuration.base_path);
5247    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5248
5249    // Create a mutable vector for query parameters
5250    let mut query_params: Vec<(String, String)> = Vec::new();
5251
5252    if let Some(ref param_value) = params.symbol {
5253        query_params.push(("symbol".to_string(), param_value.to_string()));
5254    }
5255    if let Some(ref param_value) = params.strategy_id {
5256        query_params.push(("strategyId".to_string(), param_value.to_string()));
5257    }
5258    if let Some(ref param_value) = params.start_time {
5259        query_params.push(("startTime".to_string(), param_value.to_string()));
5260    }
5261    if let Some(ref param_value) = params.end_time {
5262        query_params.push(("endTime".to_string(), param_value.to_string()));
5263    }
5264    if let Some(ref param_value) = params.limit {
5265        query_params.push(("limit".to_string(), param_value.to_string()));
5266    }
5267    if let Some(ref param_value) = params.recv_window {
5268        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5269    }
5270    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5271
5272    // Create header parameters collection
5273    let mut header_params = std::collections::HashMap::new();
5274
5275    // Handle Binance Auth first if configured
5276    if let Some(ref binance_auth) = configuration.binance_auth {
5277        // Add API key to headers
5278        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5279        
5280        // Generate request body for signing (if any)
5281        let body_string: Option<Vec<u8>> = None;
5282        
5283        // Sign the request
5284        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5285            Ok(sig) => sig,
5286            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5287        };
5288        
5289        // Add signature to query params
5290        query_params.push(("signature".to_string(), signature));
5291    }
5292
5293    // Apply all query parameters
5294    if !query_params.is_empty() {
5295        req_builder = req_builder.query(&query_params);
5296    }
5297
5298
5299    // Add user agent if configured
5300    if let Some(ref user_agent) = configuration.user_agent {
5301        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5302    }
5303
5304    // Apply all header parameters
5305    for (header_name, header_value) in header_params {
5306        req_builder = req_builder.header(&header_name, &header_value);
5307    }
5308
5309
5310    let req = req_builder.build()?;
5311    let resp = configuration.client.execute(req).await?;
5312
5313    let status = resp.status();
5314    let content_type = resp
5315        .headers()
5316        .get("content-type")
5317        .and_then(|v| v.to_str().ok())
5318        .unwrap_or("application/octet-stream");
5319    let content_type = super::ContentType::from(content_type);
5320
5321    if !status.is_client_error() && !status.is_server_error() {
5322        let content = resp.text().await?;
5323        match content_type {
5324            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5325            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmConditionalAllOrdersV1RespItem&gt;`"))),
5326            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::GetCmConditionalAllOrdersV1RespItem&gt;`")))),
5327        }
5328    } else {
5329        let content = resp.text().await?;
5330        let entity: Option<GetCmConditionalAllOrdersV1Error> = serde_json::from_str(&content).ok();
5331        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5332    }
5333}
5334
5335/// Query Current CM Open Conditional Order
5336pub async fn get_cm_conditional_open_order_v1(configuration: &configuration::Configuration, params: GetCmConditionalOpenOrderV1Params) -> Result<models::GetCmConditionalOpenOrderV1Resp, Error<GetCmConditionalOpenOrderV1Error>> {
5337
5338    let uri_str = format!("{}/papi/v1/cm/conditional/openOrder", configuration.base_path);
5339    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5340
5341    // Create a mutable vector for query parameters
5342    let mut query_params: Vec<(String, String)> = Vec::new();
5343
5344    query_params.push(("symbol".to_string(), params.symbol.to_string()));
5345    if let Some(ref param_value) = params.strategy_id {
5346        query_params.push(("strategyId".to_string(), param_value.to_string()));
5347    }
5348    if let Some(ref param_value) = params.new_client_strategy_id {
5349        query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
5350    }
5351    if let Some(ref param_value) = params.recv_window {
5352        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5353    }
5354    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5355
5356    // Create header parameters collection
5357    let mut header_params = std::collections::HashMap::new();
5358
5359    // Handle Binance Auth first if configured
5360    if let Some(ref binance_auth) = configuration.binance_auth {
5361        // Add API key to headers
5362        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5363        
5364        // Generate request body for signing (if any)
5365        let body_string: Option<Vec<u8>> = None;
5366        
5367        // Sign the request
5368        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5369            Ok(sig) => sig,
5370            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5371        };
5372        
5373        // Add signature to query params
5374        query_params.push(("signature".to_string(), signature));
5375    }
5376
5377    // Apply all query parameters
5378    if !query_params.is_empty() {
5379        req_builder = req_builder.query(&query_params);
5380    }
5381
5382
5383    // Add user agent if configured
5384    if let Some(ref user_agent) = configuration.user_agent {
5385        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5386    }
5387
5388    // Apply all header parameters
5389    for (header_name, header_value) in header_params {
5390        req_builder = req_builder.header(&header_name, &header_value);
5391    }
5392
5393
5394    let req = req_builder.build()?;
5395    let resp = configuration.client.execute(req).await?;
5396
5397    let status = resp.status();
5398    let content_type = resp
5399        .headers()
5400        .get("content-type")
5401        .and_then(|v| v.to_str().ok())
5402        .unwrap_or("application/octet-stream");
5403    let content_type = super::ContentType::from(content_type);
5404
5405    if !status.is_client_error() && !status.is_server_error() {
5406        let content = resp.text().await?;
5407        match content_type {
5408            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5409            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCmConditionalOpenOrderV1Resp`"))),
5410            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::GetCmConditionalOpenOrderV1Resp`")))),
5411        }
5412    } else {
5413        let content = resp.text().await?;
5414        let entity: Option<GetCmConditionalOpenOrderV1Error> = serde_json::from_str(&content).ok();
5415        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5416    }
5417}
5418
5419/// Get all open conditional orders on a symbol. Careful when accessing this with no symbol.
5420pub async fn get_cm_conditional_open_orders_v1(configuration: &configuration::Configuration, params: GetCmConditionalOpenOrdersV1Params) -> Result<Vec<models::GetCmConditionalOpenOrdersV1RespItem>, Error<GetCmConditionalOpenOrdersV1Error>> {
5421
5422    let uri_str = format!("{}/papi/v1/cm/conditional/openOrders", configuration.base_path);
5423    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5424
5425    // Create a mutable vector for query parameters
5426    let mut query_params: Vec<(String, String)> = Vec::new();
5427
5428    if let Some(ref param_value) = params.symbol {
5429        query_params.push(("symbol".to_string(), param_value.to_string()));
5430    }
5431    if let Some(ref param_value) = params.recv_window {
5432        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5433    }
5434    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5435
5436    // Create header parameters collection
5437    let mut header_params = std::collections::HashMap::new();
5438
5439    // Handle Binance Auth first if configured
5440    if let Some(ref binance_auth) = configuration.binance_auth {
5441        // Add API key to headers
5442        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5443        
5444        // Generate request body for signing (if any)
5445        let body_string: Option<Vec<u8>> = None;
5446        
5447        // Sign the request
5448        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5449            Ok(sig) => sig,
5450            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5451        };
5452        
5453        // Add signature to query params
5454        query_params.push(("signature".to_string(), signature));
5455    }
5456
5457    // Apply all query parameters
5458    if !query_params.is_empty() {
5459        req_builder = req_builder.query(&query_params);
5460    }
5461
5462
5463    // Add user agent if configured
5464    if let Some(ref user_agent) = configuration.user_agent {
5465        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5466    }
5467
5468    // Apply all header parameters
5469    for (header_name, header_value) in header_params {
5470        req_builder = req_builder.header(&header_name, &header_value);
5471    }
5472
5473
5474    let req = req_builder.build()?;
5475    let resp = configuration.client.execute(req).await?;
5476
5477    let status = resp.status();
5478    let content_type = resp
5479        .headers()
5480        .get("content-type")
5481        .and_then(|v| v.to_str().ok())
5482        .unwrap_or("application/octet-stream");
5483    let content_type = super::ContentType::from(content_type);
5484
5485    if !status.is_client_error() && !status.is_server_error() {
5486        let content = resp.text().await?;
5487        match content_type {
5488            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5489            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmConditionalOpenOrdersV1RespItem&gt;`"))),
5490            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::GetCmConditionalOpenOrdersV1RespItem&gt;`")))),
5491        }
5492    } else {
5493        let content = resp.text().await?;
5494        let entity: Option<GetCmConditionalOpenOrdersV1Error> = serde_json::from_str(&content).ok();
5495        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5496    }
5497}
5498
5499/// Query CM Conditional Order History
5500pub async fn get_cm_conditional_order_history_v1(configuration: &configuration::Configuration, params: GetCmConditionalOrderHistoryV1Params) -> Result<models::GetCmConditionalOrderHistoryV1Resp, Error<GetCmConditionalOrderHistoryV1Error>> {
5501
5502    let uri_str = format!("{}/papi/v1/cm/conditional/orderHistory", configuration.base_path);
5503    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5504
5505    // Create a mutable vector for query parameters
5506    let mut query_params: Vec<(String, String)> = Vec::new();
5507
5508    query_params.push(("symbol".to_string(), params.symbol.to_string()));
5509    if let Some(ref param_value) = params.strategy_id {
5510        query_params.push(("strategyId".to_string(), param_value.to_string()));
5511    }
5512    if let Some(ref param_value) = params.new_client_strategy_id {
5513        query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
5514    }
5515    if let Some(ref param_value) = params.recv_window {
5516        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5517    }
5518    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5519
5520    // Create header parameters collection
5521    let mut header_params = std::collections::HashMap::new();
5522
5523    // Handle Binance Auth first if configured
5524    if let Some(ref binance_auth) = configuration.binance_auth {
5525        // Add API key to headers
5526        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5527        
5528        // Generate request body for signing (if any)
5529        let body_string: Option<Vec<u8>> = None;
5530        
5531        // Sign the request
5532        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5533            Ok(sig) => sig,
5534            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5535        };
5536        
5537        // Add signature to query params
5538        query_params.push(("signature".to_string(), signature));
5539    }
5540
5541    // Apply all query parameters
5542    if !query_params.is_empty() {
5543        req_builder = req_builder.query(&query_params);
5544    }
5545
5546
5547    // Add user agent if configured
5548    if let Some(ref user_agent) = configuration.user_agent {
5549        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5550    }
5551
5552    // Apply all header parameters
5553    for (header_name, header_value) in header_params {
5554        req_builder = req_builder.header(&header_name, &header_value);
5555    }
5556
5557
5558    let req = req_builder.build()?;
5559    let resp = configuration.client.execute(req).await?;
5560
5561    let status = resp.status();
5562    let content_type = resp
5563        .headers()
5564        .get("content-type")
5565        .and_then(|v| v.to_str().ok())
5566        .unwrap_or("application/octet-stream");
5567    let content_type = super::ContentType::from(content_type);
5568
5569    if !status.is_client_error() && !status.is_server_error() {
5570        let content = resp.text().await?;
5571        match content_type {
5572            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5573            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCmConditionalOrderHistoryV1Resp`"))),
5574            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::GetCmConditionalOrderHistoryV1Resp`")))),
5575        }
5576    } else {
5577        let content = resp.text().await?;
5578        let entity: Option<GetCmConditionalOrderHistoryV1Error> = serde_json::from_str(&content).ok();
5579        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5580    }
5581}
5582
5583/// Query User's CM Force Orders
5584pub async fn get_cm_force_orders_v1(configuration: &configuration::Configuration, params: GetCmForceOrdersV1Params) -> Result<Vec<models::GetCmForceOrdersV1RespItem>, Error<GetCmForceOrdersV1Error>> {
5585
5586    let uri_str = format!("{}/papi/v1/cm/forceOrders", configuration.base_path);
5587    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5588
5589    // Create a mutable vector for query parameters
5590    let mut query_params: Vec<(String, String)> = Vec::new();
5591
5592    if let Some(ref param_value) = params.symbol {
5593        query_params.push(("symbol".to_string(), param_value.to_string()));
5594    }
5595    if let Some(ref param_value) = params.auto_close_type {
5596        query_params.push(("autoCloseType".to_string(), param_value.to_string()));
5597    }
5598    if let Some(ref param_value) = params.start_time {
5599        query_params.push(("startTime".to_string(), param_value.to_string()));
5600    }
5601    if let Some(ref param_value) = params.end_time {
5602        query_params.push(("endTime".to_string(), param_value.to_string()));
5603    }
5604    if let Some(ref param_value) = params.limit {
5605        query_params.push(("limit".to_string(), param_value.to_string()));
5606    }
5607    if let Some(ref param_value) = params.recv_window {
5608        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5609    }
5610    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5611
5612    // Create header parameters collection
5613    let mut header_params = std::collections::HashMap::new();
5614
5615    // Handle Binance Auth first if configured
5616    if let Some(ref binance_auth) = configuration.binance_auth {
5617        // Add API key to headers
5618        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5619        
5620        // Generate request body for signing (if any)
5621        let body_string: Option<Vec<u8>> = None;
5622        
5623        // Sign the request
5624        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5625            Ok(sig) => sig,
5626            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5627        };
5628        
5629        // Add signature to query params
5630        query_params.push(("signature".to_string(), signature));
5631    }
5632
5633    // Apply all query parameters
5634    if !query_params.is_empty() {
5635        req_builder = req_builder.query(&query_params);
5636    }
5637
5638
5639    // Add user agent if configured
5640    if let Some(ref user_agent) = configuration.user_agent {
5641        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5642    }
5643
5644    // Apply all header parameters
5645    for (header_name, header_value) in header_params {
5646        req_builder = req_builder.header(&header_name, &header_value);
5647    }
5648
5649
5650    let req = req_builder.build()?;
5651    let resp = configuration.client.execute(req).await?;
5652
5653    let status = resp.status();
5654    let content_type = resp
5655        .headers()
5656        .get("content-type")
5657        .and_then(|v| v.to_str().ok())
5658        .unwrap_or("application/octet-stream");
5659    let content_type = super::ContentType::from(content_type);
5660
5661    if !status.is_client_error() && !status.is_server_error() {
5662        let content = resp.text().await?;
5663        match content_type {
5664            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5665            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmForceOrdersV1RespItem&gt;`"))),
5666            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::GetCmForceOrdersV1RespItem&gt;`")))),
5667        }
5668    } else {
5669        let content = resp.text().await?;
5670        let entity: Option<GetCmForceOrdersV1Error> = serde_json::from_str(&content).ok();
5671        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5672    }
5673}
5674
5675/// Get CM Income History
5676pub async fn get_cm_income_v1(configuration: &configuration::Configuration, params: GetCmIncomeV1Params) -> Result<Vec<models::GetCmIncomeV1RespItem>, Error<GetCmIncomeV1Error>> {
5677
5678    let uri_str = format!("{}/papi/v1/cm/income", configuration.base_path);
5679    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5680
5681    // Create a mutable vector for query parameters
5682    let mut query_params: Vec<(String, String)> = Vec::new();
5683
5684    if let Some(ref param_value) = params.symbol {
5685        query_params.push(("symbol".to_string(), param_value.to_string()));
5686    }
5687    if let Some(ref param_value) = params.income_type {
5688        query_params.push(("incomeType".to_string(), param_value.to_string()));
5689    }
5690    if let Some(ref param_value) = params.start_time {
5691        query_params.push(("startTime".to_string(), param_value.to_string()));
5692    }
5693    if let Some(ref param_value) = params.end_time {
5694        query_params.push(("endTime".to_string(), param_value.to_string()));
5695    }
5696    if let Some(ref param_value) = params.page {
5697        query_params.push(("page".to_string(), param_value.to_string()));
5698    }
5699    if let Some(ref param_value) = params.limit {
5700        query_params.push(("limit".to_string(), param_value.to_string()));
5701    }
5702    if let Some(ref param_value) = params.recv_window {
5703        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5704    }
5705    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5706
5707    // Create header parameters collection
5708    let mut header_params = std::collections::HashMap::new();
5709
5710    // Handle Binance Auth first if configured
5711    if let Some(ref binance_auth) = configuration.binance_auth {
5712        // Add API key to headers
5713        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5714        
5715        // Generate request body for signing (if any)
5716        let body_string: Option<Vec<u8>> = None;
5717        
5718        // Sign the request
5719        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5720            Ok(sig) => sig,
5721            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5722        };
5723        
5724        // Add signature to query params
5725        query_params.push(("signature".to_string(), signature));
5726    }
5727
5728    // Apply all query parameters
5729    if !query_params.is_empty() {
5730        req_builder = req_builder.query(&query_params);
5731    }
5732
5733
5734    // Add user agent if configured
5735    if let Some(ref user_agent) = configuration.user_agent {
5736        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5737    }
5738
5739    // Apply all header parameters
5740    for (header_name, header_value) in header_params {
5741        req_builder = req_builder.header(&header_name, &header_value);
5742    }
5743
5744
5745    let req = req_builder.build()?;
5746    let resp = configuration.client.execute(req).await?;
5747
5748    let status = resp.status();
5749    let content_type = resp
5750        .headers()
5751        .get("content-type")
5752        .and_then(|v| v.to_str().ok())
5753        .unwrap_or("application/octet-stream");
5754    let content_type = super::ContentType::from(content_type);
5755
5756    if !status.is_client_error() && !status.is_server_error() {
5757        let content = resp.text().await?;
5758        match content_type {
5759            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5760            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmIncomeV1RespItem&gt;`"))),
5761            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::GetCmIncomeV1RespItem&gt;`")))),
5762        }
5763    } else {
5764        let content = resp.text().await?;
5765        let entity: Option<GetCmIncomeV1Error> = serde_json::from_str(&content).ok();
5766        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5767    }
5768}
5769
5770/// Query CM notional and leverage brackets
5771pub async fn get_cm_leverage_bracket_v1(configuration: &configuration::Configuration, params: GetCmLeverageBracketV1Params) -> Result<Vec<models::GetCmLeverageBracketV1RespItem>, Error<GetCmLeverageBracketV1Error>> {
5772
5773    let uri_str = format!("{}/papi/v1/cm/leverageBracket", configuration.base_path);
5774    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5775
5776    // Create a mutable vector for query parameters
5777    let mut query_params: Vec<(String, String)> = Vec::new();
5778
5779    if let Some(ref param_value) = params.symbol {
5780        query_params.push(("symbol".to_string(), param_value.to_string()));
5781    }
5782    if let Some(ref param_value) = params.recv_window {
5783        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5784    }
5785    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5786
5787    // Create header parameters collection
5788    let mut header_params = std::collections::HashMap::new();
5789
5790    // Handle Binance Auth first if configured
5791    if let Some(ref binance_auth) = configuration.binance_auth {
5792        // Add API key to headers
5793        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5794        
5795        // Generate request body for signing (if any)
5796        let body_string: Option<Vec<u8>> = None;
5797        
5798        // Sign the request
5799        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5800            Ok(sig) => sig,
5801            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5802        };
5803        
5804        // Add signature to query params
5805        query_params.push(("signature".to_string(), signature));
5806    }
5807
5808    // Apply all query parameters
5809    if !query_params.is_empty() {
5810        req_builder = req_builder.query(&query_params);
5811    }
5812
5813
5814    // Add user agent if configured
5815    if let Some(ref user_agent) = configuration.user_agent {
5816        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5817    }
5818
5819    // Apply all header parameters
5820    for (header_name, header_value) in header_params {
5821        req_builder = req_builder.header(&header_name, &header_value);
5822    }
5823
5824
5825    let req = req_builder.build()?;
5826    let resp = configuration.client.execute(req).await?;
5827
5828    let status = resp.status();
5829    let content_type = resp
5830        .headers()
5831        .get("content-type")
5832        .and_then(|v| v.to_str().ok())
5833        .unwrap_or("application/octet-stream");
5834    let content_type = super::ContentType::from(content_type);
5835
5836    if !status.is_client_error() && !status.is_server_error() {
5837        let content = resp.text().await?;
5838        match content_type {
5839            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5840            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmLeverageBracketV1RespItem&gt;`"))),
5841            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::GetCmLeverageBracketV1RespItem&gt;`")))),
5842        }
5843    } else {
5844        let content = resp.text().await?;
5845        let entity: Option<GetCmLeverageBracketV1Error> = serde_json::from_str(&content).ok();
5846        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5847    }
5848}
5849
5850/// Query current CM open order
5851pub async fn get_cm_open_order_v1(configuration: &configuration::Configuration, params: GetCmOpenOrderV1Params) -> Result<models::GetCmOpenOrderV1Resp, Error<GetCmOpenOrderV1Error>> {
5852
5853    let uri_str = format!("{}/papi/v1/cm/openOrder", configuration.base_path);
5854    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5855
5856    // Create a mutable vector for query parameters
5857    let mut query_params: Vec<(String, String)> = Vec::new();
5858
5859    query_params.push(("symbol".to_string(), params.symbol.to_string()));
5860    if let Some(ref param_value) = params.order_id {
5861        query_params.push(("orderId".to_string(), param_value.to_string()));
5862    }
5863    if let Some(ref param_value) = params.orig_client_order_id {
5864        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
5865    }
5866    if let Some(ref param_value) = params.recv_window {
5867        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5868    }
5869    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5870
5871    // Create header parameters collection
5872    let mut header_params = std::collections::HashMap::new();
5873
5874    // Handle Binance Auth first if configured
5875    if let Some(ref binance_auth) = configuration.binance_auth {
5876        // Add API key to headers
5877        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5878        
5879        // Generate request body for signing (if any)
5880        let body_string: Option<Vec<u8>> = None;
5881        
5882        // Sign the request
5883        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5884            Ok(sig) => sig,
5885            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5886        };
5887        
5888        // Add signature to query params
5889        query_params.push(("signature".to_string(), signature));
5890    }
5891
5892    // Apply all query parameters
5893    if !query_params.is_empty() {
5894        req_builder = req_builder.query(&query_params);
5895    }
5896
5897
5898    // Add user agent if configured
5899    if let Some(ref user_agent) = configuration.user_agent {
5900        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5901    }
5902
5903    // Apply all header parameters
5904    for (header_name, header_value) in header_params {
5905        req_builder = req_builder.header(&header_name, &header_value);
5906    }
5907
5908
5909    let req = req_builder.build()?;
5910    let resp = configuration.client.execute(req).await?;
5911
5912    let status = resp.status();
5913    let content_type = resp
5914        .headers()
5915        .get("content-type")
5916        .and_then(|v| v.to_str().ok())
5917        .unwrap_or("application/octet-stream");
5918    let content_type = super::ContentType::from(content_type);
5919
5920    if !status.is_client_error() && !status.is_server_error() {
5921        let content = resp.text().await?;
5922        match content_type {
5923            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
5924            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCmOpenOrderV1Resp`"))),
5925            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::GetCmOpenOrderV1Resp`")))),
5926        }
5927    } else {
5928        let content = resp.text().await?;
5929        let entity: Option<GetCmOpenOrderV1Error> = serde_json::from_str(&content).ok();
5930        Err(Error::ResponseError(ResponseContent { status, content, entity }))
5931    }
5932}
5933
5934/// Get all open orders on a symbol.
5935pub async fn get_cm_open_orders_v1(configuration: &configuration::Configuration, params: GetCmOpenOrdersV1Params) -> Result<Vec<models::GetCmOpenOrdersV1RespItem>, Error<GetCmOpenOrdersV1Error>> {
5936
5937    let uri_str = format!("{}/papi/v1/cm/openOrders", configuration.base_path);
5938    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
5939
5940    // Create a mutable vector for query parameters
5941    let mut query_params: Vec<(String, String)> = Vec::new();
5942
5943    if let Some(ref param_value) = params.symbol {
5944        query_params.push(("symbol".to_string(), param_value.to_string()));
5945    }
5946    if let Some(ref param_value) = params.pair {
5947        query_params.push(("pair".to_string(), param_value.to_string()));
5948    }
5949    if let Some(ref param_value) = params.recv_window {
5950        query_params.push(("recvWindow".to_string(), param_value.to_string()));
5951    }
5952    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
5953
5954    // Create header parameters collection
5955    let mut header_params = std::collections::HashMap::new();
5956
5957    // Handle Binance Auth first if configured
5958    if let Some(ref binance_auth) = configuration.binance_auth {
5959        // Add API key to headers
5960        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
5961        
5962        // Generate request body for signing (if any)
5963        let body_string: Option<Vec<u8>> = None;
5964        
5965        // Sign the request
5966        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
5967            Ok(sig) => sig,
5968            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
5969        };
5970        
5971        // Add signature to query params
5972        query_params.push(("signature".to_string(), signature));
5973    }
5974
5975    // Apply all query parameters
5976    if !query_params.is_empty() {
5977        req_builder = req_builder.query(&query_params);
5978    }
5979
5980
5981    // Add user agent if configured
5982    if let Some(ref user_agent) = configuration.user_agent {
5983        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
5984    }
5985
5986    // Apply all header parameters
5987    for (header_name, header_value) in header_params {
5988        req_builder = req_builder.header(&header_name, &header_value);
5989    }
5990
5991
5992    let req = req_builder.build()?;
5993    let resp = configuration.client.execute(req).await?;
5994
5995    let status = resp.status();
5996    let content_type = resp
5997        .headers()
5998        .get("content-type")
5999        .and_then(|v| v.to_str().ok())
6000        .unwrap_or("application/octet-stream");
6001    let content_type = super::ContentType::from(content_type);
6002
6003    if !status.is_client_error() && !status.is_server_error() {
6004        let content = resp.text().await?;
6005        match content_type {
6006            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6007            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmOpenOrdersV1RespItem&gt;`"))),
6008            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::GetCmOpenOrdersV1RespItem&gt;`")))),
6009        }
6010    } else {
6011        let content = resp.text().await?;
6012        let entity: Option<GetCmOpenOrdersV1Error> = serde_json::from_str(&content).ok();
6013        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6014    }
6015}
6016
6017/// Get order modification history
6018pub async fn get_cm_order_amendment_v1(configuration: &configuration::Configuration, params: GetCmOrderAmendmentV1Params) -> Result<Vec<models::GetCmOrderAmendmentV1RespItem>, Error<GetCmOrderAmendmentV1Error>> {
6019
6020    let uri_str = format!("{}/papi/v1/cm/orderAmendment", configuration.base_path);
6021    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6022
6023    // Create a mutable vector for query parameters
6024    let mut query_params: Vec<(String, String)> = Vec::new();
6025
6026    query_params.push(("symbol".to_string(), params.symbol.to_string()));
6027    if let Some(ref param_value) = params.order_id {
6028        query_params.push(("orderId".to_string(), param_value.to_string()));
6029    }
6030    if let Some(ref param_value) = params.orig_client_order_id {
6031        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
6032    }
6033    if let Some(ref param_value) = params.start_time {
6034        query_params.push(("startTime".to_string(), param_value.to_string()));
6035    }
6036    if let Some(ref param_value) = params.end_time {
6037        query_params.push(("endTime".to_string(), param_value.to_string()));
6038    }
6039    if let Some(ref param_value) = params.limit {
6040        query_params.push(("limit".to_string(), param_value.to_string()));
6041    }
6042    if let Some(ref param_value) = params.recv_window {
6043        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6044    }
6045    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6046
6047    // Create header parameters collection
6048    let mut header_params = std::collections::HashMap::new();
6049
6050    // Handle Binance Auth first if configured
6051    if let Some(ref binance_auth) = configuration.binance_auth {
6052        // Add API key to headers
6053        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6054        
6055        // Generate request body for signing (if any)
6056        let body_string: Option<Vec<u8>> = None;
6057        
6058        // Sign the request
6059        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6060            Ok(sig) => sig,
6061            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6062        };
6063        
6064        // Add signature to query params
6065        query_params.push(("signature".to_string(), signature));
6066    }
6067
6068    // Apply all query parameters
6069    if !query_params.is_empty() {
6070        req_builder = req_builder.query(&query_params);
6071    }
6072
6073
6074    // Add user agent if configured
6075    if let Some(ref user_agent) = configuration.user_agent {
6076        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6077    }
6078
6079    // Apply all header parameters
6080    for (header_name, header_value) in header_params {
6081        req_builder = req_builder.header(&header_name, &header_value);
6082    }
6083
6084
6085    let req = req_builder.build()?;
6086    let resp = configuration.client.execute(req).await?;
6087
6088    let status = resp.status();
6089    let content_type = resp
6090        .headers()
6091        .get("content-type")
6092        .and_then(|v| v.to_str().ok())
6093        .unwrap_or("application/octet-stream");
6094    let content_type = super::ContentType::from(content_type);
6095
6096    if !status.is_client_error() && !status.is_server_error() {
6097        let content = resp.text().await?;
6098        match content_type {
6099            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6100            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmOrderAmendmentV1RespItem&gt;`"))),
6101            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::GetCmOrderAmendmentV1RespItem&gt;`")))),
6102        }
6103    } else {
6104        let content = resp.text().await?;
6105        let entity: Option<GetCmOrderAmendmentV1Error> = serde_json::from_str(&content).ok();
6106        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6107    }
6108}
6109
6110/// Check an CM order's status.
6111pub async fn get_cm_order_v1(configuration: &configuration::Configuration, params: GetCmOrderV1Params) -> Result<models::GetCmOrderV1Resp, Error<GetCmOrderV1Error>> {
6112
6113    let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
6114    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6115
6116    // Create a mutable vector for query parameters
6117    let mut query_params: Vec<(String, String)> = Vec::new();
6118
6119    query_params.push(("symbol".to_string(), params.symbol.to_string()));
6120    if let Some(ref param_value) = params.order_id {
6121        query_params.push(("orderId".to_string(), param_value.to_string()));
6122    }
6123    if let Some(ref param_value) = params.orig_client_order_id {
6124        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
6125    }
6126    if let Some(ref param_value) = params.recv_window {
6127        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6128    }
6129    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6130
6131    // Create header parameters collection
6132    let mut header_params = std::collections::HashMap::new();
6133
6134    // Handle Binance Auth first if configured
6135    if let Some(ref binance_auth) = configuration.binance_auth {
6136        // Add API key to headers
6137        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6138        
6139        // Generate request body for signing (if any)
6140        let body_string: Option<Vec<u8>> = None;
6141        
6142        // Sign the request
6143        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6144            Ok(sig) => sig,
6145            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6146        };
6147        
6148        // Add signature to query params
6149        query_params.push(("signature".to_string(), signature));
6150    }
6151
6152    // Apply all query parameters
6153    if !query_params.is_empty() {
6154        req_builder = req_builder.query(&query_params);
6155    }
6156
6157
6158    // Add user agent if configured
6159    if let Some(ref user_agent) = configuration.user_agent {
6160        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6161    }
6162
6163    // Apply all header parameters
6164    for (header_name, header_value) in header_params {
6165        req_builder = req_builder.header(&header_name, &header_value);
6166    }
6167
6168
6169    let req = req_builder.build()?;
6170    let resp = configuration.client.execute(req).await?;
6171
6172    let status = resp.status();
6173    let content_type = resp
6174        .headers()
6175        .get("content-type")
6176        .and_then(|v| v.to_str().ok())
6177        .unwrap_or("application/octet-stream");
6178    let content_type = super::ContentType::from(content_type);
6179
6180    if !status.is_client_error() && !status.is_server_error() {
6181        let content = resp.text().await?;
6182        match content_type {
6183            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6184            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCmOrderV1Resp`"))),
6185            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::GetCmOrderV1Resp`")))),
6186        }
6187    } else {
6188        let content = resp.text().await?;
6189        let entity: Option<GetCmOrderV1Error> = serde_json::from_str(&content).ok();
6190        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6191    }
6192}
6193
6194/// Get current CM position information.
6195pub async fn get_cm_position_risk_v1(configuration: &configuration::Configuration, params: GetCmPositionRiskV1Params) -> Result<Vec<models::GetCmPositionRiskV1RespItem>, Error<GetCmPositionRiskV1Error>> {
6196
6197    let uri_str = format!("{}/papi/v1/cm/positionRisk", configuration.base_path);
6198    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6199
6200    // Create a mutable vector for query parameters
6201    let mut query_params: Vec<(String, String)> = Vec::new();
6202
6203    if let Some(ref param_value) = params.margin_asset {
6204        query_params.push(("marginAsset".to_string(), param_value.to_string()));
6205    }
6206    if let Some(ref param_value) = params.pair {
6207        query_params.push(("pair".to_string(), param_value.to_string()));
6208    }
6209    if let Some(ref param_value) = params.recv_window {
6210        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6211    }
6212    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6213
6214    // Create header parameters collection
6215    let mut header_params = std::collections::HashMap::new();
6216
6217    // Handle Binance Auth first if configured
6218    if let Some(ref binance_auth) = configuration.binance_auth {
6219        // Add API key to headers
6220        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6221        
6222        // Generate request body for signing (if any)
6223        let body_string: Option<Vec<u8>> = None;
6224        
6225        // Sign the request
6226        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6227            Ok(sig) => sig,
6228            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6229        };
6230        
6231        // Add signature to query params
6232        query_params.push(("signature".to_string(), signature));
6233    }
6234
6235    // Apply all query parameters
6236    if !query_params.is_empty() {
6237        req_builder = req_builder.query(&query_params);
6238    }
6239
6240
6241    // Add user agent if configured
6242    if let Some(ref user_agent) = configuration.user_agent {
6243        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6244    }
6245
6246    // Apply all header parameters
6247    for (header_name, header_value) in header_params {
6248        req_builder = req_builder.header(&header_name, &header_value);
6249    }
6250
6251
6252    let req = req_builder.build()?;
6253    let resp = configuration.client.execute(req).await?;
6254
6255    let status = resp.status();
6256    let content_type = resp
6257        .headers()
6258        .get("content-type")
6259        .and_then(|v| v.to_str().ok())
6260        .unwrap_or("application/octet-stream");
6261    let content_type = super::ContentType::from(content_type);
6262
6263    if !status.is_client_error() && !status.is_server_error() {
6264        let content = resp.text().await?;
6265        match content_type {
6266            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6267            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmPositionRiskV1RespItem&gt;`"))),
6268            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::GetCmPositionRiskV1RespItem&gt;`")))),
6269        }
6270    } else {
6271        let content = resp.text().await?;
6272        let entity: Option<GetCmPositionRiskV1Error> = serde_json::from_str(&content).ok();
6273        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6274    }
6275}
6276
6277/// Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in CM
6278pub async fn get_cm_position_side_dual_v1(configuration: &configuration::Configuration, params: GetCmPositionSideDualV1Params) -> Result<models::GetCmPositionSideDualV1Resp, Error<GetCmPositionSideDualV1Error>> {
6279
6280    let uri_str = format!("{}/papi/v1/cm/positionSide/dual", configuration.base_path);
6281    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6282
6283    // Create a mutable vector for query parameters
6284    let mut query_params: Vec<(String, String)> = Vec::new();
6285
6286    if let Some(ref param_value) = params.recv_window {
6287        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6288    }
6289    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6290
6291    // Create header parameters collection
6292    let mut header_params = std::collections::HashMap::new();
6293
6294    // Handle Binance Auth first if configured
6295    if let Some(ref binance_auth) = configuration.binance_auth {
6296        // Add API key to headers
6297        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6298        
6299        // Generate request body for signing (if any)
6300        let body_string: Option<Vec<u8>> = None;
6301        
6302        // Sign the request
6303        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6304            Ok(sig) => sig,
6305            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6306        };
6307        
6308        // Add signature to query params
6309        query_params.push(("signature".to_string(), signature));
6310    }
6311
6312    // Apply all query parameters
6313    if !query_params.is_empty() {
6314        req_builder = req_builder.query(&query_params);
6315    }
6316
6317
6318    // Add user agent if configured
6319    if let Some(ref user_agent) = configuration.user_agent {
6320        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6321    }
6322
6323    // Apply all header parameters
6324    for (header_name, header_value) in header_params {
6325        req_builder = req_builder.header(&header_name, &header_value);
6326    }
6327
6328
6329    let req = req_builder.build()?;
6330    let resp = configuration.client.execute(req).await?;
6331
6332    let status = resp.status();
6333    let content_type = resp
6334        .headers()
6335        .get("content-type")
6336        .and_then(|v| v.to_str().ok())
6337        .unwrap_or("application/octet-stream");
6338    let content_type = super::ContentType::from(content_type);
6339
6340    if !status.is_client_error() && !status.is_server_error() {
6341        let content = resp.text().await?;
6342        match content_type {
6343            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6344            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCmPositionSideDualV1Resp`"))),
6345            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::GetCmPositionSideDualV1Resp`")))),
6346        }
6347    } else {
6348        let content = resp.text().await?;
6349        let entity: Option<GetCmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
6350        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6351    }
6352}
6353
6354/// Get trades for a specific account and CM symbol.
6355pub async fn get_cm_user_trades_v1(configuration: &configuration::Configuration, params: GetCmUserTradesV1Params) -> Result<Vec<models::GetCmUserTradesV1RespItem>, Error<GetCmUserTradesV1Error>> {
6356
6357    let uri_str = format!("{}/papi/v1/cm/userTrades", configuration.base_path);
6358    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6359
6360    // Create a mutable vector for query parameters
6361    let mut query_params: Vec<(String, String)> = Vec::new();
6362
6363    if let Some(ref param_value) = params.symbol {
6364        query_params.push(("symbol".to_string(), param_value.to_string()));
6365    }
6366    if let Some(ref param_value) = params.pair {
6367        query_params.push(("pair".to_string(), param_value.to_string()));
6368    }
6369    if let Some(ref param_value) = params.start_time {
6370        query_params.push(("startTime".to_string(), param_value.to_string()));
6371    }
6372    if let Some(ref param_value) = params.end_time {
6373        query_params.push(("endTime".to_string(), param_value.to_string()));
6374    }
6375    if let Some(ref param_value) = params.from_id {
6376        query_params.push(("fromId".to_string(), param_value.to_string()));
6377    }
6378    if let Some(ref param_value) = params.limit {
6379        query_params.push(("limit".to_string(), param_value.to_string()));
6380    }
6381    if let Some(ref param_value) = params.recv_window {
6382        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6383    }
6384    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6385
6386    // Create header parameters collection
6387    let mut header_params = std::collections::HashMap::new();
6388
6389    // Handle Binance Auth first if configured
6390    if let Some(ref binance_auth) = configuration.binance_auth {
6391        // Add API key to headers
6392        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6393        
6394        // Generate request body for signing (if any)
6395        let body_string: Option<Vec<u8>> = None;
6396        
6397        // Sign the request
6398        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6399            Ok(sig) => sig,
6400            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6401        };
6402        
6403        // Add signature to query params
6404        query_params.push(("signature".to_string(), signature));
6405    }
6406
6407    // Apply all query parameters
6408    if !query_params.is_empty() {
6409        req_builder = req_builder.query(&query_params);
6410    }
6411
6412
6413    // Add user agent if configured
6414    if let Some(ref user_agent) = configuration.user_agent {
6415        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6416    }
6417
6418    // Apply all header parameters
6419    for (header_name, header_value) in header_params {
6420        req_builder = req_builder.header(&header_name, &header_value);
6421    }
6422
6423
6424    let req = req_builder.build()?;
6425    let resp = configuration.client.execute(req).await?;
6426
6427    let status = resp.status();
6428    let content_type = resp
6429        .headers()
6430        .get("content-type")
6431        .and_then(|v| v.to_str().ok())
6432        .unwrap_or("application/octet-stream");
6433    let content_type = super::ContentType::from(content_type);
6434
6435    if !status.is_client_error() && !status.is_server_error() {
6436        let content = resp.text().await?;
6437        match content_type {
6438            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6439            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetCmUserTradesV1RespItem&gt;`"))),
6440            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::GetCmUserTradesV1RespItem&gt;`")))),
6441        }
6442    } else {
6443        let content = resp.text().await?;
6444        let entity: Option<GetCmUserTradesV1Error> = serde_json::from_str(&content).ok();
6445        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6446    }
6447}
6448
6449/// Query all OCO for a specific margin account based on provided optional parameters
6450pub async fn get_margin_all_order_list_v1(configuration: &configuration::Configuration, params: GetMarginAllOrderListV1Params) -> Result<Vec<models::GetMarginAllOrderListV1RespItem>, Error<GetMarginAllOrderListV1Error>> {
6451
6452    let uri_str = format!("{}/papi/v1/margin/allOrderList", configuration.base_path);
6453    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6454
6455    // Create a mutable vector for query parameters
6456    let mut query_params: Vec<(String, String)> = Vec::new();
6457
6458    if let Some(ref param_value) = params.from_id {
6459        query_params.push(("fromId".to_string(), param_value.to_string()));
6460    }
6461    if let Some(ref param_value) = params.start_time {
6462        query_params.push(("startTime".to_string(), param_value.to_string()));
6463    }
6464    if let Some(ref param_value) = params.end_time {
6465        query_params.push(("endTime".to_string(), param_value.to_string()));
6466    }
6467    if let Some(ref param_value) = params.limit {
6468        query_params.push(("limit".to_string(), param_value.to_string()));
6469    }
6470    if let Some(ref param_value) = params.recv_window {
6471        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6472    }
6473    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6474
6475    // Create header parameters collection
6476    let mut header_params = std::collections::HashMap::new();
6477
6478    // Handle Binance Auth first if configured
6479    if let Some(ref binance_auth) = configuration.binance_auth {
6480        // Add API key to headers
6481        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6482        
6483        // Generate request body for signing (if any)
6484        let body_string: Option<Vec<u8>> = None;
6485        
6486        // Sign the request
6487        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6488            Ok(sig) => sig,
6489            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6490        };
6491        
6492        // Add signature to query params
6493        query_params.push(("signature".to_string(), signature));
6494    }
6495
6496    // Apply all query parameters
6497    if !query_params.is_empty() {
6498        req_builder = req_builder.query(&query_params);
6499    }
6500
6501
6502    // Add user agent if configured
6503    if let Some(ref user_agent) = configuration.user_agent {
6504        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6505    }
6506
6507    // Apply all header parameters
6508    for (header_name, header_value) in header_params {
6509        req_builder = req_builder.header(&header_name, &header_value);
6510    }
6511
6512
6513    let req = req_builder.build()?;
6514    let resp = configuration.client.execute(req).await?;
6515
6516    let status = resp.status();
6517    let content_type = resp
6518        .headers()
6519        .get("content-type")
6520        .and_then(|v| v.to_str().ok())
6521        .unwrap_or("application/octet-stream");
6522    let content_type = super::ContentType::from(content_type);
6523
6524    if !status.is_client_error() && !status.is_server_error() {
6525        let content = resp.text().await?;
6526        match content_type {
6527            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6528            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMarginAllOrderListV1RespItem&gt;`"))),
6529            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::GetMarginAllOrderListV1RespItem&gt;`")))),
6530        }
6531    } else {
6532        let content = resp.text().await?;
6533        let entity: Option<GetMarginAllOrderListV1Error> = serde_json::from_str(&content).ok();
6534        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6535    }
6536}
6537
6538/// Query All Margin Account Orders
6539pub async fn get_margin_all_orders_v1(configuration: &configuration::Configuration, params: GetMarginAllOrdersV1Params) -> Result<Vec<models::GetMarginAllOrdersV1RespItem>, Error<GetMarginAllOrdersV1Error>> {
6540
6541    let uri_str = format!("{}/papi/v1/margin/allOrders", configuration.base_path);
6542    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6543
6544    // Create a mutable vector for query parameters
6545    let mut query_params: Vec<(String, String)> = Vec::new();
6546
6547    query_params.push(("symbol".to_string(), params.symbol.to_string()));
6548    if let Some(ref param_value) = params.order_id {
6549        query_params.push(("orderId".to_string(), param_value.to_string()));
6550    }
6551    if let Some(ref param_value) = params.start_time {
6552        query_params.push(("startTime".to_string(), param_value.to_string()));
6553    }
6554    if let Some(ref param_value) = params.end_time {
6555        query_params.push(("endTime".to_string(), param_value.to_string()));
6556    }
6557    if let Some(ref param_value) = params.limit {
6558        query_params.push(("limit".to_string(), param_value.to_string()));
6559    }
6560    if let Some(ref param_value) = params.recv_window {
6561        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6562    }
6563    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6564
6565    // Create header parameters collection
6566    let mut header_params = std::collections::HashMap::new();
6567
6568    // Handle Binance Auth first if configured
6569    if let Some(ref binance_auth) = configuration.binance_auth {
6570        // Add API key to headers
6571        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6572        
6573        // Generate request body for signing (if any)
6574        let body_string: Option<Vec<u8>> = None;
6575        
6576        // Sign the request
6577        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6578            Ok(sig) => sig,
6579            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6580        };
6581        
6582        // Add signature to query params
6583        query_params.push(("signature".to_string(), signature));
6584    }
6585
6586    // Apply all query parameters
6587    if !query_params.is_empty() {
6588        req_builder = req_builder.query(&query_params);
6589    }
6590
6591
6592    // Add user agent if configured
6593    if let Some(ref user_agent) = configuration.user_agent {
6594        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6595    }
6596
6597    // Apply all header parameters
6598    for (header_name, header_value) in header_params {
6599        req_builder = req_builder.header(&header_name, &header_value);
6600    }
6601
6602
6603    let req = req_builder.build()?;
6604    let resp = configuration.client.execute(req).await?;
6605
6606    let status = resp.status();
6607    let content_type = resp
6608        .headers()
6609        .get("content-type")
6610        .and_then(|v| v.to_str().ok())
6611        .unwrap_or("application/octet-stream");
6612    let content_type = super::ContentType::from(content_type);
6613
6614    if !status.is_client_error() && !status.is_server_error() {
6615        let content = resp.text().await?;
6616        match content_type {
6617            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6618            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMarginAllOrdersV1RespItem&gt;`"))),
6619            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::GetMarginAllOrdersV1RespItem&gt;`")))),
6620        }
6621    } else {
6622        let content = resp.text().await?;
6623        let entity: Option<GetMarginAllOrdersV1Error> = serde_json::from_str(&content).ok();
6624        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6625    }
6626}
6627
6628/// Query user's margin force orders
6629pub async fn get_margin_force_orders_v1(configuration: &configuration::Configuration, params: GetMarginForceOrdersV1Params) -> Result<models::GetMarginForceOrdersV1Resp, Error<GetMarginForceOrdersV1Error>> {
6630
6631    let uri_str = format!("{}/papi/v1/margin/forceOrders", configuration.base_path);
6632    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6633
6634    // Create a mutable vector for query parameters
6635    let mut query_params: Vec<(String, String)> = Vec::new();
6636
6637    if let Some(ref param_value) = params.start_time {
6638        query_params.push(("startTime".to_string(), param_value.to_string()));
6639    }
6640    if let Some(ref param_value) = params.end_time {
6641        query_params.push(("endTime".to_string(), param_value.to_string()));
6642    }
6643    if let Some(ref param_value) = params.current {
6644        query_params.push(("current".to_string(), param_value.to_string()));
6645    }
6646    if let Some(ref param_value) = params.size {
6647        query_params.push(("size".to_string(), param_value.to_string()));
6648    }
6649    if let Some(ref param_value) = params.recv_window {
6650        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6651    }
6652    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6653
6654    // Create header parameters collection
6655    let mut header_params = std::collections::HashMap::new();
6656
6657    // Handle Binance Auth first if configured
6658    if let Some(ref binance_auth) = configuration.binance_auth {
6659        // Add API key to headers
6660        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6661        
6662        // Generate request body for signing (if any)
6663        let body_string: Option<Vec<u8>> = None;
6664        
6665        // Sign the request
6666        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6667            Ok(sig) => sig,
6668            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6669        };
6670        
6671        // Add signature to query params
6672        query_params.push(("signature".to_string(), signature));
6673    }
6674
6675    // Apply all query parameters
6676    if !query_params.is_empty() {
6677        req_builder = req_builder.query(&query_params);
6678    }
6679
6680
6681    // Add user agent if configured
6682    if let Some(ref user_agent) = configuration.user_agent {
6683        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6684    }
6685
6686    // Apply all header parameters
6687    for (header_name, header_value) in header_params {
6688        req_builder = req_builder.header(&header_name, &header_value);
6689    }
6690
6691
6692    let req = req_builder.build()?;
6693    let resp = configuration.client.execute(req).await?;
6694
6695    let status = resp.status();
6696    let content_type = resp
6697        .headers()
6698        .get("content-type")
6699        .and_then(|v| v.to_str().ok())
6700        .unwrap_or("application/octet-stream");
6701    let content_type = super::ContentType::from(content_type);
6702
6703    if !status.is_client_error() && !status.is_server_error() {
6704        let content = resp.text().await?;
6705        match content_type {
6706            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6707            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginForceOrdersV1Resp`"))),
6708            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::GetMarginForceOrdersV1Resp`")))),
6709        }
6710    } else {
6711        let content = resp.text().await?;
6712        let entity: Option<GetMarginForceOrdersV1Error> = serde_json::from_str(&content).ok();
6713        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6714    }
6715}
6716
6717/// Get Margin Borrow/Loan Interest History
6718pub async fn get_margin_margin_interest_history_v1(configuration: &configuration::Configuration, params: GetMarginMarginInterestHistoryV1Params) -> Result<models::GetMarginMarginInterestHistoryV1Resp, Error<GetMarginMarginInterestHistoryV1Error>> {
6719
6720    let uri_str = format!("{}/papi/v1/margin/marginInterestHistory", configuration.base_path);
6721    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6722
6723    // Create a mutable vector for query parameters
6724    let mut query_params: Vec<(String, String)> = Vec::new();
6725
6726    if let Some(ref param_value) = params.asset {
6727        query_params.push(("asset".to_string(), param_value.to_string()));
6728    }
6729    if let Some(ref param_value) = params.start_time {
6730        query_params.push(("startTime".to_string(), param_value.to_string()));
6731    }
6732    if let Some(ref param_value) = params.end_time {
6733        query_params.push(("endTime".to_string(), param_value.to_string()));
6734    }
6735    if let Some(ref param_value) = params.current {
6736        query_params.push(("current".to_string(), param_value.to_string()));
6737    }
6738    if let Some(ref param_value) = params.size {
6739        query_params.push(("size".to_string(), param_value.to_string()));
6740    }
6741    if let Some(ref param_value) = params.archived {
6742        query_params.push(("archived".to_string(), param_value.to_string()));
6743    }
6744    if let Some(ref param_value) = params.recv_window {
6745        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6746    }
6747    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6748
6749    // Create header parameters collection
6750    let mut header_params = std::collections::HashMap::new();
6751
6752    // Handle Binance Auth first if configured
6753    if let Some(ref binance_auth) = configuration.binance_auth {
6754        // Add API key to headers
6755        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6756        
6757        // Generate request body for signing (if any)
6758        let body_string: Option<Vec<u8>> = None;
6759        
6760        // Sign the request
6761        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6762            Ok(sig) => sig,
6763            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6764        };
6765        
6766        // Add signature to query params
6767        query_params.push(("signature".to_string(), signature));
6768    }
6769
6770    // Apply all query parameters
6771    if !query_params.is_empty() {
6772        req_builder = req_builder.query(&query_params);
6773    }
6774
6775
6776    // Add user agent if configured
6777    if let Some(ref user_agent) = configuration.user_agent {
6778        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6779    }
6780
6781    // Apply all header parameters
6782    for (header_name, header_value) in header_params {
6783        req_builder = req_builder.header(&header_name, &header_value);
6784    }
6785
6786
6787    let req = req_builder.build()?;
6788    let resp = configuration.client.execute(req).await?;
6789
6790    let status = resp.status();
6791    let content_type = resp
6792        .headers()
6793        .get("content-type")
6794        .and_then(|v| v.to_str().ok())
6795        .unwrap_or("application/octet-stream");
6796    let content_type = super::ContentType::from(content_type);
6797
6798    if !status.is_client_error() && !status.is_server_error() {
6799        let content = resp.text().await?;
6800        match content_type {
6801            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6802            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginMarginInterestHistoryV1Resp`"))),
6803            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::GetMarginMarginInterestHistoryV1Resp`")))),
6804        }
6805    } else {
6806        let content = resp.text().await?;
6807        let entity: Option<GetMarginMarginInterestHistoryV1Error> = serde_json::from_str(&content).ok();
6808        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6809    }
6810}
6811
6812/// Query margin loan record
6813pub async fn get_margin_margin_loan_v1(configuration: &configuration::Configuration, params: GetMarginMarginLoanV1Params) -> Result<models::GetMarginMarginLoanV1Resp, Error<GetMarginMarginLoanV1Error>> {
6814
6815    let uri_str = format!("{}/papi/v1/margin/marginLoan", configuration.base_path);
6816    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6817
6818    // Create a mutable vector for query parameters
6819    let mut query_params: Vec<(String, String)> = Vec::new();
6820
6821    query_params.push(("asset".to_string(), params.asset.to_string()));
6822    if let Some(ref param_value) = params.tx_id {
6823        query_params.push(("txId".to_string(), param_value.to_string()));
6824    }
6825    if let Some(ref param_value) = params.start_time {
6826        query_params.push(("startTime".to_string(), param_value.to_string()));
6827    }
6828    if let Some(ref param_value) = params.end_time {
6829        query_params.push(("endTime".to_string(), param_value.to_string()));
6830    }
6831    if let Some(ref param_value) = params.current {
6832        query_params.push(("current".to_string(), param_value.to_string()));
6833    }
6834    if let Some(ref param_value) = params.size {
6835        query_params.push(("size".to_string(), param_value.to_string()));
6836    }
6837    if let Some(ref param_value) = params.archived {
6838        query_params.push(("archived".to_string(), param_value.to_string()));
6839    }
6840    if let Some(ref param_value) = params.recv_window {
6841        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6842    }
6843    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6844
6845    // Create header parameters collection
6846    let mut header_params = std::collections::HashMap::new();
6847
6848    // Handle Binance Auth first if configured
6849    if let Some(ref binance_auth) = configuration.binance_auth {
6850        // Add API key to headers
6851        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6852        
6853        // Generate request body for signing (if any)
6854        let body_string: Option<Vec<u8>> = None;
6855        
6856        // Sign the request
6857        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6858            Ok(sig) => sig,
6859            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6860        };
6861        
6862        // Add signature to query params
6863        query_params.push(("signature".to_string(), signature));
6864    }
6865
6866    // Apply all query parameters
6867    if !query_params.is_empty() {
6868        req_builder = req_builder.query(&query_params);
6869    }
6870
6871
6872    // Add user agent if configured
6873    if let Some(ref user_agent) = configuration.user_agent {
6874        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6875    }
6876
6877    // Apply all header parameters
6878    for (header_name, header_value) in header_params {
6879        req_builder = req_builder.header(&header_name, &header_value);
6880    }
6881
6882
6883    let req = req_builder.build()?;
6884    let resp = configuration.client.execute(req).await?;
6885
6886    let status = resp.status();
6887    let content_type = resp
6888        .headers()
6889        .get("content-type")
6890        .and_then(|v| v.to_str().ok())
6891        .unwrap_or("application/octet-stream");
6892    let content_type = super::ContentType::from(content_type);
6893
6894    if !status.is_client_error() && !status.is_server_error() {
6895        let content = resp.text().await?;
6896        match content_type {
6897            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6898            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginMarginLoanV1Resp`"))),
6899            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::GetMarginMarginLoanV1Resp`")))),
6900        }
6901    } else {
6902        let content = resp.text().await?;
6903        let entity: Option<GetMarginMarginLoanV1Error> = serde_json::from_str(&content).ok();
6904        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6905    }
6906}
6907
6908/// Query margin max borrow
6909pub async fn get_margin_max_borrowable_v1(configuration: &configuration::Configuration, params: GetMarginMaxBorrowableV1Params) -> Result<models::GetMarginMaxBorrowableV1Resp, Error<GetMarginMaxBorrowableV1Error>> {
6910
6911    let uri_str = format!("{}/papi/v1/margin/maxBorrowable", configuration.base_path);
6912    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6913
6914    // Create a mutable vector for query parameters
6915    let mut query_params: Vec<(String, String)> = Vec::new();
6916
6917    query_params.push(("asset".to_string(), params.asset.to_string()));
6918    if let Some(ref param_value) = params.recv_window {
6919        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6920    }
6921    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
6922
6923    // Create header parameters collection
6924    let mut header_params = std::collections::HashMap::new();
6925
6926    // Handle Binance Auth first if configured
6927    if let Some(ref binance_auth) = configuration.binance_auth {
6928        // Add API key to headers
6929        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
6930        
6931        // Generate request body for signing (if any)
6932        let body_string: Option<Vec<u8>> = None;
6933        
6934        // Sign the request
6935        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
6936            Ok(sig) => sig,
6937            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
6938        };
6939        
6940        // Add signature to query params
6941        query_params.push(("signature".to_string(), signature));
6942    }
6943
6944    // Apply all query parameters
6945    if !query_params.is_empty() {
6946        req_builder = req_builder.query(&query_params);
6947    }
6948
6949
6950    // Add user agent if configured
6951    if let Some(ref user_agent) = configuration.user_agent {
6952        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
6953    }
6954
6955    // Apply all header parameters
6956    for (header_name, header_value) in header_params {
6957        req_builder = req_builder.header(&header_name, &header_value);
6958    }
6959
6960
6961    let req = req_builder.build()?;
6962    let resp = configuration.client.execute(req).await?;
6963
6964    let status = resp.status();
6965    let content_type = resp
6966        .headers()
6967        .get("content-type")
6968        .and_then(|v| v.to_str().ok())
6969        .unwrap_or("application/octet-stream");
6970    let content_type = super::ContentType::from(content_type);
6971
6972    if !status.is_client_error() && !status.is_server_error() {
6973        let content = resp.text().await?;
6974        match content_type {
6975            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
6976            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginMaxBorrowableV1Resp`"))),
6977            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetMarginMaxBorrowableV1Resp`")))),
6978        }
6979    } else {
6980        let content = resp.text().await?;
6981        let entity: Option<GetMarginMaxBorrowableV1Error> = serde_json::from_str(&content).ok();
6982        Err(Error::ResponseError(ResponseContent { status, content, entity }))
6983    }
6984}
6985
6986/// Query Margin Max Withdraw
6987pub async fn get_margin_max_withdraw_v1(configuration: &configuration::Configuration, params: GetMarginMaxWithdrawV1Params) -> Result<models::GetMarginMaxWithdrawV1Resp, Error<GetMarginMaxWithdrawV1Error>> {
6988
6989    let uri_str = format!("{}/papi/v1/margin/maxWithdraw", configuration.base_path);
6990    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
6991
6992    // Create a mutable vector for query parameters
6993    let mut query_params: Vec<(String, String)> = Vec::new();
6994
6995    query_params.push(("asset".to_string(), params.asset.to_string()));
6996    if let Some(ref param_value) = params.recv_window {
6997        query_params.push(("recvWindow".to_string(), param_value.to_string()));
6998    }
6999    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7000
7001    // Create header parameters collection
7002    let mut header_params = std::collections::HashMap::new();
7003
7004    // Handle Binance Auth first if configured
7005    if let Some(ref binance_auth) = configuration.binance_auth {
7006        // Add API key to headers
7007        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7008        
7009        // Generate request body for signing (if any)
7010        let body_string: Option<Vec<u8>> = None;
7011        
7012        // Sign the request
7013        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7014            Ok(sig) => sig,
7015            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7016        };
7017        
7018        // Add signature to query params
7019        query_params.push(("signature".to_string(), signature));
7020    }
7021
7022    // Apply all query parameters
7023    if !query_params.is_empty() {
7024        req_builder = req_builder.query(&query_params);
7025    }
7026
7027
7028    // Add user agent if configured
7029    if let Some(ref user_agent) = configuration.user_agent {
7030        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7031    }
7032
7033    // Apply all header parameters
7034    for (header_name, header_value) in header_params {
7035        req_builder = req_builder.header(&header_name, &header_value);
7036    }
7037
7038
7039    let req = req_builder.build()?;
7040    let resp = configuration.client.execute(req).await?;
7041
7042    let status = resp.status();
7043    let content_type = resp
7044        .headers()
7045        .get("content-type")
7046        .and_then(|v| v.to_str().ok())
7047        .unwrap_or("application/octet-stream");
7048    let content_type = super::ContentType::from(content_type);
7049
7050    if !status.is_client_error() && !status.is_server_error() {
7051        let content = resp.text().await?;
7052        match content_type {
7053            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7054            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginMaxWithdrawV1Resp`"))),
7055            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::GetMarginMaxWithdrawV1Resp`")))),
7056        }
7057    } else {
7058        let content = resp.text().await?;
7059        let entity: Option<GetMarginMaxWithdrawV1Error> = serde_json::from_str(&content).ok();
7060        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7061    }
7062}
7063
7064/// Margin Account Trade List
7065pub async fn get_margin_my_trades_v1(configuration: &configuration::Configuration, params: GetMarginMyTradesV1Params) -> Result<Vec<models::GetMarginMyTradesV1RespItem>, Error<GetMarginMyTradesV1Error>> {
7066
7067    let uri_str = format!("{}/papi/v1/margin/myTrades", configuration.base_path);
7068    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7069
7070    // Create a mutable vector for query parameters
7071    let mut query_params: Vec<(String, String)> = Vec::new();
7072
7073    query_params.push(("symbol".to_string(), params.symbol.to_string()));
7074    if let Some(ref param_value) = params.order_id {
7075        query_params.push(("orderId".to_string(), param_value.to_string()));
7076    }
7077    if let Some(ref param_value) = params.start_time {
7078        query_params.push(("startTime".to_string(), param_value.to_string()));
7079    }
7080    if let Some(ref param_value) = params.end_time {
7081        query_params.push(("endTime".to_string(), param_value.to_string()));
7082    }
7083    if let Some(ref param_value) = params.from_id {
7084        query_params.push(("fromId".to_string(), param_value.to_string()));
7085    }
7086    if let Some(ref param_value) = params.limit {
7087        query_params.push(("limit".to_string(), param_value.to_string()));
7088    }
7089    if let Some(ref param_value) = params.recv_window {
7090        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7091    }
7092    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7093
7094    // Create header parameters collection
7095    let mut header_params = std::collections::HashMap::new();
7096
7097    // Handle Binance Auth first if configured
7098    if let Some(ref binance_auth) = configuration.binance_auth {
7099        // Add API key to headers
7100        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7101        
7102        // Generate request body for signing (if any)
7103        let body_string: Option<Vec<u8>> = None;
7104        
7105        // Sign the request
7106        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7107            Ok(sig) => sig,
7108            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7109        };
7110        
7111        // Add signature to query params
7112        query_params.push(("signature".to_string(), signature));
7113    }
7114
7115    // Apply all query parameters
7116    if !query_params.is_empty() {
7117        req_builder = req_builder.query(&query_params);
7118    }
7119
7120
7121    // Add user agent if configured
7122    if let Some(ref user_agent) = configuration.user_agent {
7123        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7124    }
7125
7126    // Apply all header parameters
7127    for (header_name, header_value) in header_params {
7128        req_builder = req_builder.header(&header_name, &header_value);
7129    }
7130
7131
7132    let req = req_builder.build()?;
7133    let resp = configuration.client.execute(req).await?;
7134
7135    let status = resp.status();
7136    let content_type = resp
7137        .headers()
7138        .get("content-type")
7139        .and_then(|v| v.to_str().ok())
7140        .unwrap_or("application/octet-stream");
7141    let content_type = super::ContentType::from(content_type);
7142
7143    if !status.is_client_error() && !status.is_server_error() {
7144        let content = resp.text().await?;
7145        match content_type {
7146            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7147            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMarginMyTradesV1RespItem&gt;`"))),
7148            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::GetMarginMyTradesV1RespItem&gt;`")))),
7149        }
7150    } else {
7151        let content = resp.text().await?;
7152        let entity: Option<GetMarginMyTradesV1Error> = serde_json::from_str(&content).ok();
7153        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7154    }
7155}
7156
7157/// Query Margin Account's Open OCO
7158pub async fn get_margin_open_order_list_v1(configuration: &configuration::Configuration, params: GetMarginOpenOrderListV1Params) -> Result<Vec<models::GetMarginOpenOrderListV1RespItem>, Error<GetMarginOpenOrderListV1Error>> {
7159
7160    let uri_str = format!("{}/papi/v1/margin/openOrderList", configuration.base_path);
7161    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7162
7163    // Create a mutable vector for query parameters
7164    let mut query_params: Vec<(String, String)> = Vec::new();
7165
7166    if let Some(ref param_value) = params.recv_window {
7167        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7168    }
7169    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7170
7171    // Create header parameters collection
7172    let mut header_params = std::collections::HashMap::new();
7173
7174    // Handle Binance Auth first if configured
7175    if let Some(ref binance_auth) = configuration.binance_auth {
7176        // Add API key to headers
7177        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7178        
7179        // Generate request body for signing (if any)
7180        let body_string: Option<Vec<u8>> = None;
7181        
7182        // Sign the request
7183        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7184            Ok(sig) => sig,
7185            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7186        };
7187        
7188        // Add signature to query params
7189        query_params.push(("signature".to_string(), signature));
7190    }
7191
7192    // Apply all query parameters
7193    if !query_params.is_empty() {
7194        req_builder = req_builder.query(&query_params);
7195    }
7196
7197
7198    // Add user agent if configured
7199    if let Some(ref user_agent) = configuration.user_agent {
7200        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7201    }
7202
7203    // Apply all header parameters
7204    for (header_name, header_value) in header_params {
7205        req_builder = req_builder.header(&header_name, &header_value);
7206    }
7207
7208
7209    let req = req_builder.build()?;
7210    let resp = configuration.client.execute(req).await?;
7211
7212    let status = resp.status();
7213    let content_type = resp
7214        .headers()
7215        .get("content-type")
7216        .and_then(|v| v.to_str().ok())
7217        .unwrap_or("application/octet-stream");
7218    let content_type = super::ContentType::from(content_type);
7219
7220    if !status.is_client_error() && !status.is_server_error() {
7221        let content = resp.text().await?;
7222        match content_type {
7223            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7224            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMarginOpenOrderListV1RespItem&gt;`"))),
7225            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::GetMarginOpenOrderListV1RespItem&gt;`")))),
7226        }
7227    } else {
7228        let content = resp.text().await?;
7229        let entity: Option<GetMarginOpenOrderListV1Error> = serde_json::from_str(&content).ok();
7230        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7231    }
7232}
7233
7234/// Query Current Margin Open Order
7235pub async fn get_margin_open_orders_v1(configuration: &configuration::Configuration, params: GetMarginOpenOrdersV1Params) -> Result<Vec<models::GetMarginOpenOrdersV1RespItem>, Error<GetMarginOpenOrdersV1Error>> {
7236
7237    let uri_str = format!("{}/papi/v1/margin/openOrders", configuration.base_path);
7238    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7239
7240    // Create a mutable vector for query parameters
7241    let mut query_params: Vec<(String, String)> = Vec::new();
7242
7243    query_params.push(("symbol".to_string(), params.symbol.to_string()));
7244    if let Some(ref param_value) = params.recv_window {
7245        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7246    }
7247    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7248
7249    // Create header parameters collection
7250    let mut header_params = std::collections::HashMap::new();
7251
7252    // Handle Binance Auth first if configured
7253    if let Some(ref binance_auth) = configuration.binance_auth {
7254        // Add API key to headers
7255        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7256        
7257        // Generate request body for signing (if any)
7258        let body_string: Option<Vec<u8>> = None;
7259        
7260        // Sign the request
7261        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7262            Ok(sig) => sig,
7263            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7264        };
7265        
7266        // Add signature to query params
7267        query_params.push(("signature".to_string(), signature));
7268    }
7269
7270    // Apply all query parameters
7271    if !query_params.is_empty() {
7272        req_builder = req_builder.query(&query_params);
7273    }
7274
7275
7276    // Add user agent if configured
7277    if let Some(ref user_agent) = configuration.user_agent {
7278        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7279    }
7280
7281    // Apply all header parameters
7282    for (header_name, header_value) in header_params {
7283        req_builder = req_builder.header(&header_name, &header_value);
7284    }
7285
7286
7287    let req = req_builder.build()?;
7288    let resp = configuration.client.execute(req).await?;
7289
7290    let status = resp.status();
7291    let content_type = resp
7292        .headers()
7293        .get("content-type")
7294        .and_then(|v| v.to_str().ok())
7295        .unwrap_or("application/octet-stream");
7296    let content_type = super::ContentType::from(content_type);
7297
7298    if !status.is_client_error() && !status.is_server_error() {
7299        let content = resp.text().await?;
7300        match content_type {
7301            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7302            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMarginOpenOrdersV1RespItem&gt;`"))),
7303            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::GetMarginOpenOrdersV1RespItem&gt;`")))),
7304        }
7305    } else {
7306        let content = resp.text().await?;
7307        let entity: Option<GetMarginOpenOrdersV1Error> = serde_json::from_str(&content).ok();
7308        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7309    }
7310}
7311
7312/// Retrieves a specific OCO based on provided optional parameters
7313pub async fn get_margin_order_list_v1(configuration: &configuration::Configuration, params: GetMarginOrderListV1Params) -> Result<models::GetMarginOrderListV1Resp, Error<GetMarginOrderListV1Error>> {
7314
7315    let uri_str = format!("{}/papi/v1/margin/orderList", configuration.base_path);
7316    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7317
7318    // Create a mutable vector for query parameters
7319    let mut query_params: Vec<(String, String)> = Vec::new();
7320
7321    if let Some(ref param_value) = params.order_list_id {
7322        query_params.push(("orderListId".to_string(), param_value.to_string()));
7323    }
7324    if let Some(ref param_value) = params.orig_client_order_id {
7325        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
7326    }
7327    if let Some(ref param_value) = params.recv_window {
7328        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7329    }
7330    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7331
7332    // Create header parameters collection
7333    let mut header_params = std::collections::HashMap::new();
7334
7335    // Handle Binance Auth first if configured
7336    if let Some(ref binance_auth) = configuration.binance_auth {
7337        // Add API key to headers
7338        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7339        
7340        // Generate request body for signing (if any)
7341        let body_string: Option<Vec<u8>> = None;
7342        
7343        // Sign the request
7344        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7345            Ok(sig) => sig,
7346            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7347        };
7348        
7349        // Add signature to query params
7350        query_params.push(("signature".to_string(), signature));
7351    }
7352
7353    // Apply all query parameters
7354    if !query_params.is_empty() {
7355        req_builder = req_builder.query(&query_params);
7356    }
7357
7358
7359    // Add user agent if configured
7360    if let Some(ref user_agent) = configuration.user_agent {
7361        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7362    }
7363
7364    // Apply all header parameters
7365    for (header_name, header_value) in header_params {
7366        req_builder = req_builder.header(&header_name, &header_value);
7367    }
7368
7369
7370    let req = req_builder.build()?;
7371    let resp = configuration.client.execute(req).await?;
7372
7373    let status = resp.status();
7374    let content_type = resp
7375        .headers()
7376        .get("content-type")
7377        .and_then(|v| v.to_str().ok())
7378        .unwrap_or("application/octet-stream");
7379    let content_type = super::ContentType::from(content_type);
7380
7381    if !status.is_client_error() && !status.is_server_error() {
7382        let content = resp.text().await?;
7383        match content_type {
7384            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7385            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginOrderListV1Resp`"))),
7386            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetMarginOrderListV1Resp`")))),
7387        }
7388    } else {
7389        let content = resp.text().await?;
7390        let entity: Option<GetMarginOrderListV1Error> = serde_json::from_str(&content).ok();
7391        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7392    }
7393}
7394
7395/// Query Margin Account Order
7396pub async fn get_margin_order_v1(configuration: &configuration::Configuration, params: GetMarginOrderV1Params) -> Result<models::GetMarginOrderV1Resp, Error<GetMarginOrderV1Error>> {
7397
7398    let uri_str = format!("{}/papi/v1/margin/order", configuration.base_path);
7399    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7400
7401    // Create a mutable vector for query parameters
7402    let mut query_params: Vec<(String, String)> = Vec::new();
7403
7404    query_params.push(("symbol".to_string(), params.symbol.to_string()));
7405    if let Some(ref param_value) = params.order_id {
7406        query_params.push(("orderId".to_string(), param_value.to_string()));
7407    }
7408    if let Some(ref param_value) = params.orig_client_order_id {
7409        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
7410    }
7411    if let Some(ref param_value) = params.recv_window {
7412        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7413    }
7414    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7415
7416    // Create header parameters collection
7417    let mut header_params = std::collections::HashMap::new();
7418
7419    // Handle Binance Auth first if configured
7420    if let Some(ref binance_auth) = configuration.binance_auth {
7421        // Add API key to headers
7422        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7423        
7424        // Generate request body for signing (if any)
7425        let body_string: Option<Vec<u8>> = None;
7426        
7427        // Sign the request
7428        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7429            Ok(sig) => sig,
7430            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7431        };
7432        
7433        // Add signature to query params
7434        query_params.push(("signature".to_string(), signature));
7435    }
7436
7437    // Apply all query parameters
7438    if !query_params.is_empty() {
7439        req_builder = req_builder.query(&query_params);
7440    }
7441
7442
7443    // Add user agent if configured
7444    if let Some(ref user_agent) = configuration.user_agent {
7445        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7446    }
7447
7448    // Apply all header parameters
7449    for (header_name, header_value) in header_params {
7450        req_builder = req_builder.header(&header_name, &header_value);
7451    }
7452
7453
7454    let req = req_builder.build()?;
7455    let resp = configuration.client.execute(req).await?;
7456
7457    let status = resp.status();
7458    let content_type = resp
7459        .headers()
7460        .get("content-type")
7461        .and_then(|v| v.to_str().ok())
7462        .unwrap_or("application/octet-stream");
7463    let content_type = super::ContentType::from(content_type);
7464
7465    if !status.is_client_error() && !status.is_server_error() {
7466        let content = resp.text().await?;
7467        match content_type {
7468            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7469            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginOrderV1Resp`"))),
7470            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetMarginOrderV1Resp`")))),
7471        }
7472    } else {
7473        let content = resp.text().await?;
7474        let entity: Option<GetMarginOrderV1Error> = serde_json::from_str(&content).ok();
7475        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7476    }
7477}
7478
7479/// Query margin repay record.
7480pub async fn get_margin_repay_loan_v1(configuration: &configuration::Configuration, params: GetMarginRepayLoanV1Params) -> Result<models::GetMarginRepayLoanV1Resp, Error<GetMarginRepayLoanV1Error>> {
7481
7482    let uri_str = format!("{}/papi/v1/margin/repayLoan", configuration.base_path);
7483    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7484
7485    // Create a mutable vector for query parameters
7486    let mut query_params: Vec<(String, String)> = Vec::new();
7487
7488    query_params.push(("asset".to_string(), params.asset.to_string()));
7489    if let Some(ref param_value) = params.tx_id {
7490        query_params.push(("txId".to_string(), param_value.to_string()));
7491    }
7492    if let Some(ref param_value) = params.start_time {
7493        query_params.push(("startTime".to_string(), param_value.to_string()));
7494    }
7495    if let Some(ref param_value) = params.end_time {
7496        query_params.push(("endTime".to_string(), param_value.to_string()));
7497    }
7498    if let Some(ref param_value) = params.current {
7499        query_params.push(("current".to_string(), param_value.to_string()));
7500    }
7501    if let Some(ref param_value) = params.size {
7502        query_params.push(("size".to_string(), param_value.to_string()));
7503    }
7504    if let Some(ref param_value) = params.archived {
7505        query_params.push(("archived".to_string(), param_value.to_string()));
7506    }
7507    if let Some(ref param_value) = params.recv_window {
7508        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7509    }
7510    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7511
7512    // Create header parameters collection
7513    let mut header_params = std::collections::HashMap::new();
7514
7515    // Handle Binance Auth first if configured
7516    if let Some(ref binance_auth) = configuration.binance_auth {
7517        // Add API key to headers
7518        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7519        
7520        // Generate request body for signing (if any)
7521        let body_string: Option<Vec<u8>> = None;
7522        
7523        // Sign the request
7524        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7525            Ok(sig) => sig,
7526            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7527        };
7528        
7529        // Add signature to query params
7530        query_params.push(("signature".to_string(), signature));
7531    }
7532
7533    // Apply all query parameters
7534    if !query_params.is_empty() {
7535        req_builder = req_builder.query(&query_params);
7536    }
7537
7538
7539    // Add user agent if configured
7540    if let Some(ref user_agent) = configuration.user_agent {
7541        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7542    }
7543
7544    // Apply all header parameters
7545    for (header_name, header_value) in header_params {
7546        req_builder = req_builder.header(&header_name, &header_value);
7547    }
7548
7549
7550    let req = req_builder.build()?;
7551    let resp = configuration.client.execute(req).await?;
7552
7553    let status = resp.status();
7554    let content_type = resp
7555        .headers()
7556        .get("content-type")
7557        .and_then(|v| v.to_str().ok())
7558        .unwrap_or("application/octet-stream");
7559    let content_type = super::ContentType::from(content_type);
7560
7561    if !status.is_client_error() && !status.is_server_error() {
7562        let content = resp.text().await?;
7563        match content_type {
7564            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7565            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginRepayLoanV1Resp`"))),
7566            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::GetMarginRepayLoanV1Resp`")))),
7567        }
7568    } else {
7569        let content = resp.text().await?;
7570        let entity: Option<GetMarginRepayLoanV1Error> = serde_json::from_str(&content).ok();
7571        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7572    }
7573}
7574
7575/// Test connectivity to the Rest API.
7576pub async fn get_ping_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<GetPingV1Error>> {
7577
7578    let uri_str = format!("{}/papi/v1/ping", configuration.base_path);
7579    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7580
7581    // Create a mutable vector for query parameters
7582    let mut query_params: Vec<(String, String)> = Vec::new();
7583
7584
7585    // Create header parameters collection
7586    let mut header_params = std::collections::HashMap::new();
7587
7588    // Handle Binance Auth first if configured
7589    if let Some(ref binance_auth) = configuration.binance_auth {
7590        // Add API key to headers
7591        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7592        
7593        // Generate request body for signing (if any)
7594        let body_string: Option<Vec<u8>> = None;
7595        
7596        // Sign the request
7597        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7598            Ok(sig) => sig,
7599            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7600        };
7601        
7602        // Add signature to query params
7603        query_params.push(("signature".to_string(), signature));
7604    }
7605
7606    // Apply all query parameters
7607    if !query_params.is_empty() {
7608        req_builder = req_builder.query(&query_params);
7609    }
7610
7611
7612    // Add user agent if configured
7613    if let Some(ref user_agent) = configuration.user_agent {
7614        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7615    }
7616
7617    // Apply all header parameters
7618    for (header_name, header_value) in header_params {
7619        req_builder = req_builder.header(&header_name, &header_value);
7620    }
7621
7622
7623    let req = req_builder.build()?;
7624    let resp = configuration.client.execute(req).await?;
7625
7626    let status = resp.status();
7627    let content_type = resp
7628        .headers()
7629        .get("content-type")
7630        .and_then(|v| v.to_str().ok())
7631        .unwrap_or("application/octet-stream");
7632    let content_type = super::ContentType::from(content_type);
7633
7634    if !status.is_client_error() && !status.is_server_error() {
7635        let content = resp.text().await?;
7636        match content_type {
7637            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7638            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
7639            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
7640        }
7641    } else {
7642        let content = resp.text().await?;
7643        let entity: Option<GetPingV1Error> = serde_json::from_str(&content).ok();
7644        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7645    }
7646}
7647
7648/// Query interest history of negative balance for portfolio margin.
7649pub async fn get_portfolio_interest_history_v1(configuration: &configuration::Configuration, params: GetPortfolioInterestHistoryV1Params) -> Result<Vec<models::GetPortfolioInterestHistoryV1RespItem>, Error<GetPortfolioInterestHistoryV1Error>> {
7650
7651    let uri_str = format!("{}/papi/v1/portfolio/interest-history", configuration.base_path);
7652    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7653
7654    // Create a mutable vector for query parameters
7655    let mut query_params: Vec<(String, String)> = Vec::new();
7656
7657    if let Some(ref param_value) = params.asset {
7658        query_params.push(("asset".to_string(), param_value.to_string()));
7659    }
7660    if let Some(ref param_value) = params.start_time {
7661        query_params.push(("startTime".to_string(), param_value.to_string()));
7662    }
7663    if let Some(ref param_value) = params.end_time {
7664        query_params.push(("endTime".to_string(), param_value.to_string()));
7665    }
7666    if let Some(ref param_value) = params.size {
7667        query_params.push(("size".to_string(), param_value.to_string()));
7668    }
7669    if let Some(ref param_value) = params.recv_window {
7670        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7671    }
7672    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7673
7674    // Create header parameters collection
7675    let mut header_params = std::collections::HashMap::new();
7676
7677    // Handle Binance Auth first if configured
7678    if let Some(ref binance_auth) = configuration.binance_auth {
7679        // Add API key to headers
7680        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7681        
7682        // Generate request body for signing (if any)
7683        let body_string: Option<Vec<u8>> = None;
7684        
7685        // Sign the request
7686        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7687            Ok(sig) => sig,
7688            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7689        };
7690        
7691        // Add signature to query params
7692        query_params.push(("signature".to_string(), signature));
7693    }
7694
7695    // Apply all query parameters
7696    if !query_params.is_empty() {
7697        req_builder = req_builder.query(&query_params);
7698    }
7699
7700
7701    // Add user agent if configured
7702    if let Some(ref user_agent) = configuration.user_agent {
7703        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7704    }
7705
7706    // Apply all header parameters
7707    for (header_name, header_value) in header_params {
7708        req_builder = req_builder.header(&header_name, &header_value);
7709    }
7710
7711
7712    let req = req_builder.build()?;
7713    let resp = configuration.client.execute(req).await?;
7714
7715    let status = resp.status();
7716    let content_type = resp
7717        .headers()
7718        .get("content-type")
7719        .and_then(|v| v.to_str().ok())
7720        .unwrap_or("application/octet-stream");
7721    let content_type = super::ContentType::from(content_type);
7722
7723    if !status.is_client_error() && !status.is_server_error() {
7724        let content = resp.text().await?;
7725        match content_type {
7726            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7727            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetPortfolioInterestHistoryV1RespItem&gt;`"))),
7728            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::GetPortfolioInterestHistoryV1RespItem&gt;`")))),
7729        }
7730    } else {
7731        let content = resp.text().await?;
7732        let entity: Option<GetPortfolioInterestHistoryV1Error> = serde_json::from_str(&content).ok();
7733        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7734    }
7735}
7736
7737/// Query user negative balance auto exchange record
7738pub async fn get_portfolio_negative_balance_exchange_record_v1(configuration: &configuration::Configuration, params: GetPortfolioNegativeBalanceExchangeRecordV1Params) -> Result<models::GetPortfolioNegativeBalanceExchangeRecordV1Resp, Error<GetPortfolioNegativeBalanceExchangeRecordV1Error>> {
7739
7740    let uri_str = format!("{}/papi/v1/portfolio/negative-balance-exchange-record", configuration.base_path);
7741    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7742
7743    // Create a mutable vector for query parameters
7744    let mut query_params: Vec<(String, String)> = Vec::new();
7745
7746    query_params.push(("startTime".to_string(), params.start_time.to_string()));
7747    query_params.push(("endTime".to_string(), params.end_time.to_string()));
7748    if let Some(ref param_value) = params.recv_window {
7749        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7750    }
7751    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7752
7753    // Create header parameters collection
7754    let mut header_params = std::collections::HashMap::new();
7755
7756    // Handle Binance Auth first if configured
7757    if let Some(ref binance_auth) = configuration.binance_auth {
7758        // Add API key to headers
7759        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7760        
7761        // Generate request body for signing (if any)
7762        let body_string: Option<Vec<u8>> = None;
7763        
7764        // Sign the request
7765        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7766            Ok(sig) => sig,
7767            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7768        };
7769        
7770        // Add signature to query params
7771        query_params.push(("signature".to_string(), signature));
7772    }
7773
7774    // Apply all query parameters
7775    if !query_params.is_empty() {
7776        req_builder = req_builder.query(&query_params);
7777    }
7778
7779
7780    // Add user agent if configured
7781    if let Some(ref user_agent) = configuration.user_agent {
7782        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7783    }
7784
7785    // Apply all header parameters
7786    for (header_name, header_value) in header_params {
7787        req_builder = req_builder.header(&header_name, &header_value);
7788    }
7789
7790
7791    let req = req_builder.build()?;
7792    let resp = configuration.client.execute(req).await?;
7793
7794    let status = resp.status();
7795    let content_type = resp
7796        .headers()
7797        .get("content-type")
7798        .and_then(|v| v.to_str().ok())
7799        .unwrap_or("application/octet-stream");
7800    let content_type = super::ContentType::from(content_type);
7801
7802    if !status.is_client_error() && !status.is_server_error() {
7803        let content = resp.text().await?;
7804        match content_type {
7805            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7806            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPortfolioNegativeBalanceExchangeRecordV1Resp`"))),
7807            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::GetPortfolioNegativeBalanceExchangeRecordV1Resp`")))),
7808        }
7809    } else {
7810        let content = resp.text().await?;
7811        let entity: Option<GetPortfolioNegativeBalanceExchangeRecordV1Error> = serde_json::from_str(&content).ok();
7812        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7813    }
7814}
7815
7816/// Query User Rate Limit
7817pub async fn get_rate_limit_order_v1(configuration: &configuration::Configuration, params: GetRateLimitOrderV1Params) -> Result<Vec<models::GetRateLimitOrderV1RespItem>, Error<GetRateLimitOrderV1Error>> {
7818
7819    let uri_str = format!("{}/papi/v1/rateLimit/order", configuration.base_path);
7820    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7821
7822    // Create a mutable vector for query parameters
7823    let mut query_params: Vec<(String, String)> = Vec::new();
7824
7825    if let Some(ref param_value) = params.recv_window {
7826        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7827    }
7828    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7829
7830    // Create header parameters collection
7831    let mut header_params = std::collections::HashMap::new();
7832
7833    // Handle Binance Auth first if configured
7834    if let Some(ref binance_auth) = configuration.binance_auth {
7835        // Add API key to headers
7836        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7837        
7838        // Generate request body for signing (if any)
7839        let body_string: Option<Vec<u8>> = None;
7840        
7841        // Sign the request
7842        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7843            Ok(sig) => sig,
7844            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7845        };
7846        
7847        // Add signature to query params
7848        query_params.push(("signature".to_string(), signature));
7849    }
7850
7851    // Apply all query parameters
7852    if !query_params.is_empty() {
7853        req_builder = req_builder.query(&query_params);
7854    }
7855
7856
7857    // Add user agent if configured
7858    if let Some(ref user_agent) = configuration.user_agent {
7859        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7860    }
7861
7862    // Apply all header parameters
7863    for (header_name, header_value) in header_params {
7864        req_builder = req_builder.header(&header_name, &header_value);
7865    }
7866
7867
7868    let req = req_builder.build()?;
7869    let resp = configuration.client.execute(req).await?;
7870
7871    let status = resp.status();
7872    let content_type = resp
7873        .headers()
7874        .get("content-type")
7875        .and_then(|v| v.to_str().ok())
7876        .unwrap_or("application/octet-stream");
7877    let content_type = super::ContentType::from(content_type);
7878
7879    if !status.is_client_error() && !status.is_server_error() {
7880        let content = resp.text().await?;
7881        match content_type {
7882            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7883            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetRateLimitOrderV1RespItem&gt;`"))),
7884            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::GetRateLimitOrderV1RespItem&gt;`")))),
7885        }
7886    } else {
7887        let content = resp.text().await?;
7888        let entity: Option<GetRateLimitOrderV1Error> = serde_json::from_str(&content).ok();
7889        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7890    }
7891}
7892
7893/// Query Auto-repay-futures Status
7894pub async fn get_repay_futures_switch_v1(configuration: &configuration::Configuration, params: GetRepayFuturesSwitchV1Params) -> Result<models::GetRepayFuturesSwitchV1Resp, Error<GetRepayFuturesSwitchV1Error>> {
7895
7896    let uri_str = format!("{}/papi/v1/repay-futures-switch", configuration.base_path);
7897    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7898
7899    // Create a mutable vector for query parameters
7900    let mut query_params: Vec<(String, String)> = Vec::new();
7901
7902    if let Some(ref param_value) = params.recv_window {
7903        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7904    }
7905    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7906
7907    // Create header parameters collection
7908    let mut header_params = std::collections::HashMap::new();
7909
7910    // Handle Binance Auth first if configured
7911    if let Some(ref binance_auth) = configuration.binance_auth {
7912        // Add API key to headers
7913        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7914        
7915        // Generate request body for signing (if any)
7916        let body_string: Option<Vec<u8>> = None;
7917        
7918        // Sign the request
7919        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7920            Ok(sig) => sig,
7921            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7922        };
7923        
7924        // Add signature to query params
7925        query_params.push(("signature".to_string(), signature));
7926    }
7927
7928    // Apply all query parameters
7929    if !query_params.is_empty() {
7930        req_builder = req_builder.query(&query_params);
7931    }
7932
7933
7934    // Add user agent if configured
7935    if let Some(ref user_agent) = configuration.user_agent {
7936        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
7937    }
7938
7939    // Apply all header parameters
7940    for (header_name, header_value) in header_params {
7941        req_builder = req_builder.header(&header_name, &header_value);
7942    }
7943
7944
7945    let req = req_builder.build()?;
7946    let resp = configuration.client.execute(req).await?;
7947
7948    let status = resp.status();
7949    let content_type = resp
7950        .headers()
7951        .get("content-type")
7952        .and_then(|v| v.to_str().ok())
7953        .unwrap_or("application/octet-stream");
7954    let content_type = super::ContentType::from(content_type);
7955
7956    if !status.is_client_error() && !status.is_server_error() {
7957        let content = resp.text().await?;
7958        match content_type {
7959            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
7960            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetRepayFuturesSwitchV1Resp`"))),
7961            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::GetRepayFuturesSwitchV1Resp`")))),
7962        }
7963    } else {
7964        let content = resp.text().await?;
7965        let entity: Option<GetRepayFuturesSwitchV1Error> = serde_json::from_str(&content).ok();
7966        Err(Error::ResponseError(ResponseContent { status, content, entity }))
7967    }
7968}
7969
7970/// Query UM Futures account configuration
7971pub async fn get_um_account_config_v1(configuration: &configuration::Configuration, params: GetUmAccountConfigV1Params) -> Result<models::GetUmAccountConfigV1Resp, Error<GetUmAccountConfigV1Error>> {
7972
7973    let uri_str = format!("{}/papi/v1/um/accountConfig", configuration.base_path);
7974    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
7975
7976    // Create a mutable vector for query parameters
7977    let mut query_params: Vec<(String, String)> = Vec::new();
7978
7979    if let Some(ref param_value) = params.recv_window {
7980        query_params.push(("recvWindow".to_string(), param_value.to_string()));
7981    }
7982    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
7983
7984    // Create header parameters collection
7985    let mut header_params = std::collections::HashMap::new();
7986
7987    // Handle Binance Auth first if configured
7988    if let Some(ref binance_auth) = configuration.binance_auth {
7989        // Add API key to headers
7990        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
7991        
7992        // Generate request body for signing (if any)
7993        let body_string: Option<Vec<u8>> = None;
7994        
7995        // Sign the request
7996        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
7997            Ok(sig) => sig,
7998            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
7999        };
8000        
8001        // Add signature to query params
8002        query_params.push(("signature".to_string(), signature));
8003    }
8004
8005    // Apply all query parameters
8006    if !query_params.is_empty() {
8007        req_builder = req_builder.query(&query_params);
8008    }
8009
8010
8011    // Add user agent if configured
8012    if let Some(ref user_agent) = configuration.user_agent {
8013        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8014    }
8015
8016    // Apply all header parameters
8017    for (header_name, header_value) in header_params {
8018        req_builder = req_builder.header(&header_name, &header_value);
8019    }
8020
8021
8022    let req = req_builder.build()?;
8023    let resp = configuration.client.execute(req).await?;
8024
8025    let status = resp.status();
8026    let content_type = resp
8027        .headers()
8028        .get("content-type")
8029        .and_then(|v| v.to_str().ok())
8030        .unwrap_or("application/octet-stream");
8031    let content_type = super::ContentType::from(content_type);
8032
8033    if !status.is_client_error() && !status.is_server_error() {
8034        let content = resp.text().await?;
8035        match content_type {
8036            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8037            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmAccountConfigV1Resp`"))),
8038            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::GetUmAccountConfigV1Resp`")))),
8039        }
8040    } else {
8041        let content = resp.text().await?;
8042        let entity: Option<GetUmAccountConfigV1Error> = serde_json::from_str(&content).ok();
8043        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8044    }
8045}
8046
8047/// Get current UM account asset and position information.
8048pub async fn get_um_account_v1(configuration: &configuration::Configuration, params: GetUmAccountV1Params) -> Result<models::GetUmAccountV1Resp, Error<GetUmAccountV1Error>> {
8049
8050    let uri_str = format!("{}/papi/v1/um/account", configuration.base_path);
8051    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8052
8053    // Create a mutable vector for query parameters
8054    let mut query_params: Vec<(String, String)> = Vec::new();
8055
8056    if let Some(ref param_value) = params.recv_window {
8057        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8058    }
8059    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8060
8061    // Create header parameters collection
8062    let mut header_params = std::collections::HashMap::new();
8063
8064    // Handle Binance Auth first if configured
8065    if let Some(ref binance_auth) = configuration.binance_auth {
8066        // Add API key to headers
8067        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8068        
8069        // Generate request body for signing (if any)
8070        let body_string: Option<Vec<u8>> = None;
8071        
8072        // Sign the request
8073        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8074            Ok(sig) => sig,
8075            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8076        };
8077        
8078        // Add signature to query params
8079        query_params.push(("signature".to_string(), signature));
8080    }
8081
8082    // Apply all query parameters
8083    if !query_params.is_empty() {
8084        req_builder = req_builder.query(&query_params);
8085    }
8086
8087
8088    // Add user agent if configured
8089    if let Some(ref user_agent) = configuration.user_agent {
8090        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8091    }
8092
8093    // Apply all header parameters
8094    for (header_name, header_value) in header_params {
8095        req_builder = req_builder.header(&header_name, &header_value);
8096    }
8097
8098
8099    let req = req_builder.build()?;
8100    let resp = configuration.client.execute(req).await?;
8101
8102    let status = resp.status();
8103    let content_type = resp
8104        .headers()
8105        .get("content-type")
8106        .and_then(|v| v.to_str().ok())
8107        .unwrap_or("application/octet-stream");
8108    let content_type = super::ContentType::from(content_type);
8109
8110    if !status.is_client_error() && !status.is_server_error() {
8111        let content = resp.text().await?;
8112        match content_type {
8113            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8114            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmAccountV1Resp`"))),
8115            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::GetUmAccountV1Resp`")))),
8116        }
8117    } else {
8118        let content = resp.text().await?;
8119        let entity: Option<GetUmAccountV1Error> = serde_json::from_str(&content).ok();
8120        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8121    }
8122}
8123
8124/// Get current UM account asset and position information.
8125pub async fn get_um_account_v2(configuration: &configuration::Configuration, params: GetUmAccountV2Params) -> Result<models::GetUmAccountV2Resp, Error<GetUmAccountV2Error>> {
8126
8127    let uri_str = format!("{}/papi/v2/um/account", configuration.base_path);
8128    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8129
8130    // Create a mutable vector for query parameters
8131    let mut query_params: Vec<(String, String)> = Vec::new();
8132
8133    if let Some(ref param_value) = params.recv_window {
8134        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8135    }
8136    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8137
8138    // Create header parameters collection
8139    let mut header_params = std::collections::HashMap::new();
8140
8141    // Handle Binance Auth first if configured
8142    if let Some(ref binance_auth) = configuration.binance_auth {
8143        // Add API key to headers
8144        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8145        
8146        // Generate request body for signing (if any)
8147        let body_string: Option<Vec<u8>> = None;
8148        
8149        // Sign the request
8150        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8151            Ok(sig) => sig,
8152            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8153        };
8154        
8155        // Add signature to query params
8156        query_params.push(("signature".to_string(), signature));
8157    }
8158
8159    // Apply all query parameters
8160    if !query_params.is_empty() {
8161        req_builder = req_builder.query(&query_params);
8162    }
8163
8164
8165    // Add user agent if configured
8166    if let Some(ref user_agent) = configuration.user_agent {
8167        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8168    }
8169
8170    // Apply all header parameters
8171    for (header_name, header_value) in header_params {
8172        req_builder = req_builder.header(&header_name, &header_value);
8173    }
8174
8175
8176    let req = req_builder.build()?;
8177    let resp = configuration.client.execute(req).await?;
8178
8179    let status = resp.status();
8180    let content_type = resp
8181        .headers()
8182        .get("content-type")
8183        .and_then(|v| v.to_str().ok())
8184        .unwrap_or("application/octet-stream");
8185    let content_type = super::ContentType::from(content_type);
8186
8187    if !status.is_client_error() && !status.is_server_error() {
8188        let content = resp.text().await?;
8189        match content_type {
8190            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8191            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmAccountV2Resp`"))),
8192            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::GetUmAccountV2Resp`")))),
8193        }
8194    } else {
8195        let content = resp.text().await?;
8196        let entity: Option<GetUmAccountV2Error> = serde_json::from_str(&content).ok();
8197        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8198    }
8199}
8200
8201/// Query UM Position ADL Quantile Estimation
8202pub async fn get_um_adl_quantile_v1(configuration: &configuration::Configuration, params: GetUmAdlQuantileV1Params) -> Result<Vec<models::GetUmAdlQuantileV1RespItem>, Error<GetUmAdlQuantileV1Error>> {
8203
8204    let uri_str = format!("{}/papi/v1/um/adlQuantile", configuration.base_path);
8205    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8206
8207    // Create a mutable vector for query parameters
8208    let mut query_params: Vec<(String, String)> = Vec::new();
8209
8210    if let Some(ref param_value) = params.symbol {
8211        query_params.push(("symbol".to_string(), param_value.to_string()));
8212    }
8213    if let Some(ref param_value) = params.recv_window {
8214        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8215    }
8216    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8217
8218    // Create header parameters collection
8219    let mut header_params = std::collections::HashMap::new();
8220
8221    // Handle Binance Auth first if configured
8222    if let Some(ref binance_auth) = configuration.binance_auth {
8223        // Add API key to headers
8224        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8225        
8226        // Generate request body for signing (if any)
8227        let body_string: Option<Vec<u8>> = None;
8228        
8229        // Sign the request
8230        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8231            Ok(sig) => sig,
8232            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8233        };
8234        
8235        // Add signature to query params
8236        query_params.push(("signature".to_string(), signature));
8237    }
8238
8239    // Apply all query parameters
8240    if !query_params.is_empty() {
8241        req_builder = req_builder.query(&query_params);
8242    }
8243
8244
8245    // Add user agent if configured
8246    if let Some(ref user_agent) = configuration.user_agent {
8247        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8248    }
8249
8250    // Apply all header parameters
8251    for (header_name, header_value) in header_params {
8252        req_builder = req_builder.header(&header_name, &header_value);
8253    }
8254
8255
8256    let req = req_builder.build()?;
8257    let resp = configuration.client.execute(req).await?;
8258
8259    let status = resp.status();
8260    let content_type = resp
8261        .headers()
8262        .get("content-type")
8263        .and_then(|v| v.to_str().ok())
8264        .unwrap_or("application/octet-stream");
8265    let content_type = super::ContentType::from(content_type);
8266
8267    if !status.is_client_error() && !status.is_server_error() {
8268        let content = resp.text().await?;
8269        match content_type {
8270            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8271            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmAdlQuantileV1RespItem&gt;`"))),
8272            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::GetUmAdlQuantileV1RespItem&gt;`")))),
8273        }
8274    } else {
8275        let content = resp.text().await?;
8276        let entity: Option<GetUmAdlQuantileV1Error> = serde_json::from_str(&content).ok();
8277        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8278    }
8279}
8280
8281/// Get all account UM orders; active, canceled, or filled.
8282pub async fn get_um_all_orders_v1(configuration: &configuration::Configuration, params: GetUmAllOrdersV1Params) -> Result<Vec<models::GetUmAllOrdersV1RespItem>, Error<GetUmAllOrdersV1Error>> {
8283
8284    let uri_str = format!("{}/papi/v1/um/allOrders", configuration.base_path);
8285    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8286
8287    // Create a mutable vector for query parameters
8288    let mut query_params: Vec<(String, String)> = Vec::new();
8289
8290    query_params.push(("symbol".to_string(), params.symbol.to_string()));
8291    if let Some(ref param_value) = params.order_id {
8292        query_params.push(("orderId".to_string(), param_value.to_string()));
8293    }
8294    if let Some(ref param_value) = params.start_time {
8295        query_params.push(("startTime".to_string(), param_value.to_string()));
8296    }
8297    if let Some(ref param_value) = params.end_time {
8298        query_params.push(("endTime".to_string(), param_value.to_string()));
8299    }
8300    if let Some(ref param_value) = params.limit {
8301        query_params.push(("limit".to_string(), param_value.to_string()));
8302    }
8303    if let Some(ref param_value) = params.recv_window {
8304        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8305    }
8306    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8307
8308    // Create header parameters collection
8309    let mut header_params = std::collections::HashMap::new();
8310
8311    // Handle Binance Auth first if configured
8312    if let Some(ref binance_auth) = configuration.binance_auth {
8313        // Add API key to headers
8314        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8315        
8316        // Generate request body for signing (if any)
8317        let body_string: Option<Vec<u8>> = None;
8318        
8319        // Sign the request
8320        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8321            Ok(sig) => sig,
8322            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8323        };
8324        
8325        // Add signature to query params
8326        query_params.push(("signature".to_string(), signature));
8327    }
8328
8329    // Apply all query parameters
8330    if !query_params.is_empty() {
8331        req_builder = req_builder.query(&query_params);
8332    }
8333
8334
8335    // Add user agent if configured
8336    if let Some(ref user_agent) = configuration.user_agent {
8337        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8338    }
8339
8340    // Apply all header parameters
8341    for (header_name, header_value) in header_params {
8342        req_builder = req_builder.header(&header_name, &header_value);
8343    }
8344
8345
8346    let req = req_builder.build()?;
8347    let resp = configuration.client.execute(req).await?;
8348
8349    let status = resp.status();
8350    let content_type = resp
8351        .headers()
8352        .get("content-type")
8353        .and_then(|v| v.to_str().ok())
8354        .unwrap_or("application/octet-stream");
8355    let content_type = super::ContentType::from(content_type);
8356
8357    if !status.is_client_error() && !status.is_server_error() {
8358        let content = resp.text().await?;
8359        match content_type {
8360            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8361            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmAllOrdersV1RespItem&gt;`"))),
8362            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::GetUmAllOrdersV1RespItem&gt;`")))),
8363        }
8364    } else {
8365        let content = resp.text().await?;
8366        let entity: Option<GetUmAllOrdersV1Error> = serde_json::from_str(&content).ok();
8367        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8368    }
8369}
8370
8371/// Portfolio Margin UM Trading Quantitative Rules Indicators
8372pub async fn get_um_api_trading_status_v1(configuration: &configuration::Configuration, params: GetUmApiTradingStatusV1Params) -> Result<models::GetUmApiTradingStatusV1Resp, Error<GetUmApiTradingStatusV1Error>> {
8373
8374    let uri_str = format!("{}/papi/v1/um/apiTradingStatus", configuration.base_path);
8375    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8376
8377    // Create a mutable vector for query parameters
8378    let mut query_params: Vec<(String, String)> = Vec::new();
8379
8380    if let Some(ref param_value) = params.symbol {
8381        query_params.push(("symbol".to_string(), param_value.to_string()));
8382    }
8383    if let Some(ref param_value) = params.recv_window {
8384        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8385    }
8386    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8387
8388    // Create header parameters collection
8389    let mut header_params = std::collections::HashMap::new();
8390
8391    // Handle Binance Auth first if configured
8392    if let Some(ref binance_auth) = configuration.binance_auth {
8393        // Add API key to headers
8394        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8395        
8396        // Generate request body for signing (if any)
8397        let body_string: Option<Vec<u8>> = None;
8398        
8399        // Sign the request
8400        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8401            Ok(sig) => sig,
8402            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8403        };
8404        
8405        // Add signature to query params
8406        query_params.push(("signature".to_string(), signature));
8407    }
8408
8409    // Apply all query parameters
8410    if !query_params.is_empty() {
8411        req_builder = req_builder.query(&query_params);
8412    }
8413
8414
8415    // Add user agent if configured
8416    if let Some(ref user_agent) = configuration.user_agent {
8417        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8418    }
8419
8420    // Apply all header parameters
8421    for (header_name, header_value) in header_params {
8422        req_builder = req_builder.header(&header_name, &header_value);
8423    }
8424
8425
8426    let req = req_builder.build()?;
8427    let resp = configuration.client.execute(req).await?;
8428
8429    let status = resp.status();
8430    let content_type = resp
8431        .headers()
8432        .get("content-type")
8433        .and_then(|v| v.to_str().ok())
8434        .unwrap_or("application/octet-stream");
8435    let content_type = super::ContentType::from(content_type);
8436
8437    if !status.is_client_error() && !status.is_server_error() {
8438        let content = resp.text().await?;
8439        match content_type {
8440            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8441            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmApiTradingStatusV1Resp`"))),
8442            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::GetUmApiTradingStatusV1Resp`")))),
8443        }
8444    } else {
8445        let content = resp.text().await?;
8446        let entity: Option<GetUmApiTradingStatusV1Error> = serde_json::from_str(&content).ok();
8447        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8448    }
8449}
8450
8451/// Get User Commission Rate for UM
8452pub async fn get_um_commission_rate_v1(configuration: &configuration::Configuration, params: GetUmCommissionRateV1Params) -> Result<models::GetUmCommissionRateV1Resp, Error<GetUmCommissionRateV1Error>> {
8453
8454    let uri_str = format!("{}/papi/v1/um/commissionRate", configuration.base_path);
8455    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8456
8457    // Create a mutable vector for query parameters
8458    let mut query_params: Vec<(String, String)> = Vec::new();
8459
8460    query_params.push(("symbol".to_string(), params.symbol.to_string()));
8461    if let Some(ref param_value) = params.recv_window {
8462        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8463    }
8464    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8465
8466    // Create header parameters collection
8467    let mut header_params = std::collections::HashMap::new();
8468
8469    // Handle Binance Auth first if configured
8470    if let Some(ref binance_auth) = configuration.binance_auth {
8471        // Add API key to headers
8472        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8473        
8474        // Generate request body for signing (if any)
8475        let body_string: Option<Vec<u8>> = None;
8476        
8477        // Sign the request
8478        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8479            Ok(sig) => sig,
8480            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8481        };
8482        
8483        // Add signature to query params
8484        query_params.push(("signature".to_string(), signature));
8485    }
8486
8487    // Apply all query parameters
8488    if !query_params.is_empty() {
8489        req_builder = req_builder.query(&query_params);
8490    }
8491
8492
8493    // Add user agent if configured
8494    if let Some(ref user_agent) = configuration.user_agent {
8495        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8496    }
8497
8498    // Apply all header parameters
8499    for (header_name, header_value) in header_params {
8500        req_builder = req_builder.header(&header_name, &header_value);
8501    }
8502
8503
8504    let req = req_builder.build()?;
8505    let resp = configuration.client.execute(req).await?;
8506
8507    let status = resp.status();
8508    let content_type = resp
8509        .headers()
8510        .get("content-type")
8511        .and_then(|v| v.to_str().ok())
8512        .unwrap_or("application/octet-stream");
8513    let content_type = super::ContentType::from(content_type);
8514
8515    if !status.is_client_error() && !status.is_server_error() {
8516        let content = resp.text().await?;
8517        match content_type {
8518            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8519            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmCommissionRateV1Resp`"))),
8520            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::GetUmCommissionRateV1Resp`")))),
8521        }
8522    } else {
8523        let content = resp.text().await?;
8524        let entity: Option<GetUmCommissionRateV1Error> = serde_json::from_str(&content).ok();
8525        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8526    }
8527}
8528
8529/// Query All UM Conditional Orders
8530pub async fn get_um_conditional_all_orders_v1(configuration: &configuration::Configuration, params: GetUmConditionalAllOrdersV1Params) -> Result<Vec<models::GetUmConditionalAllOrdersV1RespItem>, Error<GetUmConditionalAllOrdersV1Error>> {
8531
8532    let uri_str = format!("{}/papi/v1/um/conditional/allOrders", configuration.base_path);
8533    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8534
8535    // Create a mutable vector for query parameters
8536    let mut query_params: Vec<(String, String)> = Vec::new();
8537
8538    if let Some(ref param_value) = params.symbol {
8539        query_params.push(("symbol".to_string(), param_value.to_string()));
8540    }
8541    if let Some(ref param_value) = params.strategy_id {
8542        query_params.push(("strategyId".to_string(), param_value.to_string()));
8543    }
8544    if let Some(ref param_value) = params.start_time {
8545        query_params.push(("startTime".to_string(), param_value.to_string()));
8546    }
8547    if let Some(ref param_value) = params.end_time {
8548        query_params.push(("endTime".to_string(), param_value.to_string()));
8549    }
8550    if let Some(ref param_value) = params.limit {
8551        query_params.push(("limit".to_string(), param_value.to_string()));
8552    }
8553    if let Some(ref param_value) = params.recv_window {
8554        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8555    }
8556    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8557
8558    // Create header parameters collection
8559    let mut header_params = std::collections::HashMap::new();
8560
8561    // Handle Binance Auth first if configured
8562    if let Some(ref binance_auth) = configuration.binance_auth {
8563        // Add API key to headers
8564        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8565        
8566        // Generate request body for signing (if any)
8567        let body_string: Option<Vec<u8>> = None;
8568        
8569        // Sign the request
8570        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8571            Ok(sig) => sig,
8572            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8573        };
8574        
8575        // Add signature to query params
8576        query_params.push(("signature".to_string(), signature));
8577    }
8578
8579    // Apply all query parameters
8580    if !query_params.is_empty() {
8581        req_builder = req_builder.query(&query_params);
8582    }
8583
8584
8585    // Add user agent if configured
8586    if let Some(ref user_agent) = configuration.user_agent {
8587        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8588    }
8589
8590    // Apply all header parameters
8591    for (header_name, header_value) in header_params {
8592        req_builder = req_builder.header(&header_name, &header_value);
8593    }
8594
8595
8596    let req = req_builder.build()?;
8597    let resp = configuration.client.execute(req).await?;
8598
8599    let status = resp.status();
8600    let content_type = resp
8601        .headers()
8602        .get("content-type")
8603        .and_then(|v| v.to_str().ok())
8604        .unwrap_or("application/octet-stream");
8605    let content_type = super::ContentType::from(content_type);
8606
8607    if !status.is_client_error() && !status.is_server_error() {
8608        let content = resp.text().await?;
8609        match content_type {
8610            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8611            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmConditionalAllOrdersV1RespItem&gt;`"))),
8612            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::GetUmConditionalAllOrdersV1RespItem&gt;`")))),
8613        }
8614    } else {
8615        let content = resp.text().await?;
8616        let entity: Option<GetUmConditionalAllOrdersV1Error> = serde_json::from_str(&content).ok();
8617        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8618    }
8619}
8620
8621/// Query Current UM Open Conditional Order
8622pub async fn get_um_conditional_open_order_v1(configuration: &configuration::Configuration, params: GetUmConditionalOpenOrderV1Params) -> Result<models::GetUmConditionalOpenOrderV1Resp, Error<GetUmConditionalOpenOrderV1Error>> {
8623
8624    let uri_str = format!("{}/papi/v1/um/conditional/openOrder", configuration.base_path);
8625    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8626
8627    // Create a mutable vector for query parameters
8628    let mut query_params: Vec<(String, String)> = Vec::new();
8629
8630    query_params.push(("symbol".to_string(), params.symbol.to_string()));
8631    if let Some(ref param_value) = params.strategy_id {
8632        query_params.push(("strategyId".to_string(), param_value.to_string()));
8633    }
8634    if let Some(ref param_value) = params.new_client_strategy_id {
8635        query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
8636    }
8637    if let Some(ref param_value) = params.recv_window {
8638        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8639    }
8640    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8641
8642    // Create header parameters collection
8643    let mut header_params = std::collections::HashMap::new();
8644
8645    // Handle Binance Auth first if configured
8646    if let Some(ref binance_auth) = configuration.binance_auth {
8647        // Add API key to headers
8648        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8649        
8650        // Generate request body for signing (if any)
8651        let body_string: Option<Vec<u8>> = None;
8652        
8653        // Sign the request
8654        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8655            Ok(sig) => sig,
8656            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8657        };
8658        
8659        // Add signature to query params
8660        query_params.push(("signature".to_string(), signature));
8661    }
8662
8663    // Apply all query parameters
8664    if !query_params.is_empty() {
8665        req_builder = req_builder.query(&query_params);
8666    }
8667
8668
8669    // Add user agent if configured
8670    if let Some(ref user_agent) = configuration.user_agent {
8671        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8672    }
8673
8674    // Apply all header parameters
8675    for (header_name, header_value) in header_params {
8676        req_builder = req_builder.header(&header_name, &header_value);
8677    }
8678
8679
8680    let req = req_builder.build()?;
8681    let resp = configuration.client.execute(req).await?;
8682
8683    let status = resp.status();
8684    let content_type = resp
8685        .headers()
8686        .get("content-type")
8687        .and_then(|v| v.to_str().ok())
8688        .unwrap_or("application/octet-stream");
8689    let content_type = super::ContentType::from(content_type);
8690
8691    if !status.is_client_error() && !status.is_server_error() {
8692        let content = resp.text().await?;
8693        match content_type {
8694            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8695            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmConditionalOpenOrderV1Resp`"))),
8696            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::GetUmConditionalOpenOrderV1Resp`")))),
8697        }
8698    } else {
8699        let content = resp.text().await?;
8700        let entity: Option<GetUmConditionalOpenOrderV1Error> = serde_json::from_str(&content).ok();
8701        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8702    }
8703}
8704
8705/// Get all open conditional orders on a symbol.
8706pub async fn get_um_conditional_open_orders_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetUmConditionalOpenOrdersV1RespItem>, Error<GetUmConditionalOpenOrdersV1Error>> {
8707
8708    let uri_str = format!("{}/papi/v1/um/conditional/openOrders", configuration.base_path);
8709    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8710
8711    // Create a mutable vector for query parameters
8712    let mut query_params: Vec<(String, String)> = Vec::new();
8713
8714
8715    // Create header parameters collection
8716    let mut header_params = std::collections::HashMap::new();
8717
8718    // Handle Binance Auth first if configured
8719    if let Some(ref binance_auth) = configuration.binance_auth {
8720        // Add API key to headers
8721        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8722        
8723        // Generate request body for signing (if any)
8724        let body_string: Option<Vec<u8>> = None;
8725        
8726        // Sign the request
8727        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8728            Ok(sig) => sig,
8729            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8730        };
8731        
8732        // Add signature to query params
8733        query_params.push(("signature".to_string(), signature));
8734    }
8735
8736    // Apply all query parameters
8737    if !query_params.is_empty() {
8738        req_builder = req_builder.query(&query_params);
8739    }
8740
8741
8742    // Add user agent if configured
8743    if let Some(ref user_agent) = configuration.user_agent {
8744        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8745    }
8746
8747    // Apply all header parameters
8748    for (header_name, header_value) in header_params {
8749        req_builder = req_builder.header(&header_name, &header_value);
8750    }
8751
8752
8753    let req = req_builder.build()?;
8754    let resp = configuration.client.execute(req).await?;
8755
8756    let status = resp.status();
8757    let content_type = resp
8758        .headers()
8759        .get("content-type")
8760        .and_then(|v| v.to_str().ok())
8761        .unwrap_or("application/octet-stream");
8762    let content_type = super::ContentType::from(content_type);
8763
8764    if !status.is_client_error() && !status.is_server_error() {
8765        let content = resp.text().await?;
8766        match content_type {
8767            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8768            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmConditionalOpenOrdersV1RespItem&gt;`"))),
8769            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::GetUmConditionalOpenOrdersV1RespItem&gt;`")))),
8770        }
8771    } else {
8772        let content = resp.text().await?;
8773        let entity: Option<GetUmConditionalOpenOrdersV1Error> = serde_json::from_str(&content).ok();
8774        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8775    }
8776}
8777
8778/// Query UM Conditional Order History
8779pub async fn get_um_conditional_order_history_v1(configuration: &configuration::Configuration, params: GetUmConditionalOrderHistoryV1Params) -> Result<models::GetUmConditionalOrderHistoryV1Resp, Error<GetUmConditionalOrderHistoryV1Error>> {
8780
8781    let uri_str = format!("{}/papi/v1/um/conditional/orderHistory", configuration.base_path);
8782    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8783
8784    // Create a mutable vector for query parameters
8785    let mut query_params: Vec<(String, String)> = Vec::new();
8786
8787    query_params.push(("symbol".to_string(), params.symbol.to_string()));
8788    if let Some(ref param_value) = params.strategy_id {
8789        query_params.push(("strategyId".to_string(), param_value.to_string()));
8790    }
8791    if let Some(ref param_value) = params.new_client_strategy_id {
8792        query_params.push(("newClientStrategyId".to_string(), param_value.to_string()));
8793    }
8794    if let Some(ref param_value) = params.recv_window {
8795        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8796    }
8797    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8798
8799    // Create header parameters collection
8800    let mut header_params = std::collections::HashMap::new();
8801
8802    // Handle Binance Auth first if configured
8803    if let Some(ref binance_auth) = configuration.binance_auth {
8804        // Add API key to headers
8805        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8806        
8807        // Generate request body for signing (if any)
8808        let body_string: Option<Vec<u8>> = None;
8809        
8810        // Sign the request
8811        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8812            Ok(sig) => sig,
8813            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8814        };
8815        
8816        // Add signature to query params
8817        query_params.push(("signature".to_string(), signature));
8818    }
8819
8820    // Apply all query parameters
8821    if !query_params.is_empty() {
8822        req_builder = req_builder.query(&query_params);
8823    }
8824
8825
8826    // Add user agent if configured
8827    if let Some(ref user_agent) = configuration.user_agent {
8828        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8829    }
8830
8831    // Apply all header parameters
8832    for (header_name, header_value) in header_params {
8833        req_builder = req_builder.header(&header_name, &header_value);
8834    }
8835
8836
8837    let req = req_builder.build()?;
8838    let resp = configuration.client.execute(req).await?;
8839
8840    let status = resp.status();
8841    let content_type = resp
8842        .headers()
8843        .get("content-type")
8844        .and_then(|v| v.to_str().ok())
8845        .unwrap_or("application/octet-stream");
8846    let content_type = super::ContentType::from(content_type);
8847
8848    if !status.is_client_error() && !status.is_server_error() {
8849        let content = resp.text().await?;
8850        match content_type {
8851            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8852            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmConditionalOrderHistoryV1Resp`"))),
8853            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::GetUmConditionalOrderHistoryV1Resp`")))),
8854        }
8855    } else {
8856        let content = resp.text().await?;
8857        let entity: Option<GetUmConditionalOrderHistoryV1Error> = serde_json::from_str(&content).ok();
8858        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8859    }
8860}
8861
8862/// Get user's BNB Fee Discount for UM Futures (Fee Discount On or Fee Discount Off )
8863pub async fn get_um_fee_burn_v1(configuration: &configuration::Configuration, params: GetUmFeeBurnV1Params) -> Result<models::GetUmFeeBurnV1Resp, Error<GetUmFeeBurnV1Error>> {
8864
8865    let uri_str = format!("{}/papi/v1/um/feeBurn", configuration.base_path);
8866    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8867
8868    // Create a mutable vector for query parameters
8869    let mut query_params: Vec<(String, String)> = Vec::new();
8870
8871    if let Some(ref param_value) = params.recv_window {
8872        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8873    }
8874    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8875
8876    // Create header parameters collection
8877    let mut header_params = std::collections::HashMap::new();
8878
8879    // Handle Binance Auth first if configured
8880    if let Some(ref binance_auth) = configuration.binance_auth {
8881        // Add API key to headers
8882        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8883        
8884        // Generate request body for signing (if any)
8885        let body_string: Option<Vec<u8>> = None;
8886        
8887        // Sign the request
8888        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8889            Ok(sig) => sig,
8890            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8891        };
8892        
8893        // Add signature to query params
8894        query_params.push(("signature".to_string(), signature));
8895    }
8896
8897    // Apply all query parameters
8898    if !query_params.is_empty() {
8899        req_builder = req_builder.query(&query_params);
8900    }
8901
8902
8903    // Add user agent if configured
8904    if let Some(ref user_agent) = configuration.user_agent {
8905        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8906    }
8907
8908    // Apply all header parameters
8909    for (header_name, header_value) in header_params {
8910        req_builder = req_builder.header(&header_name, &header_value);
8911    }
8912
8913
8914    let req = req_builder.build()?;
8915    let resp = configuration.client.execute(req).await?;
8916
8917    let status = resp.status();
8918    let content_type = resp
8919        .headers()
8920        .get("content-type")
8921        .and_then(|v| v.to_str().ok())
8922        .unwrap_or("application/octet-stream");
8923    let content_type = super::ContentType::from(content_type);
8924
8925    if !status.is_client_error() && !status.is_server_error() {
8926        let content = resp.text().await?;
8927        match content_type {
8928            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
8929            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmFeeBurnV1Resp`"))),
8930            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::GetUmFeeBurnV1Resp`")))),
8931        }
8932    } else {
8933        let content = resp.text().await?;
8934        let entity: Option<GetUmFeeBurnV1Error> = serde_json::from_str(&content).ok();
8935        Err(Error::ResponseError(ResponseContent { status, content, entity }))
8936    }
8937}
8938
8939/// Query User's UM Force Orders
8940pub async fn get_um_force_orders_v1(configuration: &configuration::Configuration, params: GetUmForceOrdersV1Params) -> Result<Vec<models::GetUmForceOrdersV1RespItem>, Error<GetUmForceOrdersV1Error>> {
8941
8942    let uri_str = format!("{}/papi/v1/um/forceOrders", configuration.base_path);
8943    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
8944
8945    // Create a mutable vector for query parameters
8946    let mut query_params: Vec<(String, String)> = Vec::new();
8947
8948    if let Some(ref param_value) = params.symbol {
8949        query_params.push(("symbol".to_string(), param_value.to_string()));
8950    }
8951    if let Some(ref param_value) = params.auto_close_type {
8952        query_params.push(("autoCloseType".to_string(), param_value.to_string()));
8953    }
8954    if let Some(ref param_value) = params.start_time {
8955        query_params.push(("startTime".to_string(), param_value.to_string()));
8956    }
8957    if let Some(ref param_value) = params.end_time {
8958        query_params.push(("endTime".to_string(), param_value.to_string()));
8959    }
8960    if let Some(ref param_value) = params.limit {
8961        query_params.push(("limit".to_string(), param_value.to_string()));
8962    }
8963    if let Some(ref param_value) = params.recv_window {
8964        query_params.push(("recvWindow".to_string(), param_value.to_string()));
8965    }
8966    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
8967
8968    // Create header parameters collection
8969    let mut header_params = std::collections::HashMap::new();
8970
8971    // Handle Binance Auth first if configured
8972    if let Some(ref binance_auth) = configuration.binance_auth {
8973        // Add API key to headers
8974        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
8975        
8976        // Generate request body for signing (if any)
8977        let body_string: Option<Vec<u8>> = None;
8978        
8979        // Sign the request
8980        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
8981            Ok(sig) => sig,
8982            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
8983        };
8984        
8985        // Add signature to query params
8986        query_params.push(("signature".to_string(), signature));
8987    }
8988
8989    // Apply all query parameters
8990    if !query_params.is_empty() {
8991        req_builder = req_builder.query(&query_params);
8992    }
8993
8994
8995    // Add user agent if configured
8996    if let Some(ref user_agent) = configuration.user_agent {
8997        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
8998    }
8999
9000    // Apply all header parameters
9001    for (header_name, header_value) in header_params {
9002        req_builder = req_builder.header(&header_name, &header_value);
9003    }
9004
9005
9006    let req = req_builder.build()?;
9007    let resp = configuration.client.execute(req).await?;
9008
9009    let status = resp.status();
9010    let content_type = resp
9011        .headers()
9012        .get("content-type")
9013        .and_then(|v| v.to_str().ok())
9014        .unwrap_or("application/octet-stream");
9015    let content_type = super::ContentType::from(content_type);
9016
9017    if !status.is_client_error() && !status.is_server_error() {
9018        let content = resp.text().await?;
9019        match content_type {
9020            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9021            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmForceOrdersV1RespItem&gt;`"))),
9022            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::GetUmForceOrdersV1RespItem&gt;`")))),
9023        }
9024    } else {
9025        let content = resp.text().await?;
9026        let entity: Option<GetUmForceOrdersV1Error> = serde_json::from_str(&content).ok();
9027        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9028    }
9029}
9030
9031/// Get UM futures Transaction download link by Id
9032pub async fn get_um_income_asyn_id_v1(configuration: &configuration::Configuration, params: GetUmIncomeAsynIdV1Params) -> Result<models::GetUmIncomeAsynIdV1Resp, Error<GetUmIncomeAsynIdV1Error>> {
9033
9034    let uri_str = format!("{}/papi/v1/um/income/asyn/id", configuration.base_path);
9035    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9036
9037    // Create a mutable vector for query parameters
9038    let mut query_params: Vec<(String, String)> = Vec::new();
9039
9040    query_params.push(("downloadId".to_string(), params.download_id.to_string()));
9041    if let Some(ref param_value) = params.recv_window {
9042        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9043    }
9044    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9045
9046    // Create header parameters collection
9047    let mut header_params = std::collections::HashMap::new();
9048
9049    // Handle Binance Auth first if configured
9050    if let Some(ref binance_auth) = configuration.binance_auth {
9051        // Add API key to headers
9052        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9053        
9054        // Generate request body for signing (if any)
9055        let body_string: Option<Vec<u8>> = None;
9056        
9057        // Sign the request
9058        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9059            Ok(sig) => sig,
9060            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9061        };
9062        
9063        // Add signature to query params
9064        query_params.push(("signature".to_string(), signature));
9065    }
9066
9067    // Apply all query parameters
9068    if !query_params.is_empty() {
9069        req_builder = req_builder.query(&query_params);
9070    }
9071
9072
9073    // Add user agent if configured
9074    if let Some(ref user_agent) = configuration.user_agent {
9075        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9076    }
9077
9078    // Apply all header parameters
9079    for (header_name, header_value) in header_params {
9080        req_builder = req_builder.header(&header_name, &header_value);
9081    }
9082
9083
9084    let req = req_builder.build()?;
9085    let resp = configuration.client.execute(req).await?;
9086
9087    let status = resp.status();
9088    let content_type = resp
9089        .headers()
9090        .get("content-type")
9091        .and_then(|v| v.to_str().ok())
9092        .unwrap_or("application/octet-stream");
9093    let content_type = super::ContentType::from(content_type);
9094
9095    if !status.is_client_error() && !status.is_server_error() {
9096        let content = resp.text().await?;
9097        match content_type {
9098            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9099            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmIncomeAsynIdV1Resp`"))),
9100            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::GetUmIncomeAsynIdV1Resp`")))),
9101        }
9102    } else {
9103        let content = resp.text().await?;
9104        let entity: Option<GetUmIncomeAsynIdV1Error> = serde_json::from_str(&content).ok();
9105        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9106    }
9107}
9108
9109/// Get download id for UM futures transaction history
9110pub async fn get_um_income_asyn_v1(configuration: &configuration::Configuration, params: GetUmIncomeAsynV1Params) -> Result<models::GetUmIncomeAsynV1Resp, Error<GetUmIncomeAsynV1Error>> {
9111
9112    let uri_str = format!("{}/papi/v1/um/income/asyn", configuration.base_path);
9113    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9114
9115    // Create a mutable vector for query parameters
9116    let mut query_params: Vec<(String, String)> = Vec::new();
9117
9118    query_params.push(("startTime".to_string(), params.start_time.to_string()));
9119    query_params.push(("endTime".to_string(), params.end_time.to_string()));
9120    if let Some(ref param_value) = params.recv_window {
9121        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9122    }
9123    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9124
9125    // Create header parameters collection
9126    let mut header_params = std::collections::HashMap::new();
9127
9128    // Handle Binance Auth first if configured
9129    if let Some(ref binance_auth) = configuration.binance_auth {
9130        // Add API key to headers
9131        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9132        
9133        // Generate request body for signing (if any)
9134        let body_string: Option<Vec<u8>> = None;
9135        
9136        // Sign the request
9137        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9138            Ok(sig) => sig,
9139            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9140        };
9141        
9142        // Add signature to query params
9143        query_params.push(("signature".to_string(), signature));
9144    }
9145
9146    // Apply all query parameters
9147    if !query_params.is_empty() {
9148        req_builder = req_builder.query(&query_params);
9149    }
9150
9151
9152    // Add user agent if configured
9153    if let Some(ref user_agent) = configuration.user_agent {
9154        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9155    }
9156
9157    // Apply all header parameters
9158    for (header_name, header_value) in header_params {
9159        req_builder = req_builder.header(&header_name, &header_value);
9160    }
9161
9162
9163    let req = req_builder.build()?;
9164    let resp = configuration.client.execute(req).await?;
9165
9166    let status = resp.status();
9167    let content_type = resp
9168        .headers()
9169        .get("content-type")
9170        .and_then(|v| v.to_str().ok())
9171        .unwrap_or("application/octet-stream");
9172    let content_type = super::ContentType::from(content_type);
9173
9174    if !status.is_client_error() && !status.is_server_error() {
9175        let content = resp.text().await?;
9176        match content_type {
9177            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9178            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmIncomeAsynV1Resp`"))),
9179            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::GetUmIncomeAsynV1Resp`")))),
9180        }
9181    } else {
9182        let content = resp.text().await?;
9183        let entity: Option<GetUmIncomeAsynV1Error> = serde_json::from_str(&content).ok();
9184        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9185    }
9186}
9187
9188/// Get UM Income History
9189pub async fn get_um_income_v1(configuration: &configuration::Configuration, params: GetUmIncomeV1Params) -> Result<Vec<models::GetUmIncomeV1RespItem>, Error<GetUmIncomeV1Error>> {
9190
9191    let uri_str = format!("{}/papi/v1/um/income", configuration.base_path);
9192    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9193
9194    // Create a mutable vector for query parameters
9195    let mut query_params: Vec<(String, String)> = Vec::new();
9196
9197    if let Some(ref param_value) = params.symbol {
9198        query_params.push(("symbol".to_string(), param_value.to_string()));
9199    }
9200    if let Some(ref param_value) = params.income_type {
9201        query_params.push(("incomeType".to_string(), param_value.to_string()));
9202    }
9203    if let Some(ref param_value) = params.start_time {
9204        query_params.push(("startTime".to_string(), param_value.to_string()));
9205    }
9206    if let Some(ref param_value) = params.end_time {
9207        query_params.push(("endTime".to_string(), param_value.to_string()));
9208    }
9209    if let Some(ref param_value) = params.page {
9210        query_params.push(("page".to_string(), param_value.to_string()));
9211    }
9212    if let Some(ref param_value) = params.limit {
9213        query_params.push(("limit".to_string(), param_value.to_string()));
9214    }
9215    if let Some(ref param_value) = params.recv_window {
9216        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9217    }
9218    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9219
9220    // Create header parameters collection
9221    let mut header_params = std::collections::HashMap::new();
9222
9223    // Handle Binance Auth first if configured
9224    if let Some(ref binance_auth) = configuration.binance_auth {
9225        // Add API key to headers
9226        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9227        
9228        // Generate request body for signing (if any)
9229        let body_string: Option<Vec<u8>> = None;
9230        
9231        // Sign the request
9232        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9233            Ok(sig) => sig,
9234            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9235        };
9236        
9237        // Add signature to query params
9238        query_params.push(("signature".to_string(), signature));
9239    }
9240
9241    // Apply all query parameters
9242    if !query_params.is_empty() {
9243        req_builder = req_builder.query(&query_params);
9244    }
9245
9246
9247    // Add user agent if configured
9248    if let Some(ref user_agent) = configuration.user_agent {
9249        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9250    }
9251
9252    // Apply all header parameters
9253    for (header_name, header_value) in header_params {
9254        req_builder = req_builder.header(&header_name, &header_value);
9255    }
9256
9257
9258    let req = req_builder.build()?;
9259    let resp = configuration.client.execute(req).await?;
9260
9261    let status = resp.status();
9262    let content_type = resp
9263        .headers()
9264        .get("content-type")
9265        .and_then(|v| v.to_str().ok())
9266        .unwrap_or("application/octet-stream");
9267    let content_type = super::ContentType::from(content_type);
9268
9269    if !status.is_client_error() && !status.is_server_error() {
9270        let content = resp.text().await?;
9271        match content_type {
9272            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9273            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmIncomeV1RespItem&gt;`"))),
9274            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::GetUmIncomeV1RespItem&gt;`")))),
9275        }
9276    } else {
9277        let content = resp.text().await?;
9278        let entity: Option<GetUmIncomeV1Error> = serde_json::from_str(&content).ok();
9279        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9280    }
9281}
9282
9283/// Query UM notional and leverage brackets
9284pub async fn get_um_leverage_bracket_v1(configuration: &configuration::Configuration, params: GetUmLeverageBracketV1Params) -> Result<Vec<models::GetUmLeverageBracketV1RespItem>, Error<GetUmLeverageBracketV1Error>> {
9285
9286    let uri_str = format!("{}/papi/v1/um/leverageBracket", configuration.base_path);
9287    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9288
9289    // Create a mutable vector for query parameters
9290    let mut query_params: Vec<(String, String)> = Vec::new();
9291
9292    if let Some(ref param_value) = params.symbol {
9293        query_params.push(("symbol".to_string(), param_value.to_string()));
9294    }
9295    if let Some(ref param_value) = params.recv_window {
9296        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9297    }
9298    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9299
9300    // Create header parameters collection
9301    let mut header_params = std::collections::HashMap::new();
9302
9303    // Handle Binance Auth first if configured
9304    if let Some(ref binance_auth) = configuration.binance_auth {
9305        // Add API key to headers
9306        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9307        
9308        // Generate request body for signing (if any)
9309        let body_string: Option<Vec<u8>> = None;
9310        
9311        // Sign the request
9312        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9313            Ok(sig) => sig,
9314            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9315        };
9316        
9317        // Add signature to query params
9318        query_params.push(("signature".to_string(), signature));
9319    }
9320
9321    // Apply all query parameters
9322    if !query_params.is_empty() {
9323        req_builder = req_builder.query(&query_params);
9324    }
9325
9326
9327    // Add user agent if configured
9328    if let Some(ref user_agent) = configuration.user_agent {
9329        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9330    }
9331
9332    // Apply all header parameters
9333    for (header_name, header_value) in header_params {
9334        req_builder = req_builder.header(&header_name, &header_value);
9335    }
9336
9337
9338    let req = req_builder.build()?;
9339    let resp = configuration.client.execute(req).await?;
9340
9341    let status = resp.status();
9342    let content_type = resp
9343        .headers()
9344        .get("content-type")
9345        .and_then(|v| v.to_str().ok())
9346        .unwrap_or("application/octet-stream");
9347    let content_type = super::ContentType::from(content_type);
9348
9349    if !status.is_client_error() && !status.is_server_error() {
9350        let content = resp.text().await?;
9351        match content_type {
9352            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9353            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmLeverageBracketV1RespItem&gt;`"))),
9354            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::GetUmLeverageBracketV1RespItem&gt;`")))),
9355        }
9356    } else {
9357        let content = resp.text().await?;
9358        let entity: Option<GetUmLeverageBracketV1Error> = serde_json::from_str(&content).ok();
9359        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9360    }
9361}
9362
9363/// Query current UM open order
9364pub async fn get_um_open_order_v1(configuration: &configuration::Configuration, params: GetUmOpenOrderV1Params) -> Result<models::GetUmOpenOrderV1Resp, Error<GetUmOpenOrderV1Error>> {
9365
9366    let uri_str = format!("{}/papi/v1/um/openOrder", configuration.base_path);
9367    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9368
9369    // Create a mutable vector for query parameters
9370    let mut query_params: Vec<(String, String)> = Vec::new();
9371
9372    query_params.push(("symbol".to_string(), params.symbol.to_string()));
9373    if let Some(ref param_value) = params.order_id {
9374        query_params.push(("orderId".to_string(), param_value.to_string()));
9375    }
9376    if let Some(ref param_value) = params.orig_client_order_id {
9377        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
9378    }
9379    if let Some(ref param_value) = params.recv_window {
9380        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9381    }
9382    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9383
9384    // Create header parameters collection
9385    let mut header_params = std::collections::HashMap::new();
9386
9387    // Handle Binance Auth first if configured
9388    if let Some(ref binance_auth) = configuration.binance_auth {
9389        // Add API key to headers
9390        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9391        
9392        // Generate request body for signing (if any)
9393        let body_string: Option<Vec<u8>> = None;
9394        
9395        // Sign the request
9396        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9397            Ok(sig) => sig,
9398            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9399        };
9400        
9401        // Add signature to query params
9402        query_params.push(("signature".to_string(), signature));
9403    }
9404
9405    // Apply all query parameters
9406    if !query_params.is_empty() {
9407        req_builder = req_builder.query(&query_params);
9408    }
9409
9410
9411    // Add user agent if configured
9412    if let Some(ref user_agent) = configuration.user_agent {
9413        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9414    }
9415
9416    // Apply all header parameters
9417    for (header_name, header_value) in header_params {
9418        req_builder = req_builder.header(&header_name, &header_value);
9419    }
9420
9421
9422    let req = req_builder.build()?;
9423    let resp = configuration.client.execute(req).await?;
9424
9425    let status = resp.status();
9426    let content_type = resp
9427        .headers()
9428        .get("content-type")
9429        .and_then(|v| v.to_str().ok())
9430        .unwrap_or("application/octet-stream");
9431    let content_type = super::ContentType::from(content_type);
9432
9433    if !status.is_client_error() && !status.is_server_error() {
9434        let content = resp.text().await?;
9435        match content_type {
9436            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9437            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmOpenOrderV1Resp`"))),
9438            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::GetUmOpenOrderV1Resp`")))),
9439        }
9440    } else {
9441        let content = resp.text().await?;
9442        let entity: Option<GetUmOpenOrderV1Error> = serde_json::from_str(&content).ok();
9443        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9444    }
9445}
9446
9447/// Get all open orders on a symbol.
9448pub async fn get_um_open_orders_v1(configuration: &configuration::Configuration, params: GetUmOpenOrdersV1Params) -> Result<Vec<models::GetUmOpenOrdersV1RespItem>, Error<GetUmOpenOrdersV1Error>> {
9449
9450    let uri_str = format!("{}/papi/v1/um/openOrders", configuration.base_path);
9451    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9452
9453    // Create a mutable vector for query parameters
9454    let mut query_params: Vec<(String, String)> = Vec::new();
9455
9456    if let Some(ref param_value) = params.symbol {
9457        query_params.push(("symbol".to_string(), param_value.to_string()));
9458    }
9459    if let Some(ref param_value) = params.recv_window {
9460        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9461    }
9462    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9463
9464    // Create header parameters collection
9465    let mut header_params = std::collections::HashMap::new();
9466
9467    // Handle Binance Auth first if configured
9468    if let Some(ref binance_auth) = configuration.binance_auth {
9469        // Add API key to headers
9470        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9471        
9472        // Generate request body for signing (if any)
9473        let body_string: Option<Vec<u8>> = None;
9474        
9475        // Sign the request
9476        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9477            Ok(sig) => sig,
9478            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9479        };
9480        
9481        // Add signature to query params
9482        query_params.push(("signature".to_string(), signature));
9483    }
9484
9485    // Apply all query parameters
9486    if !query_params.is_empty() {
9487        req_builder = req_builder.query(&query_params);
9488    }
9489
9490
9491    // Add user agent if configured
9492    if let Some(ref user_agent) = configuration.user_agent {
9493        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9494    }
9495
9496    // Apply all header parameters
9497    for (header_name, header_value) in header_params {
9498        req_builder = req_builder.header(&header_name, &header_value);
9499    }
9500
9501
9502    let req = req_builder.build()?;
9503    let resp = configuration.client.execute(req).await?;
9504
9505    let status = resp.status();
9506    let content_type = resp
9507        .headers()
9508        .get("content-type")
9509        .and_then(|v| v.to_str().ok())
9510        .unwrap_or("application/octet-stream");
9511    let content_type = super::ContentType::from(content_type);
9512
9513    if !status.is_client_error() && !status.is_server_error() {
9514        let content = resp.text().await?;
9515        match content_type {
9516            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9517            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmOpenOrdersV1RespItem&gt;`"))),
9518            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::GetUmOpenOrdersV1RespItem&gt;`")))),
9519        }
9520    } else {
9521        let content = resp.text().await?;
9522        let entity: Option<GetUmOpenOrdersV1Error> = serde_json::from_str(&content).ok();
9523        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9524    }
9525}
9526
9527/// Get order modification history
9528pub async fn get_um_order_amendment_v1(configuration: &configuration::Configuration, params: GetUmOrderAmendmentV1Params) -> Result<Vec<models::GetUmOrderAmendmentV1RespItem>, Error<GetUmOrderAmendmentV1Error>> {
9529
9530    let uri_str = format!("{}/papi/v1/um/orderAmendment", configuration.base_path);
9531    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9532
9533    // Create a mutable vector for query parameters
9534    let mut query_params: Vec<(String, String)> = Vec::new();
9535
9536    query_params.push(("symbol".to_string(), params.symbol.to_string()));
9537    if let Some(ref param_value) = params.order_id {
9538        query_params.push(("orderId".to_string(), param_value.to_string()));
9539    }
9540    if let Some(ref param_value) = params.orig_client_order_id {
9541        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
9542    }
9543    if let Some(ref param_value) = params.start_time {
9544        query_params.push(("startTime".to_string(), param_value.to_string()));
9545    }
9546    if let Some(ref param_value) = params.end_time {
9547        query_params.push(("endTime".to_string(), param_value.to_string()));
9548    }
9549    if let Some(ref param_value) = params.limit {
9550        query_params.push(("limit".to_string(), param_value.to_string()));
9551    }
9552    if let Some(ref param_value) = params.recv_window {
9553        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9554    }
9555    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9556
9557    // Create header parameters collection
9558    let mut header_params = std::collections::HashMap::new();
9559
9560    // Handle Binance Auth first if configured
9561    if let Some(ref binance_auth) = configuration.binance_auth {
9562        // Add API key to headers
9563        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9564        
9565        // Generate request body for signing (if any)
9566        let body_string: Option<Vec<u8>> = None;
9567        
9568        // Sign the request
9569        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9570            Ok(sig) => sig,
9571            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9572        };
9573        
9574        // Add signature to query params
9575        query_params.push(("signature".to_string(), signature));
9576    }
9577
9578    // Apply all query parameters
9579    if !query_params.is_empty() {
9580        req_builder = req_builder.query(&query_params);
9581    }
9582
9583
9584    // Add user agent if configured
9585    if let Some(ref user_agent) = configuration.user_agent {
9586        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9587    }
9588
9589    // Apply all header parameters
9590    for (header_name, header_value) in header_params {
9591        req_builder = req_builder.header(&header_name, &header_value);
9592    }
9593
9594
9595    let req = req_builder.build()?;
9596    let resp = configuration.client.execute(req).await?;
9597
9598    let status = resp.status();
9599    let content_type = resp
9600        .headers()
9601        .get("content-type")
9602        .and_then(|v| v.to_str().ok())
9603        .unwrap_or("application/octet-stream");
9604    let content_type = super::ContentType::from(content_type);
9605
9606    if !status.is_client_error() && !status.is_server_error() {
9607        let content = resp.text().await?;
9608        match content_type {
9609            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9610            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmOrderAmendmentV1RespItem&gt;`"))),
9611            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::GetUmOrderAmendmentV1RespItem&gt;`")))),
9612        }
9613    } else {
9614        let content = resp.text().await?;
9615        let entity: Option<GetUmOrderAmendmentV1Error> = serde_json::from_str(&content).ok();
9616        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9617    }
9618}
9619
9620/// Get UM futures order download link by Id
9621pub async fn get_um_order_asyn_id_v1(configuration: &configuration::Configuration, params: GetUmOrderAsynIdV1Params) -> Result<models::GetUmOrderAsynIdV1Resp, Error<GetUmOrderAsynIdV1Error>> {
9622
9623    let uri_str = format!("{}/papi/v1/um/order/asyn/id", configuration.base_path);
9624    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9625
9626    // Create a mutable vector for query parameters
9627    let mut query_params: Vec<(String, String)> = Vec::new();
9628
9629    query_params.push(("downloadId".to_string(), params.download_id.to_string()));
9630    if let Some(ref param_value) = params.recv_window {
9631        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9632    }
9633    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9634
9635    // Create header parameters collection
9636    let mut header_params = std::collections::HashMap::new();
9637
9638    // Handle Binance Auth first if configured
9639    if let Some(ref binance_auth) = configuration.binance_auth {
9640        // Add API key to headers
9641        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9642        
9643        // Generate request body for signing (if any)
9644        let body_string: Option<Vec<u8>> = None;
9645        
9646        // Sign the request
9647        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9648            Ok(sig) => sig,
9649            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9650        };
9651        
9652        // Add signature to query params
9653        query_params.push(("signature".to_string(), signature));
9654    }
9655
9656    // Apply all query parameters
9657    if !query_params.is_empty() {
9658        req_builder = req_builder.query(&query_params);
9659    }
9660
9661
9662    // Add user agent if configured
9663    if let Some(ref user_agent) = configuration.user_agent {
9664        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9665    }
9666
9667    // Apply all header parameters
9668    for (header_name, header_value) in header_params {
9669        req_builder = req_builder.header(&header_name, &header_value);
9670    }
9671
9672
9673    let req = req_builder.build()?;
9674    let resp = configuration.client.execute(req).await?;
9675
9676    let status = resp.status();
9677    let content_type = resp
9678        .headers()
9679        .get("content-type")
9680        .and_then(|v| v.to_str().ok())
9681        .unwrap_or("application/octet-stream");
9682    let content_type = super::ContentType::from(content_type);
9683
9684    if !status.is_client_error() && !status.is_server_error() {
9685        let content = resp.text().await?;
9686        match content_type {
9687            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9688            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmOrderAsynIdV1Resp`"))),
9689            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::GetUmOrderAsynIdV1Resp`")))),
9690        }
9691    } else {
9692        let content = resp.text().await?;
9693        let entity: Option<GetUmOrderAsynIdV1Error> = serde_json::from_str(&content).ok();
9694        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9695    }
9696}
9697
9698/// Get download id for UM futures order history
9699pub async fn get_um_order_asyn_v1(configuration: &configuration::Configuration, params: GetUmOrderAsynV1Params) -> Result<models::GetUmOrderAsynV1Resp, Error<GetUmOrderAsynV1Error>> {
9700
9701    let uri_str = format!("{}/papi/v1/um/order/asyn", configuration.base_path);
9702    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9703
9704    // Create a mutable vector for query parameters
9705    let mut query_params: Vec<(String, String)> = Vec::new();
9706
9707    query_params.push(("startTime".to_string(), params.start_time.to_string()));
9708    query_params.push(("endTime".to_string(), params.end_time.to_string()));
9709    if let Some(ref param_value) = params.recv_window {
9710        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9711    }
9712    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9713
9714    // Create header parameters collection
9715    let mut header_params = std::collections::HashMap::new();
9716
9717    // Handle Binance Auth first if configured
9718    if let Some(ref binance_auth) = configuration.binance_auth {
9719        // Add API key to headers
9720        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9721        
9722        // Generate request body for signing (if any)
9723        let body_string: Option<Vec<u8>> = None;
9724        
9725        // Sign the request
9726        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9727            Ok(sig) => sig,
9728            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9729        };
9730        
9731        // Add signature to query params
9732        query_params.push(("signature".to_string(), signature));
9733    }
9734
9735    // Apply all query parameters
9736    if !query_params.is_empty() {
9737        req_builder = req_builder.query(&query_params);
9738    }
9739
9740
9741    // Add user agent if configured
9742    if let Some(ref user_agent) = configuration.user_agent {
9743        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9744    }
9745
9746    // Apply all header parameters
9747    for (header_name, header_value) in header_params {
9748        req_builder = req_builder.header(&header_name, &header_value);
9749    }
9750
9751
9752    let req = req_builder.build()?;
9753    let resp = configuration.client.execute(req).await?;
9754
9755    let status = resp.status();
9756    let content_type = resp
9757        .headers()
9758        .get("content-type")
9759        .and_then(|v| v.to_str().ok())
9760        .unwrap_or("application/octet-stream");
9761    let content_type = super::ContentType::from(content_type);
9762
9763    if !status.is_client_error() && !status.is_server_error() {
9764        let content = resp.text().await?;
9765        match content_type {
9766            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9767            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmOrderAsynV1Resp`"))),
9768            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::GetUmOrderAsynV1Resp`")))),
9769        }
9770    } else {
9771        let content = resp.text().await?;
9772        let entity: Option<GetUmOrderAsynV1Error> = serde_json::from_str(&content).ok();
9773        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9774    }
9775}
9776
9777/// Check an UM order's status.
9778pub async fn get_um_order_v1(configuration: &configuration::Configuration, params: GetUmOrderV1Params) -> Result<models::GetUmOrderV1Resp, Error<GetUmOrderV1Error>> {
9779
9780    let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
9781    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9782
9783    // Create a mutable vector for query parameters
9784    let mut query_params: Vec<(String, String)> = Vec::new();
9785
9786    query_params.push(("symbol".to_string(), params.symbol.to_string()));
9787    if let Some(ref param_value) = params.order_id {
9788        query_params.push(("orderId".to_string(), param_value.to_string()));
9789    }
9790    if let Some(ref param_value) = params.orig_client_order_id {
9791        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
9792    }
9793    if let Some(ref param_value) = params.recv_window {
9794        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9795    }
9796    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9797
9798    // Create header parameters collection
9799    let mut header_params = std::collections::HashMap::new();
9800
9801    // Handle Binance Auth first if configured
9802    if let Some(ref binance_auth) = configuration.binance_auth {
9803        // Add API key to headers
9804        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9805        
9806        // Generate request body for signing (if any)
9807        let body_string: Option<Vec<u8>> = None;
9808        
9809        // Sign the request
9810        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9811            Ok(sig) => sig,
9812            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9813        };
9814        
9815        // Add signature to query params
9816        query_params.push(("signature".to_string(), signature));
9817    }
9818
9819    // Apply all query parameters
9820    if !query_params.is_empty() {
9821        req_builder = req_builder.query(&query_params);
9822    }
9823
9824
9825    // Add user agent if configured
9826    if let Some(ref user_agent) = configuration.user_agent {
9827        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9828    }
9829
9830    // Apply all header parameters
9831    for (header_name, header_value) in header_params {
9832        req_builder = req_builder.header(&header_name, &header_value);
9833    }
9834
9835
9836    let req = req_builder.build()?;
9837    let resp = configuration.client.execute(req).await?;
9838
9839    let status = resp.status();
9840    let content_type = resp
9841        .headers()
9842        .get("content-type")
9843        .and_then(|v| v.to_str().ok())
9844        .unwrap_or("application/octet-stream");
9845    let content_type = super::ContentType::from(content_type);
9846
9847    if !status.is_client_error() && !status.is_server_error() {
9848        let content = resp.text().await?;
9849        match content_type {
9850            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9851            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmOrderV1Resp`"))),
9852            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::GetUmOrderV1Resp`")))),
9853        }
9854    } else {
9855        let content = resp.text().await?;
9856        let entity: Option<GetUmOrderV1Error> = serde_json::from_str(&content).ok();
9857        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9858    }
9859}
9860
9861/// Get current UM position information.
9862pub async fn get_um_position_risk_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetUmPositionRiskV1RespItem>, Error<GetUmPositionRiskV1Error>> {
9863
9864    let uri_str = format!("{}/papi/v1/um/positionRisk", configuration.base_path);
9865    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9866
9867    // Create a mutable vector for query parameters
9868    let mut query_params: Vec<(String, String)> = Vec::new();
9869
9870
9871    // Create header parameters collection
9872    let mut header_params = std::collections::HashMap::new();
9873
9874    // Handle Binance Auth first if configured
9875    if let Some(ref binance_auth) = configuration.binance_auth {
9876        // Add API key to headers
9877        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9878        
9879        // Generate request body for signing (if any)
9880        let body_string: Option<Vec<u8>> = None;
9881        
9882        // Sign the request
9883        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9884            Ok(sig) => sig,
9885            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9886        };
9887        
9888        // Add signature to query params
9889        query_params.push(("signature".to_string(), signature));
9890    }
9891
9892    // Apply all query parameters
9893    if !query_params.is_empty() {
9894        req_builder = req_builder.query(&query_params);
9895    }
9896
9897
9898    // Add user agent if configured
9899    if let Some(ref user_agent) = configuration.user_agent {
9900        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9901    }
9902
9903    // Apply all header parameters
9904    for (header_name, header_value) in header_params {
9905        req_builder = req_builder.header(&header_name, &header_value);
9906    }
9907
9908
9909    let req = req_builder.build()?;
9910    let resp = configuration.client.execute(req).await?;
9911
9912    let status = resp.status();
9913    let content_type = resp
9914        .headers()
9915        .get("content-type")
9916        .and_then(|v| v.to_str().ok())
9917        .unwrap_or("application/octet-stream");
9918    let content_type = super::ContentType::from(content_type);
9919
9920    if !status.is_client_error() && !status.is_server_error() {
9921        let content = resp.text().await?;
9922        match content_type {
9923            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
9924            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmPositionRiskV1RespItem&gt;`"))),
9925            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::GetUmPositionRiskV1RespItem&gt;`")))),
9926        }
9927    } else {
9928        let content = resp.text().await?;
9929        let entity: Option<GetUmPositionRiskV1Error> = serde_json::from_str(&content).ok();
9930        Err(Error::ResponseError(ResponseContent { status, content, entity }))
9931    }
9932}
9933
9934/// Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in UM
9935pub async fn get_um_position_side_dual_v1(configuration: &configuration::Configuration, params: GetUmPositionSideDualV1Params) -> Result<models::GetUmPositionSideDualV1Resp, Error<GetUmPositionSideDualV1Error>> {
9936
9937    let uri_str = format!("{}/papi/v1/um/positionSide/dual", configuration.base_path);
9938    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
9939
9940    // Create a mutable vector for query parameters
9941    let mut query_params: Vec<(String, String)> = Vec::new();
9942
9943    if let Some(ref param_value) = params.recv_window {
9944        query_params.push(("recvWindow".to_string(), param_value.to_string()));
9945    }
9946    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
9947
9948    // Create header parameters collection
9949    let mut header_params = std::collections::HashMap::new();
9950
9951    // Handle Binance Auth first if configured
9952    if let Some(ref binance_auth) = configuration.binance_auth {
9953        // Add API key to headers
9954        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
9955        
9956        // Generate request body for signing (if any)
9957        let body_string: Option<Vec<u8>> = None;
9958        
9959        // Sign the request
9960        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
9961            Ok(sig) => sig,
9962            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
9963        };
9964        
9965        // Add signature to query params
9966        query_params.push(("signature".to_string(), signature));
9967    }
9968
9969    // Apply all query parameters
9970    if !query_params.is_empty() {
9971        req_builder = req_builder.query(&query_params);
9972    }
9973
9974
9975    // Add user agent if configured
9976    if let Some(ref user_agent) = configuration.user_agent {
9977        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
9978    }
9979
9980    // Apply all header parameters
9981    for (header_name, header_value) in header_params {
9982        req_builder = req_builder.header(&header_name, &header_value);
9983    }
9984
9985
9986    let req = req_builder.build()?;
9987    let resp = configuration.client.execute(req).await?;
9988
9989    let status = resp.status();
9990    let content_type = resp
9991        .headers()
9992        .get("content-type")
9993        .and_then(|v| v.to_str().ok())
9994        .unwrap_or("application/octet-stream");
9995    let content_type = super::ContentType::from(content_type);
9996
9997    if !status.is_client_error() && !status.is_server_error() {
9998        let content = resp.text().await?;
9999        match content_type {
10000            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
10001            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmPositionSideDualV1Resp`"))),
10002            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::GetUmPositionSideDualV1Resp`")))),
10003        }
10004    } else {
10005        let content = resp.text().await?;
10006        let entity: Option<GetUmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
10007        Err(Error::ResponseError(ResponseContent { status, content, entity }))
10008    }
10009}
10010
10011/// Get current UM account symbol configuration.
10012pub async fn get_um_symbol_config_v1(configuration: &configuration::Configuration, params: GetUmSymbolConfigV1Params) -> Result<Vec<models::GetUmSymbolConfigV1RespItem>, Error<GetUmSymbolConfigV1Error>> {
10013
10014    let uri_str = format!("{}/papi/v1/um/symbolConfig", configuration.base_path);
10015    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
10016
10017    // Create a mutable vector for query parameters
10018    let mut query_params: Vec<(String, String)> = Vec::new();
10019
10020    if let Some(ref param_value) = params.symbol {
10021        query_params.push(("symbol".to_string(), param_value.to_string()));
10022    }
10023    if let Some(ref param_value) = params.recv_window {
10024        query_params.push(("recvWindow".to_string(), param_value.to_string()));
10025    }
10026    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
10027
10028    // Create header parameters collection
10029    let mut header_params = std::collections::HashMap::new();
10030
10031    // Handle Binance Auth first if configured
10032    if let Some(ref binance_auth) = configuration.binance_auth {
10033        // Add API key to headers
10034        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
10035        
10036        // Generate request body for signing (if any)
10037        let body_string: Option<Vec<u8>> = None;
10038        
10039        // Sign the request
10040        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
10041            Ok(sig) => sig,
10042            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
10043        };
10044        
10045        // Add signature to query params
10046        query_params.push(("signature".to_string(), signature));
10047    }
10048
10049    // Apply all query parameters
10050    if !query_params.is_empty() {
10051        req_builder = req_builder.query(&query_params);
10052    }
10053
10054
10055    // Add user agent if configured
10056    if let Some(ref user_agent) = configuration.user_agent {
10057        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
10058    }
10059
10060    // Apply all header parameters
10061    for (header_name, header_value) in header_params {
10062        req_builder = req_builder.header(&header_name, &header_value);
10063    }
10064
10065
10066    let req = req_builder.build()?;
10067    let resp = configuration.client.execute(req).await?;
10068
10069    let status = resp.status();
10070    let content_type = resp
10071        .headers()
10072        .get("content-type")
10073        .and_then(|v| v.to_str().ok())
10074        .unwrap_or("application/octet-stream");
10075    let content_type = super::ContentType::from(content_type);
10076
10077    if !status.is_client_error() && !status.is_server_error() {
10078        let content = resp.text().await?;
10079        match content_type {
10080            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
10081            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmSymbolConfigV1RespItem&gt;`"))),
10082            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::GetUmSymbolConfigV1RespItem&gt;`")))),
10083        }
10084    } else {
10085        let content = resp.text().await?;
10086        let entity: Option<GetUmSymbolConfigV1Error> = serde_json::from_str(&content).ok();
10087        Err(Error::ResponseError(ResponseContent { status, content, entity }))
10088    }
10089}
10090
10091/// Get UM futures trade download link by Id
10092pub async fn get_um_trade_asyn_id_v1(configuration: &configuration::Configuration, params: GetUmTradeAsynIdV1Params) -> Result<models::GetUmTradeAsynIdV1Resp, Error<GetUmTradeAsynIdV1Error>> {
10093
10094    let uri_str = format!("{}/papi/v1/um/trade/asyn/id", configuration.base_path);
10095    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
10096
10097    // Create a mutable vector for query parameters
10098    let mut query_params: Vec<(String, String)> = Vec::new();
10099
10100    query_params.push(("downloadId".to_string(), params.download_id.to_string()));
10101    if let Some(ref param_value) = params.recv_window {
10102        query_params.push(("recvWindow".to_string(), param_value.to_string()));
10103    }
10104    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
10105
10106    // Create header parameters collection
10107    let mut header_params = std::collections::HashMap::new();
10108
10109    // Handle Binance Auth first if configured
10110    if let Some(ref binance_auth) = configuration.binance_auth {
10111        // Add API key to headers
10112        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
10113        
10114        // Generate request body for signing (if any)
10115        let body_string: Option<Vec<u8>> = None;
10116        
10117        // Sign the request
10118        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
10119            Ok(sig) => sig,
10120            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
10121        };
10122        
10123        // Add signature to query params
10124        query_params.push(("signature".to_string(), signature));
10125    }
10126
10127    // Apply all query parameters
10128    if !query_params.is_empty() {
10129        req_builder = req_builder.query(&query_params);
10130    }
10131
10132
10133    // Add user agent if configured
10134    if let Some(ref user_agent) = configuration.user_agent {
10135        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
10136    }
10137
10138    // Apply all header parameters
10139    for (header_name, header_value) in header_params {
10140        req_builder = req_builder.header(&header_name, &header_value);
10141    }
10142
10143
10144    let req = req_builder.build()?;
10145    let resp = configuration.client.execute(req).await?;
10146
10147    let status = resp.status();
10148    let content_type = resp
10149        .headers()
10150        .get("content-type")
10151        .and_then(|v| v.to_str().ok())
10152        .unwrap_or("application/octet-stream");
10153    let content_type = super::ContentType::from(content_type);
10154
10155    if !status.is_client_error() && !status.is_server_error() {
10156        let content = resp.text().await?;
10157        match content_type {
10158            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
10159            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmTradeAsynIdV1Resp`"))),
10160            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::GetUmTradeAsynIdV1Resp`")))),
10161        }
10162    } else {
10163        let content = resp.text().await?;
10164        let entity: Option<GetUmTradeAsynIdV1Error> = serde_json::from_str(&content).ok();
10165        Err(Error::ResponseError(ResponseContent { status, content, entity }))
10166    }
10167}
10168
10169/// Get download id for UM futures trade history
10170pub async fn get_um_trade_asyn_v1(configuration: &configuration::Configuration, params: GetUmTradeAsynV1Params) -> Result<models::GetUmTradeAsynV1Resp, Error<GetUmTradeAsynV1Error>> {
10171
10172    let uri_str = format!("{}/papi/v1/um/trade/asyn", configuration.base_path);
10173    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
10174
10175    // Create a mutable vector for query parameters
10176    let mut query_params: Vec<(String, String)> = Vec::new();
10177
10178    query_params.push(("startTime".to_string(), params.start_time.to_string()));
10179    query_params.push(("endTime".to_string(), params.end_time.to_string()));
10180    if let Some(ref param_value) = params.recv_window {
10181        query_params.push(("recvWindow".to_string(), param_value.to_string()));
10182    }
10183    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
10184
10185    // Create header parameters collection
10186    let mut header_params = std::collections::HashMap::new();
10187
10188    // Handle Binance Auth first if configured
10189    if let Some(ref binance_auth) = configuration.binance_auth {
10190        // Add API key to headers
10191        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
10192        
10193        // Generate request body for signing (if any)
10194        let body_string: Option<Vec<u8>> = None;
10195        
10196        // Sign the request
10197        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
10198            Ok(sig) => sig,
10199            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
10200        };
10201        
10202        // Add signature to query params
10203        query_params.push(("signature".to_string(), signature));
10204    }
10205
10206    // Apply all query parameters
10207    if !query_params.is_empty() {
10208        req_builder = req_builder.query(&query_params);
10209    }
10210
10211
10212    // Add user agent if configured
10213    if let Some(ref user_agent) = configuration.user_agent {
10214        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
10215    }
10216
10217    // Apply all header parameters
10218    for (header_name, header_value) in header_params {
10219        req_builder = req_builder.header(&header_name, &header_value);
10220    }
10221
10222
10223    let req = req_builder.build()?;
10224    let resp = configuration.client.execute(req).await?;
10225
10226    let status = resp.status();
10227    let content_type = resp
10228        .headers()
10229        .get("content-type")
10230        .and_then(|v| v.to_str().ok())
10231        .unwrap_or("application/octet-stream");
10232    let content_type = super::ContentType::from(content_type);
10233
10234    if !status.is_client_error() && !status.is_server_error() {
10235        let content = resp.text().await?;
10236        match content_type {
10237            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
10238            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetUmTradeAsynV1Resp`"))),
10239            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::GetUmTradeAsynV1Resp`")))),
10240        }
10241    } else {
10242        let content = resp.text().await?;
10243        let entity: Option<GetUmTradeAsynV1Error> = serde_json::from_str(&content).ok();
10244        Err(Error::ResponseError(ResponseContent { status, content, entity }))
10245    }
10246}
10247
10248/// Get trades for a specific account and UM symbol.
10249pub async fn get_um_user_trades_v1(configuration: &configuration::Configuration, params: GetUmUserTradesV1Params) -> Result<Vec<models::GetUmUserTradesV1RespItem>, Error<GetUmUserTradesV1Error>> {
10250
10251    let uri_str = format!("{}/papi/v1/um/userTrades", configuration.base_path);
10252    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
10253
10254    // Create a mutable vector for query parameters
10255    let mut query_params: Vec<(String, String)> = Vec::new();
10256
10257    query_params.push(("symbol".to_string(), params.symbol.to_string()));
10258    if let Some(ref param_value) = params.start_time {
10259        query_params.push(("startTime".to_string(), param_value.to_string()));
10260    }
10261    if let Some(ref param_value) = params.end_time {
10262        query_params.push(("endTime".to_string(), param_value.to_string()));
10263    }
10264    if let Some(ref param_value) = params.from_id {
10265        query_params.push(("fromId".to_string(), param_value.to_string()));
10266    }
10267    if let Some(ref param_value) = params.limit {
10268        query_params.push(("limit".to_string(), param_value.to_string()));
10269    }
10270    if let Some(ref param_value) = params.recv_window {
10271        query_params.push(("recvWindow".to_string(), param_value.to_string()));
10272    }
10273    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
10274
10275    // Create header parameters collection
10276    let mut header_params = std::collections::HashMap::new();
10277
10278    // Handle Binance Auth first if configured
10279    if let Some(ref binance_auth) = configuration.binance_auth {
10280        // Add API key to headers
10281        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
10282        
10283        // Generate request body for signing (if any)
10284        let body_string: Option<Vec<u8>> = None;
10285        
10286        // Sign the request
10287        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
10288            Ok(sig) => sig,
10289            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
10290        };
10291        
10292        // Add signature to query params
10293        query_params.push(("signature".to_string(), signature));
10294    }
10295
10296    // Apply all query parameters
10297    if !query_params.is_empty() {
10298        req_builder = req_builder.query(&query_params);
10299    }
10300
10301
10302    // Add user agent if configured
10303    if let Some(ref user_agent) = configuration.user_agent {
10304        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
10305    }
10306
10307    // Apply all header parameters
10308    for (header_name, header_value) in header_params {
10309        req_builder = req_builder.header(&header_name, &header_value);
10310    }
10311
10312
10313    let req = req_builder.build()?;
10314    let resp = configuration.client.execute(req).await?;
10315
10316    let status = resp.status();
10317    let content_type = resp
10318        .headers()
10319        .get("content-type")
10320        .and_then(|v| v.to_str().ok())
10321        .unwrap_or("application/octet-stream");
10322    let content_type = super::ContentType::from(content_type);
10323
10324    if !status.is_client_error() && !status.is_server_error() {
10325        let content = resp.text().await?;
10326        match content_type {
10327            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
10328            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUmUserTradesV1RespItem&gt;`"))),
10329            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::GetUmUserTradesV1RespItem&gt;`")))),
10330        }
10331    } else {
10332        let content = resp.text().await?;
10333        let entity: Option<GetUmUserTradesV1Error> = serde_json::from_str(&content).ok();
10334        Err(Error::ResponseError(ResponseContent { status, content, entity }))
10335    }
10336}
10337
10338/// Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
10339pub async fn update_cm_order_v1(configuration: &configuration::Configuration, params: UpdateCmOrderV1Params) -> Result<models::UpdateCmOrderV1Resp, Error<UpdateCmOrderV1Error>> {
10340
10341    let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
10342    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
10343
10344    // Create a mutable vector for query parameters
10345    let mut query_params: Vec<(String, String)> = Vec::new();
10346
10347
10348    // Create header parameters collection
10349    let mut header_params = std::collections::HashMap::new();
10350
10351    // Handle Binance Auth first if configured
10352    if let Some(ref binance_auth) = configuration.binance_auth {
10353        // Add API key to headers
10354        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
10355        
10356        // Generate request body for signing (if any)
10357        let body_string: Option<Vec<u8>> = None;
10358        
10359        // Sign the request
10360        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
10361            Ok(sig) => sig,
10362            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
10363        };
10364        
10365        // Add signature to query params
10366        query_params.push(("signature".to_string(), signature));
10367    }
10368
10369    // Apply all query parameters
10370    if !query_params.is_empty() {
10371        req_builder = req_builder.query(&query_params);
10372    }
10373
10374
10375    // Add user agent if configured
10376    if let Some(ref user_agent) = configuration.user_agent {
10377        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
10378    }
10379
10380    // Apply all header parameters
10381    for (header_name, header_value) in header_params {
10382        req_builder = req_builder.header(&header_name, &header_value);
10383    }
10384
10385    let mut multipart_form_params = std::collections::HashMap::new();
10386    if let Some(param_value) = params.order_id {
10387        multipart_form_params.insert("orderId", param_value.to_string());
10388    }
10389    if let Some(param_value) = params.orig_client_order_id {
10390        multipart_form_params.insert("origClientOrderId", param_value.to_string());
10391    }
10392    multipart_form_params.insert("price", params.price.to_string());
10393    if let Some(param_value) = params.price_match {
10394        multipart_form_params.insert("priceMatch", param_value.to_string());
10395    }
10396    multipart_form_params.insert("quantity", params.quantity.to_string());
10397    if let Some(param_value) = params.recv_window {
10398        multipart_form_params.insert("recvWindow", param_value.to_string());
10399    }
10400    multipart_form_params.insert("side", params.side.to_string());
10401    multipart_form_params.insert("symbol", params.symbol.to_string());
10402    multipart_form_params.insert("timestamp", params.timestamp.to_string());
10403    req_builder = req_builder.form(&multipart_form_params);
10404
10405    let req = req_builder.build()?;
10406    let resp = configuration.client.execute(req).await?;
10407
10408    let status = resp.status();
10409    let content_type = resp
10410        .headers()
10411        .get("content-type")
10412        .and_then(|v| v.to_str().ok())
10413        .unwrap_or("application/octet-stream");
10414    let content_type = super::ContentType::from(content_type);
10415
10416    if !status.is_client_error() && !status.is_server_error() {
10417        let content = resp.text().await?;
10418        match content_type {
10419            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
10420            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateCmOrderV1Resp`"))),
10421            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::UpdateCmOrderV1Resp`")))),
10422        }
10423    } else {
10424        let content = resp.text().await?;
10425        let entity: Option<UpdateCmOrderV1Error> = serde_json::from_str(&content).ok();
10426        Err(Error::ResponseError(ResponseContent { status, content, entity }))
10427    }
10428}
10429
10430/// Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 60 minutes.
10431pub async fn update_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<UpdateListenKeyV1Error>> {
10432
10433    let uri_str = format!("{}/papi/v1/listenKey", configuration.base_path);
10434    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
10435
10436    // Create a mutable vector for query parameters
10437    let mut query_params: Vec<(String, String)> = Vec::new();
10438
10439
10440    // Create header parameters collection
10441    let mut header_params = std::collections::HashMap::new();
10442
10443    // Handle Binance Auth first if configured
10444    if let Some(ref binance_auth) = configuration.binance_auth {
10445        // Add API key to headers
10446        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
10447        
10448        // Generate request body for signing (if any)
10449        let body_string: Option<Vec<u8>> = None;
10450        
10451        // Sign the request
10452        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
10453            Ok(sig) => sig,
10454            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
10455        };
10456        
10457        // Add signature to query params
10458        query_params.push(("signature".to_string(), signature));
10459    }
10460
10461    // Apply all query parameters
10462    if !query_params.is_empty() {
10463        req_builder = req_builder.query(&query_params);
10464    }
10465
10466
10467    // Add user agent if configured
10468    if let Some(ref user_agent) = configuration.user_agent {
10469        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
10470    }
10471
10472    // Apply all header parameters
10473    for (header_name, header_value) in header_params {
10474        req_builder = req_builder.header(&header_name, &header_value);
10475    }
10476
10477
10478    let req = req_builder.build()?;
10479    let resp = configuration.client.execute(req).await?;
10480
10481    let status = resp.status();
10482    let content_type = resp
10483        .headers()
10484        .get("content-type")
10485        .and_then(|v| v.to_str().ok())
10486        .unwrap_or("application/octet-stream");
10487    let content_type = super::ContentType::from(content_type);
10488
10489    if !status.is_client_error() && !status.is_server_error() {
10490        let content = resp.text().await?;
10491        match content_type {
10492            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
10493            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
10494            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
10495        }
10496    } else {
10497        let content = resp.text().await?;
10498        let entity: Option<UpdateListenKeyV1Error> = serde_json::from_str(&content).ok();
10499        Err(Error::ResponseError(ResponseContent { status, content, entity }))
10500    }
10501}
10502
10503/// Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
10504pub async fn update_um_order_v1(configuration: &configuration::Configuration, params: UpdateUmOrderV1Params) -> Result<models::UpdateUmOrderV1Resp, Error<UpdateUmOrderV1Error>> {
10505
10506    let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
10507    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
10508
10509    // Create a mutable vector for query parameters
10510    let mut query_params: Vec<(String, String)> = Vec::new();
10511
10512
10513    // Create header parameters collection
10514    let mut header_params = std::collections::HashMap::new();
10515
10516    // Handle Binance Auth first if configured
10517    if let Some(ref binance_auth) = configuration.binance_auth {
10518        // Add API key to headers
10519        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
10520        
10521        // Generate request body for signing (if any)
10522        let body_string: Option<Vec<u8>> = None;
10523        
10524        // Sign the request
10525        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
10526            Ok(sig) => sig,
10527            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
10528        };
10529        
10530        // Add signature to query params
10531        query_params.push(("signature".to_string(), signature));
10532    }
10533
10534    // Apply all query parameters
10535    if !query_params.is_empty() {
10536        req_builder = req_builder.query(&query_params);
10537    }
10538
10539
10540    // Add user agent if configured
10541    if let Some(ref user_agent) = configuration.user_agent {
10542        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
10543    }
10544
10545    // Apply all header parameters
10546    for (header_name, header_value) in header_params {
10547        req_builder = req_builder.header(&header_name, &header_value);
10548    }
10549
10550    let mut multipart_form_params = std::collections::HashMap::new();
10551    if let Some(param_value) = params.order_id {
10552        multipart_form_params.insert("orderId", param_value.to_string());
10553    }
10554    if let Some(param_value) = params.orig_client_order_id {
10555        multipart_form_params.insert("origClientOrderId", param_value.to_string());
10556    }
10557    multipart_form_params.insert("price", params.price.to_string());
10558    if let Some(param_value) = params.price_match {
10559        multipart_form_params.insert("priceMatch", param_value.to_string());
10560    }
10561    multipart_form_params.insert("quantity", params.quantity.to_string());
10562    if let Some(param_value) = params.recv_window {
10563        multipart_form_params.insert("recvWindow", param_value.to_string());
10564    }
10565    multipart_form_params.insert("side", params.side.to_string());
10566    multipart_form_params.insert("symbol", params.symbol.to_string());
10567    multipart_form_params.insert("timestamp", params.timestamp.to_string());
10568    req_builder = req_builder.form(&multipart_form_params);
10569
10570    let req = req_builder.build()?;
10571    let resp = configuration.client.execute(req).await?;
10572
10573    let status = resp.status();
10574    let content_type = resp
10575        .headers()
10576        .get("content-type")
10577        .and_then(|v| v.to_str().ok())
10578        .unwrap_or("application/octet-stream");
10579    let content_type = super::ContentType::from(content_type);
10580
10581    if !status.is_client_error() && !status.is_server_error() {
10582        let content = resp.text().await?;
10583        match content_type {
10584            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
10585            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateUmOrderV1Resp`"))),
10586            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::UpdateUmOrderV1Resp`")))),
10587        }
10588    } else {
10589        let content = resp.text().await?;
10590        let entity: Option<UpdateUmOrderV1Error> = serde_json::from_str(&content).ok();
10591        Err(Error::ResponseError(ResponseContent { status, content, entity }))
10592    }
10593}
10594