binance/cmfutures/apis/
futures_api.rs

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