binance/options/apis/
options_api.rs

1/*
2 * Binance Options API
3 *
4 * OpenAPI specification for Binance exchange - Options API
5 *
6 * The version of the OpenAPI document: 0.3.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::options::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`create_batch_orders_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateBatchOrdersV1Params {
20    pub orders: Vec<models::OptionsCreateBatchOrdersV1ReqOrdersItem>,
21    pub timestamp: i64,
22    pub recv_window: Option<i64>
23}
24
25/// struct for passing parameters to the method [`create_block_order_execute_v1`]
26#[derive(Clone, Debug, Default)]
27pub struct CreateBlockOrderExecuteV1Params {
28    pub block_order_matching_key: String,
29    pub timestamp: i64,
30    pub recv_window: Option<i64>
31}
32
33/// struct for passing parameters to the method [`create_countdown_cancel_all_heart_beat_v1`]
34#[derive(Clone, Debug, Default)]
35pub struct CreateCountdownCancelAllHeartBeatV1Params {
36    pub timestamp: i64,
37    pub underlyings: String,
38    pub recv_window: Option<i64>
39}
40
41/// struct for passing parameters to the method [`create_countdown_cancel_all_v1`]
42#[derive(Clone, Debug, Default)]
43pub struct CreateCountdownCancelAllV1Params {
44    pub countdown_time: i64,
45    pub timestamp: i64,
46    pub underlying: String,
47    pub recv_window: Option<i64>
48}
49
50/// struct for passing parameters to the method [`create_mmp_reset_v1`]
51#[derive(Clone, Debug, Default)]
52pub struct CreateMmpResetV1Params {
53    pub timestamp: i64,
54    pub recv_window: Option<i64>,
55    pub underlying: Option<String>
56}
57
58/// struct for passing parameters to the method [`create_mmp_set_v1`]
59#[derive(Clone, Debug, Default)]
60pub struct CreateMmpSetV1Params {
61    pub timestamp: i64,
62    pub delta_limit: Option<String>,
63    pub frozen_time_in_milliseconds: Option<i64>,
64    pub qty_limit: Option<String>,
65    pub recv_window: Option<i64>,
66    pub underlying: Option<String>,
67    pub window_time_in_milliseconds: Option<i64>
68}
69
70/// struct for passing parameters to the method [`create_order_v1`]
71#[derive(Clone, Debug, Default)]
72pub struct CreateOrderV1Params {
73    pub quantity: String,
74    pub side: String,
75    pub symbol: String,
76    pub timestamp: i64,
77    pub r#type: String,
78    pub client_order_id: Option<String>,
79    pub is_mmp: Option<bool>,
80    pub new_order_resp_type: Option<String>,
81    pub post_only: Option<bool>,
82    pub price: Option<String>,
83    pub recv_window: Option<i64>,
84    pub reduce_only: Option<bool>,
85    pub time_in_force: Option<String>
86}
87
88/// struct for passing parameters to the method [`delete_all_open_orders_by_underlying_v1`]
89#[derive(Clone, Debug, Default)]
90pub struct DeleteAllOpenOrdersByUnderlyingV1Params {
91    /// Option underlying, e.g BTCUSDT
92    pub underlying: String,
93    pub timestamp: i64,
94    pub recv_window: Option<i64>
95}
96
97/// struct for passing parameters to the method [`delete_all_open_orders_v1`]
98#[derive(Clone, Debug, Default)]
99pub struct DeleteAllOpenOrdersV1Params {
100    /// Option trading pair, e.g BTC-200730-9000-C
101    pub symbol: String,
102    pub timestamp: i64,
103    pub recv_window: Option<i64>
104}
105
106/// struct for passing parameters to the method [`delete_batch_orders_v1`]
107#[derive(Clone, Debug, Default)]
108pub struct DeleteBatchOrdersV1Params {
109    /// Option trading pair, e.g BTC-200730-9000-C
110    pub symbol: String,
111    pub timestamp: i64,
112    /// Order ID, e.g [4611875134427365377,4611875134427365378]
113    pub order_ids: Option<Vec<i64>>,
114    /// User-defined order ID, e.g [&#34;my_id_1&#34;,&#34;my_id_2&#34;]
115    pub client_order_ids: Option<Vec<String>>,
116    pub recv_window: Option<i64>
117}
118
119/// struct for passing parameters to the method [`delete_order_v1`]
120#[derive(Clone, Debug, Default)]
121pub struct DeleteOrderV1Params {
122    /// Option trading pair, e.g BTC-200730-9000-C
123    pub symbol: String,
124    pub timestamp: i64,
125    /// Order ID, e.g 4611875134427365377
126    pub order_id: Option<i64>,
127    /// User-defined order ID, e.g 10000
128    pub client_order_id: Option<String>,
129    pub recv_window: Option<i64>
130}
131
132/// struct for passing parameters to the method [`get_account_v1`]
133#[derive(Clone, Debug, Default)]
134pub struct GetAccountV1Params {
135    pub timestamp: i64,
136    pub recv_window: Option<i64>
137}
138
139/// struct for passing parameters to the method [`get_bill_v1`]
140#[derive(Clone, Debug, Default)]
141pub struct GetBillV1Params {
142    /// Asset type, only support USDT  as of now
143    pub currency: String,
144    pub timestamp: i64,
145    /// Return the recordId and subsequent data, the latest data is returned by default, e.g 100000
146    pub record_id: Option<i64>,
147    /// Start Time, e.g 1593511200000
148    pub start_time: Option<i64>,
149    /// End Time, e.g 1593512200000
150    pub end_time: Option<i64>,
151    /// Number of result sets returned Default:100 Max:1000
152    pub limit: Option<i32>,
153    pub recv_window: Option<i64>
154}
155
156/// struct for passing parameters to the method [`get_block_order_execute_v1`]
157#[derive(Clone, Debug, Default)]
158pub struct GetBlockOrderExecuteV1Params {
159    pub block_order_matching_key: String,
160    pub timestamp: i64,
161    /// The value cannot be greater than 60000
162    pub recv_window: Option<i64>
163}
164
165/// struct for passing parameters to the method [`get_block_order_orders_v1`]
166#[derive(Clone, Debug, Default)]
167pub struct GetBlockOrderOrdersV1Params {
168    pub timestamp: i64,
169    /// If specified, returns the specific block trade associated with the blockOrderMatchingKey
170    pub block_order_matching_key: Option<String>,
171    pub end_time: Option<i64>,
172    pub start_time: Option<i64>,
173    pub underlying: Option<String>,
174    /// The value cannot be greater than 60000
175    pub recv_window: Option<i64>
176}
177
178/// struct for passing parameters to the method [`get_block_trades_v1`]
179#[derive(Clone, Debug, Default)]
180pub struct GetBlockTradesV1Params {
181    /// Option trading pair, e.g. BTC-200730-9000-C
182    pub symbol: Option<String>,
183    /// Number of records; Default: 100 and Max: 500
184    pub limit: Option<i32>
185}
186
187/// struct for passing parameters to the method [`get_block_user_trades_v1`]
188#[derive(Clone, Debug, Default)]
189pub struct GetBlockUserTradesV1Params {
190    pub timestamp: i64,
191    pub end_time: Option<i64>,
192    pub start_time: Option<i64>,
193    pub underlying: Option<String>,
194    /// The value cannot be greater than 60000
195    pub recv_window: Option<i64>
196}
197
198/// struct for passing parameters to the method [`get_countdown_cancel_all_v1`]
199#[derive(Clone, Debug, Default)]
200pub struct GetCountdownCancelAllV1Params {
201    pub timestamp: i64,
202    /// Option underlying, e.g BTCUSDT
203    pub underlying: Option<String>,
204    pub recv_window: Option<i64>
205}
206
207/// struct for passing parameters to the method [`get_depth_v1`]
208#[derive(Clone, Debug, Default)]
209pub struct GetDepthV1Params {
210    /// Option trading pair, e.g BTC-200730-9000-C
211    pub symbol: String,
212    /// Default:100 Max:1000.Optional value:[10, 20, 50, 100, 500, 1000]
213    pub limit: Option<i32>
214}
215
216/// struct for passing parameters to the method [`get_exercise_history_v1`]
217#[derive(Clone, Debug, Default)]
218pub struct GetExerciseHistoryV1Params {
219    /// Underlying index like BTCUSDT
220    pub underlying: Option<String>,
221    /// Start Time
222    pub start_time: Option<i64>,
223    /// End Time
224    pub end_time: Option<i64>,
225    /// Number of records Default:100 Max:100
226    pub limit: Option<i32>
227}
228
229/// struct for passing parameters to the method [`get_exercise_record_v1`]
230#[derive(Clone, Debug, Default)]
231pub struct GetExerciseRecordV1Params {
232    pub timestamp: i64,
233    /// Option trading pair, e.g BTC-200730-9000-C
234    pub symbol: Option<String>,
235    /// startTime
236    pub start_time: Option<i64>,
237    /// endTime
238    pub end_time: Option<i64>,
239    /// default 1000, max 1000
240    pub limit: Option<i32>,
241    pub recv_window: Option<i64>
242}
243
244/// struct for passing parameters to the method [`get_historical_trades_v1`]
245#[derive(Clone, Debug, Default)]
246pub struct GetHistoricalTradesV1Params {
247    /// Option trading pair, e.g BTC-200730-9000-C
248    pub symbol: String,
249    /// The UniqueId ID from which to return. The latest deal record is returned by default
250    pub from_id: Option<i64>,
251    /// Number of records Default:100 Max:500
252    pub limit: Option<i32>
253}
254
255/// struct for passing parameters to the method [`get_history_orders_v1`]
256#[derive(Clone, Debug, Default)]
257pub struct GetHistoryOrdersV1Params {
258    /// Option trading pair
259    pub symbol: String,
260    pub timestamp: i64,
261    /// Returns the orderId and subsequent orders, the most recent order is returned by default
262    pub order_id: Option<i64>,
263    /// Start Time, e.g 1593511200000
264    pub start_time: Option<i64>,
265    /// End Time, e.g 1593512200000
266    pub end_time: Option<i64>,
267    /// Number of result sets returned Default:100 Max:1000
268    pub limit: Option<i32>,
269    pub recv_window: Option<i64>
270}
271
272/// struct for passing parameters to the method [`get_income_asyn_id_v1`]
273#[derive(Clone, Debug, Default)]
274pub struct GetIncomeAsynIdV1Params {
275    /// get by download id api
276    pub download_id: String,
277    pub timestamp: i64,
278    pub recv_window: Option<i64>
279}
280
281/// struct for passing parameters to the method [`get_index_v1`]
282#[derive(Clone, Debug, Default)]
283pub struct GetIndexV1Params {
284    /// Spot pair(Option contract underlying asset, e.g BTCUSDT)
285    pub underlying: String
286}
287
288/// struct for passing parameters to the method [`get_klines_v1`]
289#[derive(Clone, Debug, Default)]
290pub struct GetKlinesV1Params {
291    /// Option trading pair, e.g BTC-200730-9000-C
292    pub symbol: String,
293    /// Time interval
294    pub interval: String,
295    /// Start Time  1592317127349
296    pub start_time: Option<i64>,
297    /// End Time
298    pub end_time: Option<i64>,
299    /// Number of records Default:500 Max:1500
300    pub limit: Option<i32>
301}
302
303/// struct for passing parameters to the method [`get_margin_account_v1`]
304#[derive(Clone, Debug, Default)]
305pub struct GetMarginAccountV1Params {
306    pub timestamp: i64,
307    pub recv_window: Option<i64>
308}
309
310/// struct for passing parameters to the method [`get_mark_v1`]
311#[derive(Clone, Debug, Default)]
312pub struct GetMarkV1Params {
313    /// Option trading pair, e.g BTC-200730-9000-C
314    pub symbol: Option<String>
315}
316
317/// struct for passing parameters to the method [`get_mmp_v1`]
318#[derive(Clone, Debug, Default)]
319pub struct GetMmpV1Params {
320    pub timestamp: i64,
321    /// underlying, e.g BTCUSDT
322    pub underlying: Option<String>,
323    pub recv_window: Option<i64>
324}
325
326/// struct for passing parameters to the method [`get_open_interest_v1`]
327#[derive(Clone, Debug, Default)]
328pub struct GetOpenInterestV1Params {
329    /// underlying asset, e.g ETH/BTC
330    pub underlying_asset: String,
331    /// expiration date, e.g 221225
332    pub expiration: String
333}
334
335/// struct for passing parameters to the method [`get_open_orders_v1`]
336#[derive(Clone, Debug, Default)]
337pub struct GetOpenOrdersV1Params {
338    pub timestamp: i64,
339    /// return all orders if don&#39;t pass, Option trading pair, e.g BTC-200730-9000-C,
340    pub symbol: Option<String>,
341    /// Returns the orderId and subsequent orders, the most recent order is returned by default
342    pub order_id: Option<i64>,
343    /// Start Time
344    pub start_time: Option<i64>,
345    /// End Time
346    pub end_time: Option<i64>,
347    /// Number of result sets returned Default:100 Max:1000
348    pub limit: Option<i32>,
349    pub recv_window: Option<i64>
350}
351
352/// struct for passing parameters to the method [`get_order_v1`]
353#[derive(Clone, Debug, Default)]
354pub struct GetOrderV1Params {
355    /// Option trading pair, e.g BTC-200730-9000-C
356    pub symbol: String,
357    pub timestamp: i64,
358    /// Order id
359    pub order_id: Option<i64>,
360    /// User-defined order ID cannot be repeated in pending orders
361    pub client_order_id: Option<String>,
362    pub recv_window: Option<i64>
363}
364
365/// struct for passing parameters to the method [`get_position_v1`]
366#[derive(Clone, Debug, Default)]
367pub struct GetPositionV1Params {
368    pub timestamp: i64,
369    /// Option trading pair, e.g BTC-200730-9000-C
370    pub symbol: Option<String>,
371    pub recv_window: Option<i64>
372}
373
374/// struct for passing parameters to the method [`get_ticker_v1`]
375#[derive(Clone, Debug, Default)]
376pub struct GetTickerV1Params {
377    /// Option trading pair, e.g BTC-200730-9000-C
378    pub symbol: Option<String>
379}
380
381/// struct for passing parameters to the method [`get_trades_v1`]
382#[derive(Clone, Debug, Default)]
383pub struct GetTradesV1Params {
384    /// Option trading pair, e.g BTC-200730-9000-C
385    pub symbol: String,
386    /// Number of records Default:100 Max:500
387    pub limit: Option<i32>
388}
389
390/// struct for passing parameters to the method [`get_user_trades_v1`]
391#[derive(Clone, Debug, Default)]
392pub struct GetUserTradesV1Params {
393    pub timestamp: i64,
394    /// Option symbol, e.g BTC-200730-9000-C
395    pub symbol: Option<String>,
396    /// Trade id to fetch from. Default gets most recent trades, e.g 4611875134427365376
397    pub from_id: Option<i64>,
398    /// Start time, e.g 1593511200000
399    pub start_time: Option<i64>,
400    /// End time, e.g 1593512200000
401    pub end_time: Option<i64>,
402    /// Default 100; max 1000
403    pub limit: Option<i32>,
404    pub recv_window: Option<i64>
405}
406
407/// struct for passing parameters to the method [`update_block_order_create_v1`]
408#[derive(Clone, Debug, Default)]
409pub struct UpdateBlockOrderCreateV1Params {
410    pub block_order_matching_key: String,
411    pub timestamp: i32,
412    pub recv_window: Option<i32>
413}
414
415
416/// struct for typed errors of method [`create_batch_orders_v1`]
417#[derive(Debug, Clone, Serialize, Deserialize)]
418#[serde(untagged)]
419pub enum CreateBatchOrdersV1Error {
420    Status4XX(models::ApiError),
421    Status5XX(models::ApiError),
422    UnknownValue(serde_json::Value),
423}
424
425/// struct for typed errors of method [`create_block_order_execute_v1`]
426#[derive(Debug, Clone, Serialize, Deserialize)]
427#[serde(untagged)]
428pub enum CreateBlockOrderExecuteV1Error {
429    Status4XX(models::ApiError),
430    Status5XX(models::ApiError),
431    UnknownValue(serde_json::Value),
432}
433
434/// struct for typed errors of method [`create_countdown_cancel_all_heart_beat_v1`]
435#[derive(Debug, Clone, Serialize, Deserialize)]
436#[serde(untagged)]
437pub enum CreateCountdownCancelAllHeartBeatV1Error {
438    Status4XX(models::ApiError),
439    Status5XX(models::ApiError),
440    UnknownValue(serde_json::Value),
441}
442
443/// struct for typed errors of method [`create_countdown_cancel_all_v1`]
444#[derive(Debug, Clone, Serialize, Deserialize)]
445#[serde(untagged)]
446pub enum CreateCountdownCancelAllV1Error {
447    Status4XX(models::ApiError),
448    Status5XX(models::ApiError),
449    UnknownValue(serde_json::Value),
450}
451
452/// struct for typed errors of method [`create_listen_key_v1`]
453#[derive(Debug, Clone, Serialize, Deserialize)]
454#[serde(untagged)]
455pub enum CreateListenKeyV1Error {
456    Status4XX(models::ApiError),
457    Status5XX(models::ApiError),
458    UnknownValue(serde_json::Value),
459}
460
461/// struct for typed errors of method [`create_mmp_reset_v1`]
462#[derive(Debug, Clone, Serialize, Deserialize)]
463#[serde(untagged)]
464pub enum CreateMmpResetV1Error {
465    Status4XX(models::ApiError),
466    Status5XX(models::ApiError),
467    UnknownValue(serde_json::Value),
468}
469
470/// struct for typed errors of method [`create_mmp_set_v1`]
471#[derive(Debug, Clone, Serialize, Deserialize)]
472#[serde(untagged)]
473pub enum CreateMmpSetV1Error {
474    Status4XX(models::ApiError),
475    Status5XX(models::ApiError),
476    UnknownValue(serde_json::Value),
477}
478
479/// struct for typed errors of method [`create_order_v1`]
480#[derive(Debug, Clone, Serialize, Deserialize)]
481#[serde(untagged)]
482pub enum CreateOrderV1Error {
483    Status4XX(models::ApiError),
484    Status5XX(models::ApiError),
485    UnknownValue(serde_json::Value),
486}
487
488/// struct for typed errors of method [`delete_all_open_orders_by_underlying_v1`]
489#[derive(Debug, Clone, Serialize, Deserialize)]
490#[serde(untagged)]
491pub enum DeleteAllOpenOrdersByUnderlyingV1Error {
492    Status4XX(models::ApiError),
493    Status5XX(models::ApiError),
494    UnknownValue(serde_json::Value),
495}
496
497/// struct for typed errors of method [`delete_all_open_orders_v1`]
498#[derive(Debug, Clone, Serialize, Deserialize)]
499#[serde(untagged)]
500pub enum DeleteAllOpenOrdersV1Error {
501    Status4XX(models::ApiError),
502    Status5XX(models::ApiError),
503    UnknownValue(serde_json::Value),
504}
505
506/// struct for typed errors of method [`delete_batch_orders_v1`]
507#[derive(Debug, Clone, Serialize, Deserialize)]
508#[serde(untagged)]
509pub enum DeleteBatchOrdersV1Error {
510    Status4XX(models::ApiError),
511    Status5XX(models::ApiError),
512    UnknownValue(serde_json::Value),
513}
514
515/// struct for typed errors of method [`delete_listen_key_v1`]
516#[derive(Debug, Clone, Serialize, Deserialize)]
517#[serde(untagged)]
518pub enum DeleteListenKeyV1Error {
519    Status4XX(models::ApiError),
520    Status5XX(models::ApiError),
521    UnknownValue(serde_json::Value),
522}
523
524/// struct for typed errors of method [`delete_order_v1`]
525#[derive(Debug, Clone, Serialize, Deserialize)]
526#[serde(untagged)]
527pub enum DeleteOrderV1Error {
528    Status4XX(models::ApiError),
529    Status5XX(models::ApiError),
530    UnknownValue(serde_json::Value),
531}
532
533/// struct for typed errors of method [`get_account_v1`]
534#[derive(Debug, Clone, Serialize, Deserialize)]
535#[serde(untagged)]
536pub enum GetAccountV1Error {
537    Status4XX(models::ApiError),
538    Status5XX(models::ApiError),
539    UnknownValue(serde_json::Value),
540}
541
542/// struct for typed errors of method [`get_bill_v1`]
543#[derive(Debug, Clone, Serialize, Deserialize)]
544#[serde(untagged)]
545pub enum GetBillV1Error {
546    Status4XX(models::ApiError),
547    Status5XX(models::ApiError),
548    UnknownValue(serde_json::Value),
549}
550
551/// struct for typed errors of method [`get_block_order_execute_v1`]
552#[derive(Debug, Clone, Serialize, Deserialize)]
553#[serde(untagged)]
554pub enum GetBlockOrderExecuteV1Error {
555    Status4XX(models::ApiError),
556    Status5XX(models::ApiError),
557    UnknownValue(serde_json::Value),
558}
559
560/// struct for typed errors of method [`get_block_order_orders_v1`]
561#[derive(Debug, Clone, Serialize, Deserialize)]
562#[serde(untagged)]
563pub enum GetBlockOrderOrdersV1Error {
564    Status4XX(models::ApiError),
565    Status5XX(models::ApiError),
566    UnknownValue(serde_json::Value),
567}
568
569/// struct for typed errors of method [`get_block_trades_v1`]
570#[derive(Debug, Clone, Serialize, Deserialize)]
571#[serde(untagged)]
572pub enum GetBlockTradesV1Error {
573    Status4XX(models::ApiError),
574    Status5XX(models::ApiError),
575    UnknownValue(serde_json::Value),
576}
577
578/// struct for typed errors of method [`get_block_user_trades_v1`]
579#[derive(Debug, Clone, Serialize, Deserialize)]
580#[serde(untagged)]
581pub enum GetBlockUserTradesV1Error {
582    Status4XX(models::ApiError),
583    Status5XX(models::ApiError),
584    UnknownValue(serde_json::Value),
585}
586
587/// struct for typed errors of method [`get_countdown_cancel_all_v1`]
588#[derive(Debug, Clone, Serialize, Deserialize)]
589#[serde(untagged)]
590pub enum GetCountdownCancelAllV1Error {
591    Status4XX(models::ApiError),
592    Status5XX(models::ApiError),
593    UnknownValue(serde_json::Value),
594}
595
596/// struct for typed errors of method [`get_depth_v1`]
597#[derive(Debug, Clone, Serialize, Deserialize)]
598#[serde(untagged)]
599pub enum GetDepthV1Error {
600    Status4XX(models::ApiError),
601    Status5XX(models::ApiError),
602    UnknownValue(serde_json::Value),
603}
604
605/// struct for typed errors of method [`get_exchange_info_v1`]
606#[derive(Debug, Clone, Serialize, Deserialize)]
607#[serde(untagged)]
608pub enum GetExchangeInfoV1Error {
609    Status4XX(models::ApiError),
610    Status5XX(models::ApiError),
611    UnknownValue(serde_json::Value),
612}
613
614/// struct for typed errors of method [`get_exercise_history_v1`]
615#[derive(Debug, Clone, Serialize, Deserialize)]
616#[serde(untagged)]
617pub enum GetExerciseHistoryV1Error {
618    Status4XX(models::ApiError),
619    Status5XX(models::ApiError),
620    UnknownValue(serde_json::Value),
621}
622
623/// struct for typed errors of method [`get_exercise_record_v1`]
624#[derive(Debug, Clone, Serialize, Deserialize)]
625#[serde(untagged)]
626pub enum GetExerciseRecordV1Error {
627    Status4XX(models::ApiError),
628    Status5XX(models::ApiError),
629    UnknownValue(serde_json::Value),
630}
631
632/// struct for typed errors of method [`get_historical_trades_v1`]
633#[derive(Debug, Clone, Serialize, Deserialize)]
634#[serde(untagged)]
635pub enum GetHistoricalTradesV1Error {
636    Status4XX(models::ApiError),
637    Status5XX(models::ApiError),
638    UnknownValue(serde_json::Value),
639}
640
641/// struct for typed errors of method [`get_history_orders_v1`]
642#[derive(Debug, Clone, Serialize, Deserialize)]
643#[serde(untagged)]
644pub enum GetHistoryOrdersV1Error {
645    Status4XX(models::ApiError),
646    Status5XX(models::ApiError),
647    UnknownValue(serde_json::Value),
648}
649
650/// struct for typed errors of method [`get_income_asyn_id_v1`]
651#[derive(Debug, Clone, Serialize, Deserialize)]
652#[serde(untagged)]
653pub enum GetIncomeAsynIdV1Error {
654    Status4XX(models::ApiError),
655    Status5XX(models::ApiError),
656    UnknownValue(serde_json::Value),
657}
658
659/// struct for typed errors of method [`get_income_asyn_v1`]
660#[derive(Debug, Clone, Serialize, Deserialize)]
661#[serde(untagged)]
662pub enum GetIncomeAsynV1Error {
663    Status4XX(models::ApiError),
664    Status5XX(models::ApiError),
665    UnknownValue(serde_json::Value),
666}
667
668/// struct for typed errors of method [`get_index_v1`]
669#[derive(Debug, Clone, Serialize, Deserialize)]
670#[serde(untagged)]
671pub enum GetIndexV1Error {
672    Status4XX(models::ApiError),
673    Status5XX(models::ApiError),
674    UnknownValue(serde_json::Value),
675}
676
677/// struct for typed errors of method [`get_klines_v1`]
678#[derive(Debug, Clone, Serialize, Deserialize)]
679#[serde(untagged)]
680pub enum GetKlinesV1Error {
681    Status4XX(models::ApiError),
682    Status5XX(models::ApiError),
683    UnknownValue(serde_json::Value),
684}
685
686/// struct for typed errors of method [`get_margin_account_v1`]
687#[derive(Debug, Clone, Serialize, Deserialize)]
688#[serde(untagged)]
689pub enum GetMarginAccountV1Error {
690    Status4XX(models::ApiError),
691    Status5XX(models::ApiError),
692    UnknownValue(serde_json::Value),
693}
694
695/// struct for typed errors of method [`get_mark_v1`]
696#[derive(Debug, Clone, Serialize, Deserialize)]
697#[serde(untagged)]
698pub enum GetMarkV1Error {
699    Status4XX(models::ApiError),
700    Status5XX(models::ApiError),
701    UnknownValue(serde_json::Value),
702}
703
704/// struct for typed errors of method [`get_mmp_v1`]
705#[derive(Debug, Clone, Serialize, Deserialize)]
706#[serde(untagged)]
707pub enum GetMmpV1Error {
708    Status4XX(models::ApiError),
709    Status5XX(models::ApiError),
710    UnknownValue(serde_json::Value),
711}
712
713/// struct for typed errors of method [`get_open_interest_v1`]
714#[derive(Debug, Clone, Serialize, Deserialize)]
715#[serde(untagged)]
716pub enum GetOpenInterestV1Error {
717    Status4XX(models::ApiError),
718    Status5XX(models::ApiError),
719    UnknownValue(serde_json::Value),
720}
721
722/// struct for typed errors of method [`get_open_orders_v1`]
723#[derive(Debug, Clone, Serialize, Deserialize)]
724#[serde(untagged)]
725pub enum GetOpenOrdersV1Error {
726    Status4XX(models::ApiError),
727    Status5XX(models::ApiError),
728    UnknownValue(serde_json::Value),
729}
730
731/// struct for typed errors of method [`get_order_v1`]
732#[derive(Debug, Clone, Serialize, Deserialize)]
733#[serde(untagged)]
734pub enum GetOrderV1Error {
735    Status4XX(models::ApiError),
736    Status5XX(models::ApiError),
737    UnknownValue(serde_json::Value),
738}
739
740/// struct for typed errors of method [`get_ping_v1`]
741#[derive(Debug, Clone, Serialize, Deserialize)]
742#[serde(untagged)]
743pub enum GetPingV1Error {
744    Status4XX(models::ApiError),
745    Status5XX(models::ApiError),
746    UnknownValue(serde_json::Value),
747}
748
749/// struct for typed errors of method [`get_position_v1`]
750#[derive(Debug, Clone, Serialize, Deserialize)]
751#[serde(untagged)]
752pub enum GetPositionV1Error {
753    Status4XX(models::ApiError),
754    Status5XX(models::ApiError),
755    UnknownValue(serde_json::Value),
756}
757
758/// struct for typed errors of method [`get_ticker_v1`]
759#[derive(Debug, Clone, Serialize, Deserialize)]
760#[serde(untagged)]
761pub enum GetTickerV1Error {
762    Status4XX(models::ApiError),
763    Status5XX(models::ApiError),
764    UnknownValue(serde_json::Value),
765}
766
767/// struct for typed errors of method [`get_time_v1`]
768#[derive(Debug, Clone, Serialize, Deserialize)]
769#[serde(untagged)]
770pub enum GetTimeV1Error {
771    Status4XX(models::ApiError),
772    Status5XX(models::ApiError),
773    UnknownValue(serde_json::Value),
774}
775
776/// struct for typed errors of method [`get_trades_v1`]
777#[derive(Debug, Clone, Serialize, Deserialize)]
778#[serde(untagged)]
779pub enum GetTradesV1Error {
780    Status4XX(models::ApiError),
781    Status5XX(models::ApiError),
782    UnknownValue(serde_json::Value),
783}
784
785/// struct for typed errors of method [`get_user_trades_v1`]
786#[derive(Debug, Clone, Serialize, Deserialize)]
787#[serde(untagged)]
788pub enum GetUserTradesV1Error {
789    Status4XX(models::ApiError),
790    Status5XX(models::ApiError),
791    UnknownValue(serde_json::Value),
792}
793
794/// struct for typed errors of method [`update_block_order_create_v1`]
795#[derive(Debug, Clone, Serialize, Deserialize)]
796#[serde(untagged)]
797pub enum UpdateBlockOrderCreateV1Error {
798    Status4XX(models::ApiError),
799    Status5XX(models::ApiError),
800    UnknownValue(serde_json::Value),
801}
802
803/// struct for typed errors of method [`update_listen_key_v1`]
804#[derive(Debug, Clone, Serialize, Deserialize)]
805#[serde(untagged)]
806pub enum UpdateListenKeyV1Error {
807    Status4XX(models::ApiError),
808    Status5XX(models::ApiError),
809    UnknownValue(serde_json::Value),
810}
811
812
813/// Send multiple option orders.
814pub async fn create_batch_orders_v1(configuration: &configuration::Configuration, params: CreateBatchOrdersV1Params) -> Result<Vec<models::OptionsCreateBatchOrdersV1RespInner>, Error<CreateBatchOrdersV1Error>> {
815
816    let uri_str = format!("{}/eapi/v1/batchOrders", configuration.base_path);
817    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
818
819    // Create a mutable vector for query parameters
820    let mut query_params: Vec<(String, String)> = Vec::new();
821
822
823    // Create header parameters collection
824    let mut header_params = std::collections::HashMap::new();
825
826    // Handle Binance Auth first if configured
827    if let Some(ref binance_auth) = configuration.binance_auth {
828        // Add API key to headers
829        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
830        
831        // Generate request body for signing (if any)
832        let body_string: Option<Vec<u8>> = None;
833        
834        // Sign the request
835        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
836            Ok(sig) => sig,
837            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
838        };
839        
840        // Add signature to query params
841        query_params.push(("signature".to_string(), signature));
842    }
843
844    // Apply all query parameters
845    if !query_params.is_empty() {
846        req_builder = req_builder.query(&query_params);
847    }
848
849
850    // Add user agent if configured
851    if let Some(ref user_agent) = configuration.user_agent {
852        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
853    }
854
855    // Apply all header parameters
856    for (header_name, header_value) in header_params {
857        req_builder = req_builder.header(&header_name, &header_value);
858    }
859
860    let mut multipart_form_params = std::collections::HashMap::new();
861    multipart_form_params.insert("orders", params.orders.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
862    if let Some(param_value) = params.recv_window {
863        multipart_form_params.insert("recvWindow", param_value.to_string());
864    }
865    multipart_form_params.insert("timestamp", params.timestamp.to_string());
866    req_builder = req_builder.form(&multipart_form_params);
867
868    let req = req_builder.build()?;
869    let resp = configuration.client.execute(req).await?;
870
871    let status = resp.status();
872    let content_type = resp
873        .headers()
874        .get("content-type")
875        .and_then(|v| v.to_str().ok())
876        .unwrap_or("application/octet-stream");
877    let content_type = super::ContentType::from(content_type);
878
879    if !status.is_client_error() && !status.is_server_error() {
880        let content = resp.text().await?;
881        match content_type {
882            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
883            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::OptionsCreateBatchOrdersV1RespInner&gt;`"))),
884            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::OptionsCreateBatchOrdersV1RespInner&gt;`")))),
885        }
886    } else {
887        let content = resp.text().await?;
888        let entity: Option<CreateBatchOrdersV1Error> = serde_json::from_str(&content).ok();
889        Err(Error::ResponseError(ResponseContent { status, content, entity }))
890    }
891}
892
893/// Accept a block trade order
894pub async fn create_block_order_execute_v1(configuration: &configuration::Configuration, params: CreateBlockOrderExecuteV1Params) -> Result<models::CreateBlockOrderExecuteV1Resp, Error<CreateBlockOrderExecuteV1Error>> {
895
896    let uri_str = format!("{}/eapi/v1/block/order/execute", configuration.base_path);
897    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
898
899    // Create a mutable vector for query parameters
900    let mut query_params: Vec<(String, String)> = Vec::new();
901
902
903    // Create header parameters collection
904    let mut header_params = std::collections::HashMap::new();
905
906    // Handle Binance Auth first if configured
907    if let Some(ref binance_auth) = configuration.binance_auth {
908        // Add API key to headers
909        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
910        
911        // Generate request body for signing (if any)
912        let body_string: Option<Vec<u8>> = None;
913        
914        // Sign the request
915        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
916            Ok(sig) => sig,
917            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
918        };
919        
920        // Add signature to query params
921        query_params.push(("signature".to_string(), signature));
922    }
923
924    // Apply all query parameters
925    if !query_params.is_empty() {
926        req_builder = req_builder.query(&query_params);
927    }
928
929
930    // Add user agent if configured
931    if let Some(ref user_agent) = configuration.user_agent {
932        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
933    }
934
935    // Apply all header parameters
936    for (header_name, header_value) in header_params {
937        req_builder = req_builder.header(&header_name, &header_value);
938    }
939
940    let mut multipart_form_params = std::collections::HashMap::new();
941    multipart_form_params.insert("blockOrderMatchingKey", params.block_order_matching_key.to_string());
942    if let Some(param_value) = params.recv_window {
943        multipart_form_params.insert("recvWindow", param_value.to_string());
944    }
945    multipart_form_params.insert("timestamp", params.timestamp.to_string());
946    req_builder = req_builder.form(&multipart_form_params);
947
948    let req = req_builder.build()?;
949    let resp = configuration.client.execute(req).await?;
950
951    let status = resp.status();
952    let content_type = resp
953        .headers()
954        .get("content-type")
955        .and_then(|v| v.to_str().ok())
956        .unwrap_or("application/octet-stream");
957    let content_type = super::ContentType::from(content_type);
958
959    if !status.is_client_error() && !status.is_server_error() {
960        let content = resp.text().await?;
961        match content_type {
962            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
963            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateBlockOrderExecuteV1Resp`"))),
964            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::CreateBlockOrderExecuteV1Resp`")))),
965        }
966    } else {
967        let content = resp.text().await?;
968        let entity: Option<CreateBlockOrderExecuteV1Error> = serde_json::from_str(&content).ok();
969        Err(Error::ResponseError(ResponseContent { status, content, entity }))
970    }
971}
972
973/// This endpoint resets the time from which the countdown will begin to the time this messaged is received.  It should be called repeatedly as heartbeats.  Multiple heartbeats can be updated at once by specifying the underlying symbols as a list (ex. BTCUSDT,ETHUSDT) in the underlyings parameter.
974pub async fn create_countdown_cancel_all_heart_beat_v1(configuration: &configuration::Configuration, params: CreateCountdownCancelAllHeartBeatV1Params) -> Result<models::CreateCountdownCancelAllHeartBeatV1Resp, Error<CreateCountdownCancelAllHeartBeatV1Error>> {
975
976    let uri_str = format!("{}/eapi/v1/countdownCancelAllHeartBeat", configuration.base_path);
977    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
978
979    // Create a mutable vector for query parameters
980    let mut query_params: Vec<(String, String)> = Vec::new();
981
982
983    // Create header parameters collection
984    let mut header_params = std::collections::HashMap::new();
985
986    // Handle Binance Auth first if configured
987    if let Some(ref binance_auth) = configuration.binance_auth {
988        // Add API key to headers
989        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
990        
991        // Generate request body for signing (if any)
992        let body_string: Option<Vec<u8>> = None;
993        
994        // Sign the request
995        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
996            Ok(sig) => sig,
997            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
998        };
999        
1000        // Add signature to query params
1001        query_params.push(("signature".to_string(), signature));
1002    }
1003
1004    // Apply all query parameters
1005    if !query_params.is_empty() {
1006        req_builder = req_builder.query(&query_params);
1007    }
1008
1009
1010    // Add user agent if configured
1011    if let Some(ref user_agent) = configuration.user_agent {
1012        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1013    }
1014
1015    // Apply all header parameters
1016    for (header_name, header_value) in header_params {
1017        req_builder = req_builder.header(&header_name, &header_value);
1018    }
1019
1020    let mut multipart_form_params = std::collections::HashMap::new();
1021    if let Some(param_value) = params.recv_window {
1022        multipart_form_params.insert("recvWindow", param_value.to_string());
1023    }
1024    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1025    multipart_form_params.insert("underlyings", params.underlyings.to_string());
1026    req_builder = req_builder.form(&multipart_form_params);
1027
1028    let req = req_builder.build()?;
1029    let resp = configuration.client.execute(req).await?;
1030
1031    let status = resp.status();
1032    let content_type = resp
1033        .headers()
1034        .get("content-type")
1035        .and_then(|v| v.to_str().ok())
1036        .unwrap_or("application/octet-stream");
1037    let content_type = super::ContentType::from(content_type);
1038
1039    if !status.is_client_error() && !status.is_server_error() {
1040        let content = resp.text().await?;
1041        match content_type {
1042            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1043            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCountdownCancelAllHeartBeatV1Resp`"))),
1044            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::CreateCountdownCancelAllHeartBeatV1Resp`")))),
1045        }
1046    } else {
1047        let content = resp.text().await?;
1048        let entity: Option<CreateCountdownCancelAllHeartBeatV1Error> = serde_json::from_str(&content).ok();
1049        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1050    }
1051}
1052
1053/// This endpoint sets the parameters of the auto-cancel feature which cancels all open orders (both market maker protection and non market maker protection order types) of the underlying symbol at the end of the specified countdown time period if no heartbeat message is sent.  After the countdown time period, all open orders will be cancelled and new orders will be rejected with error code -2010 until either a heartbeat message is sent or the auto-cancel feature is turned off by setting countdownTime to 0.
1054pub async fn create_countdown_cancel_all_v1(configuration: &configuration::Configuration, params: CreateCountdownCancelAllV1Params) -> Result<models::CreateCountdownCancelAllV1Resp, Error<CreateCountdownCancelAllV1Error>> {
1055
1056    let uri_str = format!("{}/eapi/v1/countdownCancelAll", configuration.base_path);
1057    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1058
1059    // Create a mutable vector for query parameters
1060    let mut query_params: Vec<(String, String)> = Vec::new();
1061
1062
1063    // Create header parameters collection
1064    let mut header_params = std::collections::HashMap::new();
1065
1066    // Handle Binance Auth first if configured
1067    if let Some(ref binance_auth) = configuration.binance_auth {
1068        // Add API key to headers
1069        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1070        
1071        // Generate request body for signing (if any)
1072        let body_string: Option<Vec<u8>> = None;
1073        
1074        // Sign the request
1075        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1076            Ok(sig) => sig,
1077            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1078        };
1079        
1080        // Add signature to query params
1081        query_params.push(("signature".to_string(), signature));
1082    }
1083
1084    // Apply all query parameters
1085    if !query_params.is_empty() {
1086        req_builder = req_builder.query(&query_params);
1087    }
1088
1089
1090    // Add user agent if configured
1091    if let Some(ref user_agent) = configuration.user_agent {
1092        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1093    }
1094
1095    // Apply all header parameters
1096    for (header_name, header_value) in header_params {
1097        req_builder = req_builder.header(&header_name, &header_value);
1098    }
1099
1100    let mut multipart_form_params = std::collections::HashMap::new();
1101    multipart_form_params.insert("countdownTime", params.countdown_time.to_string());
1102    if let Some(param_value) = params.recv_window {
1103        multipart_form_params.insert("recvWindow", param_value.to_string());
1104    }
1105    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1106    multipart_form_params.insert("underlying", params.underlying.to_string());
1107    req_builder = req_builder.form(&multipart_form_params);
1108
1109    let req = req_builder.build()?;
1110    let resp = configuration.client.execute(req).await?;
1111
1112    let status = resp.status();
1113    let content_type = resp
1114        .headers()
1115        .get("content-type")
1116        .and_then(|v| v.to_str().ok())
1117        .unwrap_or("application/octet-stream");
1118    let content_type = super::ContentType::from(content_type);
1119
1120    if !status.is_client_error() && !status.is_server_error() {
1121        let content = resp.text().await?;
1122        match content_type {
1123            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1124            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCountdownCancelAllV1Resp`"))),
1125            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateCountdownCancelAllV1Resp`")))),
1126        }
1127    } else {
1128        let content = resp.text().await?;
1129        let entity: Option<CreateCountdownCancelAllV1Error> = serde_json::from_str(&content).ok();
1130        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1131    }
1132}
1133
1134/// Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active listenKey, that listenKey will be returned and its validity will be extended for 60 minutes.
1135pub async fn create_listen_key_v1(configuration: &configuration::Configuration) -> Result<models::CreateListenKeyV1Resp, Error<CreateListenKeyV1Error>> {
1136
1137    let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
1138    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1139
1140    // Create a mutable vector for query parameters
1141    let mut query_params: Vec<(String, String)> = Vec::new();
1142
1143
1144    // Create header parameters collection
1145    let mut header_params = std::collections::HashMap::new();
1146
1147    // Handle Binance Auth first if configured
1148    if let Some(ref binance_auth) = configuration.binance_auth {
1149        // Add API key to headers
1150        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1151        
1152        // Generate request body for signing (if any)
1153        let body_string: Option<Vec<u8>> = None;
1154        
1155        // Sign the request
1156        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1157            Ok(sig) => sig,
1158            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1159        };
1160        
1161        // Add signature to query params
1162        query_params.push(("signature".to_string(), signature));
1163    }
1164
1165    // Apply all query parameters
1166    if !query_params.is_empty() {
1167        req_builder = req_builder.query(&query_params);
1168    }
1169
1170
1171    // Add user agent if configured
1172    if let Some(ref user_agent) = configuration.user_agent {
1173        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1174    }
1175
1176    // Apply all header parameters
1177    for (header_name, header_value) in header_params {
1178        req_builder = req_builder.header(&header_name, &header_value);
1179    }
1180
1181
1182    let req = req_builder.build()?;
1183    let resp = configuration.client.execute(req).await?;
1184
1185    let status = resp.status();
1186    let content_type = resp
1187        .headers()
1188        .get("content-type")
1189        .and_then(|v| v.to_str().ok())
1190        .unwrap_or("application/octet-stream");
1191    let content_type = super::ContentType::from(content_type);
1192
1193    if !status.is_client_error() && !status.is_server_error() {
1194        let content = resp.text().await?;
1195        match content_type {
1196            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1197            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateListenKeyV1Resp`"))),
1198            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateListenKeyV1Resp`")))),
1199        }
1200    } else {
1201        let content = resp.text().await?;
1202        let entity: Option<CreateListenKeyV1Error> = serde_json::from_str(&content).ok();
1203        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1204    }
1205}
1206
1207/// Reset MMP, start MMP order again.
1208pub async fn create_mmp_reset_v1(configuration: &configuration::Configuration, params: CreateMmpResetV1Params) -> Result<models::CreateMmpResetV1Resp, Error<CreateMmpResetV1Error>> {
1209
1210    let uri_str = format!("{}/eapi/v1/mmpReset", configuration.base_path);
1211    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1212
1213    // Create a mutable vector for query parameters
1214    let mut query_params: Vec<(String, String)> = Vec::new();
1215
1216
1217    // Create header parameters collection
1218    let mut header_params = std::collections::HashMap::new();
1219
1220    // Handle Binance Auth first if configured
1221    if let Some(ref binance_auth) = configuration.binance_auth {
1222        // Add API key to headers
1223        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1224        
1225        // Generate request body for signing (if any)
1226        let body_string: Option<Vec<u8>> = None;
1227        
1228        // Sign the request
1229        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1230            Ok(sig) => sig,
1231            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1232        };
1233        
1234        // Add signature to query params
1235        query_params.push(("signature".to_string(), signature));
1236    }
1237
1238    // Apply all query parameters
1239    if !query_params.is_empty() {
1240        req_builder = req_builder.query(&query_params);
1241    }
1242
1243
1244    // Add user agent if configured
1245    if let Some(ref user_agent) = configuration.user_agent {
1246        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1247    }
1248
1249    // Apply all header parameters
1250    for (header_name, header_value) in header_params {
1251        req_builder = req_builder.header(&header_name, &header_value);
1252    }
1253
1254    let mut multipart_form_params = std::collections::HashMap::new();
1255    if let Some(param_value) = params.recv_window {
1256        multipart_form_params.insert("recvWindow", param_value.to_string());
1257    }
1258    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1259    if let Some(param_value) = params.underlying {
1260        multipart_form_params.insert("underlying", param_value.to_string());
1261    }
1262    req_builder = req_builder.form(&multipart_form_params);
1263
1264    let req = req_builder.build()?;
1265    let resp = configuration.client.execute(req).await?;
1266
1267    let status = resp.status();
1268    let content_type = resp
1269        .headers()
1270        .get("content-type")
1271        .and_then(|v| v.to_str().ok())
1272        .unwrap_or("application/octet-stream");
1273    let content_type = super::ContentType::from(content_type);
1274
1275    if !status.is_client_error() && !status.is_server_error() {
1276        let content = resp.text().await?;
1277        match content_type {
1278            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1279            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMmpResetV1Resp`"))),
1280            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::CreateMmpResetV1Resp`")))),
1281        }
1282    } else {
1283        let content = resp.text().await?;
1284        let entity: Option<CreateMmpResetV1Error> = serde_json::from_str(&content).ok();
1285        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1286    }
1287}
1288
1289/// Set config for MMP. Market Maker Protection(MMP) is a set of protection mechanism for option market maker, this mechanism is able to prevent mass trading in short period time. Once market maker's account branches the threshold, the Market Maker Protection will be triggered. When Market Maker Protection triggers, all the current MMP orders will be canceled, new MMP orders will be rejected. Market maker can use this time to reevaluate market and modify order price.
1290pub async fn create_mmp_set_v1(configuration: &configuration::Configuration, params: CreateMmpSetV1Params) -> Result<models::CreateMmpSetV1Resp, Error<CreateMmpSetV1Error>> {
1291
1292    let uri_str = format!("{}/eapi/v1/mmpSet", configuration.base_path);
1293    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1294
1295    // Create a mutable vector for query parameters
1296    let mut query_params: Vec<(String, String)> = Vec::new();
1297
1298
1299    // Create header parameters collection
1300    let mut header_params = std::collections::HashMap::new();
1301
1302    // Handle Binance Auth first if configured
1303    if let Some(ref binance_auth) = configuration.binance_auth {
1304        // Add API key to headers
1305        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1306        
1307        // Generate request body for signing (if any)
1308        let body_string: Option<Vec<u8>> = None;
1309        
1310        // Sign the request
1311        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1312            Ok(sig) => sig,
1313            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1314        };
1315        
1316        // Add signature to query params
1317        query_params.push(("signature".to_string(), signature));
1318    }
1319
1320    // Apply all query parameters
1321    if !query_params.is_empty() {
1322        req_builder = req_builder.query(&query_params);
1323    }
1324
1325
1326    // Add user agent if configured
1327    if let Some(ref user_agent) = configuration.user_agent {
1328        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1329    }
1330
1331    // Apply all header parameters
1332    for (header_name, header_value) in header_params {
1333        req_builder = req_builder.header(&header_name, &header_value);
1334    }
1335
1336    let mut multipart_form_params = std::collections::HashMap::new();
1337    if let Some(param_value) = params.delta_limit {
1338        multipart_form_params.insert("deltaLimit", param_value.to_string());
1339    }
1340    if let Some(param_value) = params.frozen_time_in_milliseconds {
1341        multipart_form_params.insert("frozenTimeInMilliseconds", param_value.to_string());
1342    }
1343    if let Some(param_value) = params.qty_limit {
1344        multipart_form_params.insert("qtyLimit", param_value.to_string());
1345    }
1346    if let Some(param_value) = params.recv_window {
1347        multipart_form_params.insert("recvWindow", param_value.to_string());
1348    }
1349    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1350    if let Some(param_value) = params.underlying {
1351        multipart_form_params.insert("underlying", param_value.to_string());
1352    }
1353    if let Some(param_value) = params.window_time_in_milliseconds {
1354        multipart_form_params.insert("windowTimeInMilliseconds", param_value.to_string());
1355    }
1356    req_builder = req_builder.form(&multipart_form_params);
1357
1358    let req = req_builder.build()?;
1359    let resp = configuration.client.execute(req).await?;
1360
1361    let status = resp.status();
1362    let content_type = resp
1363        .headers()
1364        .get("content-type")
1365        .and_then(|v| v.to_str().ok())
1366        .unwrap_or("application/octet-stream");
1367    let content_type = super::ContentType::from(content_type);
1368
1369    if !status.is_client_error() && !status.is_server_error() {
1370        let content = resp.text().await?;
1371        match content_type {
1372            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1373            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMmpSetV1Resp`"))),
1374            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::CreateMmpSetV1Resp`")))),
1375        }
1376    } else {
1377        let content = resp.text().await?;
1378        let entity: Option<CreateMmpSetV1Error> = serde_json::from_str(&content).ok();
1379        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1380    }
1381}
1382
1383/// Send a new order.
1384pub async fn create_order_v1(configuration: &configuration::Configuration, params: CreateOrderV1Params) -> Result<models::OptionsCreateOrderV1Resp, Error<CreateOrderV1Error>> {
1385
1386    let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
1387    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1388
1389    // Create a mutable vector for query parameters
1390    let mut query_params: Vec<(String, String)> = Vec::new();
1391
1392
1393    // Create header parameters collection
1394    let mut header_params = std::collections::HashMap::new();
1395
1396    // Handle Binance Auth first if configured
1397    if let Some(ref binance_auth) = configuration.binance_auth {
1398        // Add API key to headers
1399        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1400        
1401        // Generate request body for signing (if any)
1402        let body_string: Option<Vec<u8>> = None;
1403        
1404        // Sign the request
1405        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1406            Ok(sig) => sig,
1407            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1408        };
1409        
1410        // Add signature to query params
1411        query_params.push(("signature".to_string(), signature));
1412    }
1413
1414    // Apply all query parameters
1415    if !query_params.is_empty() {
1416        req_builder = req_builder.query(&query_params);
1417    }
1418
1419
1420    // Add user agent if configured
1421    if let Some(ref user_agent) = configuration.user_agent {
1422        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1423    }
1424
1425    // Apply all header parameters
1426    for (header_name, header_value) in header_params {
1427        req_builder = req_builder.header(&header_name, &header_value);
1428    }
1429
1430    let mut multipart_form_params = std::collections::HashMap::new();
1431    if let Some(param_value) = params.client_order_id {
1432        multipart_form_params.insert("clientOrderId", param_value.to_string());
1433    }
1434    if let Some(param_value) = params.is_mmp {
1435        multipart_form_params.insert("isMmp", param_value.to_string());
1436    }
1437    if let Some(param_value) = params.new_order_resp_type {
1438        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1439    }
1440    if let Some(param_value) = params.post_only {
1441        multipart_form_params.insert("postOnly", param_value.to_string());
1442    }
1443    if let Some(param_value) = params.price {
1444        multipart_form_params.insert("price", param_value.to_string());
1445    }
1446    multipart_form_params.insert("quantity", params.quantity.to_string());
1447    if let Some(param_value) = params.recv_window {
1448        multipart_form_params.insert("recvWindow", param_value.to_string());
1449    }
1450    if let Some(param_value) = params.reduce_only {
1451        multipart_form_params.insert("reduceOnly", param_value.to_string());
1452    }
1453    multipart_form_params.insert("side", params.side.to_string());
1454    multipart_form_params.insert("symbol", params.symbol.to_string());
1455    if let Some(param_value) = params.time_in_force {
1456        multipart_form_params.insert("timeInForce", param_value.to_string());
1457    }
1458    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1459    multipart_form_params.insert("type", params.r#type.to_string());
1460    req_builder = req_builder.form(&multipart_form_params);
1461
1462    let req = req_builder.build()?;
1463    let resp = configuration.client.execute(req).await?;
1464
1465    let status = resp.status();
1466    let content_type = resp
1467        .headers()
1468        .get("content-type")
1469        .and_then(|v| v.to_str().ok())
1470        .unwrap_or("application/octet-stream");
1471    let content_type = super::ContentType::from(content_type);
1472
1473    if !status.is_client_error() && !status.is_server_error() {
1474        let content = resp.text().await?;
1475        match content_type {
1476            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1477            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsCreateOrderV1Resp`"))),
1478            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::OptionsCreateOrderV1Resp`")))),
1479        }
1480    } else {
1481        let content = resp.text().await?;
1482        let entity: Option<CreateOrderV1Error> = serde_json::from_str(&content).ok();
1483        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1484    }
1485}
1486
1487/// Cancel all active orders on specified underlying.
1488pub async fn delete_all_open_orders_by_underlying_v1(configuration: &configuration::Configuration, params: DeleteAllOpenOrdersByUnderlyingV1Params) -> Result<models::DeleteAllOpenOrdersByUnderlyingV1Resp, Error<DeleteAllOpenOrdersByUnderlyingV1Error>> {
1489
1490    let uri_str = format!("{}/eapi/v1/allOpenOrdersByUnderlying", configuration.base_path);
1491    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1492
1493    // Create a mutable vector for query parameters
1494    let mut query_params: Vec<(String, String)> = Vec::new();
1495
1496    query_params.push(("underlying".to_string(), params.underlying.to_string()));
1497    if let Some(ref param_value) = params.recv_window {
1498        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1499    }
1500    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1501
1502    // Create header parameters collection
1503    let mut header_params = std::collections::HashMap::new();
1504
1505    // Handle Binance Auth first if configured
1506    if let Some(ref binance_auth) = configuration.binance_auth {
1507        // Add API key to headers
1508        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1509        
1510        // Generate request body for signing (if any)
1511        let body_string: Option<Vec<u8>> = None;
1512        
1513        // Sign the request
1514        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1515            Ok(sig) => sig,
1516            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1517        };
1518        
1519        // Add signature to query params
1520        query_params.push(("signature".to_string(), signature));
1521    }
1522
1523    // Apply all query parameters
1524    if !query_params.is_empty() {
1525        req_builder = req_builder.query(&query_params);
1526    }
1527
1528
1529    // Add user agent if configured
1530    if let Some(ref user_agent) = configuration.user_agent {
1531        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1532    }
1533
1534    // Apply all header parameters
1535    for (header_name, header_value) in header_params {
1536        req_builder = req_builder.header(&header_name, &header_value);
1537    }
1538
1539
1540    let req = req_builder.build()?;
1541    let resp = configuration.client.execute(req).await?;
1542
1543    let status = resp.status();
1544    let content_type = resp
1545        .headers()
1546        .get("content-type")
1547        .and_then(|v| v.to_str().ok())
1548        .unwrap_or("application/octet-stream");
1549    let content_type = super::ContentType::from(content_type);
1550
1551    if !status.is_client_error() && !status.is_server_error() {
1552        let content = resp.text().await?;
1553        match content_type {
1554            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1555            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAllOpenOrdersByUnderlyingV1Resp`"))),
1556            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::DeleteAllOpenOrdersByUnderlyingV1Resp`")))),
1557        }
1558    } else {
1559        let content = resp.text().await?;
1560        let entity: Option<DeleteAllOpenOrdersByUnderlyingV1Error> = serde_json::from_str(&content).ok();
1561        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1562    }
1563}
1564
1565/// Cancel all active order on a symbol.
1566pub async fn delete_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteAllOpenOrdersV1Params) -> Result<models::DeleteAllOpenOrdersV1Resp, Error<DeleteAllOpenOrdersV1Error>> {
1567
1568    let uri_str = format!("{}/eapi/v1/allOpenOrders", configuration.base_path);
1569    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1570
1571    // Create a mutable vector for query parameters
1572    let mut query_params: Vec<(String, String)> = Vec::new();
1573
1574    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1575    if let Some(ref param_value) = params.recv_window {
1576        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1577    }
1578    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1579
1580    // Create header parameters collection
1581    let mut header_params = std::collections::HashMap::new();
1582
1583    // Handle Binance Auth first if configured
1584    if let Some(ref binance_auth) = configuration.binance_auth {
1585        // Add API key to headers
1586        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1587        
1588        // Generate request body for signing (if any)
1589        let body_string: Option<Vec<u8>> = None;
1590        
1591        // Sign the request
1592        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1593            Ok(sig) => sig,
1594            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1595        };
1596        
1597        // Add signature to query params
1598        query_params.push(("signature".to_string(), signature));
1599    }
1600
1601    // Apply all query parameters
1602    if !query_params.is_empty() {
1603        req_builder = req_builder.query(&query_params);
1604    }
1605
1606
1607    // Add user agent if configured
1608    if let Some(ref user_agent) = configuration.user_agent {
1609        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1610    }
1611
1612    // Apply all header parameters
1613    for (header_name, header_value) in header_params {
1614        req_builder = req_builder.header(&header_name, &header_value);
1615    }
1616
1617
1618    let req = req_builder.build()?;
1619    let resp = configuration.client.execute(req).await?;
1620
1621    let status = resp.status();
1622    let content_type = resp
1623        .headers()
1624        .get("content-type")
1625        .and_then(|v| v.to_str().ok())
1626        .unwrap_or("application/octet-stream");
1627    let content_type = super::ContentType::from(content_type);
1628
1629    if !status.is_client_error() && !status.is_server_error() {
1630        let content = resp.text().await?;
1631        match content_type {
1632            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1633            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAllOpenOrdersV1Resp`"))),
1634            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteAllOpenOrdersV1Resp`")))),
1635        }
1636    } else {
1637        let content = resp.text().await?;
1638        let entity: Option<DeleteAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
1639        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1640    }
1641}
1642
1643/// Cancel multiple orders.
1644pub async fn delete_batch_orders_v1(configuration: &configuration::Configuration, params: DeleteBatchOrdersV1Params) -> Result<Vec<models::OptionsDeleteBatchOrdersV1RespInner>, Error<DeleteBatchOrdersV1Error>> {
1645
1646    let uri_str = format!("{}/eapi/v1/batchOrders", configuration.base_path);
1647    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1648
1649    // Create a mutable vector for query parameters
1650    let mut query_params: Vec<(String, String)> = Vec::new();
1651
1652    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1653    if let Some(ref param_value) = params.order_ids {
1654        match "multi" {
1655            "multi" => {
1656                for p in param_value {
1657                    query_params.push(("orderIds".to_string(), p.to_string()));
1658                }
1659            },
1660            _ => {
1661                let joined = param_value.iter()
1662                    .map(|p| p.to_string())
1663                    .collect::<Vec<String>>()
1664                    .join(",");
1665                query_params.push(("orderIds".to_string(), joined));
1666            }
1667        };
1668    }
1669    if let Some(ref param_value) = params.client_order_ids {
1670        match "multi" {
1671            "multi" => {
1672                for p in param_value {
1673                    query_params.push(("clientOrderIds".to_string(), p.to_string()));
1674                }
1675            },
1676            _ => {
1677                let joined = param_value.iter()
1678                    .map(|p| p.to_string())
1679                    .collect::<Vec<String>>()
1680                    .join(",");
1681                query_params.push(("clientOrderIds".to_string(), joined));
1682            }
1683        };
1684    }
1685    if let Some(ref param_value) = params.recv_window {
1686        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1687    }
1688    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1689
1690    // Create header parameters collection
1691    let mut header_params = std::collections::HashMap::new();
1692
1693    // Handle Binance Auth first if configured
1694    if let Some(ref binance_auth) = configuration.binance_auth {
1695        // Add API key to headers
1696        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1697        
1698        // Generate request body for signing (if any)
1699        let body_string: Option<Vec<u8>> = None;
1700        
1701        // Sign the request
1702        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1703            Ok(sig) => sig,
1704            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1705        };
1706        
1707        // Add signature to query params
1708        query_params.push(("signature".to_string(), signature));
1709    }
1710
1711    // Apply all query parameters
1712    if !query_params.is_empty() {
1713        req_builder = req_builder.query(&query_params);
1714    }
1715
1716
1717    // Add user agent if configured
1718    if let Some(ref user_agent) = configuration.user_agent {
1719        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1720    }
1721
1722    // Apply all header parameters
1723    for (header_name, header_value) in header_params {
1724        req_builder = req_builder.header(&header_name, &header_value);
1725    }
1726
1727
1728    let req = req_builder.build()?;
1729    let resp = configuration.client.execute(req).await?;
1730
1731    let status = resp.status();
1732    let content_type = resp
1733        .headers()
1734        .get("content-type")
1735        .and_then(|v| v.to_str().ok())
1736        .unwrap_or("application/octet-stream");
1737    let content_type = super::ContentType::from(content_type);
1738
1739    if !status.is_client_error() && !status.is_server_error() {
1740        let content = resp.text().await?;
1741        match content_type {
1742            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1743            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::OptionsDeleteBatchOrdersV1RespInner&gt;`"))),
1744            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::OptionsDeleteBatchOrdersV1RespInner&gt;`")))),
1745        }
1746    } else {
1747        let content = resp.text().await?;
1748        let entity: Option<DeleteBatchOrdersV1Error> = serde_json::from_str(&content).ok();
1749        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1750    }
1751}
1752
1753/// Close out a user data stream.
1754pub async fn delete_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<DeleteListenKeyV1Error>> {
1755
1756    let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
1757    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1758
1759    // Create a mutable vector for query parameters
1760    let mut query_params: Vec<(String, String)> = Vec::new();
1761
1762
1763    // Create header parameters collection
1764    let mut header_params = std::collections::HashMap::new();
1765
1766    // Handle Binance Auth first if configured
1767    if let Some(ref binance_auth) = configuration.binance_auth {
1768        // Add API key to headers
1769        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1770        
1771        // Generate request body for signing (if any)
1772        let body_string: Option<Vec<u8>> = None;
1773        
1774        // Sign the request
1775        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1776            Ok(sig) => sig,
1777            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1778        };
1779        
1780        // Add signature to query params
1781        query_params.push(("signature".to_string(), signature));
1782    }
1783
1784    // Apply all query parameters
1785    if !query_params.is_empty() {
1786        req_builder = req_builder.query(&query_params);
1787    }
1788
1789
1790    // Add user agent if configured
1791    if let Some(ref user_agent) = configuration.user_agent {
1792        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1793    }
1794
1795    // Apply all header parameters
1796    for (header_name, header_value) in header_params {
1797        req_builder = req_builder.header(&header_name, &header_value);
1798    }
1799
1800
1801    let req = req_builder.build()?;
1802    let resp = configuration.client.execute(req).await?;
1803
1804    let status = resp.status();
1805    let content_type = resp
1806        .headers()
1807        .get("content-type")
1808        .and_then(|v| v.to_str().ok())
1809        .unwrap_or("application/octet-stream");
1810    let content_type = super::ContentType::from(content_type);
1811
1812    if !status.is_client_error() && !status.is_server_error() {
1813        let content = resp.text().await?;
1814        match content_type {
1815            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1816            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
1817            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`")))),
1818        }
1819    } else {
1820        let content = resp.text().await?;
1821        let entity: Option<DeleteListenKeyV1Error> = serde_json::from_str(&content).ok();
1822        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1823    }
1824}
1825
1826/// Cancel an active order.
1827pub async fn delete_order_v1(configuration: &configuration::Configuration, params: DeleteOrderV1Params) -> Result<models::DeleteOrderV1Resp, Error<DeleteOrderV1Error>> {
1828
1829    let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
1830    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1831
1832    // Create a mutable vector for query parameters
1833    let mut query_params: Vec<(String, String)> = Vec::new();
1834
1835    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1836    if let Some(ref param_value) = params.order_id {
1837        query_params.push(("orderId".to_string(), param_value.to_string()));
1838    }
1839    if let Some(ref param_value) = params.client_order_id {
1840        query_params.push(("clientOrderId".to_string(), param_value.to_string()));
1841    }
1842    if let Some(ref param_value) = params.recv_window {
1843        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1844    }
1845    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1846
1847    // Create header parameters collection
1848    let mut header_params = std::collections::HashMap::new();
1849
1850    // Handle Binance Auth first if configured
1851    if let Some(ref binance_auth) = configuration.binance_auth {
1852        // Add API key to headers
1853        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1854        
1855        // Generate request body for signing (if any)
1856        let body_string: Option<Vec<u8>> = None;
1857        
1858        // Sign the request
1859        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1860            Ok(sig) => sig,
1861            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1862        };
1863        
1864        // Add signature to query params
1865        query_params.push(("signature".to_string(), signature));
1866    }
1867
1868    // Apply all query parameters
1869    if !query_params.is_empty() {
1870        req_builder = req_builder.query(&query_params);
1871    }
1872
1873
1874    // Add user agent if configured
1875    if let Some(ref user_agent) = configuration.user_agent {
1876        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1877    }
1878
1879    // Apply all header parameters
1880    for (header_name, header_value) in header_params {
1881        req_builder = req_builder.header(&header_name, &header_value);
1882    }
1883
1884
1885    let req = req_builder.build()?;
1886    let resp = configuration.client.execute(req).await?;
1887
1888    let status = resp.status();
1889    let content_type = resp
1890        .headers()
1891        .get("content-type")
1892        .and_then(|v| v.to_str().ok())
1893        .unwrap_or("application/octet-stream");
1894    let content_type = super::ContentType::from(content_type);
1895
1896    if !status.is_client_error() && !status.is_server_error() {
1897        let content = resp.text().await?;
1898        match content_type {
1899            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1900            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteOrderV1Resp`"))),
1901            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteOrderV1Resp`")))),
1902        }
1903    } else {
1904        let content = resp.text().await?;
1905        let entity: Option<DeleteOrderV1Error> = serde_json::from_str(&content).ok();
1906        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1907    }
1908}
1909
1910/// Get current account information.
1911pub async fn get_account_v1(configuration: &configuration::Configuration, params: GetAccountV1Params) -> Result<models::GetAccountV1Resp, Error<GetAccountV1Error>> {
1912
1913    let uri_str = format!("{}/eapi/v1/account", configuration.base_path);
1914    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1915
1916    // Create a mutable vector for query parameters
1917    let mut query_params: Vec<(String, String)> = Vec::new();
1918
1919    if let Some(ref param_value) = params.recv_window {
1920        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1921    }
1922    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1923
1924    // Create header parameters collection
1925    let mut header_params = std::collections::HashMap::new();
1926
1927    // Handle Binance Auth first if configured
1928    if let Some(ref binance_auth) = configuration.binance_auth {
1929        // Add API key to headers
1930        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1931        
1932        // Generate request body for signing (if any)
1933        let body_string: Option<Vec<u8>> = None;
1934        
1935        // Sign the request
1936        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1937            Ok(sig) => sig,
1938            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1939        };
1940        
1941        // Add signature to query params
1942        query_params.push(("signature".to_string(), signature));
1943    }
1944
1945    // Apply all query parameters
1946    if !query_params.is_empty() {
1947        req_builder = req_builder.query(&query_params);
1948    }
1949
1950
1951    // Add user agent if configured
1952    if let Some(ref user_agent) = configuration.user_agent {
1953        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1954    }
1955
1956    // Apply all header parameters
1957    for (header_name, header_value) in header_params {
1958        req_builder = req_builder.header(&header_name, &header_value);
1959    }
1960
1961
1962    let req = req_builder.build()?;
1963    let resp = configuration.client.execute(req).await?;
1964
1965    let status = resp.status();
1966    let content_type = resp
1967        .headers()
1968        .get("content-type")
1969        .and_then(|v| v.to_str().ok())
1970        .unwrap_or("application/octet-stream");
1971    let content_type = super::ContentType::from(content_type);
1972
1973    if !status.is_client_error() && !status.is_server_error() {
1974        let content = resp.text().await?;
1975        match content_type {
1976            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1977            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountV1Resp`"))),
1978            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAccountV1Resp`")))),
1979        }
1980    } else {
1981        let content = resp.text().await?;
1982        let entity: Option<GetAccountV1Error> = serde_json::from_str(&content).ok();
1983        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1984    }
1985}
1986
1987/// Query account funding flows.
1988pub async fn get_bill_v1(configuration: &configuration::Configuration, params: GetBillV1Params) -> Result<Vec<models::GetBillV1RespItem>, Error<GetBillV1Error>> {
1989
1990    let uri_str = format!("{}/eapi/v1/bill", configuration.base_path);
1991    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1992
1993    // Create a mutable vector for query parameters
1994    let mut query_params: Vec<(String, String)> = Vec::new();
1995
1996    query_params.push(("currency".to_string(), params.currency.to_string()));
1997    if let Some(ref param_value) = params.record_id {
1998        query_params.push(("recordId".to_string(), param_value.to_string()));
1999    }
2000    if let Some(ref param_value) = params.start_time {
2001        query_params.push(("startTime".to_string(), param_value.to_string()));
2002    }
2003    if let Some(ref param_value) = params.end_time {
2004        query_params.push(("endTime".to_string(), param_value.to_string()));
2005    }
2006    if let Some(ref param_value) = params.limit {
2007        query_params.push(("limit".to_string(), param_value.to_string()));
2008    }
2009    if let Some(ref param_value) = params.recv_window {
2010        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2011    }
2012    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2013
2014    // Create header parameters collection
2015    let mut header_params = std::collections::HashMap::new();
2016
2017    // Handle Binance Auth first if configured
2018    if let Some(ref binance_auth) = configuration.binance_auth {
2019        // Add API key to headers
2020        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2021        
2022        // Generate request body for signing (if any)
2023        let body_string: Option<Vec<u8>> = None;
2024        
2025        // Sign the request
2026        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2027            Ok(sig) => sig,
2028            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2029        };
2030        
2031        // Add signature to query params
2032        query_params.push(("signature".to_string(), signature));
2033    }
2034
2035    // Apply all query parameters
2036    if !query_params.is_empty() {
2037        req_builder = req_builder.query(&query_params);
2038    }
2039
2040
2041    // Add user agent if configured
2042    if let Some(ref user_agent) = configuration.user_agent {
2043        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2044    }
2045
2046    // Apply all header parameters
2047    for (header_name, header_value) in header_params {
2048        req_builder = req_builder.header(&header_name, &header_value);
2049    }
2050
2051
2052    let req = req_builder.build()?;
2053    let resp = configuration.client.execute(req).await?;
2054
2055    let status = resp.status();
2056    let content_type = resp
2057        .headers()
2058        .get("content-type")
2059        .and_then(|v| v.to_str().ok())
2060        .unwrap_or("application/octet-stream");
2061    let content_type = super::ContentType::from(content_type);
2062
2063    if !status.is_client_error() && !status.is_server_error() {
2064        let content = resp.text().await?;
2065        match content_type {
2066            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2067            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetBillV1RespItem&gt;`"))),
2068            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::GetBillV1RespItem&gt;`")))),
2069        }
2070    } else {
2071        let content = resp.text().await?;
2072        let entity: Option<GetBillV1Error> = serde_json::from_str(&content).ok();
2073        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2074    }
2075}
2076
2077/// Query block trade details; returns block trade details from counterparty's perspective.
2078pub async fn get_block_order_execute_v1(configuration: &configuration::Configuration, params: GetBlockOrderExecuteV1Params) -> Result<models::GetBlockOrderExecuteV1Resp, Error<GetBlockOrderExecuteV1Error>> {
2079
2080    let uri_str = format!("{}/eapi/v1/block/order/execute", configuration.base_path);
2081    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2082
2083    // Create a mutable vector for query parameters
2084    let mut query_params: Vec<(String, String)> = Vec::new();
2085
2086    query_params.push(("blockOrderMatchingKey".to_string(), params.block_order_matching_key.to_string()));
2087    if let Some(ref param_value) = params.recv_window {
2088        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2089    }
2090    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2091
2092    // Create header parameters collection
2093    let mut header_params = std::collections::HashMap::new();
2094
2095    // Handle Binance Auth first if configured
2096    if let Some(ref binance_auth) = configuration.binance_auth {
2097        // Add API key to headers
2098        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2099        
2100        // Generate request body for signing (if any)
2101        let body_string: Option<Vec<u8>> = None;
2102        
2103        // Sign the request
2104        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2105            Ok(sig) => sig,
2106            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2107        };
2108        
2109        // Add signature to query params
2110        query_params.push(("signature".to_string(), signature));
2111    }
2112
2113    // Apply all query parameters
2114    if !query_params.is_empty() {
2115        req_builder = req_builder.query(&query_params);
2116    }
2117
2118
2119    // Add user agent if configured
2120    if let Some(ref user_agent) = configuration.user_agent {
2121        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2122    }
2123
2124    // Apply all header parameters
2125    for (header_name, header_value) in header_params {
2126        req_builder = req_builder.header(&header_name, &header_value);
2127    }
2128
2129
2130    let req = req_builder.build()?;
2131    let resp = configuration.client.execute(req).await?;
2132
2133    let status = resp.status();
2134    let content_type = resp
2135        .headers()
2136        .get("content-type")
2137        .and_then(|v| v.to_str().ok())
2138        .unwrap_or("application/octet-stream");
2139    let content_type = super::ContentType::from(content_type);
2140
2141    if !status.is_client_error() && !status.is_server_error() {
2142        let content = resp.text().await?;
2143        match content_type {
2144            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2145            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetBlockOrderExecuteV1Resp`"))),
2146            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::GetBlockOrderExecuteV1Resp`")))),
2147        }
2148    } else {
2149        let content = resp.text().await?;
2150        let entity: Option<GetBlockOrderExecuteV1Error> = serde_json::from_str(&content).ok();
2151        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2152    }
2153}
2154
2155/// Check block trade order status.
2156pub async fn get_block_order_orders_v1(configuration: &configuration::Configuration, params: GetBlockOrderOrdersV1Params) -> Result<Vec<models::GetBlockOrderOrdersV1RespItem>, Error<GetBlockOrderOrdersV1Error>> {
2157
2158    let uri_str = format!("{}/eapi/v1/block/order/orders", configuration.base_path);
2159    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2160
2161    // Create a mutable vector for query parameters
2162    let mut query_params: Vec<(String, String)> = Vec::new();
2163
2164    if let Some(ref param_value) = params.block_order_matching_key {
2165        query_params.push(("blockOrderMatchingKey".to_string(), param_value.to_string()));
2166    }
2167    if let Some(ref param_value) = params.end_time {
2168        query_params.push(("endTime".to_string(), param_value.to_string()));
2169    }
2170    if let Some(ref param_value) = params.start_time {
2171        query_params.push(("startTime".to_string(), param_value.to_string()));
2172    }
2173    if let Some(ref param_value) = params.underlying {
2174        query_params.push(("underlying".to_string(), param_value.to_string()));
2175    }
2176    if let Some(ref param_value) = params.recv_window {
2177        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2178    }
2179    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2180
2181    // Create header parameters collection
2182    let mut header_params = std::collections::HashMap::new();
2183
2184    // Handle Binance Auth first if configured
2185    if let Some(ref binance_auth) = configuration.binance_auth {
2186        // Add API key to headers
2187        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2188        
2189        // Generate request body for signing (if any)
2190        let body_string: Option<Vec<u8>> = None;
2191        
2192        // Sign the request
2193        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2194            Ok(sig) => sig,
2195            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2196        };
2197        
2198        // Add signature to query params
2199        query_params.push(("signature".to_string(), signature));
2200    }
2201
2202    // Apply all query parameters
2203    if !query_params.is_empty() {
2204        req_builder = req_builder.query(&query_params);
2205    }
2206
2207
2208    // Add user agent if configured
2209    if let Some(ref user_agent) = configuration.user_agent {
2210        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2211    }
2212
2213    // Apply all header parameters
2214    for (header_name, header_value) in header_params {
2215        req_builder = req_builder.header(&header_name, &header_value);
2216    }
2217
2218
2219    let req = req_builder.build()?;
2220    let resp = configuration.client.execute(req).await?;
2221
2222    let status = resp.status();
2223    let content_type = resp
2224        .headers()
2225        .get("content-type")
2226        .and_then(|v| v.to_str().ok())
2227        .unwrap_or("application/octet-stream");
2228    let content_type = super::ContentType::from(content_type);
2229
2230    if !status.is_client_error() && !status.is_server_error() {
2231        let content = resp.text().await?;
2232        match content_type {
2233            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2234            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetBlockOrderOrdersV1RespItem&gt;`"))),
2235            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::GetBlockOrderOrdersV1RespItem&gt;`")))),
2236        }
2237    } else {
2238        let content = resp.text().await?;
2239        let entity: Option<GetBlockOrderOrdersV1Error> = serde_json::from_str(&content).ok();
2240        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2241    }
2242}
2243
2244/// Get recent block trades
2245pub async fn get_block_trades_v1(configuration: &configuration::Configuration, params: GetBlockTradesV1Params) -> Result<Vec<models::GetBlockTradesV1RespItem>, Error<GetBlockTradesV1Error>> {
2246
2247    let uri_str = format!("{}/eapi/v1/blockTrades", configuration.base_path);
2248    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2249
2250    // Create a mutable vector for query parameters
2251    let mut query_params: Vec<(String, String)> = Vec::new();
2252
2253    if let Some(ref param_value) = params.symbol {
2254        query_params.push(("symbol".to_string(), param_value.to_string()));
2255    }
2256    if let Some(ref param_value) = params.limit {
2257        query_params.push(("limit".to_string(), param_value.to_string()));
2258    }
2259
2260    // Create header parameters collection
2261    let mut header_params = std::collections::HashMap::new();
2262
2263    // Handle Binance Auth first if configured
2264    if let Some(ref binance_auth) = configuration.binance_auth {
2265        // Add API key to headers
2266        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2267        
2268        // Generate request body for signing (if any)
2269        let body_string: Option<Vec<u8>> = None;
2270        
2271        // Sign the request
2272        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2273            Ok(sig) => sig,
2274            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2275        };
2276        
2277        // Add signature to query params
2278        query_params.push(("signature".to_string(), signature));
2279    }
2280
2281    // Apply all query parameters
2282    if !query_params.is_empty() {
2283        req_builder = req_builder.query(&query_params);
2284    }
2285
2286
2287    // Add user agent if configured
2288    if let Some(ref user_agent) = configuration.user_agent {
2289        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2290    }
2291
2292    // Apply all header parameters
2293    for (header_name, header_value) in header_params {
2294        req_builder = req_builder.header(&header_name, &header_value);
2295    }
2296
2297
2298    let req = req_builder.build()?;
2299    let resp = configuration.client.execute(req).await?;
2300
2301    let status = resp.status();
2302    let content_type = resp
2303        .headers()
2304        .get("content-type")
2305        .and_then(|v| v.to_str().ok())
2306        .unwrap_or("application/octet-stream");
2307    let content_type = super::ContentType::from(content_type);
2308
2309    if !status.is_client_error() && !status.is_server_error() {
2310        let content = resp.text().await?;
2311        match content_type {
2312            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2313            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetBlockTradesV1RespItem&gt;`"))),
2314            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::GetBlockTradesV1RespItem&gt;`")))),
2315        }
2316    } else {
2317        let content = resp.text().await?;
2318        let entity: Option<GetBlockTradesV1Error> = serde_json::from_str(&content).ok();
2319        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2320    }
2321}
2322
2323/// Gets block trades for a specific account.
2324pub async fn get_block_user_trades_v1(configuration: &configuration::Configuration, params: GetBlockUserTradesV1Params) -> Result<Vec<models::GetBlockUserTradesV1RespItem>, Error<GetBlockUserTradesV1Error>> {
2325
2326    let uri_str = format!("{}/eapi/v1/block/user-trades", configuration.base_path);
2327    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2328
2329    // Create a mutable vector for query parameters
2330    let mut query_params: Vec<(String, String)> = Vec::new();
2331
2332    if let Some(ref param_value) = params.end_time {
2333        query_params.push(("endTime".to_string(), param_value.to_string()));
2334    }
2335    if let Some(ref param_value) = params.start_time {
2336        query_params.push(("startTime".to_string(), param_value.to_string()));
2337    }
2338    if let Some(ref param_value) = params.underlying {
2339        query_params.push(("underlying".to_string(), param_value.to_string()));
2340    }
2341    if let Some(ref param_value) = params.recv_window {
2342        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2343    }
2344    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2345
2346    // Create header parameters collection
2347    let mut header_params = std::collections::HashMap::new();
2348
2349    // Handle Binance Auth first if configured
2350    if let Some(ref binance_auth) = configuration.binance_auth {
2351        // Add API key to headers
2352        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2353        
2354        // Generate request body for signing (if any)
2355        let body_string: Option<Vec<u8>> = None;
2356        
2357        // Sign the request
2358        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2359            Ok(sig) => sig,
2360            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2361        };
2362        
2363        // Add signature to query params
2364        query_params.push(("signature".to_string(), signature));
2365    }
2366
2367    // Apply all query parameters
2368    if !query_params.is_empty() {
2369        req_builder = req_builder.query(&query_params);
2370    }
2371
2372
2373    // Add user agent if configured
2374    if let Some(ref user_agent) = configuration.user_agent {
2375        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2376    }
2377
2378    // Apply all header parameters
2379    for (header_name, header_value) in header_params {
2380        req_builder = req_builder.header(&header_name, &header_value);
2381    }
2382
2383
2384    let req = req_builder.build()?;
2385    let resp = configuration.client.execute(req).await?;
2386
2387    let status = resp.status();
2388    let content_type = resp
2389        .headers()
2390        .get("content-type")
2391        .and_then(|v| v.to_str().ok())
2392        .unwrap_or("application/octet-stream");
2393    let content_type = super::ContentType::from(content_type);
2394
2395    if !status.is_client_error() && !status.is_server_error() {
2396        let content = resp.text().await?;
2397        match content_type {
2398            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2399            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetBlockUserTradesV1RespItem&gt;`"))),
2400            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::GetBlockUserTradesV1RespItem&gt;`")))),
2401        }
2402    } else {
2403        let content = resp.text().await?;
2404        let entity: Option<GetBlockUserTradesV1Error> = serde_json::from_str(&content).ok();
2405        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2406    }
2407}
2408
2409/// This endpoint returns the auto-cancel parameters for each underlying symbol. Note only active auto-cancel parameters will be returned, if countdownTime is set to 0 (ie. countdownTime has been turned off), the underlying symbol and corresponding countdownTime parameter will not be returned in the response.
2410pub async fn get_countdown_cancel_all_v1(configuration: &configuration::Configuration, params: GetCountdownCancelAllV1Params) -> Result<models::GetCountdownCancelAllV1Resp, Error<GetCountdownCancelAllV1Error>> {
2411
2412    let uri_str = format!("{}/eapi/v1/countdownCancelAll", configuration.base_path);
2413    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2414
2415    // Create a mutable vector for query parameters
2416    let mut query_params: Vec<(String, String)> = Vec::new();
2417
2418    if let Some(ref param_value) = params.underlying {
2419        query_params.push(("underlying".to_string(), param_value.to_string()));
2420    }
2421    if let Some(ref param_value) = params.recv_window {
2422        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2423    }
2424    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2425
2426    // Create header parameters collection
2427    let mut header_params = std::collections::HashMap::new();
2428
2429    // Handle Binance Auth first if configured
2430    if let Some(ref binance_auth) = configuration.binance_auth {
2431        // Add API key to headers
2432        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2433        
2434        // Generate request body for signing (if any)
2435        let body_string: Option<Vec<u8>> = None;
2436        
2437        // Sign the request
2438        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2439            Ok(sig) => sig,
2440            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2441        };
2442        
2443        // Add signature to query params
2444        query_params.push(("signature".to_string(), signature));
2445    }
2446
2447    // Apply all query parameters
2448    if !query_params.is_empty() {
2449        req_builder = req_builder.query(&query_params);
2450    }
2451
2452
2453    // Add user agent if configured
2454    if let Some(ref user_agent) = configuration.user_agent {
2455        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2456    }
2457
2458    // Apply all header parameters
2459    for (header_name, header_value) in header_params {
2460        req_builder = req_builder.header(&header_name, &header_value);
2461    }
2462
2463
2464    let req = req_builder.build()?;
2465    let resp = configuration.client.execute(req).await?;
2466
2467    let status = resp.status();
2468    let content_type = resp
2469        .headers()
2470        .get("content-type")
2471        .and_then(|v| v.to_str().ok())
2472        .unwrap_or("application/octet-stream");
2473    let content_type = super::ContentType::from(content_type);
2474
2475    if !status.is_client_error() && !status.is_server_error() {
2476        let content = resp.text().await?;
2477        match content_type {
2478            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2479            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCountdownCancelAllV1Resp`"))),
2480            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetCountdownCancelAllV1Resp`")))),
2481        }
2482    } else {
2483        let content = resp.text().await?;
2484        let entity: Option<GetCountdownCancelAllV1Error> = serde_json::from_str(&content).ok();
2485        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2486    }
2487}
2488
2489/// Check orderbook depth on specific symbol
2490pub async fn get_depth_v1(configuration: &configuration::Configuration, params: GetDepthV1Params) -> Result<models::GetDepthV1Resp, Error<GetDepthV1Error>> {
2491
2492    let uri_str = format!("{}/eapi/v1/depth", configuration.base_path);
2493    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2494
2495    // Create a mutable vector for query parameters
2496    let mut query_params: Vec<(String, String)> = Vec::new();
2497
2498    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2499    if let Some(ref param_value) = params.limit {
2500        query_params.push(("limit".to_string(), param_value.to_string()));
2501    }
2502
2503    // Create header parameters collection
2504    let mut header_params = std::collections::HashMap::new();
2505
2506    // Handle Binance Auth first if configured
2507    if let Some(ref binance_auth) = configuration.binance_auth {
2508        // Add API key to headers
2509        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2510        
2511        // Generate request body for signing (if any)
2512        let body_string: Option<Vec<u8>> = None;
2513        
2514        // Sign the request
2515        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2516            Ok(sig) => sig,
2517            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2518        };
2519        
2520        // Add signature to query params
2521        query_params.push(("signature".to_string(), signature));
2522    }
2523
2524    // Apply all query parameters
2525    if !query_params.is_empty() {
2526        req_builder = req_builder.query(&query_params);
2527    }
2528
2529
2530    // Add user agent if configured
2531    if let Some(ref user_agent) = configuration.user_agent {
2532        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2533    }
2534
2535    // Apply all header parameters
2536    for (header_name, header_value) in header_params {
2537        req_builder = req_builder.header(&header_name, &header_value);
2538    }
2539
2540
2541    let req = req_builder.build()?;
2542    let resp = configuration.client.execute(req).await?;
2543
2544    let status = resp.status();
2545    let content_type = resp
2546        .headers()
2547        .get("content-type")
2548        .and_then(|v| v.to_str().ok())
2549        .unwrap_or("application/octet-stream");
2550    let content_type = super::ContentType::from(content_type);
2551
2552    if !status.is_client_error() && !status.is_server_error() {
2553        let content = resp.text().await?;
2554        match content_type {
2555            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2556            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetDepthV1Resp`"))),
2557            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetDepthV1Resp`")))),
2558        }
2559    } else {
2560        let content = resp.text().await?;
2561        let entity: Option<GetDepthV1Error> = serde_json::from_str(&content).ok();
2562        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2563    }
2564}
2565
2566/// Current exchange trading rules and symbol information
2567pub async fn get_exchange_info_v1(configuration: &configuration::Configuration) -> Result<models::OptionsGetExchangeInfoV1Resp, Error<GetExchangeInfoV1Error>> {
2568
2569    let uri_str = format!("{}/eapi/v1/exchangeInfo", configuration.base_path);
2570    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2571
2572    // Create a mutable vector for query parameters
2573    let mut query_params: Vec<(String, String)> = Vec::new();
2574
2575
2576    // Create header parameters collection
2577    let mut header_params = std::collections::HashMap::new();
2578
2579    // Handle Binance Auth first if configured
2580    if let Some(ref binance_auth) = configuration.binance_auth {
2581        // Add API key to headers
2582        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2583        
2584        // Generate request body for signing (if any)
2585        let body_string: Option<Vec<u8>> = None;
2586        
2587        // Sign the request
2588        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2589            Ok(sig) => sig,
2590            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2591        };
2592        
2593        // Add signature to query params
2594        query_params.push(("signature".to_string(), signature));
2595    }
2596
2597    // Apply all query parameters
2598    if !query_params.is_empty() {
2599        req_builder = req_builder.query(&query_params);
2600    }
2601
2602
2603    // Add user agent if configured
2604    if let Some(ref user_agent) = configuration.user_agent {
2605        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2606    }
2607
2608    // Apply all header parameters
2609    for (header_name, header_value) in header_params {
2610        req_builder = req_builder.header(&header_name, &header_value);
2611    }
2612
2613
2614    let req = req_builder.build()?;
2615    let resp = configuration.client.execute(req).await?;
2616
2617    let status = resp.status();
2618    let content_type = resp
2619        .headers()
2620        .get("content-type")
2621        .and_then(|v| v.to_str().ok())
2622        .unwrap_or("application/octet-stream");
2623    let content_type = super::ContentType::from(content_type);
2624
2625    if !status.is_client_error() && !status.is_server_error() {
2626        let content = resp.text().await?;
2627        match content_type {
2628            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2629            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsGetExchangeInfoV1Resp`"))),
2630            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::OptionsGetExchangeInfoV1Resp`")))),
2631        }
2632    } else {
2633        let content = resp.text().await?;
2634        let entity: Option<GetExchangeInfoV1Error> = serde_json::from_str(&content).ok();
2635        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2636    }
2637}
2638
2639/// Get historical exercise records.
2640pub async fn get_exercise_history_v1(configuration: &configuration::Configuration, params: GetExerciseHistoryV1Params) -> Result<Vec<models::GetExerciseHistoryV1RespItem>, Error<GetExerciseHistoryV1Error>> {
2641
2642    let uri_str = format!("{}/eapi/v1/exerciseHistory", configuration.base_path);
2643    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2644
2645    // Create a mutable vector for query parameters
2646    let mut query_params: Vec<(String, String)> = Vec::new();
2647
2648    if let Some(ref param_value) = params.underlying {
2649        query_params.push(("underlying".to_string(), param_value.to_string()));
2650    }
2651    if let Some(ref param_value) = params.start_time {
2652        query_params.push(("startTime".to_string(), param_value.to_string()));
2653    }
2654    if let Some(ref param_value) = params.end_time {
2655        query_params.push(("endTime".to_string(), param_value.to_string()));
2656    }
2657    if let Some(ref param_value) = params.limit {
2658        query_params.push(("limit".to_string(), param_value.to_string()));
2659    }
2660
2661    // Create header parameters collection
2662    let mut header_params = std::collections::HashMap::new();
2663
2664    // Handle Binance Auth first if configured
2665    if let Some(ref binance_auth) = configuration.binance_auth {
2666        // Add API key to headers
2667        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2668        
2669        // Generate request body for signing (if any)
2670        let body_string: Option<Vec<u8>> = None;
2671        
2672        // Sign the request
2673        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2674            Ok(sig) => sig,
2675            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2676        };
2677        
2678        // Add signature to query params
2679        query_params.push(("signature".to_string(), signature));
2680    }
2681
2682    // Apply all query parameters
2683    if !query_params.is_empty() {
2684        req_builder = req_builder.query(&query_params);
2685    }
2686
2687
2688    // Add user agent if configured
2689    if let Some(ref user_agent) = configuration.user_agent {
2690        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2691    }
2692
2693    // Apply all header parameters
2694    for (header_name, header_value) in header_params {
2695        req_builder = req_builder.header(&header_name, &header_value);
2696    }
2697
2698
2699    let req = req_builder.build()?;
2700    let resp = configuration.client.execute(req).await?;
2701
2702    let status = resp.status();
2703    let content_type = resp
2704        .headers()
2705        .get("content-type")
2706        .and_then(|v| v.to_str().ok())
2707        .unwrap_or("application/octet-stream");
2708    let content_type = super::ContentType::from(content_type);
2709
2710    if !status.is_client_error() && !status.is_server_error() {
2711        let content = resp.text().await?;
2712        match content_type {
2713            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2714            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetExerciseHistoryV1RespItem&gt;`"))),
2715            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::GetExerciseHistoryV1RespItem&gt;`")))),
2716        }
2717    } else {
2718        let content = resp.text().await?;
2719        let entity: Option<GetExerciseHistoryV1Error> = serde_json::from_str(&content).ok();
2720        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2721    }
2722}
2723
2724/// Get account exercise records.
2725pub async fn get_exercise_record_v1(configuration: &configuration::Configuration, params: GetExerciseRecordV1Params) -> Result<Vec<models::GetExerciseRecordV1RespItem>, Error<GetExerciseRecordV1Error>> {
2726
2727    let uri_str = format!("{}/eapi/v1/exerciseRecord", configuration.base_path);
2728    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2729
2730    // Create a mutable vector for query parameters
2731    let mut query_params: Vec<(String, String)> = Vec::new();
2732
2733    if let Some(ref param_value) = params.symbol {
2734        query_params.push(("symbol".to_string(), param_value.to_string()));
2735    }
2736    if let Some(ref param_value) = params.start_time {
2737        query_params.push(("startTime".to_string(), param_value.to_string()));
2738    }
2739    if let Some(ref param_value) = params.end_time {
2740        query_params.push(("endTime".to_string(), param_value.to_string()));
2741    }
2742    if let Some(ref param_value) = params.limit {
2743        query_params.push(("limit".to_string(), param_value.to_string()));
2744    }
2745    if let Some(ref param_value) = params.recv_window {
2746        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2747    }
2748    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2749
2750    // Create header parameters collection
2751    let mut header_params = std::collections::HashMap::new();
2752
2753    // Handle Binance Auth first if configured
2754    if let Some(ref binance_auth) = configuration.binance_auth {
2755        // Add API key to headers
2756        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2757        
2758        // Generate request body for signing (if any)
2759        let body_string: Option<Vec<u8>> = None;
2760        
2761        // Sign the request
2762        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2763            Ok(sig) => sig,
2764            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2765        };
2766        
2767        // Add signature to query params
2768        query_params.push(("signature".to_string(), signature));
2769    }
2770
2771    // Apply all query parameters
2772    if !query_params.is_empty() {
2773        req_builder = req_builder.query(&query_params);
2774    }
2775
2776
2777    // Add user agent if configured
2778    if let Some(ref user_agent) = configuration.user_agent {
2779        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2780    }
2781
2782    // Apply all header parameters
2783    for (header_name, header_value) in header_params {
2784        req_builder = req_builder.header(&header_name, &header_value);
2785    }
2786
2787
2788    let req = req_builder.build()?;
2789    let resp = configuration.client.execute(req).await?;
2790
2791    let status = resp.status();
2792    let content_type = resp
2793        .headers()
2794        .get("content-type")
2795        .and_then(|v| v.to_str().ok())
2796        .unwrap_or("application/octet-stream");
2797    let content_type = super::ContentType::from(content_type);
2798
2799    if !status.is_client_error() && !status.is_server_error() {
2800        let content = resp.text().await?;
2801        match content_type {
2802            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2803            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetExerciseRecordV1RespItem&gt;`"))),
2804            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::GetExerciseRecordV1RespItem&gt;`")))),
2805        }
2806    } else {
2807        let content = resp.text().await?;
2808        let entity: Option<GetExerciseRecordV1Error> = serde_json::from_str(&content).ok();
2809        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2810    }
2811}
2812
2813/// Get older market historical trades.
2814pub async fn get_historical_trades_v1(configuration: &configuration::Configuration, params: GetHistoricalTradesV1Params) -> Result<Vec<models::GetHistoricalTradesV1RespItem>, Error<GetHistoricalTradesV1Error>> {
2815
2816    let uri_str = format!("{}/eapi/v1/historicalTrades", configuration.base_path);
2817    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2818
2819    // Create a mutable vector for query parameters
2820    let mut query_params: Vec<(String, String)> = Vec::new();
2821
2822    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2823    if let Some(ref param_value) = params.from_id {
2824        query_params.push(("fromId".to_string(), param_value.to_string()));
2825    }
2826    if let Some(ref param_value) = params.limit {
2827        query_params.push(("limit".to_string(), param_value.to_string()));
2828    }
2829
2830    // Create header parameters collection
2831    let mut header_params = std::collections::HashMap::new();
2832
2833    // Handle Binance Auth first if configured
2834    if let Some(ref binance_auth) = configuration.binance_auth {
2835        // Add API key to headers
2836        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2837        
2838        // Generate request body for signing (if any)
2839        let body_string: Option<Vec<u8>> = None;
2840        
2841        // Sign the request
2842        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2843            Ok(sig) => sig,
2844            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2845        };
2846        
2847        // Add signature to query params
2848        query_params.push(("signature".to_string(), signature));
2849    }
2850
2851    // Apply all query parameters
2852    if !query_params.is_empty() {
2853        req_builder = req_builder.query(&query_params);
2854    }
2855
2856
2857    // Add user agent if configured
2858    if let Some(ref user_agent) = configuration.user_agent {
2859        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2860    }
2861
2862    // Apply all header parameters
2863    for (header_name, header_value) in header_params {
2864        req_builder = req_builder.header(&header_name, &header_value);
2865    }
2866
2867
2868    let req = req_builder.build()?;
2869    let resp = configuration.client.execute(req).await?;
2870
2871    let status = resp.status();
2872    let content_type = resp
2873        .headers()
2874        .get("content-type")
2875        .and_then(|v| v.to_str().ok())
2876        .unwrap_or("application/octet-stream");
2877    let content_type = super::ContentType::from(content_type);
2878
2879    if !status.is_client_error() && !status.is_server_error() {
2880        let content = resp.text().await?;
2881        match content_type {
2882            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2883            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetHistoricalTradesV1RespItem&gt;`"))),
2884            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::GetHistoricalTradesV1RespItem&gt;`")))),
2885        }
2886    } else {
2887        let content = resp.text().await?;
2888        let entity: Option<GetHistoricalTradesV1Error> = serde_json::from_str(&content).ok();
2889        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2890    }
2891}
2892
2893/// Query all finished orders within 5 days, finished status: CANCELLED FILLED REJECTED.
2894pub async fn get_history_orders_v1(configuration: &configuration::Configuration, params: GetHistoryOrdersV1Params) -> Result<Vec<models::GetHistoryOrdersV1RespItem>, Error<GetHistoryOrdersV1Error>> {
2895
2896    let uri_str = format!("{}/eapi/v1/historyOrders", configuration.base_path);
2897    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2898
2899    // Create a mutable vector for query parameters
2900    let mut query_params: Vec<(String, String)> = Vec::new();
2901
2902    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2903    if let Some(ref param_value) = params.order_id {
2904        query_params.push(("orderId".to_string(), param_value.to_string()));
2905    }
2906    if let Some(ref param_value) = params.start_time {
2907        query_params.push(("startTime".to_string(), param_value.to_string()));
2908    }
2909    if let Some(ref param_value) = params.end_time {
2910        query_params.push(("endTime".to_string(), param_value.to_string()));
2911    }
2912    if let Some(ref param_value) = params.limit {
2913        query_params.push(("limit".to_string(), param_value.to_string()));
2914    }
2915    if let Some(ref param_value) = params.recv_window {
2916        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2917    }
2918    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2919
2920    // Create header parameters collection
2921    let mut header_params = std::collections::HashMap::new();
2922
2923    // Handle Binance Auth first if configured
2924    if let Some(ref binance_auth) = configuration.binance_auth {
2925        // Add API key to headers
2926        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2927        
2928        // Generate request body for signing (if any)
2929        let body_string: Option<Vec<u8>> = None;
2930        
2931        // Sign the request
2932        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2933            Ok(sig) => sig,
2934            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2935        };
2936        
2937        // Add signature to query params
2938        query_params.push(("signature".to_string(), signature));
2939    }
2940
2941    // Apply all query parameters
2942    if !query_params.is_empty() {
2943        req_builder = req_builder.query(&query_params);
2944    }
2945
2946
2947    // Add user agent if configured
2948    if let Some(ref user_agent) = configuration.user_agent {
2949        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2950    }
2951
2952    // Apply all header parameters
2953    for (header_name, header_value) in header_params {
2954        req_builder = req_builder.header(&header_name, &header_value);
2955    }
2956
2957
2958    let req = req_builder.build()?;
2959    let resp = configuration.client.execute(req).await?;
2960
2961    let status = resp.status();
2962    let content_type = resp
2963        .headers()
2964        .get("content-type")
2965        .and_then(|v| v.to_str().ok())
2966        .unwrap_or("application/octet-stream");
2967    let content_type = super::ContentType::from(content_type);
2968
2969    if !status.is_client_error() && !status.is_server_error() {
2970        let content = resp.text().await?;
2971        match content_type {
2972            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2973            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetHistoryOrdersV1RespItem&gt;`"))),
2974            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::GetHistoryOrdersV1RespItem&gt;`")))),
2975        }
2976    } else {
2977        let content = resp.text().await?;
2978        let entity: Option<GetHistoryOrdersV1Error> = serde_json::from_str(&content).ok();
2979        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2980    }
2981}
2982
2983/// Get option transaction history download Link by Id
2984pub async fn get_income_asyn_id_v1(configuration: &configuration::Configuration, params: GetIncomeAsynIdV1Params) -> Result<models::GetIncomeAsynIdV1Resp, Error<GetIncomeAsynIdV1Error>> {
2985
2986    let uri_str = format!("{}/eapi/v1/income/asyn/id", configuration.base_path);
2987    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2988
2989    // Create a mutable vector for query parameters
2990    let mut query_params: Vec<(String, String)> = Vec::new();
2991
2992    query_params.push(("downloadId".to_string(), params.download_id.to_string()));
2993    if let Some(ref param_value) = params.recv_window {
2994        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2995    }
2996    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2997
2998    // Create header parameters collection
2999    let mut header_params = std::collections::HashMap::new();
3000
3001    // Handle Binance Auth first if configured
3002    if let Some(ref binance_auth) = configuration.binance_auth {
3003        // Add API key to headers
3004        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3005        
3006        // Generate request body for signing (if any)
3007        let body_string: Option<Vec<u8>> = None;
3008        
3009        // Sign the request
3010        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3011            Ok(sig) => sig,
3012            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3013        };
3014        
3015        // Add signature to query params
3016        query_params.push(("signature".to_string(), signature));
3017    }
3018
3019    // Apply all query parameters
3020    if !query_params.is_empty() {
3021        req_builder = req_builder.query(&query_params);
3022    }
3023
3024
3025    // Add user agent if configured
3026    if let Some(ref user_agent) = configuration.user_agent {
3027        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3028    }
3029
3030    // Apply all header parameters
3031    for (header_name, header_value) in header_params {
3032        req_builder = req_builder.header(&header_name, &header_value);
3033    }
3034
3035
3036    let req = req_builder.build()?;
3037    let resp = configuration.client.execute(req).await?;
3038
3039    let status = resp.status();
3040    let content_type = resp
3041        .headers()
3042        .get("content-type")
3043        .and_then(|v| v.to_str().ok())
3044        .unwrap_or("application/octet-stream");
3045    let content_type = super::ContentType::from(content_type);
3046
3047    if !status.is_client_error() && !status.is_server_error() {
3048        let content = resp.text().await?;
3049        match content_type {
3050            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3051            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIncomeAsynIdV1Resp`"))),
3052            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetIncomeAsynIdV1Resp`")))),
3053        }
3054    } else {
3055        let content = resp.text().await?;
3056        let entity: Option<GetIncomeAsynIdV1Error> = serde_json::from_str(&content).ok();
3057        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3058    }
3059}
3060
3061/// Get download id for option transaction history
3062pub async fn get_income_asyn_v1(configuration: &configuration::Configuration) -> Result<models::GetIncomeAsynV1Resp, Error<GetIncomeAsynV1Error>> {
3063
3064    let uri_str = format!("{}/eapi/v1/income/asyn", configuration.base_path);
3065    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3066
3067    // Create a mutable vector for query parameters
3068    let mut query_params: Vec<(String, String)> = Vec::new();
3069
3070
3071    // Create header parameters collection
3072    let mut header_params = std::collections::HashMap::new();
3073
3074    // Handle Binance Auth first if configured
3075    if let Some(ref binance_auth) = configuration.binance_auth {
3076        // Add API key to headers
3077        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3078        
3079        // Generate request body for signing (if any)
3080        let body_string: Option<Vec<u8>> = None;
3081        
3082        // Sign the request
3083        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3084            Ok(sig) => sig,
3085            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3086        };
3087        
3088        // Add signature to query params
3089        query_params.push(("signature".to_string(), signature));
3090    }
3091
3092    // Apply all query parameters
3093    if !query_params.is_empty() {
3094        req_builder = req_builder.query(&query_params);
3095    }
3096
3097
3098    // Add user agent if configured
3099    if let Some(ref user_agent) = configuration.user_agent {
3100        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3101    }
3102
3103    // Apply all header parameters
3104    for (header_name, header_value) in header_params {
3105        req_builder = req_builder.header(&header_name, &header_value);
3106    }
3107
3108
3109    let req = req_builder.build()?;
3110    let resp = configuration.client.execute(req).await?;
3111
3112    let status = resp.status();
3113    let content_type = resp
3114        .headers()
3115        .get("content-type")
3116        .and_then(|v| v.to_str().ok())
3117        .unwrap_or("application/octet-stream");
3118    let content_type = super::ContentType::from(content_type);
3119
3120    if !status.is_client_error() && !status.is_server_error() {
3121        let content = resp.text().await?;
3122        match content_type {
3123            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3124            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIncomeAsynV1Resp`"))),
3125            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetIncomeAsynV1Resp`")))),
3126        }
3127    } else {
3128        let content = resp.text().await?;
3129        let entity: Option<GetIncomeAsynV1Error> = serde_json::from_str(&content).ok();
3130        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3131    }
3132}
3133
3134/// Get spot index price for option underlying.
3135pub async fn get_index_v1(configuration: &configuration::Configuration, params: GetIndexV1Params) -> Result<models::GetIndexV1Resp, Error<GetIndexV1Error>> {
3136
3137    let uri_str = format!("{}/eapi/v1/index", configuration.base_path);
3138    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3139
3140    // Create a mutable vector for query parameters
3141    let mut query_params: Vec<(String, String)> = Vec::new();
3142
3143    query_params.push(("underlying".to_string(), params.underlying.to_string()));
3144
3145    // Create header parameters collection
3146    let mut header_params = std::collections::HashMap::new();
3147
3148    // Handle Binance Auth first if configured
3149    if let Some(ref binance_auth) = configuration.binance_auth {
3150        // Add API key to headers
3151        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3152        
3153        // Generate request body for signing (if any)
3154        let body_string: Option<Vec<u8>> = None;
3155        
3156        // Sign the request
3157        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3158            Ok(sig) => sig,
3159            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3160        };
3161        
3162        // Add signature to query params
3163        query_params.push(("signature".to_string(), signature));
3164    }
3165
3166    // Apply all query parameters
3167    if !query_params.is_empty() {
3168        req_builder = req_builder.query(&query_params);
3169    }
3170
3171
3172    // Add user agent if configured
3173    if let Some(ref user_agent) = configuration.user_agent {
3174        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3175    }
3176
3177    // Apply all header parameters
3178    for (header_name, header_value) in header_params {
3179        req_builder = req_builder.header(&header_name, &header_value);
3180    }
3181
3182
3183    let req = req_builder.build()?;
3184    let resp = configuration.client.execute(req).await?;
3185
3186    let status = resp.status();
3187    let content_type = resp
3188        .headers()
3189        .get("content-type")
3190        .and_then(|v| v.to_str().ok())
3191        .unwrap_or("application/octet-stream");
3192    let content_type = super::ContentType::from(content_type);
3193
3194    if !status.is_client_error() && !status.is_server_error() {
3195        let content = resp.text().await?;
3196        match content_type {
3197            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3198            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIndexV1Resp`"))),
3199            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::GetIndexV1Resp`")))),
3200        }
3201    } else {
3202        let content = resp.text().await?;
3203        let entity: Option<GetIndexV1Error> = serde_json::from_str(&content).ok();
3204        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3205    }
3206}
3207
3208/// Kline/candlestick bars for an option symbol. Klines are uniquely identified by their open time.
3209pub async fn get_klines_v1(configuration: &configuration::Configuration, params: GetKlinesV1Params) -> Result<Vec<models::GetKlinesV1RespItem>, Error<GetKlinesV1Error>> {
3210
3211    let uri_str = format!("{}/eapi/v1/klines", configuration.base_path);
3212    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3213
3214    // Create a mutable vector for query parameters
3215    let mut query_params: Vec<(String, String)> = Vec::new();
3216
3217    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3218    query_params.push(("interval".to_string(), params.interval.to_string()));
3219    if let Some(ref param_value) = params.start_time {
3220        query_params.push(("startTime".to_string(), param_value.to_string()));
3221    }
3222    if let Some(ref param_value) = params.end_time {
3223        query_params.push(("endTime".to_string(), param_value.to_string()));
3224    }
3225    if let Some(ref param_value) = params.limit {
3226        query_params.push(("limit".to_string(), param_value.to_string()));
3227    }
3228
3229    // Create header parameters collection
3230    let mut header_params = std::collections::HashMap::new();
3231
3232    // Handle Binance Auth first if configured
3233    if let Some(ref binance_auth) = configuration.binance_auth {
3234        // Add API key to headers
3235        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3236        
3237        // Generate request body for signing (if any)
3238        let body_string: Option<Vec<u8>> = None;
3239        
3240        // Sign the request
3241        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3242            Ok(sig) => sig,
3243            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3244        };
3245        
3246        // Add signature to query params
3247        query_params.push(("signature".to_string(), signature));
3248    }
3249
3250    // Apply all query parameters
3251    if !query_params.is_empty() {
3252        req_builder = req_builder.query(&query_params);
3253    }
3254
3255
3256    // Add user agent if configured
3257    if let Some(ref user_agent) = configuration.user_agent {
3258        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3259    }
3260
3261    // Apply all header parameters
3262    for (header_name, header_value) in header_params {
3263        req_builder = req_builder.header(&header_name, &header_value);
3264    }
3265
3266
3267    let req = req_builder.build()?;
3268    let resp = configuration.client.execute(req).await?;
3269
3270    let status = resp.status();
3271    let content_type = resp
3272        .headers()
3273        .get("content-type")
3274        .and_then(|v| v.to_str().ok())
3275        .unwrap_or("application/octet-stream");
3276    let content_type = super::ContentType::from(content_type);
3277
3278    if !status.is_client_error() && !status.is_server_error() {
3279        let content = resp.text().await?;
3280        match content_type {
3281            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3282            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetKlinesV1RespItem&gt;`"))),
3283            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::GetKlinesV1RespItem&gt;`")))),
3284        }
3285    } else {
3286        let content = resp.text().await?;
3287        let entity: Option<GetKlinesV1Error> = serde_json::from_str(&content).ok();
3288        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3289    }
3290}
3291
3292/// Get current account information.
3293pub async fn get_margin_account_v1(configuration: &configuration::Configuration, params: GetMarginAccountV1Params) -> Result<models::GetMarginAccountV1Resp, Error<GetMarginAccountV1Error>> {
3294
3295    let uri_str = format!("{}/eapi/v1/marginAccount", configuration.base_path);
3296    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3297
3298    // Create a mutable vector for query parameters
3299    let mut query_params: Vec<(String, String)> = Vec::new();
3300
3301    if let Some(ref param_value) = params.recv_window {
3302        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3303    }
3304    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3305
3306    // Create header parameters collection
3307    let mut header_params = std::collections::HashMap::new();
3308
3309    // Handle Binance Auth first if configured
3310    if let Some(ref binance_auth) = configuration.binance_auth {
3311        // Add API key to headers
3312        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3313        
3314        // Generate request body for signing (if any)
3315        let body_string: Option<Vec<u8>> = None;
3316        
3317        // Sign the request
3318        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3319            Ok(sig) => sig,
3320            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3321        };
3322        
3323        // Add signature to query params
3324        query_params.push(("signature".to_string(), signature));
3325    }
3326
3327    // Apply all query parameters
3328    if !query_params.is_empty() {
3329        req_builder = req_builder.query(&query_params);
3330    }
3331
3332
3333    // Add user agent if configured
3334    if let Some(ref user_agent) = configuration.user_agent {
3335        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3336    }
3337
3338    // Apply all header parameters
3339    for (header_name, header_value) in header_params {
3340        req_builder = req_builder.header(&header_name, &header_value);
3341    }
3342
3343
3344    let req = req_builder.build()?;
3345    let resp = configuration.client.execute(req).await?;
3346
3347    let status = resp.status();
3348    let content_type = resp
3349        .headers()
3350        .get("content-type")
3351        .and_then(|v| v.to_str().ok())
3352        .unwrap_or("application/octet-stream");
3353    let content_type = super::ContentType::from(content_type);
3354
3355    if !status.is_client_error() && !status.is_server_error() {
3356        let content = resp.text().await?;
3357        match content_type {
3358            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3359            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginAccountV1Resp`"))),
3360            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`")))),
3361        }
3362    } else {
3363        let content = resp.text().await?;
3364        let entity: Option<GetMarginAccountV1Error> = serde_json::from_str(&content).ok();
3365        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3366    }
3367}
3368
3369/// Option mark price and greek info.
3370pub async fn get_mark_v1(configuration: &configuration::Configuration, params: GetMarkV1Params) -> Result<Vec<models::GetMarkV1RespItem>, Error<GetMarkV1Error>> {
3371
3372    let uri_str = format!("{}/eapi/v1/mark", configuration.base_path);
3373    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3374
3375    // Create a mutable vector for query parameters
3376    let mut query_params: Vec<(String, String)> = Vec::new();
3377
3378    if let Some(ref param_value) = params.symbol {
3379        query_params.push(("symbol".to_string(), param_value.to_string()));
3380    }
3381
3382    // Create header parameters collection
3383    let mut header_params = std::collections::HashMap::new();
3384
3385    // Handle Binance Auth first if configured
3386    if let Some(ref binance_auth) = configuration.binance_auth {
3387        // Add API key to headers
3388        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3389        
3390        // Generate request body for signing (if any)
3391        let body_string: Option<Vec<u8>> = None;
3392        
3393        // Sign the request
3394        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3395            Ok(sig) => sig,
3396            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3397        };
3398        
3399        // Add signature to query params
3400        query_params.push(("signature".to_string(), signature));
3401    }
3402
3403    // Apply all query parameters
3404    if !query_params.is_empty() {
3405        req_builder = req_builder.query(&query_params);
3406    }
3407
3408
3409    // Add user agent if configured
3410    if let Some(ref user_agent) = configuration.user_agent {
3411        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3412    }
3413
3414    // Apply all header parameters
3415    for (header_name, header_value) in header_params {
3416        req_builder = req_builder.header(&header_name, &header_value);
3417    }
3418
3419
3420    let req = req_builder.build()?;
3421    let resp = configuration.client.execute(req).await?;
3422
3423    let status = resp.status();
3424    let content_type = resp
3425        .headers()
3426        .get("content-type")
3427        .and_then(|v| v.to_str().ok())
3428        .unwrap_or("application/octet-stream");
3429    let content_type = super::ContentType::from(content_type);
3430
3431    if !status.is_client_error() && !status.is_server_error() {
3432        let content = resp.text().await?;
3433        match content_type {
3434            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3435            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMarkV1RespItem&gt;`"))),
3436            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::GetMarkV1RespItem&gt;`")))),
3437        }
3438    } else {
3439        let content = resp.text().await?;
3440        let entity: Option<GetMarkV1Error> = serde_json::from_str(&content).ok();
3441        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3442    }
3443}
3444
3445/// Get config for MMP.
3446pub async fn get_mmp_v1(configuration: &configuration::Configuration, params: GetMmpV1Params) -> Result<models::GetMmpV1Resp, Error<GetMmpV1Error>> {
3447
3448    let uri_str = format!("{}/eapi/v1/mmp", configuration.base_path);
3449    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3450
3451    // Create a mutable vector for query parameters
3452    let mut query_params: Vec<(String, String)> = Vec::new();
3453
3454    if let Some(ref param_value) = params.underlying {
3455        query_params.push(("underlying".to_string(), param_value.to_string()));
3456    }
3457    if let Some(ref param_value) = params.recv_window {
3458        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3459    }
3460    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3461
3462    // Create header parameters collection
3463    let mut header_params = std::collections::HashMap::new();
3464
3465    // Handle Binance Auth first if configured
3466    if let Some(ref binance_auth) = configuration.binance_auth {
3467        // Add API key to headers
3468        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3469        
3470        // Generate request body for signing (if any)
3471        let body_string: Option<Vec<u8>> = None;
3472        
3473        // Sign the request
3474        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3475            Ok(sig) => sig,
3476            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3477        };
3478        
3479        // Add signature to query params
3480        query_params.push(("signature".to_string(), signature));
3481    }
3482
3483    // Apply all query parameters
3484    if !query_params.is_empty() {
3485        req_builder = req_builder.query(&query_params);
3486    }
3487
3488
3489    // Add user agent if configured
3490    if let Some(ref user_agent) = configuration.user_agent {
3491        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3492    }
3493
3494    // Apply all header parameters
3495    for (header_name, header_value) in header_params {
3496        req_builder = req_builder.header(&header_name, &header_value);
3497    }
3498
3499
3500    let req = req_builder.build()?;
3501    let resp = configuration.client.execute(req).await?;
3502
3503    let status = resp.status();
3504    let content_type = resp
3505        .headers()
3506        .get("content-type")
3507        .and_then(|v| v.to_str().ok())
3508        .unwrap_or("application/octet-stream");
3509    let content_type = super::ContentType::from(content_type);
3510
3511    if !status.is_client_error() && !status.is_server_error() {
3512        let content = resp.text().await?;
3513        match content_type {
3514            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3515            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMmpV1Resp`"))),
3516            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::GetMmpV1Resp`")))),
3517        }
3518    } else {
3519        let content = resp.text().await?;
3520        let entity: Option<GetMmpV1Error> = serde_json::from_str(&content).ok();
3521        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3522    }
3523}
3524
3525/// Get open interest for specific underlying asset on specific expiration date.
3526pub async fn get_open_interest_v1(configuration: &configuration::Configuration, params: GetOpenInterestV1Params) -> Result<Vec<models::GetOpenInterestV1RespItem>, Error<GetOpenInterestV1Error>> {
3527
3528    let uri_str = format!("{}/eapi/v1/openInterest", configuration.base_path);
3529    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3530
3531    // Create a mutable vector for query parameters
3532    let mut query_params: Vec<(String, String)> = Vec::new();
3533
3534    query_params.push(("underlyingAsset".to_string(), params.underlying_asset.to_string()));
3535    query_params.push(("expiration".to_string(), params.expiration.to_string()));
3536
3537    // Create header parameters collection
3538    let mut header_params = std::collections::HashMap::new();
3539
3540    // Handle Binance Auth first if configured
3541    if let Some(ref binance_auth) = configuration.binance_auth {
3542        // Add API key to headers
3543        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3544        
3545        // Generate request body for signing (if any)
3546        let body_string: Option<Vec<u8>> = None;
3547        
3548        // Sign the request
3549        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3550            Ok(sig) => sig,
3551            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3552        };
3553        
3554        // Add signature to query params
3555        query_params.push(("signature".to_string(), signature));
3556    }
3557
3558    // Apply all query parameters
3559    if !query_params.is_empty() {
3560        req_builder = req_builder.query(&query_params);
3561    }
3562
3563
3564    // Add user agent if configured
3565    if let Some(ref user_agent) = configuration.user_agent {
3566        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3567    }
3568
3569    // Apply all header parameters
3570    for (header_name, header_value) in header_params {
3571        req_builder = req_builder.header(&header_name, &header_value);
3572    }
3573
3574
3575    let req = req_builder.build()?;
3576    let resp = configuration.client.execute(req).await?;
3577
3578    let status = resp.status();
3579    let content_type = resp
3580        .headers()
3581        .get("content-type")
3582        .and_then(|v| v.to_str().ok())
3583        .unwrap_or("application/octet-stream");
3584    let content_type = super::ContentType::from(content_type);
3585
3586    if !status.is_client_error() && !status.is_server_error() {
3587        let content = resp.text().await?;
3588        match content_type {
3589            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3590            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetOpenInterestV1RespItem&gt;`"))),
3591            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::GetOpenInterestV1RespItem&gt;`")))),
3592        }
3593    } else {
3594        let content = resp.text().await?;
3595        let entity: Option<GetOpenInterestV1Error> = serde_json::from_str(&content).ok();
3596        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3597    }
3598}
3599
3600/// Query current all open orders, status: ACCEPTED PARTIALLY_FILLED
3601pub async fn get_open_orders_v1(configuration: &configuration::Configuration, params: GetOpenOrdersV1Params) -> Result<Vec<models::GetOpenOrdersV1RespItem>, Error<GetOpenOrdersV1Error>> {
3602
3603    let uri_str = format!("{}/eapi/v1/openOrders", configuration.base_path);
3604    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3605
3606    // Create a mutable vector for query parameters
3607    let mut query_params: Vec<(String, String)> = Vec::new();
3608
3609    if let Some(ref param_value) = params.symbol {
3610        query_params.push(("symbol".to_string(), param_value.to_string()));
3611    }
3612    if let Some(ref param_value) = params.order_id {
3613        query_params.push(("orderId".to_string(), param_value.to_string()));
3614    }
3615    if let Some(ref param_value) = params.start_time {
3616        query_params.push(("startTime".to_string(), param_value.to_string()));
3617    }
3618    if let Some(ref param_value) = params.end_time {
3619        query_params.push(("endTime".to_string(), param_value.to_string()));
3620    }
3621    if let Some(ref param_value) = params.limit {
3622        query_params.push(("limit".to_string(), param_value.to_string()));
3623    }
3624    if let Some(ref param_value) = params.recv_window {
3625        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3626    }
3627    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3628
3629    // Create header parameters collection
3630    let mut header_params = std::collections::HashMap::new();
3631
3632    // Handle Binance Auth first if configured
3633    if let Some(ref binance_auth) = configuration.binance_auth {
3634        // Add API key to headers
3635        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3636        
3637        // Generate request body for signing (if any)
3638        let body_string: Option<Vec<u8>> = None;
3639        
3640        // Sign the request
3641        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3642            Ok(sig) => sig,
3643            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3644        };
3645        
3646        // Add signature to query params
3647        query_params.push(("signature".to_string(), signature));
3648    }
3649
3650    // Apply all query parameters
3651    if !query_params.is_empty() {
3652        req_builder = req_builder.query(&query_params);
3653    }
3654
3655
3656    // Add user agent if configured
3657    if let Some(ref user_agent) = configuration.user_agent {
3658        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3659    }
3660
3661    // Apply all header parameters
3662    for (header_name, header_value) in header_params {
3663        req_builder = req_builder.header(&header_name, &header_value);
3664    }
3665
3666
3667    let req = req_builder.build()?;
3668    let resp = configuration.client.execute(req).await?;
3669
3670    let status = resp.status();
3671    let content_type = resp
3672        .headers()
3673        .get("content-type")
3674        .and_then(|v| v.to_str().ok())
3675        .unwrap_or("application/octet-stream");
3676    let content_type = super::ContentType::from(content_type);
3677
3678    if !status.is_client_error() && !status.is_server_error() {
3679        let content = resp.text().await?;
3680        match content_type {
3681            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3682            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetOpenOrdersV1RespItem&gt;`"))),
3683            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::GetOpenOrdersV1RespItem&gt;`")))),
3684        }
3685    } else {
3686        let content = resp.text().await?;
3687        let entity: Option<GetOpenOrdersV1Error> = serde_json::from_str(&content).ok();
3688        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3689    }
3690}
3691
3692/// Check an order status.
3693pub async fn get_order_v1(configuration: &configuration::Configuration, params: GetOrderV1Params) -> Result<models::GetOrderV1Resp, Error<GetOrderV1Error>> {
3694
3695    let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
3696    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3697
3698    // Create a mutable vector for query parameters
3699    let mut query_params: Vec<(String, String)> = Vec::new();
3700
3701    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3702    if let Some(ref param_value) = params.order_id {
3703        query_params.push(("orderId".to_string(), param_value.to_string()));
3704    }
3705    if let Some(ref param_value) = params.client_order_id {
3706        query_params.push(("clientOrderId".to_string(), param_value.to_string()));
3707    }
3708    if let Some(ref param_value) = params.recv_window {
3709        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3710    }
3711    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3712
3713    // Create header parameters collection
3714    let mut header_params = std::collections::HashMap::new();
3715
3716    // Handle Binance Auth first if configured
3717    if let Some(ref binance_auth) = configuration.binance_auth {
3718        // Add API key to headers
3719        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3720        
3721        // Generate request body for signing (if any)
3722        let body_string: Option<Vec<u8>> = None;
3723        
3724        // Sign the request
3725        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3726            Ok(sig) => sig,
3727            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3728        };
3729        
3730        // Add signature to query params
3731        query_params.push(("signature".to_string(), signature));
3732    }
3733
3734    // Apply all query parameters
3735    if !query_params.is_empty() {
3736        req_builder = req_builder.query(&query_params);
3737    }
3738
3739
3740    // Add user agent if configured
3741    if let Some(ref user_agent) = configuration.user_agent {
3742        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3743    }
3744
3745    // Apply all header parameters
3746    for (header_name, header_value) in header_params {
3747        req_builder = req_builder.header(&header_name, &header_value);
3748    }
3749
3750
3751    let req = req_builder.build()?;
3752    let resp = configuration.client.execute(req).await?;
3753
3754    let status = resp.status();
3755    let content_type = resp
3756        .headers()
3757        .get("content-type")
3758        .and_then(|v| v.to_str().ok())
3759        .unwrap_or("application/octet-stream");
3760    let content_type = super::ContentType::from(content_type);
3761
3762    if !status.is_client_error() && !status.is_server_error() {
3763        let content = resp.text().await?;
3764        match content_type {
3765            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3766            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrderV1Resp`"))),
3767            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetOrderV1Resp`")))),
3768        }
3769    } else {
3770        let content = resp.text().await?;
3771        let entity: Option<GetOrderV1Error> = serde_json::from_str(&content).ok();
3772        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3773    }
3774}
3775
3776/// Test connectivity to the Rest API.
3777pub async fn get_ping_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<GetPingV1Error>> {
3778
3779    let uri_str = format!("{}/eapi/v1/ping", configuration.base_path);
3780    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3781
3782    // Create a mutable vector for query parameters
3783    let mut query_params: Vec<(String, String)> = Vec::new();
3784
3785
3786    // Create header parameters collection
3787    let mut header_params = std::collections::HashMap::new();
3788
3789    // Handle Binance Auth first if configured
3790    if let Some(ref binance_auth) = configuration.binance_auth {
3791        // Add API key to headers
3792        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3793        
3794        // Generate request body for signing (if any)
3795        let body_string: Option<Vec<u8>> = None;
3796        
3797        // Sign the request
3798        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3799            Ok(sig) => sig,
3800            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3801        };
3802        
3803        // Add signature to query params
3804        query_params.push(("signature".to_string(), signature));
3805    }
3806
3807    // Apply all query parameters
3808    if !query_params.is_empty() {
3809        req_builder = req_builder.query(&query_params);
3810    }
3811
3812
3813    // Add user agent if configured
3814    if let Some(ref user_agent) = configuration.user_agent {
3815        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3816    }
3817
3818    // Apply all header parameters
3819    for (header_name, header_value) in header_params {
3820        req_builder = req_builder.header(&header_name, &header_value);
3821    }
3822
3823
3824    let req = req_builder.build()?;
3825    let resp = configuration.client.execute(req).await?;
3826
3827    let status = resp.status();
3828    let content_type = resp
3829        .headers()
3830        .get("content-type")
3831        .and_then(|v| v.to_str().ok())
3832        .unwrap_or("application/octet-stream");
3833    let content_type = super::ContentType::from(content_type);
3834
3835    if !status.is_client_error() && !status.is_server_error() {
3836        let content = resp.text().await?;
3837        match content_type {
3838            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3839            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
3840            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`")))),
3841        }
3842    } else {
3843        let content = resp.text().await?;
3844        let entity: Option<GetPingV1Error> = serde_json::from_str(&content).ok();
3845        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3846    }
3847}
3848
3849/// Get current position information.
3850pub async fn get_position_v1(configuration: &configuration::Configuration, params: GetPositionV1Params) -> Result<Vec<models::GetPositionV1RespItem>, Error<GetPositionV1Error>> {
3851
3852    let uri_str = format!("{}/eapi/v1/position", configuration.base_path);
3853    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3854
3855    // Create a mutable vector for query parameters
3856    let mut query_params: Vec<(String, String)> = Vec::new();
3857
3858    if let Some(ref param_value) = params.symbol {
3859        query_params.push(("symbol".to_string(), param_value.to_string()));
3860    }
3861    if let Some(ref param_value) = params.recv_window {
3862        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3863    }
3864    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3865
3866    // Create header parameters collection
3867    let mut header_params = std::collections::HashMap::new();
3868
3869    // Handle Binance Auth first if configured
3870    if let Some(ref binance_auth) = configuration.binance_auth {
3871        // Add API key to headers
3872        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3873        
3874        // Generate request body for signing (if any)
3875        let body_string: Option<Vec<u8>> = None;
3876        
3877        // Sign the request
3878        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3879            Ok(sig) => sig,
3880            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3881        };
3882        
3883        // Add signature to query params
3884        query_params.push(("signature".to_string(), signature));
3885    }
3886
3887    // Apply all query parameters
3888    if !query_params.is_empty() {
3889        req_builder = req_builder.query(&query_params);
3890    }
3891
3892
3893    // Add user agent if configured
3894    if let Some(ref user_agent) = configuration.user_agent {
3895        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3896    }
3897
3898    // Apply all header parameters
3899    for (header_name, header_value) in header_params {
3900        req_builder = req_builder.header(&header_name, &header_value);
3901    }
3902
3903
3904    let req = req_builder.build()?;
3905    let resp = configuration.client.execute(req).await?;
3906
3907    let status = resp.status();
3908    let content_type = resp
3909        .headers()
3910        .get("content-type")
3911        .and_then(|v| v.to_str().ok())
3912        .unwrap_or("application/octet-stream");
3913    let content_type = super::ContentType::from(content_type);
3914
3915    if !status.is_client_error() && !status.is_server_error() {
3916        let content = resp.text().await?;
3917        match content_type {
3918            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3919            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetPositionV1RespItem&gt;`"))),
3920            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::GetPositionV1RespItem&gt;`")))),
3921        }
3922    } else {
3923        let content = resp.text().await?;
3924        let entity: Option<GetPositionV1Error> = serde_json::from_str(&content).ok();
3925        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3926    }
3927}
3928
3929/// 24 hour rolling window price change statistics.
3930pub async fn get_ticker_v1(configuration: &configuration::Configuration, params: GetTickerV1Params) -> Result<Vec<models::GetTickerV1RespItem>, Error<GetTickerV1Error>> {
3931
3932    let uri_str = format!("{}/eapi/v1/ticker", configuration.base_path);
3933    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3934
3935    // Create a mutable vector for query parameters
3936    let mut query_params: Vec<(String, String)> = Vec::new();
3937
3938    if let Some(ref param_value) = params.symbol {
3939        query_params.push(("symbol".to_string(), param_value.to_string()));
3940    }
3941
3942    // Create header parameters collection
3943    let mut header_params = std::collections::HashMap::new();
3944
3945    // Handle Binance Auth first if configured
3946    if let Some(ref binance_auth) = configuration.binance_auth {
3947        // Add API key to headers
3948        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3949        
3950        // Generate request body for signing (if any)
3951        let body_string: Option<Vec<u8>> = None;
3952        
3953        // Sign the request
3954        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3955            Ok(sig) => sig,
3956            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3957        };
3958        
3959        // Add signature to query params
3960        query_params.push(("signature".to_string(), signature));
3961    }
3962
3963    // Apply all query parameters
3964    if !query_params.is_empty() {
3965        req_builder = req_builder.query(&query_params);
3966    }
3967
3968
3969    // Add user agent if configured
3970    if let Some(ref user_agent) = configuration.user_agent {
3971        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3972    }
3973
3974    // Apply all header parameters
3975    for (header_name, header_value) in header_params {
3976        req_builder = req_builder.header(&header_name, &header_value);
3977    }
3978
3979
3980    let req = req_builder.build()?;
3981    let resp = configuration.client.execute(req).await?;
3982
3983    let status = resp.status();
3984    let content_type = resp
3985        .headers()
3986        .get("content-type")
3987        .and_then(|v| v.to_str().ok())
3988        .unwrap_or("application/octet-stream");
3989    let content_type = super::ContentType::from(content_type);
3990
3991    if !status.is_client_error() && !status.is_server_error() {
3992        let content = resp.text().await?;
3993        match content_type {
3994            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3995            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetTickerV1RespItem&gt;`"))),
3996            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::GetTickerV1RespItem&gt;`")))),
3997        }
3998    } else {
3999        let content = resp.text().await?;
4000        let entity: Option<GetTickerV1Error> = serde_json::from_str(&content).ok();
4001        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4002    }
4003}
4004
4005/// Test connectivity to the Rest API and get the current server time.
4006pub async fn get_time_v1(configuration: &configuration::Configuration) -> Result<models::GetTimeV1Resp, Error<GetTimeV1Error>> {
4007
4008    let uri_str = format!("{}/eapi/v1/time", configuration.base_path);
4009    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4010
4011    // Create a mutable vector for query parameters
4012    let mut query_params: Vec<(String, String)> = Vec::new();
4013
4014
4015    // Create header parameters collection
4016    let mut header_params = std::collections::HashMap::new();
4017
4018    // Handle Binance Auth first if configured
4019    if let Some(ref binance_auth) = configuration.binance_auth {
4020        // Add API key to headers
4021        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4022        
4023        // Generate request body for signing (if any)
4024        let body_string: Option<Vec<u8>> = None;
4025        
4026        // Sign the request
4027        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4028            Ok(sig) => sig,
4029            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4030        };
4031        
4032        // Add signature to query params
4033        query_params.push(("signature".to_string(), signature));
4034    }
4035
4036    // Apply all query parameters
4037    if !query_params.is_empty() {
4038        req_builder = req_builder.query(&query_params);
4039    }
4040
4041
4042    // Add user agent if configured
4043    if let Some(ref user_agent) = configuration.user_agent {
4044        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4045    }
4046
4047    // Apply all header parameters
4048    for (header_name, header_value) in header_params {
4049        req_builder = req_builder.header(&header_name, &header_value);
4050    }
4051
4052
4053    let req = req_builder.build()?;
4054    let resp = configuration.client.execute(req).await?;
4055
4056    let status = resp.status();
4057    let content_type = resp
4058        .headers()
4059        .get("content-type")
4060        .and_then(|v| v.to_str().ok())
4061        .unwrap_or("application/octet-stream");
4062    let content_type = super::ContentType::from(content_type);
4063
4064    if !status.is_client_error() && !status.is_server_error() {
4065        let content = resp.text().await?;
4066        match content_type {
4067            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4068            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTimeV1Resp`"))),
4069            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetTimeV1Resp`")))),
4070        }
4071    } else {
4072        let content = resp.text().await?;
4073        let entity: Option<GetTimeV1Error> = serde_json::from_str(&content).ok();
4074        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4075    }
4076}
4077
4078/// Get recent market trades
4079pub async fn get_trades_v1(configuration: &configuration::Configuration, params: GetTradesV1Params) -> Result<Vec<models::GetTradesV1RespItem>, Error<GetTradesV1Error>> {
4080
4081    let uri_str = format!("{}/eapi/v1/trades", configuration.base_path);
4082    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4083
4084    // Create a mutable vector for query parameters
4085    let mut query_params: Vec<(String, String)> = Vec::new();
4086
4087    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4088    if let Some(ref param_value) = params.limit {
4089        query_params.push(("limit".to_string(), param_value.to_string()));
4090    }
4091
4092    // Create header parameters collection
4093    let mut header_params = std::collections::HashMap::new();
4094
4095    // Handle Binance Auth first if configured
4096    if let Some(ref binance_auth) = configuration.binance_auth {
4097        // Add API key to headers
4098        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4099        
4100        // Generate request body for signing (if any)
4101        let body_string: Option<Vec<u8>> = None;
4102        
4103        // Sign the request
4104        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4105            Ok(sig) => sig,
4106            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4107        };
4108        
4109        // Add signature to query params
4110        query_params.push(("signature".to_string(), signature));
4111    }
4112
4113    // Apply all query parameters
4114    if !query_params.is_empty() {
4115        req_builder = req_builder.query(&query_params);
4116    }
4117
4118
4119    // Add user agent if configured
4120    if let Some(ref user_agent) = configuration.user_agent {
4121        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4122    }
4123
4124    // Apply all header parameters
4125    for (header_name, header_value) in header_params {
4126        req_builder = req_builder.header(&header_name, &header_value);
4127    }
4128
4129
4130    let req = req_builder.build()?;
4131    let resp = configuration.client.execute(req).await?;
4132
4133    let status = resp.status();
4134    let content_type = resp
4135        .headers()
4136        .get("content-type")
4137        .and_then(|v| v.to_str().ok())
4138        .unwrap_or("application/octet-stream");
4139    let content_type = super::ContentType::from(content_type);
4140
4141    if !status.is_client_error() && !status.is_server_error() {
4142        let content = resp.text().await?;
4143        match content_type {
4144            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4145            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetTradesV1RespItem&gt;`"))),
4146            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::GetTradesV1RespItem&gt;`")))),
4147        }
4148    } else {
4149        let content = resp.text().await?;
4150        let entity: Option<GetTradesV1Error> = serde_json::from_str(&content).ok();
4151        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4152    }
4153}
4154
4155/// Get trades for a specific account and symbol.
4156pub async fn get_user_trades_v1(configuration: &configuration::Configuration, params: GetUserTradesV1Params) -> Result<Vec<models::GetUserTradesV1RespItem>, Error<GetUserTradesV1Error>> {
4157
4158    let uri_str = format!("{}/eapi/v1/userTrades", configuration.base_path);
4159    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4160
4161    // Create a mutable vector for query parameters
4162    let mut query_params: Vec<(String, String)> = Vec::new();
4163
4164    if let Some(ref param_value) = params.symbol {
4165        query_params.push(("symbol".to_string(), param_value.to_string()));
4166    }
4167    if let Some(ref param_value) = params.from_id {
4168        query_params.push(("fromId".to_string(), param_value.to_string()));
4169    }
4170    if let Some(ref param_value) = params.start_time {
4171        query_params.push(("startTime".to_string(), param_value.to_string()));
4172    }
4173    if let Some(ref param_value) = params.end_time {
4174        query_params.push(("endTime".to_string(), param_value.to_string()));
4175    }
4176    if let Some(ref param_value) = params.limit {
4177        query_params.push(("limit".to_string(), param_value.to_string()));
4178    }
4179    if let Some(ref param_value) = params.recv_window {
4180        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4181    }
4182    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4183
4184    // Create header parameters collection
4185    let mut header_params = std::collections::HashMap::new();
4186
4187    // Handle Binance Auth first if configured
4188    if let Some(ref binance_auth) = configuration.binance_auth {
4189        // Add API key to headers
4190        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4191        
4192        // Generate request body for signing (if any)
4193        let body_string: Option<Vec<u8>> = None;
4194        
4195        // Sign the request
4196        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4197            Ok(sig) => sig,
4198            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4199        };
4200        
4201        // Add signature to query params
4202        query_params.push(("signature".to_string(), signature));
4203    }
4204
4205    // Apply all query parameters
4206    if !query_params.is_empty() {
4207        req_builder = req_builder.query(&query_params);
4208    }
4209
4210
4211    // Add user agent if configured
4212    if let Some(ref user_agent) = configuration.user_agent {
4213        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4214    }
4215
4216    // Apply all header parameters
4217    for (header_name, header_value) in header_params {
4218        req_builder = req_builder.header(&header_name, &header_value);
4219    }
4220
4221
4222    let req = req_builder.build()?;
4223    let resp = configuration.client.execute(req).await?;
4224
4225    let status = resp.status();
4226    let content_type = resp
4227        .headers()
4228        .get("content-type")
4229        .and_then(|v| v.to_str().ok())
4230        .unwrap_or("application/octet-stream");
4231    let content_type = super::ContentType::from(content_type);
4232
4233    if !status.is_client_error() && !status.is_server_error() {
4234        let content = resp.text().await?;
4235        match content_type {
4236            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4237            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetUserTradesV1RespItem&gt;`"))),
4238            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::GetUserTradesV1RespItem&gt;`")))),
4239        }
4240    } else {
4241        let content = resp.text().await?;
4242        let entity: Option<GetUserTradesV1Error> = serde_json::from_str(&content).ok();
4243        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4244    }
4245}
4246
4247/// Extends a block trade expire time by 30 mins from the current time.
4248pub async fn update_block_order_create_v1(configuration: &configuration::Configuration, params: UpdateBlockOrderCreateV1Params) -> Result<models::UpdateBlockOrderCreateV1Resp, Error<UpdateBlockOrderCreateV1Error>> {
4249
4250    let uri_str = format!("{}/eapi/v1/block/order/create", configuration.base_path);
4251    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
4252
4253    // Create a mutable vector for query parameters
4254    let mut query_params: Vec<(String, String)> = Vec::new();
4255
4256
4257    // Create header parameters collection
4258    let mut header_params = std::collections::HashMap::new();
4259
4260    // Handle Binance Auth first if configured
4261    if let Some(ref binance_auth) = configuration.binance_auth {
4262        // Add API key to headers
4263        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4264        
4265        // Generate request body for signing (if any)
4266        let body_string: Option<Vec<u8>> = None;
4267        
4268        // Sign the request
4269        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4270            Ok(sig) => sig,
4271            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4272        };
4273        
4274        // Add signature to query params
4275        query_params.push(("signature".to_string(), signature));
4276    }
4277
4278    // Apply all query parameters
4279    if !query_params.is_empty() {
4280        req_builder = req_builder.query(&query_params);
4281    }
4282
4283
4284    // Add user agent if configured
4285    if let Some(ref user_agent) = configuration.user_agent {
4286        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4287    }
4288
4289    // Apply all header parameters
4290    for (header_name, header_value) in header_params {
4291        req_builder = req_builder.header(&header_name, &header_value);
4292    }
4293
4294    let mut multipart_form_params = std::collections::HashMap::new();
4295    multipart_form_params.insert("blockOrderMatchingKey", params.block_order_matching_key.to_string());
4296    if let Some(param_value) = params.recv_window {
4297        multipart_form_params.insert("recvWindow", param_value.to_string());
4298    }
4299    multipart_form_params.insert("timestamp", params.timestamp.to_string());
4300    req_builder = req_builder.form(&multipart_form_params);
4301
4302    let req = req_builder.build()?;
4303    let resp = configuration.client.execute(req).await?;
4304
4305    let status = resp.status();
4306    let content_type = resp
4307        .headers()
4308        .get("content-type")
4309        .and_then(|v| v.to_str().ok())
4310        .unwrap_or("application/octet-stream");
4311    let content_type = super::ContentType::from(content_type);
4312
4313    if !status.is_client_error() && !status.is_server_error() {
4314        let content = resp.text().await?;
4315        match content_type {
4316            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4317            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateBlockOrderCreateV1Resp`"))),
4318            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::UpdateBlockOrderCreateV1Resp`")))),
4319        }
4320    } else {
4321        let content = resp.text().await?;
4322        let entity: Option<UpdateBlockOrderCreateV1Error> = serde_json::from_str(&content).ok();
4323        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4324    }
4325}
4326
4327/// Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 60 minutes.
4328pub async fn update_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<UpdateListenKeyV1Error>> {
4329
4330    let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
4331    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
4332
4333    // Create a mutable vector for query parameters
4334    let mut query_params: Vec<(String, String)> = Vec::new();
4335
4336
4337    // Create header parameters collection
4338    let mut header_params = std::collections::HashMap::new();
4339
4340    // Handle Binance Auth first if configured
4341    if let Some(ref binance_auth) = configuration.binance_auth {
4342        // Add API key to headers
4343        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4344        
4345        // Generate request body for signing (if any)
4346        let body_string: Option<Vec<u8>> = None;
4347        
4348        // Sign the request
4349        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4350            Ok(sig) => sig,
4351            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4352        };
4353        
4354        // Add signature to query params
4355        query_params.push(("signature".to_string(), signature));
4356    }
4357
4358    // Apply all query parameters
4359    if !query_params.is_empty() {
4360        req_builder = req_builder.query(&query_params);
4361    }
4362
4363
4364    // Add user agent if configured
4365    if let Some(ref user_agent) = configuration.user_agent {
4366        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4367    }
4368
4369    // Apply all header parameters
4370    for (header_name, header_value) in header_params {
4371        req_builder = req_builder.header(&header_name, &header_value);
4372    }
4373
4374
4375    let req = req_builder.build()?;
4376    let resp = configuration.client.execute(req).await?;
4377
4378    let status = resp.status();
4379    let content_type = resp
4380        .headers()
4381        .get("content-type")
4382        .and_then(|v| v.to_str().ok())
4383        .unwrap_or("application/octet-stream");
4384    let content_type = super::ContentType::from(content_type);
4385
4386    if !status.is_client_error() && !status.is_server_error() {
4387        let content = resp.text().await?;
4388        match content_type {
4389            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4390            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
4391            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`")))),
4392        }
4393    } else {
4394        let content = resp.text().await?;
4395        let entity: Option<UpdateListenKeyV1Error> = serde_json::from_str(&content).ok();
4396        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4397    }
4398}
4399