binance/spot/apis/
margin_trading_api.rs

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