binance/spot/apis/
spot_trading_api.rs

1/*
2 * Binance Spot API
3 *
4 * OpenAPI specification for Binance exchange - Spot API
5 *
6 * The version of the OpenAPI document: 0.2.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::spot::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`create_order_cancel_replace_v3`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateOrderCancelReplaceV3Params {
20    pub cancel_replace_mode: String,
21    pub side: String,
22    pub symbol: String,
23    pub timestamp: i64,
24    pub r#type: String,
25    pub cancel_new_client_order_id: Option<String>,
26    pub cancel_order_id: Option<i64>,
27    pub cancel_orig_client_order_id: Option<String>,
28    pub cancel_restrictions: Option<String>,
29    pub iceberg_qty: Option<String>,
30    pub new_client_order_id: Option<String>,
31    pub new_order_resp_type: Option<String>,
32    pub order_rate_limit_exceeded_mode: Option<String>,
33    pub price: Option<String>,
34    pub quantity: Option<String>,
35    pub quote_order_qty: Option<String>,
36    pub recv_window: Option<i64>,
37    pub self_trade_prevention_mode: Option<String>,
38    pub stop_price: Option<String>,
39    pub strategy_id: Option<i64>,
40    pub strategy_type: Option<i32>,
41    pub time_in_force: Option<String>,
42    pub trailing_delta: Option<i64>
43}
44
45/// struct for passing parameters to the method [`create_order_list_oco_v3`]
46#[derive(Clone, Debug, Default)]
47pub struct CreateOrderListOcoV3Params {
48    pub above_type: String,
49    pub below_type: String,
50    pub quantity: String,
51    pub side: String,
52    pub symbol: String,
53    pub timestamp: i64,
54    pub above_client_order_id: Option<String>,
55    pub above_iceberg_qty: Option<i64>,
56    pub above_price: Option<String>,
57    pub above_stop_price: Option<String>,
58    pub above_strategy_id: Option<i64>,
59    pub above_strategy_type: Option<i32>,
60    pub above_time_in_force: Option<String>,
61    pub above_trailing_delta: Option<i64>,
62    pub below_client_order_id: Option<String>,
63    pub below_iceberg_qty: Option<i64>,
64    pub below_price: Option<String>,
65    pub below_stop_price: Option<String>,
66    pub below_strategy_id: Option<i64>,
67    pub below_strategy_type: Option<i32>,
68    pub below_time_in_force: Option<String>,
69    pub below_trailing_delta: Option<i64>,
70    pub list_client_order_id: Option<String>,
71    pub new_order_resp_type: Option<String>,
72    pub recv_window: Option<i64>,
73    pub self_trade_prevention_mode: Option<String>
74}
75
76/// struct for passing parameters to the method [`create_order_list_oto_v3`]
77#[derive(Clone, Debug, Default)]
78pub struct CreateOrderListOtoV3Params {
79    pub pending_quantity: String,
80    pub pending_side: String,
81    pub pending_type: String,
82    pub symbol: String,
83    pub timestamp: i64,
84    pub working_price: String,
85    pub working_quantity: String,
86    pub working_side: String,
87    pub working_type: String,
88    pub list_client_order_id: Option<String>,
89    pub new_order_resp_type: Option<String>,
90    pub pending_client_order_id: Option<String>,
91    pub pending_iceberg_qty: Option<String>,
92    pub pending_price: Option<String>,
93    pub pending_stop_price: Option<String>,
94    pub pending_strategy_id: Option<i64>,
95    pub pending_strategy_type: Option<i32>,
96    pub pending_time_in_force: Option<String>,
97    pub pending_trailing_delta: Option<String>,
98    pub recv_window: Option<i64>,
99    pub self_trade_prevention_mode: Option<String>,
100    pub working_client_order_id: Option<String>,
101    pub working_iceberg_qty: Option<String>,
102    pub working_strategy_id: Option<i64>,
103    pub working_strategy_type: Option<i32>,
104    pub working_time_in_force: Option<String>
105}
106
107/// struct for passing parameters to the method [`create_order_list_otoco_v3`]
108#[derive(Clone, Debug, Default)]
109pub struct CreateOrderListOtocoV3Params {
110    pub pending_above_type: String,
111    pub pending_quantity: String,
112    pub pending_side: String,
113    pub symbol: String,
114    pub timestamp: i64,
115    pub working_price: String,
116    pub working_quantity: String,
117    pub working_side: String,
118    pub working_type: String,
119    pub list_client_order_id: Option<String>,
120    pub new_order_resp_type: Option<String>,
121    pub pending_above_client_order_id: Option<String>,
122    pub pending_above_iceberg_qty: Option<String>,
123    pub pending_above_price: Option<String>,
124    pub pending_above_stop_price: Option<String>,
125    pub pending_above_strategy_id: Option<i64>,
126    pub pending_above_strategy_type: Option<i32>,
127    pub pending_above_time_in_force: Option<String>,
128    pub pending_above_trailing_delta: Option<String>,
129    pub pending_below_client_order_id: Option<String>,
130    pub pending_below_iceberg_qty: Option<String>,
131    pub pending_below_price: Option<String>,
132    pub pending_below_stop_price: Option<String>,
133    pub pending_below_strategy_id: Option<i64>,
134    pub pending_below_strategy_type: Option<i32>,
135    pub pending_below_time_in_force: Option<String>,
136    pub pending_below_trailing_delta: Option<String>,
137    pub pending_below_type: Option<String>,
138    pub recv_window: Option<i64>,
139    pub self_trade_prevention_mode: Option<String>,
140    pub working_client_order_id: Option<String>,
141    pub working_iceberg_qty: Option<String>,
142    pub working_strategy_id: Option<i64>,
143    pub working_strategy_type: Option<i32>,
144    pub working_time_in_force: Option<String>
145}
146
147/// struct for passing parameters to the method [`create_order_oco_v3`]
148#[derive(Clone, Debug, Default)]
149pub struct CreateOrderOcoV3Params {
150    pub price: String,
151    pub quantity: String,
152    pub side: String,
153    pub stop_price: String,
154    pub symbol: String,
155    pub timestamp: i64,
156    pub limit_client_order_id: Option<String>,
157    pub limit_iceberg_qty: Option<String>,
158    pub limit_strategy_id: Option<i64>,
159    pub limit_strategy_type: Option<i32>,
160    pub list_client_order_id: Option<String>,
161    pub new_order_resp_type: Option<String>,
162    pub recv_window: Option<i64>,
163    pub self_trade_prevention_mode: Option<String>,
164    pub stop_client_order_id: Option<String>,
165    pub stop_iceberg_qty: Option<String>,
166    pub stop_limit_price: Option<String>,
167    pub stop_limit_time_in_force: Option<String>,
168    pub stop_strategy_id: Option<i64>,
169    pub stop_strategy_type: Option<i32>,
170    pub trailing_delta: Option<i64>
171}
172
173/// struct for passing parameters to the method [`create_order_test_v3`]
174#[derive(Clone, Debug, Default)]
175pub struct CreateOrderTestV3Params {
176    pub side: String,
177    pub symbol: String,
178    pub timestamp: i64,
179    pub r#type: String,
180    pub compute_commission_rates: Option<bool>,
181    pub iceberg_qty: Option<String>,
182    pub new_client_order_id: Option<String>,
183    pub new_order_resp_type: Option<String>,
184    pub price: Option<String>,
185    pub quantity: Option<String>,
186    pub quote_order_qty: Option<String>,
187    pub recv_window: Option<i64>,
188    pub self_trade_prevention_mode: Option<String>,
189    pub stop_price: Option<String>,
190    pub strategy_id: Option<i64>,
191    pub strategy_type: Option<i32>,
192    pub time_in_force: Option<String>,
193    pub trailing_delta: Option<i64>
194}
195
196/// struct for passing parameters to the method [`create_order_v3`]
197#[derive(Clone, Debug, Default)]
198pub struct CreateOrderV3Params {
199    pub side: String,
200    pub symbol: String,
201    pub timestamp: i64,
202    pub r#type: String,
203    pub iceberg_qty: Option<String>,
204    pub new_client_order_id: Option<String>,
205    pub new_order_resp_type: Option<String>,
206    pub price: Option<String>,
207    pub quantity: Option<String>,
208    pub quote_order_qty: Option<String>,
209    pub recv_window: Option<i64>,
210    pub self_trade_prevention_mode: Option<String>,
211    pub stop_price: Option<String>,
212    pub strategy_id: Option<i64>,
213    pub strategy_type: Option<i32>,
214    pub time_in_force: Option<String>,
215    pub trailing_delta: Option<i64>
216}
217
218/// struct for passing parameters to the method [`create_sor_order_test_v3`]
219#[derive(Clone, Debug, Default)]
220pub struct CreateSorOrderTestV3Params {
221    pub quantity: String,
222    pub side: String,
223    pub symbol: String,
224    pub timestamp: i64,
225    pub r#type: String,
226    pub compute_commission_rates: Option<bool>,
227    pub iceberg_qty: Option<String>,
228    pub new_client_order_id: Option<String>,
229    pub new_order_resp_type: Option<String>,
230    pub price: Option<String>,
231    pub recv_window: Option<i64>,
232    pub self_trade_prevention_mode: Option<String>,
233    pub strategy_id: Option<i64>,
234    pub strategy_type: Option<i32>,
235    pub time_in_force: Option<String>
236}
237
238/// struct for passing parameters to the method [`create_sor_order_v3`]
239#[derive(Clone, Debug, Default)]
240pub struct CreateSorOrderV3Params {
241    pub quantity: String,
242    pub side: String,
243    pub symbol: String,
244    pub timestamp: i64,
245    pub r#type: String,
246    pub iceberg_qty: Option<String>,
247    pub new_client_order_id: Option<String>,
248    pub new_order_resp_type: Option<String>,
249    pub price: Option<String>,
250    pub recv_window: Option<i64>,
251    pub self_trade_prevention_mode: Option<String>,
252    pub strategy_id: Option<i64>,
253    pub strategy_type: Option<i32>,
254    pub time_in_force: Option<String>
255}
256
257/// struct for passing parameters to the method [`delete_open_orders_v3`]
258#[derive(Clone, Debug, Default)]
259pub struct DeleteOpenOrdersV3Params {
260    pub symbol: String,
261    pub timestamp: i64,
262    /// The value cannot be greater than `60000`
263    pub recv_window: Option<i64>
264}
265
266/// struct for passing parameters to the method [`delete_order_list_v3`]
267#[derive(Clone, Debug, Default)]
268pub struct DeleteOrderListV3Params {
269    pub symbol: String,
270    pub timestamp: i64,
271    /// Either `orderListId` or `listClientOrderId` must be provided
272    pub order_list_id: Option<i64>,
273    /// Either `orderListId` or `listClientOrderId` must be provided
274    pub list_client_order_id: Option<String>,
275    /// Used to uniquely identify this cancel. Automatically generated by default
276    pub new_client_order_id: Option<String>,
277    /// The value cannot be greater than `60000`
278    pub recv_window: Option<i64>
279}
280
281/// struct for passing parameters to the method [`delete_order_v3`]
282#[derive(Clone, Debug, Default)]
283pub struct DeleteOrderV3Params {
284    pub symbol: String,
285    pub timestamp: i64,
286    pub order_id: Option<i64>,
287    pub orig_client_order_id: Option<String>,
288    /// Used to uniquely identify this cancel. Automatically generated by default.
289    pub new_client_order_id: Option<String>,
290    /// Supported values: <br/>`ONLY_NEW` - Cancel will succeed if the order status is `NEW`.<br/> `ONLY_PARTIALLY_FILLED ` - Cancel will succeed if order status is `PARTIALLY_FILLED`.
291    pub cancel_restrictions: Option<String>,
292    /// The value cannot be greater than `60000`.
293    pub recv_window: Option<i64>
294}
295
296/// struct for passing parameters to the method [`delete_user_data_stream_v3`]
297#[derive(Clone, Debug, Default)]
298pub struct DeleteUserDataStreamV3Params {
299    pub listen_key: String
300}
301
302/// struct for passing parameters to the method [`get_account_commission_v3`]
303#[derive(Clone, Debug, Default)]
304pub struct GetAccountCommissionV3Params {
305    pub symbol: String
306}
307
308/// struct for passing parameters to the method [`get_account_v3`]
309#[derive(Clone, Debug, Default)]
310pub struct GetAccountV3Params {
311    pub timestamp: i64,
312    /// When set to `true`, emits only the non-zero balances of an account. <br/>Default value: `false`
313    pub omit_zero_balances: Option<bool>,
314    /// The value cannot be greater than `60000`
315    pub recv_window: Option<i64>
316}
317
318/// struct for passing parameters to the method [`get_agg_trades_v3`]
319#[derive(Clone, Debug, Default)]
320pub struct GetAggTradesV3Params {
321    pub symbol: String,
322    /// ID to get aggregate trades from INCLUSIVE.
323    pub from_id: Option<i64>,
324    /// Timestamp in ms to get aggregate trades from INCLUSIVE.
325    pub start_time: Option<i64>,
326    /// Timestamp in ms to get aggregate trades until INCLUSIVE.
327    pub end_time: Option<i64>,
328    /// Default 500; max 1000.
329    pub limit: Option<i32>
330}
331
332/// struct for passing parameters to the method [`get_all_order_list_v3`]
333#[derive(Clone, Debug, Default)]
334pub struct GetAllOrderListV3Params {
335    pub timestamp: i64,
336    /// If supplied, neither `startTime` or `endTime` can be provided
337    pub from_id: Option<i64>,
338    pub start_time: Option<i64>,
339    pub end_time: Option<i64>,
340    /// Default Value: 500; Max Value: 1000
341    pub limit: Option<i32>,
342    /// The value cannot be greater than `60000`
343    pub recv_window: Option<i64>
344}
345
346/// struct for passing parameters to the method [`get_all_orders_v3`]
347#[derive(Clone, Debug, Default)]
348pub struct GetAllOrdersV3Params {
349    pub symbol: String,
350    pub timestamp: i64,
351    pub order_id: Option<i64>,
352    pub start_time: Option<i64>,
353    pub end_time: Option<i64>,
354    /// Default 500; max 1000.
355    pub limit: Option<i32>,
356    /// The value cannot be greater than `60000`
357    pub recv_window: Option<i64>
358}
359
360/// struct for passing parameters to the method [`get_avg_price_v3`]
361#[derive(Clone, Debug, Default)]
362pub struct GetAvgPriceV3Params {
363    pub symbol: String
364}
365
366/// struct for passing parameters to the method [`get_depth_v3`]
367#[derive(Clone, Debug, Default)]
368pub struct GetDepthV3Params {
369    pub symbol: String,
370    /// Default 100; max 5000. <br/> If limit &gt; 5000. then the response will truncate to 5000.
371    pub limit: Option<i32>
372}
373
374/// struct for passing parameters to the method [`get_exchange_info_v3`]
375#[derive(Clone, Debug, Default)]
376pub struct GetExchangeInfoV3Params {
377    /// Example: curl -X GET &#34;<a href=\"https://api.binance.com/api/v3/exchangeInfo?symbol=BNBBTC\" target=\"_blank\" rel=\"noopener noreferrer\">https://api.binance.com/api/v3/exchangeInfo?symbol=BNBBTC</a>&#34;
378    pub symbol: Option<String>,
379    /// Examples: curl -X GET &#34;<a href=\"https://api.binance.com/api/v3/exchangeInfo?symbols=%5B%22BNBBTC%22,%22BTCUSDT%22%5D\" target=\"_blank\" rel=\"noopener noreferrer\">https://api.binance.com/api/v3/exchangeInfo?symbols=%5B%22BNBBTC%22,%22BTCUSDT%22%5D</a>&#34; <br/> or <br/> curl -g -X  GET &#39;<a href=\"https://api.binance.com/api/v3/exchangeInfo?symbols=%5B%22BTCUSDT%22,%22BNBBTC\" target=\"_blank\" rel=\"noopener noreferrer\">https://api.binance.com/api/v3/exchangeInfo?symbols=[&#34;BTCUSDT&#34;,&#34;BNBBTC</a>&#34;]&#39;
380    pub symbols: Option<Vec<String>>,
381    /// Examples: curl -X GET &#34;<a href=\"https://api.binance.com/api/v3/exchangeInfo?permissions=SPOT\" target=\"_blank\" rel=\"noopener noreferrer\">https://api.binance.com/api/v3/exchangeInfo?permissions=SPOT</a>&#34; <br/> or <br/> curl -X GET &#34;<a href=\"https://api.binance.com/api/v3/exchangeInfo?permissions=%5B%22MARGIN%22%2C%22LEVERAGED%22%5D\" target=\"_blank\" rel=\"noopener noreferrer\">https://api.binance.com/api/v3/exchangeInfo?permissions=%5B%22MARGIN%22%2C%22LEVERAGED%22%5D</a>&#34; <br/> or <br/> curl -g -X GET &#39;<a href=\"https://api.binance.com/api/v3/exchangeInfo?permissions=%5B%22MARGIN%22,%22LEVERAGED\" target=\"_blank\" rel=\"noopener noreferrer\">https://api.binance.com/api/v3/exchangeInfo?permissions=[&#34;MARGIN&#34;,&#34;LEVERAGED</a>&#34;]&#39;
382    pub permissions: Option<String>,
383    /// Controls whether the content of the `permissionSets` field is populated or not. Defaults to `true`
384    pub show_permission_sets: Option<bool>,
385    /// Filters symbols that have this `tradingStatus`. Valid values: `TRADING`, `HALT`, `BREAK` <br/> Cannot be used in combination with `symbols` or `symbol`.
386    pub symbol_status: Option<String>
387}
388
389/// struct for passing parameters to the method [`get_historical_trades_v3`]
390#[derive(Clone, Debug, Default)]
391pub struct GetHistoricalTradesV3Params {
392    pub symbol: String,
393    /// Default 500; max 1000.
394    pub limit: Option<i32>,
395    /// TradeId to fetch from. Default gets most recent trades.
396    pub from_id: Option<i64>
397}
398
399/// struct for passing parameters to the method [`get_klines_v3`]
400#[derive(Clone, Debug, Default)]
401pub struct GetKlinesV3Params {
402    pub symbol: String,
403    pub interval: String,
404    pub start_time: Option<i64>,
405    pub end_time: Option<i64>,
406    /// Default: 0 (UTC)
407    pub time_zone: Option<String>,
408    /// Default 500; max 1000.
409    pub limit: Option<i32>
410}
411
412/// struct for passing parameters to the method [`get_my_allocations_v3`]
413#[derive(Clone, Debug, Default)]
414pub struct GetMyAllocationsV3Params {
415    pub symbol: String,
416    pub start_time: Option<i64>,
417    pub end_time: Option<i64>,
418    pub from_allocation_id: Option<i32>,
419    /// Default 500;Max 1000
420    pub limit: Option<i32>,
421    pub order_id: Option<i64>,
422    /// The value cannot be greater than `60000`.
423    pub recv_window: Option<i64>,
424    pub timestamp: Option<i64>
425}
426
427/// struct for passing parameters to the method [`get_my_prevented_matches_v3`]
428#[derive(Clone, Debug, Default)]
429pub struct GetMyPreventedMatchesV3Params {
430    pub symbol: String,
431    pub timestamp: i64,
432    pub prevented_match_id: Option<i64>,
433    pub order_id: Option<i64>,
434    pub from_prevented_match_id: Option<i64>,
435    /// Default: `500`; Max: `1000`
436    pub limit: Option<i32>,
437    /// The value cannot be greater than `60000`
438    pub recv_window: Option<i64>
439}
440
441/// struct for passing parameters to the method [`get_my_trades_v3`]
442#[derive(Clone, Debug, Default)]
443pub struct GetMyTradesV3Params {
444    pub symbol: String,
445    pub timestamp: i64,
446    /// This can only be used in combination with `symbol`.
447    pub order_id: Option<i64>,
448    pub start_time: Option<i64>,
449    pub end_time: Option<i64>,
450    /// TradeId to fetch from. Default gets most recent trades.
451    pub from_id: Option<i64>,
452    /// Default 500; max 1000.
453    pub limit: Option<i32>,
454    /// The value cannot be greater than `60000`
455    pub recv_window: Option<i64>
456}
457
458/// struct for passing parameters to the method [`get_open_order_list_v3`]
459#[derive(Clone, Debug, Default)]
460pub struct GetOpenOrderListV3Params {
461    pub timestamp: i64,
462    /// The value cannot be greater than `60000`
463    pub recv_window: Option<i64>
464}
465
466/// struct for passing parameters to the method [`get_open_orders_v3`]
467#[derive(Clone, Debug, Default)]
468pub struct GetOpenOrdersV3Params {
469    pub timestamp: i64,
470    pub symbol: Option<String>,
471    /// The value cannot be greater than `60000`
472    pub recv_window: Option<i64>
473}
474
475/// struct for passing parameters to the method [`get_order_list_v3`]
476#[derive(Clone, Debug, Default)]
477pub struct GetOrderListV3Params {
478    pub timestamp: i64,
479    /// Either `orderListId` or `listClientOrderId` must be provided
480    pub order_list_id: Option<i64>,
481    /// Either `orderListId` or `listClientOrderId` must be provided
482    pub orig_client_order_id: Option<String>,
483    /// The value cannot be greater than `60000`
484    pub recv_window: Option<i64>
485}
486
487/// struct for passing parameters to the method [`get_order_v3`]
488#[derive(Clone, Debug, Default)]
489pub struct GetOrderV3Params {
490    pub symbol: String,
491    pub timestamp: i64,
492    pub order_id: Option<i64>,
493    pub orig_client_order_id: Option<String>,
494    /// The value cannot be greater than `60000`
495    pub recv_window: Option<i64>
496}
497
498/// struct for passing parameters to the method [`get_rate_limit_order_v3`]
499#[derive(Clone, Debug, Default)]
500pub struct GetRateLimitOrderV3Params {
501    pub timestamp: i64,
502    /// The value cannot be greater than `60000`
503    pub recv_window: Option<i64>
504}
505
506/// struct for passing parameters to the method [`get_ticker24hr_v3`]
507#[derive(Clone, Debug, Default)]
508pub struct GetTicker24hrV3Params {
509    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, tickers for all symbols will be returned in an array. <br/><br/>          Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
510    pub symbol: Option<String>,
511    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, tickers for all symbols will be returned in an array. <br/><br/>          Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
512    pub symbols: Option<String>,
513    /// Supported values: `FULL` or `MINI`. <br/>If none provided, the default is `FULL`
514    pub r#type: Option<String>
515}
516
517/// struct for passing parameters to the method [`get_ticker_book_ticker_v3`]
518#[derive(Clone, Debug, Default)]
519pub struct GetTickerBookTickerV3Params {
520    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, bookTickers for all symbols will be returned in an array.          <br/><br/>         Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
521    pub symbol: Option<String>,
522    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, bookTickers for all symbols will be returned in an array.          <br/><br/>         Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
523    pub symbols: Option<String>
524}
525
526/// struct for passing parameters to the method [`get_ticker_price_v3`]
527#[derive(Clone, Debug, Default)]
528pub struct GetTickerPriceV3Params {
529    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, prices for all symbols will be returned in an array. <br/><br/>         Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
530    pub symbol: Option<String>,
531    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, prices for all symbols will be returned in an array. <br/><br/>         Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
532    pub symbols: Option<String>
533}
534
535/// struct for passing parameters to the method [`get_ticker_trading_day_v3`]
536#[derive(Clone, Debug, Default)]
537pub struct GetTickerTradingDayV3Params {
538    /// Either `symbol` or `symbols` must be provided <br/><br/> Examples of accepted format for the `symbols` parameter: <br/> [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>or <br/>%5B%22BTCUSDT%22,%22BNBUSDT%22%5D <br/><br/> The maximum number of `symbols` allowed in a request is 100.
539    pub symbol: String,
540    /// Either `symbol` or `symbols` must be provided <br/><br/> Examples of accepted format for the `symbols` parameter: <br/> [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>or <br/>%5B%22BTCUSDT%22,%22BNBUSDT%22%5D <br/><br/> The maximum number of `symbols` allowed in a request is 100.
541    pub symbols: String,
542    /// Default: 0 (UTC)
543    pub time_zone: Option<String>,
544    /// Supported values: `FULL` or `MINI`. <br/>If none provided, the default is `FULL`
545    pub r#type: Option<String>
546}
547
548/// struct for passing parameters to the method [`get_ticker_v3`]
549#[derive(Clone, Debug, Default)]
550pub struct GetTickerV3Params {
551    /// Either `symbol` or `symbols` must be provided <br/><br/> Examples of accepted format for the `symbols` parameter: <br/> [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>or <br/>%5B%22BTCUSDT%22,%22BNBUSDT%22%5D <br/><br/> The maximum number of `symbols` allowed in a request is 100.
552    pub symbol: String,
553    /// Either `symbol` or `symbols` must be provided <br/><br/> Examples of accepted format for the `symbols` parameter: <br/> [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>or <br/>%5B%22BTCUSDT%22,%22BNBUSDT%22%5D <br/><br/> The maximum number of `symbols` allowed in a request is 100.
554    pub symbols: String,
555    /// Defaults to `1d` if no parameter provided <br/> Supported `windowSize` values: <br/> `1m`,`2m`....`59m` for minutes <br/> `1h`, `2h`....`23h` - for hours <br/> `1d`...`7d` - for days <br/><br/> Units cannot be combined (e.g. `1d2h` is not allowed)
556    pub window_size: Option<String>,
557    /// Supported values: `FULL` or `MINI`. <br/>If none provided, the default is `FULL`
558    pub r#type: Option<String>
559}
560
561/// struct for passing parameters to the method [`get_trades_v3`]
562#[derive(Clone, Debug, Default)]
563pub struct GetTradesV3Params {
564    pub symbol: String,
565    /// Default 500; max 1000.
566    pub limit: Option<i32>
567}
568
569/// struct for passing parameters to the method [`get_ui_klines_v3`]
570#[derive(Clone, Debug, Default)]
571pub struct GetUiKlinesV3Params {
572    pub symbol: String,
573    /// See <a href=\"/docs/binance-spot-api-docs/rest-api/market-data-endpoints#kline-intervals\">`klines`</a>
574    pub interval: String,
575    pub start_time: Option<i64>,
576    pub end_time: Option<i64>,
577    /// Default: 0 (UTC)
578    pub time_zone: Option<String>,
579    /// Default 500; max 1000.
580    pub limit: Option<i32>
581}
582
583/// struct for passing parameters to the method [`update_user_data_stream_v3`]
584#[derive(Clone, Debug, Default)]
585pub struct UpdateUserDataStreamV3Params {
586    pub listen_key: String
587}
588
589
590/// struct for typed errors of method [`create_order_cancel_replace_v3`]
591#[derive(Debug, Clone, Serialize, Deserialize)]
592#[serde(untagged)]
593pub enum CreateOrderCancelReplaceV3Error {
594    Status4XX(models::ApiError),
595    Status5XX(models::ApiError),
596    UnknownValue(serde_json::Value),
597}
598
599/// struct for typed errors of method [`create_order_list_oco_v3`]
600#[derive(Debug, Clone, Serialize, Deserialize)]
601#[serde(untagged)]
602pub enum CreateOrderListOcoV3Error {
603    Status4XX(models::ApiError),
604    Status5XX(models::ApiError),
605    UnknownValue(serde_json::Value),
606}
607
608/// struct for typed errors of method [`create_order_list_oto_v3`]
609#[derive(Debug, Clone, Serialize, Deserialize)]
610#[serde(untagged)]
611pub enum CreateOrderListOtoV3Error {
612    Status4XX(models::ApiError),
613    Status5XX(models::ApiError),
614    UnknownValue(serde_json::Value),
615}
616
617/// struct for typed errors of method [`create_order_list_otoco_v3`]
618#[derive(Debug, Clone, Serialize, Deserialize)]
619#[serde(untagged)]
620pub enum CreateOrderListOtocoV3Error {
621    Status4XX(models::ApiError),
622    Status5XX(models::ApiError),
623    UnknownValue(serde_json::Value),
624}
625
626/// struct for typed errors of method [`create_order_oco_v3`]
627#[derive(Debug, Clone, Serialize, Deserialize)]
628#[serde(untagged)]
629pub enum CreateOrderOcoV3Error {
630    Status4XX(models::ApiError),
631    Status5XX(models::ApiError),
632    UnknownValue(serde_json::Value),
633}
634
635/// struct for typed errors of method [`create_order_test_v3`]
636#[derive(Debug, Clone, Serialize, Deserialize)]
637#[serde(untagged)]
638pub enum CreateOrderTestV3Error {
639    Status4XX(models::ApiError),
640    Status5XX(models::ApiError),
641    UnknownValue(serde_json::Value),
642}
643
644/// struct for typed errors of method [`create_order_v3`]
645#[derive(Debug, Clone, Serialize, Deserialize)]
646#[serde(untagged)]
647pub enum CreateOrderV3Error {
648    Status4XX(models::ApiError),
649    Status5XX(models::ApiError),
650    UnknownValue(serde_json::Value),
651}
652
653/// struct for typed errors of method [`create_sor_order_test_v3`]
654#[derive(Debug, Clone, Serialize, Deserialize)]
655#[serde(untagged)]
656pub enum CreateSorOrderTestV3Error {
657    Status4XX(models::ApiError),
658    Status5XX(models::ApiError),
659    UnknownValue(serde_json::Value),
660}
661
662/// struct for typed errors of method [`create_sor_order_v3`]
663#[derive(Debug, Clone, Serialize, Deserialize)]
664#[serde(untagged)]
665pub enum CreateSorOrderV3Error {
666    Status4XX(models::ApiError),
667    Status5XX(models::ApiError),
668    UnknownValue(serde_json::Value),
669}
670
671/// struct for typed errors of method [`create_user_data_stream_v3`]
672#[derive(Debug, Clone, Serialize, Deserialize)]
673#[serde(untagged)]
674pub enum CreateUserDataStreamV3Error {
675    Status4XX(models::ApiError),
676    Status5XX(models::ApiError),
677    UnknownValue(serde_json::Value),
678}
679
680/// struct for typed errors of method [`delete_open_orders_v3`]
681#[derive(Debug, Clone, Serialize, Deserialize)]
682#[serde(untagged)]
683pub enum DeleteOpenOrdersV3Error {
684    Status4XX(models::ApiError),
685    Status5XX(models::ApiError),
686    UnknownValue(serde_json::Value),
687}
688
689/// struct for typed errors of method [`delete_order_list_v3`]
690#[derive(Debug, Clone, Serialize, Deserialize)]
691#[serde(untagged)]
692pub enum DeleteOrderListV3Error {
693    Status4XX(models::ApiError),
694    Status5XX(models::ApiError),
695    UnknownValue(serde_json::Value),
696}
697
698/// struct for typed errors of method [`delete_order_v3`]
699#[derive(Debug, Clone, Serialize, Deserialize)]
700#[serde(untagged)]
701pub enum DeleteOrderV3Error {
702    Status4XX(models::ApiError),
703    Status5XX(models::ApiError),
704    UnknownValue(serde_json::Value),
705}
706
707/// struct for typed errors of method [`delete_user_data_stream_v3`]
708#[derive(Debug, Clone, Serialize, Deserialize)]
709#[serde(untagged)]
710pub enum DeleteUserDataStreamV3Error {
711    Status4XX(models::ApiError),
712    Status5XX(models::ApiError),
713    UnknownValue(serde_json::Value),
714}
715
716/// struct for typed errors of method [`get_account_commission_v3`]
717#[derive(Debug, Clone, Serialize, Deserialize)]
718#[serde(untagged)]
719pub enum GetAccountCommissionV3Error {
720    Status4XX(models::ApiError),
721    Status5XX(models::ApiError),
722    UnknownValue(serde_json::Value),
723}
724
725/// struct for typed errors of method [`get_account_v3`]
726#[derive(Debug, Clone, Serialize, Deserialize)]
727#[serde(untagged)]
728pub enum GetAccountV3Error {
729    Status4XX(models::ApiError),
730    Status5XX(models::ApiError),
731    UnknownValue(serde_json::Value),
732}
733
734/// struct for typed errors of method [`get_agg_trades_v3`]
735#[derive(Debug, Clone, Serialize, Deserialize)]
736#[serde(untagged)]
737pub enum GetAggTradesV3Error {
738    Status4XX(models::ApiError),
739    Status5XX(models::ApiError),
740    UnknownValue(serde_json::Value),
741}
742
743/// struct for typed errors of method [`get_all_order_list_v3`]
744#[derive(Debug, Clone, Serialize, Deserialize)]
745#[serde(untagged)]
746pub enum GetAllOrderListV3Error {
747    Status4XX(models::ApiError),
748    Status5XX(models::ApiError),
749    UnknownValue(serde_json::Value),
750}
751
752/// struct for typed errors of method [`get_all_orders_v3`]
753#[derive(Debug, Clone, Serialize, Deserialize)]
754#[serde(untagged)]
755pub enum GetAllOrdersV3Error {
756    Status4XX(models::ApiError),
757    Status5XX(models::ApiError),
758    UnknownValue(serde_json::Value),
759}
760
761/// struct for typed errors of method [`get_avg_price_v3`]
762#[derive(Debug, Clone, Serialize, Deserialize)]
763#[serde(untagged)]
764pub enum GetAvgPriceV3Error {
765    Status4XX(models::ApiError),
766    Status5XX(models::ApiError),
767    UnknownValue(serde_json::Value),
768}
769
770/// struct for typed errors of method [`get_depth_v3`]
771#[derive(Debug, Clone, Serialize, Deserialize)]
772#[serde(untagged)]
773pub enum GetDepthV3Error {
774    Status4XX(models::ApiError),
775    Status5XX(models::ApiError),
776    UnknownValue(serde_json::Value),
777}
778
779/// struct for typed errors of method [`get_exchange_info_v3`]
780#[derive(Debug, Clone, Serialize, Deserialize)]
781#[serde(untagged)]
782pub enum GetExchangeInfoV3Error {
783    Status4XX(models::ApiError),
784    Status5XX(models::ApiError),
785    UnknownValue(serde_json::Value),
786}
787
788/// struct for typed errors of method [`get_historical_trades_v3`]
789#[derive(Debug, Clone, Serialize, Deserialize)]
790#[serde(untagged)]
791pub enum GetHistoricalTradesV3Error {
792    Status4XX(models::ApiError),
793    Status5XX(models::ApiError),
794    UnknownValue(serde_json::Value),
795}
796
797/// struct for typed errors of method [`get_klines_v3`]
798#[derive(Debug, Clone, Serialize, Deserialize)]
799#[serde(untagged)]
800pub enum GetKlinesV3Error {
801    Status4XX(models::ApiError),
802    Status5XX(models::ApiError),
803    UnknownValue(serde_json::Value),
804}
805
806/// struct for typed errors of method [`get_my_allocations_v3`]
807#[derive(Debug, Clone, Serialize, Deserialize)]
808#[serde(untagged)]
809pub enum GetMyAllocationsV3Error {
810    Status4XX(models::ApiError),
811    Status5XX(models::ApiError),
812    UnknownValue(serde_json::Value),
813}
814
815/// struct for typed errors of method [`get_my_prevented_matches_v3`]
816#[derive(Debug, Clone, Serialize, Deserialize)]
817#[serde(untagged)]
818pub enum GetMyPreventedMatchesV3Error {
819    Status4XX(models::ApiError),
820    Status5XX(models::ApiError),
821    UnknownValue(serde_json::Value),
822}
823
824/// struct for typed errors of method [`get_my_trades_v3`]
825#[derive(Debug, Clone, Serialize, Deserialize)]
826#[serde(untagged)]
827pub enum GetMyTradesV3Error {
828    Status4XX(models::ApiError),
829    Status5XX(models::ApiError),
830    UnknownValue(serde_json::Value),
831}
832
833/// struct for typed errors of method [`get_open_order_list_v3`]
834#[derive(Debug, Clone, Serialize, Deserialize)]
835#[serde(untagged)]
836pub enum GetOpenOrderListV3Error {
837    Status4XX(models::ApiError),
838    Status5XX(models::ApiError),
839    UnknownValue(serde_json::Value),
840}
841
842/// struct for typed errors of method [`get_open_orders_v3`]
843#[derive(Debug, Clone, Serialize, Deserialize)]
844#[serde(untagged)]
845pub enum GetOpenOrdersV3Error {
846    Status4XX(models::ApiError),
847    Status5XX(models::ApiError),
848    UnknownValue(serde_json::Value),
849}
850
851/// struct for typed errors of method [`get_order_list_v3`]
852#[derive(Debug, Clone, Serialize, Deserialize)]
853#[serde(untagged)]
854pub enum GetOrderListV3Error {
855    Status4XX(models::ApiError),
856    Status5XX(models::ApiError),
857    UnknownValue(serde_json::Value),
858}
859
860/// struct for typed errors of method [`get_order_v3`]
861#[derive(Debug, Clone, Serialize, Deserialize)]
862#[serde(untagged)]
863pub enum GetOrderV3Error {
864    Status4XX(models::ApiError),
865    Status5XX(models::ApiError),
866    UnknownValue(serde_json::Value),
867}
868
869/// struct for typed errors of method [`get_ping_v3`]
870#[derive(Debug, Clone, Serialize, Deserialize)]
871#[serde(untagged)]
872pub enum GetPingV3Error {
873    Status4XX(models::ApiError),
874    Status5XX(models::ApiError),
875    UnknownValue(serde_json::Value),
876}
877
878/// struct for typed errors of method [`get_rate_limit_order_v3`]
879#[derive(Debug, Clone, Serialize, Deserialize)]
880#[serde(untagged)]
881pub enum GetRateLimitOrderV3Error {
882    Status4XX(models::ApiError),
883    Status5XX(models::ApiError),
884    UnknownValue(serde_json::Value),
885}
886
887/// struct for typed errors of method [`get_ticker24hr_v3`]
888#[derive(Debug, Clone, Serialize, Deserialize)]
889#[serde(untagged)]
890pub enum GetTicker24hrV3Error {
891    Status4XX(models::ApiError),
892    Status5XX(models::ApiError),
893    UnknownValue(serde_json::Value),
894}
895
896/// struct for typed errors of method [`get_ticker_book_ticker_v3`]
897#[derive(Debug, Clone, Serialize, Deserialize)]
898#[serde(untagged)]
899pub enum GetTickerBookTickerV3Error {
900    Status4XX(models::ApiError),
901    Status5XX(models::ApiError),
902    UnknownValue(serde_json::Value),
903}
904
905/// struct for typed errors of method [`get_ticker_price_v3`]
906#[derive(Debug, Clone, Serialize, Deserialize)]
907#[serde(untagged)]
908pub enum GetTickerPriceV3Error {
909    Status4XX(models::ApiError),
910    Status5XX(models::ApiError),
911    UnknownValue(serde_json::Value),
912}
913
914/// struct for typed errors of method [`get_ticker_trading_day_v3`]
915#[derive(Debug, Clone, Serialize, Deserialize)]
916#[serde(untagged)]
917pub enum GetTickerTradingDayV3Error {
918    Status4XX(models::ApiError),
919    Status5XX(models::ApiError),
920    UnknownValue(serde_json::Value),
921}
922
923/// struct for typed errors of method [`get_ticker_v3`]
924#[derive(Debug, Clone, Serialize, Deserialize)]
925#[serde(untagged)]
926pub enum GetTickerV3Error {
927    Status4XX(models::ApiError),
928    Status5XX(models::ApiError),
929    UnknownValue(serde_json::Value),
930}
931
932/// struct for typed errors of method [`get_time_v3`]
933#[derive(Debug, Clone, Serialize, Deserialize)]
934#[serde(untagged)]
935pub enum GetTimeV3Error {
936    Status4XX(models::ApiError),
937    Status5XX(models::ApiError),
938    UnknownValue(serde_json::Value),
939}
940
941/// struct for typed errors of method [`get_trades_v3`]
942#[derive(Debug, Clone, Serialize, Deserialize)]
943#[serde(untagged)]
944pub enum GetTradesV3Error {
945    Status4XX(models::ApiError),
946    Status5XX(models::ApiError),
947    UnknownValue(serde_json::Value),
948}
949
950/// struct for typed errors of method [`get_ui_klines_v3`]
951#[derive(Debug, Clone, Serialize, Deserialize)]
952#[serde(untagged)]
953pub enum GetUiKlinesV3Error {
954    Status4XX(models::ApiError),
955    Status5XX(models::ApiError),
956    UnknownValue(serde_json::Value),
957}
958
959/// struct for typed errors of method [`update_user_data_stream_v3`]
960#[derive(Debug, Clone, Serialize, Deserialize)]
961#[serde(untagged)]
962pub enum UpdateUserDataStreamV3Error {
963    Status4XX(models::ApiError),
964    Status5XX(models::ApiError),
965    UnknownValue(serde_json::Value),
966}
967
968
969/// Cancels an existing order and places a new order on the same symbol. Filters and Order Count are evaluated before the processing of the cancellation and order placement occurs. A new order that was not attempted (i.e. when newOrderResult: NOT_ATTEMPTED ), will still increase the order count by 1.
970pub async fn create_order_cancel_replace_v3(configuration: &configuration::Configuration, params: CreateOrderCancelReplaceV3Params) -> Result<models::SpotCreateOrderCancelReplaceV3Resp, Error<CreateOrderCancelReplaceV3Error>> {
971
972    let uri_str = format!("{}/api/v3/order/cancelReplace", configuration.base_path);
973    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
974
975    // Create a mutable vector for query parameters
976    let mut query_params: Vec<(String, String)> = Vec::new();
977
978
979    // Create header parameters collection
980    let mut header_params = std::collections::HashMap::new();
981
982    // Handle Binance Auth first if configured
983    if let Some(ref binance_auth) = configuration.binance_auth {
984        // Add API key to headers
985        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
986        
987        // Generate request body for signing (if any)
988        let body_string: Option<Vec<u8>> = None;
989        
990        // Sign the request
991        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
992            Ok(sig) => sig,
993            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
994        };
995        
996        // Add signature to query params
997        query_params.push(("signature".to_string(), signature));
998    }
999
1000    // Apply all query parameters
1001    if !query_params.is_empty() {
1002        req_builder = req_builder.query(&query_params);
1003    }
1004
1005
1006    // Add user agent if configured
1007    if let Some(ref user_agent) = configuration.user_agent {
1008        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1009    }
1010
1011    // Apply all header parameters
1012    for (header_name, header_value) in header_params {
1013        req_builder = req_builder.header(&header_name, &header_value);
1014    }
1015
1016    let mut multipart_form_params = std::collections::HashMap::new();
1017    if let Some(param_value) = params.cancel_new_client_order_id {
1018        multipart_form_params.insert("cancelNewClientOrderId", param_value.to_string());
1019    }
1020    if let Some(param_value) = params.cancel_order_id {
1021        multipart_form_params.insert("cancelOrderId", param_value.to_string());
1022    }
1023    if let Some(param_value) = params.cancel_orig_client_order_id {
1024        multipart_form_params.insert("cancelOrigClientOrderId", param_value.to_string());
1025    }
1026    multipart_form_params.insert("cancelReplaceMode", params.cancel_replace_mode.to_string());
1027    if let Some(param_value) = params.cancel_restrictions {
1028        multipart_form_params.insert("cancelRestrictions", param_value.to_string());
1029    }
1030    if let Some(param_value) = params.iceberg_qty {
1031        multipart_form_params.insert("icebergQty", param_value.to_string());
1032    }
1033    if let Some(param_value) = params.new_client_order_id {
1034        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1035    }
1036    if let Some(param_value) = params.new_order_resp_type {
1037        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1038    }
1039    if let Some(param_value) = params.order_rate_limit_exceeded_mode {
1040        multipart_form_params.insert("orderRateLimitExceededMode", param_value.to_string());
1041    }
1042    if let Some(param_value) = params.price {
1043        multipart_form_params.insert("price", param_value.to_string());
1044    }
1045    if let Some(param_value) = params.quantity {
1046        multipart_form_params.insert("quantity", param_value.to_string());
1047    }
1048    if let Some(param_value) = params.quote_order_qty {
1049        multipart_form_params.insert("quoteOrderQty", param_value.to_string());
1050    }
1051    if let Some(param_value) = params.recv_window {
1052        multipart_form_params.insert("recvWindow", param_value.to_string());
1053    }
1054    if let Some(param_value) = params.self_trade_prevention_mode {
1055        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1056    }
1057    multipart_form_params.insert("side", params.side.to_string());
1058    if let Some(param_value) = params.stop_price {
1059        multipart_form_params.insert("stopPrice", param_value.to_string());
1060    }
1061    if let Some(param_value) = params.strategy_id {
1062        multipart_form_params.insert("strategyId", param_value.to_string());
1063    }
1064    if let Some(param_value) = params.strategy_type {
1065        multipart_form_params.insert("strategyType", param_value.to_string());
1066    }
1067    multipart_form_params.insert("symbol", params.symbol.to_string());
1068    if let Some(param_value) = params.time_in_force {
1069        multipart_form_params.insert("timeInForce", param_value.to_string());
1070    }
1071    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1072    if let Some(param_value) = params.trailing_delta {
1073        multipart_form_params.insert("trailingDelta", param_value.to_string());
1074    }
1075    multipart_form_params.insert("type", params.r#type.to_string());
1076    req_builder = req_builder.form(&multipart_form_params);
1077
1078    let req = req_builder.build()?;
1079    let resp = configuration.client.execute(req).await?;
1080
1081    let status = resp.status();
1082    let content_type = resp
1083        .headers()
1084        .get("content-type")
1085        .and_then(|v| v.to_str().ok())
1086        .unwrap_or("application/octet-stream");
1087    let content_type = super::ContentType::from(content_type);
1088
1089    if !status.is_client_error() && !status.is_server_error() {
1090        let content = resp.text().await?;
1091        match content_type {
1092            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1093            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderCancelReplaceV3Resp`"))),
1094            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::SpotCreateOrderCancelReplaceV3Resp`")))),
1095        }
1096    } else {
1097        let content = resp.text().await?;
1098        let entity: Option<CreateOrderCancelReplaceV3Error> = serde_json::from_str(&content).ok();
1099        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1100    }
1101}
1102
1103/// Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other. - An OCO has 2 orders called the above order and below order. - One of the orders must be a LIMIT_MAKER/TAKE_PROFIT/TAKE_PROFIT_LIMIT order and the other must be STOP_LOSS or STOP_LOSS_LIMIT order. - Price restrictions  If the OCO is on the SELL side:  LIMIT_MAKER/TAKE_PROFIT_LIMIT price > Last Traded Price >  STOP_LOSS/STOP_LOSS_LIMIT stopPrice TAKE_PROFIT stopPrice > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice   If the OCO is on the BUY side:  LIMIT_MAKER/TAKE_PROFIT_LIMIT price < Last Traded Price < stopPrice TAKE_PROFIT stopPrice < Last Traded Price < STOP_LOSS/STOP_LOSS_LIMIT stopPrice - OCOs add 2 orders to the unfilled order count, EXCHANGE_MAX_ORDERS filter, and the MAX_NUM_ORDERS filter.
1104pub async fn create_order_list_oco_v3(configuration: &configuration::Configuration, params: CreateOrderListOcoV3Params) -> Result<models::CreateOrderListOcoV3Resp, Error<CreateOrderListOcoV3Error>> {
1105
1106    let uri_str = format!("{}/api/v3/orderList/oco", configuration.base_path);
1107    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1108
1109    // Create a mutable vector for query parameters
1110    let mut query_params: Vec<(String, String)> = Vec::new();
1111
1112
1113    // Create header parameters collection
1114    let mut header_params = std::collections::HashMap::new();
1115
1116    // Handle Binance Auth first if configured
1117    if let Some(ref binance_auth) = configuration.binance_auth {
1118        // Add API key to headers
1119        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1120        
1121        // Generate request body for signing (if any)
1122        let body_string: Option<Vec<u8>> = None;
1123        
1124        // Sign the request
1125        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1126            Ok(sig) => sig,
1127            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1128        };
1129        
1130        // Add signature to query params
1131        query_params.push(("signature".to_string(), signature));
1132    }
1133
1134    // Apply all query parameters
1135    if !query_params.is_empty() {
1136        req_builder = req_builder.query(&query_params);
1137    }
1138
1139
1140    // Add user agent if configured
1141    if let Some(ref user_agent) = configuration.user_agent {
1142        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1143    }
1144
1145    // Apply all header parameters
1146    for (header_name, header_value) in header_params {
1147        req_builder = req_builder.header(&header_name, &header_value);
1148    }
1149
1150    let mut multipart_form_params = std::collections::HashMap::new();
1151    if let Some(param_value) = params.above_client_order_id {
1152        multipart_form_params.insert("aboveClientOrderId", param_value.to_string());
1153    }
1154    if let Some(param_value) = params.above_iceberg_qty {
1155        multipart_form_params.insert("aboveIcebergQty", param_value.to_string());
1156    }
1157    if let Some(param_value) = params.above_price {
1158        multipart_form_params.insert("abovePrice", param_value.to_string());
1159    }
1160    if let Some(param_value) = params.above_stop_price {
1161        multipart_form_params.insert("aboveStopPrice", param_value.to_string());
1162    }
1163    if let Some(param_value) = params.above_strategy_id {
1164        multipart_form_params.insert("aboveStrategyId", param_value.to_string());
1165    }
1166    if let Some(param_value) = params.above_strategy_type {
1167        multipart_form_params.insert("aboveStrategyType", param_value.to_string());
1168    }
1169    if let Some(param_value) = params.above_time_in_force {
1170        multipart_form_params.insert("aboveTimeInForce", param_value.to_string());
1171    }
1172    if let Some(param_value) = params.above_trailing_delta {
1173        multipart_form_params.insert("aboveTrailingDelta", param_value.to_string());
1174    }
1175    multipart_form_params.insert("aboveType", params.above_type.to_string());
1176    if let Some(param_value) = params.below_client_order_id {
1177        multipart_form_params.insert("belowClientOrderId", param_value.to_string());
1178    }
1179    if let Some(param_value) = params.below_iceberg_qty {
1180        multipart_form_params.insert("belowIcebergQty", param_value.to_string());
1181    }
1182    if let Some(param_value) = params.below_price {
1183        multipart_form_params.insert("belowPrice", param_value.to_string());
1184    }
1185    if let Some(param_value) = params.below_stop_price {
1186        multipart_form_params.insert("belowStopPrice", param_value.to_string());
1187    }
1188    if let Some(param_value) = params.below_strategy_id {
1189        multipart_form_params.insert("belowStrategyId", param_value.to_string());
1190    }
1191    if let Some(param_value) = params.below_strategy_type {
1192        multipart_form_params.insert("belowStrategyType", param_value.to_string());
1193    }
1194    if let Some(param_value) = params.below_time_in_force {
1195        multipart_form_params.insert("belowTimeInForce", param_value.to_string());
1196    }
1197    if let Some(param_value) = params.below_trailing_delta {
1198        multipart_form_params.insert("belowTrailingDelta", param_value.to_string());
1199    }
1200    multipart_form_params.insert("belowType", params.below_type.to_string());
1201    if let Some(param_value) = params.list_client_order_id {
1202        multipart_form_params.insert("listClientOrderId", param_value.to_string());
1203    }
1204    if let Some(param_value) = params.new_order_resp_type {
1205        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1206    }
1207    multipart_form_params.insert("quantity", params.quantity.to_string());
1208    if let Some(param_value) = params.recv_window {
1209        multipart_form_params.insert("recvWindow", param_value.to_string());
1210    }
1211    if let Some(param_value) = params.self_trade_prevention_mode {
1212        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1213    }
1214    multipart_form_params.insert("side", params.side.to_string());
1215    multipart_form_params.insert("symbol", params.symbol.to_string());
1216    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1217    req_builder = req_builder.form(&multipart_form_params);
1218
1219    let req = req_builder.build()?;
1220    let resp = configuration.client.execute(req).await?;
1221
1222    let status = resp.status();
1223    let content_type = resp
1224        .headers()
1225        .get("content-type")
1226        .and_then(|v| v.to_str().ok())
1227        .unwrap_or("application/octet-stream");
1228    let content_type = super::ContentType::from(content_type);
1229
1230    if !status.is_client_error() && !status.is_server_error() {
1231        let content = resp.text().await?;
1232        match content_type {
1233            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1234            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateOrderListOcoV3Resp`"))),
1235            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::CreateOrderListOcoV3Resp`")))),
1236        }
1237    } else {
1238        let content = resp.text().await?;
1239        let entity: Option<CreateOrderListOcoV3Error> = serde_json::from_str(&content).ok();
1240        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1241    }
1242}
1243
1244/// Places an OTO. - An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders. - The first order is called the working order and must be LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book. - The second order is called the pending order. It can be any order type except for MARKET orders using parameter quoteOrderQty. The pending order is only placed on the order book when the working order gets fully filled. - If either the working order or the pending order is cancelled individually, the other order in the order list will also be canceled or expired. - When the order list is placed, if the working order gets immediately fully filled, the placement response will show the working order as FILLED but the pending order will still appear as PENDING_NEW. You need to query the status of the pending order again to see its updated status. - OTOs add 2 orders to the unfilled order count, EXCHANGE_MAX_NUM_ORDERS filter and MAX_NUM_ORDERS filter.
1245pub async fn create_order_list_oto_v3(configuration: &configuration::Configuration, params: CreateOrderListOtoV3Params) -> Result<models::CreateOrderListOtoV3Resp, Error<CreateOrderListOtoV3Error>> {
1246
1247    let uri_str = format!("{}/api/v3/orderList/oto", configuration.base_path);
1248    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1249
1250    // Create a mutable vector for query parameters
1251    let mut query_params: Vec<(String, String)> = Vec::new();
1252
1253
1254    // Create header parameters collection
1255    let mut header_params = std::collections::HashMap::new();
1256
1257    // Handle Binance Auth first if configured
1258    if let Some(ref binance_auth) = configuration.binance_auth {
1259        // Add API key to headers
1260        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1261        
1262        // Generate request body for signing (if any)
1263        let body_string: Option<Vec<u8>> = None;
1264        
1265        // Sign the request
1266        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1267            Ok(sig) => sig,
1268            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1269        };
1270        
1271        // Add signature to query params
1272        query_params.push(("signature".to_string(), signature));
1273    }
1274
1275    // Apply all query parameters
1276    if !query_params.is_empty() {
1277        req_builder = req_builder.query(&query_params);
1278    }
1279
1280
1281    // Add user agent if configured
1282    if let Some(ref user_agent) = configuration.user_agent {
1283        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1284    }
1285
1286    // Apply all header parameters
1287    for (header_name, header_value) in header_params {
1288        req_builder = req_builder.header(&header_name, &header_value);
1289    }
1290
1291    let mut multipart_form_params = std::collections::HashMap::new();
1292    if let Some(param_value) = params.list_client_order_id {
1293        multipart_form_params.insert("listClientOrderId", param_value.to_string());
1294    }
1295    if let Some(param_value) = params.new_order_resp_type {
1296        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1297    }
1298    if let Some(param_value) = params.pending_client_order_id {
1299        multipart_form_params.insert("pendingClientOrderId", param_value.to_string());
1300    }
1301    if let Some(param_value) = params.pending_iceberg_qty {
1302        multipart_form_params.insert("pendingIcebergQty", param_value.to_string());
1303    }
1304    if let Some(param_value) = params.pending_price {
1305        multipart_form_params.insert("pendingPrice", param_value.to_string());
1306    }
1307    multipart_form_params.insert("pendingQuantity", params.pending_quantity.to_string());
1308    multipart_form_params.insert("pendingSide", params.pending_side.to_string());
1309    if let Some(param_value) = params.pending_stop_price {
1310        multipart_form_params.insert("pendingStopPrice", param_value.to_string());
1311    }
1312    if let Some(param_value) = params.pending_strategy_id {
1313        multipart_form_params.insert("pendingStrategyId", param_value.to_string());
1314    }
1315    if let Some(param_value) = params.pending_strategy_type {
1316        multipart_form_params.insert("pendingStrategyType", param_value.to_string());
1317    }
1318    if let Some(param_value) = params.pending_time_in_force {
1319        multipart_form_params.insert("pendingTimeInForce", param_value.to_string());
1320    }
1321    if let Some(param_value) = params.pending_trailing_delta {
1322        multipart_form_params.insert("pendingTrailingDelta", param_value.to_string());
1323    }
1324    multipart_form_params.insert("pendingType", params.pending_type.to_string());
1325    if let Some(param_value) = params.recv_window {
1326        multipart_form_params.insert("recvWindow", param_value.to_string());
1327    }
1328    if let Some(param_value) = params.self_trade_prevention_mode {
1329        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1330    }
1331    multipart_form_params.insert("symbol", params.symbol.to_string());
1332    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1333    if let Some(param_value) = params.working_client_order_id {
1334        multipart_form_params.insert("workingClientOrderId", param_value.to_string());
1335    }
1336    if let Some(param_value) = params.working_iceberg_qty {
1337        multipart_form_params.insert("workingIcebergQty", param_value.to_string());
1338    }
1339    multipart_form_params.insert("workingPrice", params.working_price.to_string());
1340    multipart_form_params.insert("workingQuantity", params.working_quantity.to_string());
1341    multipart_form_params.insert("workingSide", params.working_side.to_string());
1342    if let Some(param_value) = params.working_strategy_id {
1343        multipart_form_params.insert("workingStrategyId", param_value.to_string());
1344    }
1345    if let Some(param_value) = params.working_strategy_type {
1346        multipart_form_params.insert("workingStrategyType", param_value.to_string());
1347    }
1348    if let Some(param_value) = params.working_time_in_force {
1349        multipart_form_params.insert("workingTimeInForce", param_value.to_string());
1350    }
1351    multipart_form_params.insert("workingType", params.working_type.to_string());
1352    req_builder = req_builder.form(&multipart_form_params);
1353
1354    let req = req_builder.build()?;
1355    let resp = configuration.client.execute(req).await?;
1356
1357    let status = resp.status();
1358    let content_type = resp
1359        .headers()
1360        .get("content-type")
1361        .and_then(|v| v.to_str().ok())
1362        .unwrap_or("application/octet-stream");
1363    let content_type = super::ContentType::from(content_type);
1364
1365    if !status.is_client_error() && !status.is_server_error() {
1366        let content = resp.text().await?;
1367        match content_type {
1368            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1369            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateOrderListOtoV3Resp`"))),
1370            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::CreateOrderListOtoV3Resp`")))),
1371        }
1372    } else {
1373        let content = resp.text().await?;
1374        let entity: Option<CreateOrderListOtoV3Error> = serde_json::from_str(&content).ok();
1375        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1376    }
1377}
1378
1379/// Place an OTOCO. - An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders. - The first order is called the working order and must be LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book.  The behavior of the working order is the same as the OTO. - OTOCO has 2 pending orders (pending above and pending below), forming an OCO pair. The pending orders are only placed on the order book when the working order gets fully filled.  The rules of the pending above and pending below follow the same rules as the Order list OCO. - OTOCOs add 3 orders against the unfilled order count, EXCHANGE_MAX_NUM_ORDERS filter, and MAX_NUM_ORDERS filter.
1380pub async fn create_order_list_otoco_v3(configuration: &configuration::Configuration, params: CreateOrderListOtocoV3Params) -> Result<models::CreateOrderListOtocoV3Resp, Error<CreateOrderListOtocoV3Error>> {
1381
1382    let uri_str = format!("{}/api/v3/orderList/otoco", configuration.base_path);
1383    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1384
1385    // Create a mutable vector for query parameters
1386    let mut query_params: Vec<(String, String)> = Vec::new();
1387
1388
1389    // Create header parameters collection
1390    let mut header_params = std::collections::HashMap::new();
1391
1392    // Handle Binance Auth first if configured
1393    if let Some(ref binance_auth) = configuration.binance_auth {
1394        // Add API key to headers
1395        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1396        
1397        // Generate request body for signing (if any)
1398        let body_string: Option<Vec<u8>> = None;
1399        
1400        // Sign the request
1401        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1402            Ok(sig) => sig,
1403            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1404        };
1405        
1406        // Add signature to query params
1407        query_params.push(("signature".to_string(), signature));
1408    }
1409
1410    // Apply all query parameters
1411    if !query_params.is_empty() {
1412        req_builder = req_builder.query(&query_params);
1413    }
1414
1415
1416    // Add user agent if configured
1417    if let Some(ref user_agent) = configuration.user_agent {
1418        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1419    }
1420
1421    // Apply all header parameters
1422    for (header_name, header_value) in header_params {
1423        req_builder = req_builder.header(&header_name, &header_value);
1424    }
1425
1426    let mut multipart_form_params = std::collections::HashMap::new();
1427    if let Some(param_value) = params.list_client_order_id {
1428        multipart_form_params.insert("listClientOrderId", param_value.to_string());
1429    }
1430    if let Some(param_value) = params.new_order_resp_type {
1431        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1432    }
1433    if let Some(param_value) = params.pending_above_client_order_id {
1434        multipart_form_params.insert("pendingAboveClientOrderId", param_value.to_string());
1435    }
1436    if let Some(param_value) = params.pending_above_iceberg_qty {
1437        multipart_form_params.insert("pendingAboveIcebergQty", param_value.to_string());
1438    }
1439    if let Some(param_value) = params.pending_above_price {
1440        multipart_form_params.insert("pendingAbovePrice", param_value.to_string());
1441    }
1442    if let Some(param_value) = params.pending_above_stop_price {
1443        multipart_form_params.insert("pendingAboveStopPrice", param_value.to_string());
1444    }
1445    if let Some(param_value) = params.pending_above_strategy_id {
1446        multipart_form_params.insert("pendingAboveStrategyId", param_value.to_string());
1447    }
1448    if let Some(param_value) = params.pending_above_strategy_type {
1449        multipart_form_params.insert("pendingAboveStrategyType", param_value.to_string());
1450    }
1451    if let Some(param_value) = params.pending_above_time_in_force {
1452        multipart_form_params.insert("pendingAboveTimeInForce", param_value.to_string());
1453    }
1454    if let Some(param_value) = params.pending_above_trailing_delta {
1455        multipart_form_params.insert("pendingAboveTrailingDelta", param_value.to_string());
1456    }
1457    multipart_form_params.insert("pendingAboveType", params.pending_above_type.to_string());
1458    if let Some(param_value) = params.pending_below_client_order_id {
1459        multipart_form_params.insert("pendingBelowClientOrderId", param_value.to_string());
1460    }
1461    if let Some(param_value) = params.pending_below_iceberg_qty {
1462        multipart_form_params.insert("pendingBelowIcebergQty", param_value.to_string());
1463    }
1464    if let Some(param_value) = params.pending_below_price {
1465        multipart_form_params.insert("pendingBelowPrice", param_value.to_string());
1466    }
1467    if let Some(param_value) = params.pending_below_stop_price {
1468        multipart_form_params.insert("pendingBelowStopPrice", param_value.to_string());
1469    }
1470    if let Some(param_value) = params.pending_below_strategy_id {
1471        multipart_form_params.insert("pendingBelowStrategyId", param_value.to_string());
1472    }
1473    if let Some(param_value) = params.pending_below_strategy_type {
1474        multipart_form_params.insert("pendingBelowStrategyType", param_value.to_string());
1475    }
1476    if let Some(param_value) = params.pending_below_time_in_force {
1477        multipart_form_params.insert("pendingBelowTimeInForce", param_value.to_string());
1478    }
1479    if let Some(param_value) = params.pending_below_trailing_delta {
1480        multipart_form_params.insert("pendingBelowTrailingDelta", param_value.to_string());
1481    }
1482    if let Some(param_value) = params.pending_below_type {
1483        multipart_form_params.insert("pendingBelowType", param_value.to_string());
1484    }
1485    multipart_form_params.insert("pendingQuantity", params.pending_quantity.to_string());
1486    multipart_form_params.insert("pendingSide", params.pending_side.to_string());
1487    if let Some(param_value) = params.recv_window {
1488        multipart_form_params.insert("recvWindow", param_value.to_string());
1489    }
1490    if let Some(param_value) = params.self_trade_prevention_mode {
1491        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1492    }
1493    multipart_form_params.insert("symbol", params.symbol.to_string());
1494    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1495    if let Some(param_value) = params.working_client_order_id {
1496        multipart_form_params.insert("workingClientOrderId", param_value.to_string());
1497    }
1498    if let Some(param_value) = params.working_iceberg_qty {
1499        multipart_form_params.insert("workingIcebergQty", param_value.to_string());
1500    }
1501    multipart_form_params.insert("workingPrice", params.working_price.to_string());
1502    multipart_form_params.insert("workingQuantity", params.working_quantity.to_string());
1503    multipart_form_params.insert("workingSide", params.working_side.to_string());
1504    if let Some(param_value) = params.working_strategy_id {
1505        multipart_form_params.insert("workingStrategyId", param_value.to_string());
1506    }
1507    if let Some(param_value) = params.working_strategy_type {
1508        multipart_form_params.insert("workingStrategyType", param_value.to_string());
1509    }
1510    if let Some(param_value) = params.working_time_in_force {
1511        multipart_form_params.insert("workingTimeInForce", param_value.to_string());
1512    }
1513    multipart_form_params.insert("workingType", params.working_type.to_string());
1514    req_builder = req_builder.form(&multipart_form_params);
1515
1516    let req = req_builder.build()?;
1517    let resp = configuration.client.execute(req).await?;
1518
1519    let status = resp.status();
1520    let content_type = resp
1521        .headers()
1522        .get("content-type")
1523        .and_then(|v| v.to_str().ok())
1524        .unwrap_or("application/octet-stream");
1525    let content_type = super::ContentType::from(content_type);
1526
1527    if !status.is_client_error() && !status.is_server_error() {
1528        let content = resp.text().await?;
1529        match content_type {
1530            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1531            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateOrderListOtocoV3Resp`"))),
1532            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::CreateOrderListOtocoV3Resp`")))),
1533        }
1534    } else {
1535        let content = resp.text().await?;
1536        let entity: Option<CreateOrderListOtocoV3Error> = serde_json::from_str(&content).ok();
1537        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1538    }
1539}
1540
1541/// Send in a new OCO. - Price Restrictions:  SELL: Limit Price > Last Price > Stop Price BUY: Limit Price < Last Price < Stop Price - Quantity Restrictions:  Both legs must have the same quantity. ICEBERG quantities however do not have to be the same - OCO adds 2 orders to the unfilled order count, EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
1542pub async fn create_order_oco_v3(configuration: &configuration::Configuration, params: CreateOrderOcoV3Params) -> Result<models::CreateOrderOcoV3Resp, Error<CreateOrderOcoV3Error>> {
1543
1544    let uri_str = format!("{}/api/v3/order/oco", configuration.base_path);
1545    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1546
1547    // Create a mutable vector for query parameters
1548    let mut query_params: Vec<(String, String)> = Vec::new();
1549
1550
1551    // Create header parameters collection
1552    let mut header_params = std::collections::HashMap::new();
1553
1554    // Handle Binance Auth first if configured
1555    if let Some(ref binance_auth) = configuration.binance_auth {
1556        // Add API key to headers
1557        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1558        
1559        // Generate request body for signing (if any)
1560        let body_string: Option<Vec<u8>> = None;
1561        
1562        // Sign the request
1563        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1564            Ok(sig) => sig,
1565            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1566        };
1567        
1568        // Add signature to query params
1569        query_params.push(("signature".to_string(), signature));
1570    }
1571
1572    // Apply all query parameters
1573    if !query_params.is_empty() {
1574        req_builder = req_builder.query(&query_params);
1575    }
1576
1577
1578    // Add user agent if configured
1579    if let Some(ref user_agent) = configuration.user_agent {
1580        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1581    }
1582
1583    // Apply all header parameters
1584    for (header_name, header_value) in header_params {
1585        req_builder = req_builder.header(&header_name, &header_value);
1586    }
1587
1588    let mut multipart_form_params = std::collections::HashMap::new();
1589    if let Some(param_value) = params.limit_client_order_id {
1590        multipart_form_params.insert("limitClientOrderId", param_value.to_string());
1591    }
1592    if let Some(param_value) = params.limit_iceberg_qty {
1593        multipart_form_params.insert("limitIcebergQty", param_value.to_string());
1594    }
1595    if let Some(param_value) = params.limit_strategy_id {
1596        multipart_form_params.insert("limitStrategyId", param_value.to_string());
1597    }
1598    if let Some(param_value) = params.limit_strategy_type {
1599        multipart_form_params.insert("limitStrategyType", param_value.to_string());
1600    }
1601    if let Some(param_value) = params.list_client_order_id {
1602        multipart_form_params.insert("listClientOrderId", param_value.to_string());
1603    }
1604    if let Some(param_value) = params.new_order_resp_type {
1605        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1606    }
1607    multipart_form_params.insert("price", params.price.to_string());
1608    multipart_form_params.insert("quantity", params.quantity.to_string());
1609    if let Some(param_value) = params.recv_window {
1610        multipart_form_params.insert("recvWindow", param_value.to_string());
1611    }
1612    if let Some(param_value) = params.self_trade_prevention_mode {
1613        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1614    }
1615    multipart_form_params.insert("side", params.side.to_string());
1616    if let Some(param_value) = params.stop_client_order_id {
1617        multipart_form_params.insert("stopClientOrderId", param_value.to_string());
1618    }
1619    if let Some(param_value) = params.stop_iceberg_qty {
1620        multipart_form_params.insert("stopIcebergQty", param_value.to_string());
1621    }
1622    if let Some(param_value) = params.stop_limit_price {
1623        multipart_form_params.insert("stopLimitPrice", param_value.to_string());
1624    }
1625    if let Some(param_value) = params.stop_limit_time_in_force {
1626        multipart_form_params.insert("stopLimitTimeInForce", param_value.to_string());
1627    }
1628    multipart_form_params.insert("stopPrice", params.stop_price.to_string());
1629    if let Some(param_value) = params.stop_strategy_id {
1630        multipart_form_params.insert("stopStrategyId", param_value.to_string());
1631    }
1632    if let Some(param_value) = params.stop_strategy_type {
1633        multipart_form_params.insert("stopStrategyType", param_value.to_string());
1634    }
1635    multipart_form_params.insert("symbol", params.symbol.to_string());
1636    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1637    if let Some(param_value) = params.trailing_delta {
1638        multipart_form_params.insert("trailingDelta", param_value.to_string());
1639    }
1640    req_builder = req_builder.form(&multipart_form_params);
1641
1642    let req = req_builder.build()?;
1643    let resp = configuration.client.execute(req).await?;
1644
1645    let status = resp.status();
1646    let content_type = resp
1647        .headers()
1648        .get("content-type")
1649        .and_then(|v| v.to_str().ok())
1650        .unwrap_or("application/octet-stream");
1651    let content_type = super::ContentType::from(content_type);
1652
1653    if !status.is_client_error() && !status.is_server_error() {
1654        let content = resp.text().await?;
1655        match content_type {
1656            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1657            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateOrderOcoV3Resp`"))),
1658            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::CreateOrderOcoV3Resp`")))),
1659        }
1660    } else {
1661        let content = resp.text().await?;
1662        let entity: Option<CreateOrderOcoV3Error> = serde_json::from_str(&content).ok();
1663        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1664    }
1665}
1666
1667/// Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.
1668pub async fn create_order_test_v3(configuration: &configuration::Configuration, params: CreateOrderTestV3Params) -> Result<models::SpotCreateOrderTestV3Resp, Error<CreateOrderTestV3Error>> {
1669
1670    let uri_str = format!("{}/api/v3/order/test", configuration.base_path);
1671    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1672
1673    // Create a mutable vector for query parameters
1674    let mut query_params: Vec<(String, String)> = Vec::new();
1675
1676
1677    // Create header parameters collection
1678    let mut header_params = std::collections::HashMap::new();
1679
1680    // Handle Binance Auth first if configured
1681    if let Some(ref binance_auth) = configuration.binance_auth {
1682        // Add API key to headers
1683        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1684        
1685        // Generate request body for signing (if any)
1686        let body_string: Option<Vec<u8>> = None;
1687        
1688        // Sign the request
1689        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1690            Ok(sig) => sig,
1691            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1692        };
1693        
1694        // Add signature to query params
1695        query_params.push(("signature".to_string(), signature));
1696    }
1697
1698    // Apply all query parameters
1699    if !query_params.is_empty() {
1700        req_builder = req_builder.query(&query_params);
1701    }
1702
1703
1704    // Add user agent if configured
1705    if let Some(ref user_agent) = configuration.user_agent {
1706        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1707    }
1708
1709    // Apply all header parameters
1710    for (header_name, header_value) in header_params {
1711        req_builder = req_builder.header(&header_name, &header_value);
1712    }
1713
1714    let mut multipart_form_params = std::collections::HashMap::new();
1715    if let Some(param_value) = params.compute_commission_rates {
1716        multipart_form_params.insert("computeCommissionRates", param_value.to_string());
1717    }
1718    if let Some(param_value) = params.iceberg_qty {
1719        multipart_form_params.insert("icebergQty", param_value.to_string());
1720    }
1721    if let Some(param_value) = params.new_client_order_id {
1722        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1723    }
1724    if let Some(param_value) = params.new_order_resp_type {
1725        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1726    }
1727    if let Some(param_value) = params.price {
1728        multipart_form_params.insert("price", param_value.to_string());
1729    }
1730    if let Some(param_value) = params.quantity {
1731        multipart_form_params.insert("quantity", param_value.to_string());
1732    }
1733    if let Some(param_value) = params.quote_order_qty {
1734        multipart_form_params.insert("quoteOrderQty", param_value.to_string());
1735    }
1736    if let Some(param_value) = params.recv_window {
1737        multipart_form_params.insert("recvWindow", param_value.to_string());
1738    }
1739    if let Some(param_value) = params.self_trade_prevention_mode {
1740        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1741    }
1742    multipart_form_params.insert("side", params.side.to_string());
1743    if let Some(param_value) = params.stop_price {
1744        multipart_form_params.insert("stopPrice", param_value.to_string());
1745    }
1746    if let Some(param_value) = params.strategy_id {
1747        multipart_form_params.insert("strategyId", param_value.to_string());
1748    }
1749    if let Some(param_value) = params.strategy_type {
1750        multipart_form_params.insert("strategyType", param_value.to_string());
1751    }
1752    multipart_form_params.insert("symbol", params.symbol.to_string());
1753    if let Some(param_value) = params.time_in_force {
1754        multipart_form_params.insert("timeInForce", param_value.to_string());
1755    }
1756    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1757    if let Some(param_value) = params.trailing_delta {
1758        multipart_form_params.insert("trailingDelta", param_value.to_string());
1759    }
1760    multipart_form_params.insert("type", params.r#type.to_string());
1761    req_builder = req_builder.form(&multipart_form_params);
1762
1763    let req = req_builder.build()?;
1764    let resp = configuration.client.execute(req).await?;
1765
1766    let status = resp.status();
1767    let content_type = resp
1768        .headers()
1769        .get("content-type")
1770        .and_then(|v| v.to_str().ok())
1771        .unwrap_or("application/octet-stream");
1772    let content_type = super::ContentType::from(content_type);
1773
1774    if !status.is_client_error() && !status.is_server_error() {
1775        let content = resp.text().await?;
1776        match content_type {
1777            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1778            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderTestV3Resp`"))),
1779            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::SpotCreateOrderTestV3Resp`")))),
1780        }
1781    } else {
1782        let content = resp.text().await?;
1783        let entity: Option<CreateOrderTestV3Error> = serde_json::from_str(&content).ok();
1784        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1785    }
1786}
1787
1788/// Send in a new order.
1789pub async fn create_order_v3(configuration: &configuration::Configuration, params: CreateOrderV3Params) -> Result<models::SpotCreateOrderV3Resp, Error<CreateOrderV3Error>> {
1790
1791    let uri_str = format!("{}/api/v3/order", configuration.base_path);
1792    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1793
1794    // Create a mutable vector for query parameters
1795    let mut query_params: Vec<(String, String)> = Vec::new();
1796
1797
1798    // Create header parameters collection
1799    let mut header_params = std::collections::HashMap::new();
1800
1801    // Handle Binance Auth first if configured
1802    if let Some(ref binance_auth) = configuration.binance_auth {
1803        // Add API key to headers
1804        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1805        
1806        // Generate request body for signing (if any)
1807        let body_string: Option<Vec<u8>> = None;
1808        
1809        // Sign the request
1810        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1811            Ok(sig) => sig,
1812            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1813        };
1814        
1815        // Add signature to query params
1816        query_params.push(("signature".to_string(), signature));
1817    }
1818
1819    // Apply all query parameters
1820    if !query_params.is_empty() {
1821        req_builder = req_builder.query(&query_params);
1822    }
1823
1824
1825    // Add user agent if configured
1826    if let Some(ref user_agent) = configuration.user_agent {
1827        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1828    }
1829
1830    // Apply all header parameters
1831    for (header_name, header_value) in header_params {
1832        req_builder = req_builder.header(&header_name, &header_value);
1833    }
1834
1835    let mut multipart_form_params = std::collections::HashMap::new();
1836    if let Some(param_value) = params.iceberg_qty {
1837        multipart_form_params.insert("icebergQty", param_value.to_string());
1838    }
1839    if let Some(param_value) = params.new_client_order_id {
1840        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1841    }
1842    if let Some(param_value) = params.new_order_resp_type {
1843        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1844    }
1845    if let Some(param_value) = params.price {
1846        multipart_form_params.insert("price", param_value.to_string());
1847    }
1848    if let Some(param_value) = params.quantity {
1849        multipart_form_params.insert("quantity", param_value.to_string());
1850    }
1851    if let Some(param_value) = params.quote_order_qty {
1852        multipart_form_params.insert("quoteOrderQty", param_value.to_string());
1853    }
1854    if let Some(param_value) = params.recv_window {
1855        multipart_form_params.insert("recvWindow", param_value.to_string());
1856    }
1857    if let Some(param_value) = params.self_trade_prevention_mode {
1858        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1859    }
1860    multipart_form_params.insert("side", params.side.to_string());
1861    if let Some(param_value) = params.stop_price {
1862        multipart_form_params.insert("stopPrice", param_value.to_string());
1863    }
1864    if let Some(param_value) = params.strategy_id {
1865        multipart_form_params.insert("strategyId", param_value.to_string());
1866    }
1867    if let Some(param_value) = params.strategy_type {
1868        multipart_form_params.insert("strategyType", param_value.to_string());
1869    }
1870    multipart_form_params.insert("symbol", params.symbol.to_string());
1871    if let Some(param_value) = params.time_in_force {
1872        multipart_form_params.insert("timeInForce", param_value.to_string());
1873    }
1874    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1875    if let Some(param_value) = params.trailing_delta {
1876        multipart_form_params.insert("trailingDelta", param_value.to_string());
1877    }
1878    multipart_form_params.insert("type", params.r#type.to_string());
1879    req_builder = req_builder.form(&multipart_form_params);
1880
1881    let req = req_builder.build()?;
1882    let resp = configuration.client.execute(req).await?;
1883
1884    let status = resp.status();
1885    let content_type = resp
1886        .headers()
1887        .get("content-type")
1888        .and_then(|v| v.to_str().ok())
1889        .unwrap_or("application/octet-stream");
1890    let content_type = super::ContentType::from(content_type);
1891
1892    if !status.is_client_error() && !status.is_server_error() {
1893        let content = resp.text().await?;
1894        match content_type {
1895            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1896            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderV3Resp`"))),
1897            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::SpotCreateOrderV3Resp`")))),
1898        }
1899    } else {
1900        let content = resp.text().await?;
1901        let entity: Option<CreateOrderV3Error> = serde_json::from_str(&content).ok();
1902        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1903    }
1904}
1905
1906/// Test new order creation and signature/recvWindow using smart order routing (SOR). Creates and validates a new order but does not send it into the matching engine.
1907pub async fn create_sor_order_test_v3(configuration: &configuration::Configuration, params: CreateSorOrderTestV3Params) -> Result<models::SpotCreateSorOrderTestV3Resp, Error<CreateSorOrderTestV3Error>> {
1908
1909    let uri_str = format!("{}/api/v3/sor/order/test", configuration.base_path);
1910    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1911
1912    // Create a mutable vector for query parameters
1913    let mut query_params: Vec<(String, String)> = Vec::new();
1914
1915
1916    // Create header parameters collection
1917    let mut header_params = std::collections::HashMap::new();
1918
1919    // Handle Binance Auth first if configured
1920    if let Some(ref binance_auth) = configuration.binance_auth {
1921        // Add API key to headers
1922        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1923        
1924        // Generate request body for signing (if any)
1925        let body_string: Option<Vec<u8>> = None;
1926        
1927        // Sign the request
1928        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1929            Ok(sig) => sig,
1930            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1931        };
1932        
1933        // Add signature to query params
1934        query_params.push(("signature".to_string(), signature));
1935    }
1936
1937    // Apply all query parameters
1938    if !query_params.is_empty() {
1939        req_builder = req_builder.query(&query_params);
1940    }
1941
1942
1943    // Add user agent if configured
1944    if let Some(ref user_agent) = configuration.user_agent {
1945        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1946    }
1947
1948    // Apply all header parameters
1949    for (header_name, header_value) in header_params {
1950        req_builder = req_builder.header(&header_name, &header_value);
1951    }
1952
1953    let mut multipart_form_params = std::collections::HashMap::new();
1954    if let Some(param_value) = params.compute_commission_rates {
1955        multipart_form_params.insert("computeCommissionRates", param_value.to_string());
1956    }
1957    if let Some(param_value) = params.iceberg_qty {
1958        multipart_form_params.insert("icebergQty", param_value.to_string());
1959    }
1960    if let Some(param_value) = params.new_client_order_id {
1961        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1962    }
1963    if let Some(param_value) = params.new_order_resp_type {
1964        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1965    }
1966    if let Some(param_value) = params.price {
1967        multipart_form_params.insert("price", param_value.to_string());
1968    }
1969    multipart_form_params.insert("quantity", params.quantity.to_string());
1970    if let Some(param_value) = params.recv_window {
1971        multipart_form_params.insert("recvWindow", param_value.to_string());
1972    }
1973    if let Some(param_value) = params.self_trade_prevention_mode {
1974        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1975    }
1976    multipart_form_params.insert("side", params.side.to_string());
1977    if let Some(param_value) = params.strategy_id {
1978        multipart_form_params.insert("strategyId", param_value.to_string());
1979    }
1980    if let Some(param_value) = params.strategy_type {
1981        multipart_form_params.insert("strategyType", param_value.to_string());
1982    }
1983    multipart_form_params.insert("symbol", params.symbol.to_string());
1984    if let Some(param_value) = params.time_in_force {
1985        multipart_form_params.insert("timeInForce", param_value.to_string());
1986    }
1987    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1988    multipart_form_params.insert("type", params.r#type.to_string());
1989    req_builder = req_builder.form(&multipart_form_params);
1990
1991    let req = req_builder.build()?;
1992    let resp = configuration.client.execute(req).await?;
1993
1994    let status = resp.status();
1995    let content_type = resp
1996        .headers()
1997        .get("content-type")
1998        .and_then(|v| v.to_str().ok())
1999        .unwrap_or("application/octet-stream");
2000    let content_type = super::ContentType::from(content_type);
2001
2002    if !status.is_client_error() && !status.is_server_error() {
2003        let content = resp.text().await?;
2004        match content_type {
2005            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2006            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateSorOrderTestV3Resp`"))),
2007            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::SpotCreateSorOrderTestV3Resp`")))),
2008        }
2009    } else {
2010        let content = resp.text().await?;
2011        let entity: Option<CreateSorOrderTestV3Error> = serde_json::from_str(&content).ok();
2012        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2013    }
2014}
2015
2016/// Places an order using smart order routing (SOR).
2017pub async fn create_sor_order_v3(configuration: &configuration::Configuration, params: CreateSorOrderV3Params) -> Result<models::CreateSorOrderV3Resp, Error<CreateSorOrderV3Error>> {
2018
2019    let uri_str = format!("{}/api/v3/sor/order", configuration.base_path);
2020    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2021
2022    // Create a mutable vector for query parameters
2023    let mut query_params: Vec<(String, String)> = Vec::new();
2024
2025
2026    // Create header parameters collection
2027    let mut header_params = std::collections::HashMap::new();
2028
2029    // Handle Binance Auth first if configured
2030    if let Some(ref binance_auth) = configuration.binance_auth {
2031        // Add API key to headers
2032        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2033        
2034        // Generate request body for signing (if any)
2035        let body_string: Option<Vec<u8>> = None;
2036        
2037        // Sign the request
2038        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2039            Ok(sig) => sig,
2040            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2041        };
2042        
2043        // Add signature to query params
2044        query_params.push(("signature".to_string(), signature));
2045    }
2046
2047    // Apply all query parameters
2048    if !query_params.is_empty() {
2049        req_builder = req_builder.query(&query_params);
2050    }
2051
2052
2053    // Add user agent if configured
2054    if let Some(ref user_agent) = configuration.user_agent {
2055        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2056    }
2057
2058    // Apply all header parameters
2059    for (header_name, header_value) in header_params {
2060        req_builder = req_builder.header(&header_name, &header_value);
2061    }
2062
2063    let mut multipart_form_params = std::collections::HashMap::new();
2064    if let Some(param_value) = params.iceberg_qty {
2065        multipart_form_params.insert("icebergQty", param_value.to_string());
2066    }
2067    if let Some(param_value) = params.new_client_order_id {
2068        multipart_form_params.insert("newClientOrderId", param_value.to_string());
2069    }
2070    if let Some(param_value) = params.new_order_resp_type {
2071        multipart_form_params.insert("newOrderRespType", param_value.to_string());
2072    }
2073    if let Some(param_value) = params.price {
2074        multipart_form_params.insert("price", param_value.to_string());
2075    }
2076    multipart_form_params.insert("quantity", params.quantity.to_string());
2077    if let Some(param_value) = params.recv_window {
2078        multipart_form_params.insert("recvWindow", param_value.to_string());
2079    }
2080    if let Some(param_value) = params.self_trade_prevention_mode {
2081        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
2082    }
2083    multipart_form_params.insert("side", params.side.to_string());
2084    if let Some(param_value) = params.strategy_id {
2085        multipart_form_params.insert("strategyId", param_value.to_string());
2086    }
2087    if let Some(param_value) = params.strategy_type {
2088        multipart_form_params.insert("strategyType", param_value.to_string());
2089    }
2090    multipart_form_params.insert("symbol", params.symbol.to_string());
2091    if let Some(param_value) = params.time_in_force {
2092        multipart_form_params.insert("timeInForce", param_value.to_string());
2093    }
2094    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2095    multipart_form_params.insert("type", params.r#type.to_string());
2096    req_builder = req_builder.form(&multipart_form_params);
2097
2098    let req = req_builder.build()?;
2099    let resp = configuration.client.execute(req).await?;
2100
2101    let status = resp.status();
2102    let content_type = resp
2103        .headers()
2104        .get("content-type")
2105        .and_then(|v| v.to_str().ok())
2106        .unwrap_or("application/octet-stream");
2107    let content_type = super::ContentType::from(content_type);
2108
2109    if !status.is_client_error() && !status.is_server_error() {
2110        let content = resp.text().await?;
2111        match content_type {
2112            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2113            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateSorOrderV3Resp`"))),
2114            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::CreateSorOrderV3Resp`")))),
2115        }
2116    } else {
2117        let content = resp.text().await?;
2118        let entity: Option<CreateSorOrderV3Error> = serde_json::from_str(&content).ok();
2119        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2120    }
2121}
2122
2123/// Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent.
2124pub async fn create_user_data_stream_v3(configuration: &configuration::Configuration) -> Result<models::CreateUserDataStreamV3Resp, Error<CreateUserDataStreamV3Error>> {
2125
2126    let uri_str = format!("{}/api/v3/userDataStream", configuration.base_path);
2127    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2128
2129    // Create a mutable vector for query parameters
2130    let mut query_params: Vec<(String, String)> = Vec::new();
2131
2132
2133    // Create header parameters collection
2134    let mut header_params = std::collections::HashMap::new();
2135
2136    // Handle Binance Auth first if configured
2137    if let Some(ref binance_auth) = configuration.binance_auth {
2138        // Add API key to headers
2139        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2140        
2141        // Generate request body for signing (if any)
2142        let body_string: Option<Vec<u8>> = None;
2143        
2144        // Sign the request
2145        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2146            Ok(sig) => sig,
2147            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2148        };
2149        
2150        // Add signature to query params
2151        query_params.push(("signature".to_string(), signature));
2152    }
2153
2154    // Apply all query parameters
2155    if !query_params.is_empty() {
2156        req_builder = req_builder.query(&query_params);
2157    }
2158
2159
2160    // Add user agent if configured
2161    if let Some(ref user_agent) = configuration.user_agent {
2162        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2163    }
2164
2165    // Apply all header parameters
2166    for (header_name, header_value) in header_params {
2167        req_builder = req_builder.header(&header_name, &header_value);
2168    }
2169
2170
2171    let req = req_builder.build()?;
2172    let resp = configuration.client.execute(req).await?;
2173
2174    let status = resp.status();
2175    let content_type = resp
2176        .headers()
2177        .get("content-type")
2178        .and_then(|v| v.to_str().ok())
2179        .unwrap_or("application/octet-stream");
2180    let content_type = super::ContentType::from(content_type);
2181
2182    if !status.is_client_error() && !status.is_server_error() {
2183        let content = resp.text().await?;
2184        match content_type {
2185            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2186            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateUserDataStreamV3Resp`"))),
2187            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::CreateUserDataStreamV3Resp`")))),
2188        }
2189    } else {
2190        let content = resp.text().await?;
2191        let entity: Option<CreateUserDataStreamV3Error> = serde_json::from_str(&content).ok();
2192        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2193    }
2194}
2195
2196/// Cancels all active orders on a symbol. This includes orders that are part of an order list.
2197pub async fn delete_open_orders_v3(configuration: &configuration::Configuration, params: DeleteOpenOrdersV3Params) -> Result<Vec<Vec<models::SpotDeleteOpenOrdersV3RespInner>>, Error<DeleteOpenOrdersV3Error>> {
2198
2199    let uri_str = format!("{}/api/v3/openOrders", configuration.base_path);
2200    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2201
2202    // Create a mutable vector for query parameters
2203    let mut query_params: Vec<(String, String)> = Vec::new();
2204
2205    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2206    if let Some(ref param_value) = params.recv_window {
2207        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2208    }
2209    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2210
2211    // Create header parameters collection
2212    let mut header_params = std::collections::HashMap::new();
2213
2214    // Handle Binance Auth first if configured
2215    if let Some(ref binance_auth) = configuration.binance_auth {
2216        // Add API key to headers
2217        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2218        
2219        // Generate request body for signing (if any)
2220        let body_string: Option<Vec<u8>> = None;
2221        
2222        // Sign the request
2223        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2224            Ok(sig) => sig,
2225            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2226        };
2227        
2228        // Add signature to query params
2229        query_params.push(("signature".to_string(), signature));
2230    }
2231
2232    // Apply all query parameters
2233    if !query_params.is_empty() {
2234        req_builder = req_builder.query(&query_params);
2235    }
2236
2237
2238    // Add user agent if configured
2239    if let Some(ref user_agent) = configuration.user_agent {
2240        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2241    }
2242
2243    // Apply all header parameters
2244    for (header_name, header_value) in header_params {
2245        req_builder = req_builder.header(&header_name, &header_value);
2246    }
2247
2248
2249    let req = req_builder.build()?;
2250    let resp = configuration.client.execute(req).await?;
2251
2252    let status = resp.status();
2253    let content_type = resp
2254        .headers()
2255        .get("content-type")
2256        .and_then(|v| v.to_str().ok())
2257        .unwrap_or("application/octet-stream");
2258    let content_type = super::ContentType::from(content_type);
2259
2260    if !status.is_client_error() && !status.is_server_error() {
2261        let content = resp.text().await?;
2262        match content_type {
2263            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2264            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;Vec&lt;models::SpotDeleteOpenOrdersV3RespInner&gt;&gt;`"))),
2265            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;Vec&lt;models::SpotDeleteOpenOrdersV3RespInner&gt;&gt;`")))),
2266        }
2267    } else {
2268        let content = resp.text().await?;
2269        let entity: Option<DeleteOpenOrdersV3Error> = serde_json::from_str(&content).ok();
2270        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2271    }
2272}
2273
2274/// Cancel an entire Order list
2275pub async fn delete_order_list_v3(configuration: &configuration::Configuration, params: DeleteOrderListV3Params) -> Result<models::DeleteOrderListV3Resp, Error<DeleteOrderListV3Error>> {
2276
2277    let uri_str = format!("{}/api/v3/orderList", configuration.base_path);
2278    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2279
2280    // Create a mutable vector for query parameters
2281    let mut query_params: Vec<(String, String)> = Vec::new();
2282
2283    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2284    if let Some(ref param_value) = params.order_list_id {
2285        query_params.push(("orderListId".to_string(), param_value.to_string()));
2286    }
2287    if let Some(ref param_value) = params.list_client_order_id {
2288        query_params.push(("listClientOrderId".to_string(), param_value.to_string()));
2289    }
2290    if let Some(ref param_value) = params.new_client_order_id {
2291        query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
2292    }
2293    if let Some(ref param_value) = params.recv_window {
2294        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2295    }
2296    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2297
2298    // Create header parameters collection
2299    let mut header_params = std::collections::HashMap::new();
2300
2301    // Handle Binance Auth first if configured
2302    if let Some(ref binance_auth) = configuration.binance_auth {
2303        // Add API key to headers
2304        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2305        
2306        // Generate request body for signing (if any)
2307        let body_string: Option<Vec<u8>> = None;
2308        
2309        // Sign the request
2310        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2311            Ok(sig) => sig,
2312            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2313        };
2314        
2315        // Add signature to query params
2316        query_params.push(("signature".to_string(), signature));
2317    }
2318
2319    // Apply all query parameters
2320    if !query_params.is_empty() {
2321        req_builder = req_builder.query(&query_params);
2322    }
2323
2324
2325    // Add user agent if configured
2326    if let Some(ref user_agent) = configuration.user_agent {
2327        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2328    }
2329
2330    // Apply all header parameters
2331    for (header_name, header_value) in header_params {
2332        req_builder = req_builder.header(&header_name, &header_value);
2333    }
2334
2335
2336    let req = req_builder.build()?;
2337    let resp = configuration.client.execute(req).await?;
2338
2339    let status = resp.status();
2340    let content_type = resp
2341        .headers()
2342        .get("content-type")
2343        .and_then(|v| v.to_str().ok())
2344        .unwrap_or("application/octet-stream");
2345    let content_type = super::ContentType::from(content_type);
2346
2347    if !status.is_client_error() && !status.is_server_error() {
2348        let content = resp.text().await?;
2349        match content_type {
2350            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2351            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteOrderListV3Resp`"))),
2352            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::DeleteOrderListV3Resp`")))),
2353        }
2354    } else {
2355        let content = resp.text().await?;
2356        let entity: Option<DeleteOrderListV3Error> = serde_json::from_str(&content).ok();
2357        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2358    }
2359}
2360
2361/// Cancel an active order.
2362pub async fn delete_order_v3(configuration: &configuration::Configuration, params: DeleteOrderV3Params) -> Result<models::DeleteOrderV3Resp, Error<DeleteOrderV3Error>> {
2363
2364    let uri_str = format!("{}/api/v3/order", configuration.base_path);
2365    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2366
2367    // Create a mutable vector for query parameters
2368    let mut query_params: Vec<(String, String)> = Vec::new();
2369
2370    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2371    if let Some(ref param_value) = params.order_id {
2372        query_params.push(("orderId".to_string(), param_value.to_string()));
2373    }
2374    if let Some(ref param_value) = params.orig_client_order_id {
2375        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2376    }
2377    if let Some(ref param_value) = params.new_client_order_id {
2378        query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
2379    }
2380    if let Some(ref param_value) = params.cancel_restrictions {
2381        query_params.push(("cancelRestrictions".to_string(), param_value.to_string()));
2382    }
2383    if let Some(ref param_value) = params.recv_window {
2384        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2385    }
2386    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2387
2388    // Create header parameters collection
2389    let mut header_params = std::collections::HashMap::new();
2390
2391    // Handle Binance Auth first if configured
2392    if let Some(ref binance_auth) = configuration.binance_auth {
2393        // Add API key to headers
2394        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2395        
2396        // Generate request body for signing (if any)
2397        let body_string: Option<Vec<u8>> = None;
2398        
2399        // Sign the request
2400        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2401            Ok(sig) => sig,
2402            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2403        };
2404        
2405        // Add signature to query params
2406        query_params.push(("signature".to_string(), signature));
2407    }
2408
2409    // Apply all query parameters
2410    if !query_params.is_empty() {
2411        req_builder = req_builder.query(&query_params);
2412    }
2413
2414
2415    // Add user agent if configured
2416    if let Some(ref user_agent) = configuration.user_agent {
2417        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2418    }
2419
2420    // Apply all header parameters
2421    for (header_name, header_value) in header_params {
2422        req_builder = req_builder.header(&header_name, &header_value);
2423    }
2424
2425
2426    let req = req_builder.build()?;
2427    let resp = configuration.client.execute(req).await?;
2428
2429    let status = resp.status();
2430    let content_type = resp
2431        .headers()
2432        .get("content-type")
2433        .and_then(|v| v.to_str().ok())
2434        .unwrap_or("application/octet-stream");
2435    let content_type = super::ContentType::from(content_type);
2436
2437    if !status.is_client_error() && !status.is_server_error() {
2438        let content = resp.text().await?;
2439        match content_type {
2440            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2441            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteOrderV3Resp`"))),
2442            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::DeleteOrderV3Resp`")))),
2443        }
2444    } else {
2445        let content = resp.text().await?;
2446        let entity: Option<DeleteOrderV3Error> = serde_json::from_str(&content).ok();
2447        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2448    }
2449}
2450
2451/// Close out a user data stream.
2452pub async fn delete_user_data_stream_v3(configuration: &configuration::Configuration, params: DeleteUserDataStreamV3Params) -> Result<serde_json::Value, Error<DeleteUserDataStreamV3Error>> {
2453
2454    let uri_str = format!("{}/api/v3/userDataStream", configuration.base_path);
2455    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2456
2457    // Create a mutable vector for query parameters
2458    let mut query_params: Vec<(String, String)> = Vec::new();
2459
2460    query_params.push(("listenKey".to_string(), params.listen_key.to_string()));
2461
2462    // Create header parameters collection
2463    let mut header_params = std::collections::HashMap::new();
2464
2465    // Handle Binance Auth first if configured
2466    if let Some(ref binance_auth) = configuration.binance_auth {
2467        // Add API key to headers
2468        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2469        
2470        // Generate request body for signing (if any)
2471        let body_string: Option<Vec<u8>> = None;
2472        
2473        // Sign the request
2474        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2475            Ok(sig) => sig,
2476            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2477        };
2478        
2479        // Add signature to query params
2480        query_params.push(("signature".to_string(), signature));
2481    }
2482
2483    // Apply all query parameters
2484    if !query_params.is_empty() {
2485        req_builder = req_builder.query(&query_params);
2486    }
2487
2488
2489    // Add user agent if configured
2490    if let Some(ref user_agent) = configuration.user_agent {
2491        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2492    }
2493
2494    // Apply all header parameters
2495    for (header_name, header_value) in header_params {
2496        req_builder = req_builder.header(&header_name, &header_value);
2497    }
2498
2499
2500    let req = req_builder.build()?;
2501    let resp = configuration.client.execute(req).await?;
2502
2503    let status = resp.status();
2504    let content_type = resp
2505        .headers()
2506        .get("content-type")
2507        .and_then(|v| v.to_str().ok())
2508        .unwrap_or("application/octet-stream");
2509    let content_type = super::ContentType::from(content_type);
2510
2511    if !status.is_client_error() && !status.is_server_error() {
2512        let content = resp.text().await?;
2513        match content_type {
2514            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2515            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
2516            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`")))),
2517        }
2518    } else {
2519        let content = resp.text().await?;
2520        let entity: Option<DeleteUserDataStreamV3Error> = serde_json::from_str(&content).ok();
2521        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2522    }
2523}
2524
2525/// Get current account commission rates.
2526pub async fn get_account_commission_v3(configuration: &configuration::Configuration, params: GetAccountCommissionV3Params) -> Result<models::GetAccountCommissionV3Resp, Error<GetAccountCommissionV3Error>> {
2527
2528    let uri_str = format!("{}/api/v3/account/commission", configuration.base_path);
2529    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2530
2531    // Create a mutable vector for query parameters
2532    let mut query_params: Vec<(String, String)> = Vec::new();
2533
2534    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2535
2536    // Create header parameters collection
2537    let mut header_params = std::collections::HashMap::new();
2538
2539    // Handle Binance Auth first if configured
2540    if let Some(ref binance_auth) = configuration.binance_auth {
2541        // Add API key to headers
2542        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2543        
2544        // Generate request body for signing (if any)
2545        let body_string: Option<Vec<u8>> = None;
2546        
2547        // Sign the request
2548        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2549            Ok(sig) => sig,
2550            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2551        };
2552        
2553        // Add signature to query params
2554        query_params.push(("signature".to_string(), signature));
2555    }
2556
2557    // Apply all query parameters
2558    if !query_params.is_empty() {
2559        req_builder = req_builder.query(&query_params);
2560    }
2561
2562
2563    // Add user agent if configured
2564    if let Some(ref user_agent) = configuration.user_agent {
2565        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2566    }
2567
2568    // Apply all header parameters
2569    for (header_name, header_value) in header_params {
2570        req_builder = req_builder.header(&header_name, &header_value);
2571    }
2572
2573
2574    let req = req_builder.build()?;
2575    let resp = configuration.client.execute(req).await?;
2576
2577    let status = resp.status();
2578    let content_type = resp
2579        .headers()
2580        .get("content-type")
2581        .and_then(|v| v.to_str().ok())
2582        .unwrap_or("application/octet-stream");
2583    let content_type = super::ContentType::from(content_type);
2584
2585    if !status.is_client_error() && !status.is_server_error() {
2586        let content = resp.text().await?;
2587        match content_type {
2588            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2589            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountCommissionV3Resp`"))),
2590            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::GetAccountCommissionV3Resp`")))),
2591        }
2592    } else {
2593        let content = resp.text().await?;
2594        let entity: Option<GetAccountCommissionV3Error> = serde_json::from_str(&content).ok();
2595        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2596    }
2597}
2598
2599/// Get current account information.
2600pub async fn get_account_v3(configuration: &configuration::Configuration, params: GetAccountV3Params) -> Result<models::GetAccountV3Resp, Error<GetAccountV3Error>> {
2601
2602    let uri_str = format!("{}/api/v3/account", configuration.base_path);
2603    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2604
2605    // Create a mutable vector for query parameters
2606    let mut query_params: Vec<(String, String)> = Vec::new();
2607
2608    if let Some(ref param_value) = params.omit_zero_balances {
2609        query_params.push(("omitZeroBalances".to_string(), param_value.to_string()));
2610    }
2611    if let Some(ref param_value) = params.recv_window {
2612        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2613    }
2614    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2615
2616    // Create header parameters collection
2617    let mut header_params = std::collections::HashMap::new();
2618
2619    // Handle Binance Auth first if configured
2620    if let Some(ref binance_auth) = configuration.binance_auth {
2621        // Add API key to headers
2622        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2623        
2624        // Generate request body for signing (if any)
2625        let body_string: Option<Vec<u8>> = None;
2626        
2627        // Sign the request
2628        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2629            Ok(sig) => sig,
2630            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2631        };
2632        
2633        // Add signature to query params
2634        query_params.push(("signature".to_string(), signature));
2635    }
2636
2637    // Apply all query parameters
2638    if !query_params.is_empty() {
2639        req_builder = req_builder.query(&query_params);
2640    }
2641
2642
2643    // Add user agent if configured
2644    if let Some(ref user_agent) = configuration.user_agent {
2645        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2646    }
2647
2648    // Apply all header parameters
2649    for (header_name, header_value) in header_params {
2650        req_builder = req_builder.header(&header_name, &header_value);
2651    }
2652
2653
2654    let req = req_builder.build()?;
2655    let resp = configuration.client.execute(req).await?;
2656
2657    let status = resp.status();
2658    let content_type = resp
2659        .headers()
2660        .get("content-type")
2661        .and_then(|v| v.to_str().ok())
2662        .unwrap_or("application/octet-stream");
2663    let content_type = super::ContentType::from(content_type);
2664
2665    if !status.is_client_error() && !status.is_server_error() {
2666        let content = resp.text().await?;
2667        match content_type {
2668            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2669            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountV3Resp`"))),
2670            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::GetAccountV3Resp`")))),
2671        }
2672    } else {
2673        let content = resp.text().await?;
2674        let entity: Option<GetAccountV3Error> = serde_json::from_str(&content).ok();
2675        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2676    }
2677}
2678
2679/// Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated.
2680pub async fn get_agg_trades_v3(configuration: &configuration::Configuration, params: GetAggTradesV3Params) -> Result<Vec<models::SpotGetAggTradesV3RespItem>, Error<GetAggTradesV3Error>> {
2681
2682    let uri_str = format!("{}/api/v3/aggTrades", configuration.base_path);
2683    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2684
2685    // Create a mutable vector for query parameters
2686    let mut query_params: Vec<(String, String)> = Vec::new();
2687
2688    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2689    if let Some(ref param_value) = params.from_id {
2690        query_params.push(("fromId".to_string(), param_value.to_string()));
2691    }
2692    if let Some(ref param_value) = params.start_time {
2693        query_params.push(("startTime".to_string(), param_value.to_string()));
2694    }
2695    if let Some(ref param_value) = params.end_time {
2696        query_params.push(("endTime".to_string(), param_value.to_string()));
2697    }
2698    if let Some(ref param_value) = params.limit {
2699        query_params.push(("limit".to_string(), param_value.to_string()));
2700    }
2701
2702    // Create header parameters collection
2703    let mut header_params = std::collections::HashMap::new();
2704
2705    // Handle Binance Auth first if configured
2706    if let Some(ref binance_auth) = configuration.binance_auth {
2707        // Add API key to headers
2708        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2709        
2710        // Generate request body for signing (if any)
2711        let body_string: Option<Vec<u8>> = None;
2712        
2713        // Sign the request
2714        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2715            Ok(sig) => sig,
2716            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2717        };
2718        
2719        // Add signature to query params
2720        query_params.push(("signature".to_string(), signature));
2721    }
2722
2723    // Apply all query parameters
2724    if !query_params.is_empty() {
2725        req_builder = req_builder.query(&query_params);
2726    }
2727
2728
2729    // Add user agent if configured
2730    if let Some(ref user_agent) = configuration.user_agent {
2731        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2732    }
2733
2734    // Apply all header parameters
2735    for (header_name, header_value) in header_params {
2736        req_builder = req_builder.header(&header_name, &header_value);
2737    }
2738
2739
2740    let req = req_builder.build()?;
2741    let resp = configuration.client.execute(req).await?;
2742
2743    let status = resp.status();
2744    let content_type = resp
2745        .headers()
2746        .get("content-type")
2747        .and_then(|v| v.to_str().ok())
2748        .unwrap_or("application/octet-stream");
2749    let content_type = super::ContentType::from(content_type);
2750
2751    if !status.is_client_error() && !status.is_server_error() {
2752        let content = resp.text().await?;
2753        match content_type {
2754            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2755            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetAggTradesV3RespItem&gt;`"))),
2756            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::SpotGetAggTradesV3RespItem&gt;`")))),
2757        }
2758    } else {
2759        let content = resp.text().await?;
2760        let entity: Option<GetAggTradesV3Error> = serde_json::from_str(&content).ok();
2761        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2762    }
2763}
2764
2765/// Retrieves all order lists based on provided optional parameters. Note that the time between startTime and endTime can't be longer than 24 hours.
2766pub async fn get_all_order_list_v3(configuration: &configuration::Configuration, params: GetAllOrderListV3Params) -> Result<Vec<models::GetAllOrderListV3RespItem>, Error<GetAllOrderListV3Error>> {
2767
2768    let uri_str = format!("{}/api/v3/allOrderList", configuration.base_path);
2769    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2770
2771    // Create a mutable vector for query parameters
2772    let mut query_params: Vec<(String, String)> = Vec::new();
2773
2774    if let Some(ref param_value) = params.from_id {
2775        query_params.push(("fromId".to_string(), param_value.to_string()));
2776    }
2777    if let Some(ref param_value) = params.start_time {
2778        query_params.push(("startTime".to_string(), param_value.to_string()));
2779    }
2780    if let Some(ref param_value) = params.end_time {
2781        query_params.push(("endTime".to_string(), param_value.to_string()));
2782    }
2783    if let Some(ref param_value) = params.limit {
2784        query_params.push(("limit".to_string(), param_value.to_string()));
2785    }
2786    if let Some(ref param_value) = params.recv_window {
2787        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2788    }
2789    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2790
2791    // Create header parameters collection
2792    let mut header_params = std::collections::HashMap::new();
2793
2794    // Handle Binance Auth first if configured
2795    if let Some(ref binance_auth) = configuration.binance_auth {
2796        // Add API key to headers
2797        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2798        
2799        // Generate request body for signing (if any)
2800        let body_string: Option<Vec<u8>> = None;
2801        
2802        // Sign the request
2803        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2804            Ok(sig) => sig,
2805            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2806        };
2807        
2808        // Add signature to query params
2809        query_params.push(("signature".to_string(), signature));
2810    }
2811
2812    // Apply all query parameters
2813    if !query_params.is_empty() {
2814        req_builder = req_builder.query(&query_params);
2815    }
2816
2817
2818    // Add user agent if configured
2819    if let Some(ref user_agent) = configuration.user_agent {
2820        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2821    }
2822
2823    // Apply all header parameters
2824    for (header_name, header_value) in header_params {
2825        req_builder = req_builder.header(&header_name, &header_value);
2826    }
2827
2828
2829    let req = req_builder.build()?;
2830    let resp = configuration.client.execute(req).await?;
2831
2832    let status = resp.status();
2833    let content_type = resp
2834        .headers()
2835        .get("content-type")
2836        .and_then(|v| v.to_str().ok())
2837        .unwrap_or("application/octet-stream");
2838    let content_type = super::ContentType::from(content_type);
2839
2840    if !status.is_client_error() && !status.is_server_error() {
2841        let content = resp.text().await?;
2842        match content_type {
2843            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2844            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetAllOrderListV3RespItem&gt;`"))),
2845            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::GetAllOrderListV3RespItem&gt;`")))),
2846        }
2847    } else {
2848        let content = resp.text().await?;
2849        let entity: Option<GetAllOrderListV3Error> = serde_json::from_str(&content).ok();
2850        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2851    }
2852}
2853
2854/// Get all account orders; active, canceled, or filled.
2855pub async fn get_all_orders_v3(configuration: &configuration::Configuration, params: GetAllOrdersV3Params) -> Result<Vec<models::GetAllOrdersV3RespItem>, Error<GetAllOrdersV3Error>> {
2856
2857    let uri_str = format!("{}/api/v3/allOrders", configuration.base_path);
2858    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2859
2860    // Create a mutable vector for query parameters
2861    let mut query_params: Vec<(String, String)> = Vec::new();
2862
2863    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2864    if let Some(ref param_value) = params.order_id {
2865        query_params.push(("orderId".to_string(), param_value.to_string()));
2866    }
2867    if let Some(ref param_value) = params.start_time {
2868        query_params.push(("startTime".to_string(), param_value.to_string()));
2869    }
2870    if let Some(ref param_value) = params.end_time {
2871        query_params.push(("endTime".to_string(), param_value.to_string()));
2872    }
2873    if let Some(ref param_value) = params.limit {
2874        query_params.push(("limit".to_string(), param_value.to_string()));
2875    }
2876    if let Some(ref param_value) = params.recv_window {
2877        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2878    }
2879    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2880
2881    // Create header parameters collection
2882    let mut header_params = std::collections::HashMap::new();
2883
2884    // Handle Binance Auth first if configured
2885    if let Some(ref binance_auth) = configuration.binance_auth {
2886        // Add API key to headers
2887        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2888        
2889        // Generate request body for signing (if any)
2890        let body_string: Option<Vec<u8>> = None;
2891        
2892        // Sign the request
2893        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2894            Ok(sig) => sig,
2895            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2896        };
2897        
2898        // Add signature to query params
2899        query_params.push(("signature".to_string(), signature));
2900    }
2901
2902    // Apply all query parameters
2903    if !query_params.is_empty() {
2904        req_builder = req_builder.query(&query_params);
2905    }
2906
2907
2908    // Add user agent if configured
2909    if let Some(ref user_agent) = configuration.user_agent {
2910        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2911    }
2912
2913    // Apply all header parameters
2914    for (header_name, header_value) in header_params {
2915        req_builder = req_builder.header(&header_name, &header_value);
2916    }
2917
2918
2919    let req = req_builder.build()?;
2920    let resp = configuration.client.execute(req).await?;
2921
2922    let status = resp.status();
2923    let content_type = resp
2924        .headers()
2925        .get("content-type")
2926        .and_then(|v| v.to_str().ok())
2927        .unwrap_or("application/octet-stream");
2928    let content_type = super::ContentType::from(content_type);
2929
2930    if !status.is_client_error() && !status.is_server_error() {
2931        let content = resp.text().await?;
2932        match content_type {
2933            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2934            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetAllOrdersV3RespItem&gt;`"))),
2935            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::GetAllOrdersV3RespItem&gt;`")))),
2936        }
2937    } else {
2938        let content = resp.text().await?;
2939        let entity: Option<GetAllOrdersV3Error> = serde_json::from_str(&content).ok();
2940        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2941    }
2942}
2943
2944/// Current average price for a symbol.
2945pub async fn get_avg_price_v3(configuration: &configuration::Configuration, params: GetAvgPriceV3Params) -> Result<models::GetAvgPriceV3Resp, Error<GetAvgPriceV3Error>> {
2946
2947    let uri_str = format!("{}/api/v3/avgPrice", configuration.base_path);
2948    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2949
2950    // Create a mutable vector for query parameters
2951    let mut query_params: Vec<(String, String)> = Vec::new();
2952
2953    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2954
2955    // Create header parameters collection
2956    let mut header_params = std::collections::HashMap::new();
2957
2958    // Handle Binance Auth first if configured
2959    if let Some(ref binance_auth) = configuration.binance_auth {
2960        // Add API key to headers
2961        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2962        
2963        // Generate request body for signing (if any)
2964        let body_string: Option<Vec<u8>> = None;
2965        
2966        // Sign the request
2967        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2968            Ok(sig) => sig,
2969            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2970        };
2971        
2972        // Add signature to query params
2973        query_params.push(("signature".to_string(), signature));
2974    }
2975
2976    // Apply all query parameters
2977    if !query_params.is_empty() {
2978        req_builder = req_builder.query(&query_params);
2979    }
2980
2981
2982    // Add user agent if configured
2983    if let Some(ref user_agent) = configuration.user_agent {
2984        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2985    }
2986
2987    // Apply all header parameters
2988    for (header_name, header_value) in header_params {
2989        req_builder = req_builder.header(&header_name, &header_value);
2990    }
2991
2992
2993    let req = req_builder.build()?;
2994    let resp = configuration.client.execute(req).await?;
2995
2996    let status = resp.status();
2997    let content_type = resp
2998        .headers()
2999        .get("content-type")
3000        .and_then(|v| v.to_str().ok())
3001        .unwrap_or("application/octet-stream");
3002    let content_type = super::ContentType::from(content_type);
3003
3004    if !status.is_client_error() && !status.is_server_error() {
3005        let content = resp.text().await?;
3006        match content_type {
3007            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3008            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAvgPriceV3Resp`"))),
3009            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::GetAvgPriceV3Resp`")))),
3010        }
3011    } else {
3012        let content = resp.text().await?;
3013        let entity: Option<GetAvgPriceV3Error> = serde_json::from_str(&content).ok();
3014        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3015    }
3016}
3017
3018pub async fn get_depth_v3(configuration: &configuration::Configuration, params: GetDepthV3Params) -> Result<models::GetDepthV3Resp, Error<GetDepthV3Error>> {
3019
3020    let uri_str = format!("{}/api/v3/depth", configuration.base_path);
3021    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3022
3023    // Create a mutable vector for query parameters
3024    let mut query_params: Vec<(String, String)> = Vec::new();
3025
3026    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3027    if let Some(ref param_value) = params.limit {
3028        query_params.push(("limit".to_string(), param_value.to_string()));
3029    }
3030
3031    // Create header parameters collection
3032    let mut header_params = std::collections::HashMap::new();
3033
3034    // Handle Binance Auth first if configured
3035    if let Some(ref binance_auth) = configuration.binance_auth {
3036        // Add API key to headers
3037        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3038        
3039        // Generate request body for signing (if any)
3040        let body_string: Option<Vec<u8>> = None;
3041        
3042        // Sign the request
3043        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3044            Ok(sig) => sig,
3045            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3046        };
3047        
3048        // Add signature to query params
3049        query_params.push(("signature".to_string(), signature));
3050    }
3051
3052    // Apply all query parameters
3053    if !query_params.is_empty() {
3054        req_builder = req_builder.query(&query_params);
3055    }
3056
3057
3058    // Add user agent if configured
3059    if let Some(ref user_agent) = configuration.user_agent {
3060        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3061    }
3062
3063    // Apply all header parameters
3064    for (header_name, header_value) in header_params {
3065        req_builder = req_builder.header(&header_name, &header_value);
3066    }
3067
3068
3069    let req = req_builder.build()?;
3070    let resp = configuration.client.execute(req).await?;
3071
3072    let status = resp.status();
3073    let content_type = resp
3074        .headers()
3075        .get("content-type")
3076        .and_then(|v| v.to_str().ok())
3077        .unwrap_or("application/octet-stream");
3078    let content_type = super::ContentType::from(content_type);
3079
3080    if !status.is_client_error() && !status.is_server_error() {
3081        let content = resp.text().await?;
3082        match content_type {
3083            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3084            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetDepthV3Resp`"))),
3085            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetDepthV3Resp`")))),
3086        }
3087    } else {
3088        let content = resp.text().await?;
3089        let entity: Option<GetDepthV3Error> = serde_json::from_str(&content).ok();
3090        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3091    }
3092}
3093
3094/// Current exchange trading rules and symbol information
3095pub async fn get_exchange_info_v3(configuration: &configuration::Configuration, params: GetExchangeInfoV3Params) -> Result<models::SpotGetExchangeInfoV3Resp, Error<GetExchangeInfoV3Error>> {
3096
3097    let uri_str = format!("{}/api/v3/exchangeInfo", configuration.base_path);
3098    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3099
3100    // Create a mutable vector for query parameters
3101    let mut query_params: Vec<(String, String)> = Vec::new();
3102
3103    if let Some(ref param_value) = params.symbol {
3104        query_params.push(("symbol".to_string(), param_value.to_string()));
3105    }
3106    if let Some(ref param_value) = params.symbols {
3107        match "multi" {
3108            "multi" => {
3109                for p in param_value {
3110                    query_params.push(("symbols".to_string(), p.to_string()));
3111                }
3112            },
3113            _ => {
3114                let joined = param_value.iter()
3115                    .map(|p| p.to_string())
3116                    .collect::<Vec<String>>()
3117                    .join(",");
3118                query_params.push(("symbols".to_string(), joined));
3119            }
3120        };
3121    }
3122    if let Some(ref param_value) = params.permissions {
3123        query_params.push(("permissions".to_string(), param_value.to_string()));
3124    }
3125    if let Some(ref param_value) = params.show_permission_sets {
3126        query_params.push(("showPermissionSets".to_string(), param_value.to_string()));
3127    }
3128    if let Some(ref param_value) = params.symbol_status {
3129        query_params.push(("symbolStatus".to_string(), param_value.to_string()));
3130    }
3131
3132    // Create header parameters collection
3133    let mut header_params = std::collections::HashMap::new();
3134
3135    // Handle Binance Auth first if configured
3136    if let Some(ref binance_auth) = configuration.binance_auth {
3137        // Add API key to headers
3138        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3139        
3140        // Generate request body for signing (if any)
3141        let body_string: Option<Vec<u8>> = None;
3142        
3143        // Sign the request
3144        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3145            Ok(sig) => sig,
3146            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3147        };
3148        
3149        // Add signature to query params
3150        query_params.push(("signature".to_string(), signature));
3151    }
3152
3153    // Apply all query parameters
3154    if !query_params.is_empty() {
3155        req_builder = req_builder.query(&query_params);
3156    }
3157
3158
3159    // Add user agent if configured
3160    if let Some(ref user_agent) = configuration.user_agent {
3161        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3162    }
3163
3164    // Apply all header parameters
3165    for (header_name, header_value) in header_params {
3166        req_builder = req_builder.header(&header_name, &header_value);
3167    }
3168
3169
3170    let req = req_builder.build()?;
3171    let resp = configuration.client.execute(req).await?;
3172
3173    let status = resp.status();
3174    let content_type = resp
3175        .headers()
3176        .get("content-type")
3177        .and_then(|v| v.to_str().ok())
3178        .unwrap_or("application/octet-stream");
3179    let content_type = super::ContentType::from(content_type);
3180
3181    if !status.is_client_error() && !status.is_server_error() {
3182        let content = resp.text().await?;
3183        match content_type {
3184            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3185            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetExchangeInfoV3Resp`"))),
3186            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::SpotGetExchangeInfoV3Resp`")))),
3187        }
3188    } else {
3189        let content = resp.text().await?;
3190        let entity: Option<GetExchangeInfoV3Error> = serde_json::from_str(&content).ok();
3191        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3192    }
3193}
3194
3195/// Get older trades.
3196pub async fn get_historical_trades_v3(configuration: &configuration::Configuration, params: GetHistoricalTradesV3Params) -> Result<Vec<models::GetHistoricalTradesV3RespItem>, Error<GetHistoricalTradesV3Error>> {
3197
3198    let uri_str = format!("{}/api/v3/historicalTrades", configuration.base_path);
3199    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3200
3201    // Create a mutable vector for query parameters
3202    let mut query_params: Vec<(String, String)> = Vec::new();
3203
3204    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3205    if let Some(ref param_value) = params.limit {
3206        query_params.push(("limit".to_string(), param_value.to_string()));
3207    }
3208    if let Some(ref param_value) = params.from_id {
3209        query_params.push(("fromId".to_string(), param_value.to_string()));
3210    }
3211
3212    // Create header parameters collection
3213    let mut header_params = std::collections::HashMap::new();
3214
3215    // Handle Binance Auth first if configured
3216    if let Some(ref binance_auth) = configuration.binance_auth {
3217        // Add API key to headers
3218        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3219        
3220        // Generate request body for signing (if any)
3221        let body_string: Option<Vec<u8>> = None;
3222        
3223        // Sign the request
3224        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3225            Ok(sig) => sig,
3226            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3227        };
3228        
3229        // Add signature to query params
3230        query_params.push(("signature".to_string(), signature));
3231    }
3232
3233    // Apply all query parameters
3234    if !query_params.is_empty() {
3235        req_builder = req_builder.query(&query_params);
3236    }
3237
3238
3239    // Add user agent if configured
3240    if let Some(ref user_agent) = configuration.user_agent {
3241        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3242    }
3243
3244    // Apply all header parameters
3245    for (header_name, header_value) in header_params {
3246        req_builder = req_builder.header(&header_name, &header_value);
3247    }
3248
3249
3250    let req = req_builder.build()?;
3251    let resp = configuration.client.execute(req).await?;
3252
3253    let status = resp.status();
3254    let content_type = resp
3255        .headers()
3256        .get("content-type")
3257        .and_then(|v| v.to_str().ok())
3258        .unwrap_or("application/octet-stream");
3259    let content_type = super::ContentType::from(content_type);
3260
3261    if !status.is_client_error() && !status.is_server_error() {
3262        let content = resp.text().await?;
3263        match content_type {
3264            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3265            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetHistoricalTradesV3RespItem&gt;`"))),
3266            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::GetHistoricalTradesV3RespItem&gt;`")))),
3267        }
3268    } else {
3269        let content = resp.text().await?;
3270        let entity: Option<GetHistoricalTradesV3Error> = serde_json::from_str(&content).ok();
3271        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3272    }
3273}
3274
3275/// Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
3276pub async fn get_klines_v3(configuration: &configuration::Configuration, params: GetKlinesV3Params) -> Result<Vec<Vec<models::GetKlinesV3200ResponseInnerInner>>, Error<GetKlinesV3Error>> {
3277
3278    let uri_str = format!("{}/api/v3/klines", configuration.base_path);
3279    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3280
3281    // Create a mutable vector for query parameters
3282    let mut query_params: Vec<(String, String)> = Vec::new();
3283
3284    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3285    query_params.push(("interval".to_string(), params.interval.to_string()));
3286    if let Some(ref param_value) = params.start_time {
3287        query_params.push(("startTime".to_string(), param_value.to_string()));
3288    }
3289    if let Some(ref param_value) = params.end_time {
3290        query_params.push(("endTime".to_string(), param_value.to_string()));
3291    }
3292    if let Some(ref param_value) = params.time_zone {
3293        query_params.push(("timeZone".to_string(), param_value.to_string()));
3294    }
3295    if let Some(ref param_value) = params.limit {
3296        query_params.push(("limit".to_string(), param_value.to_string()));
3297    }
3298
3299    // Create header parameters collection
3300    let mut header_params = std::collections::HashMap::new();
3301
3302    // Handle Binance Auth first if configured
3303    if let Some(ref binance_auth) = configuration.binance_auth {
3304        // Add API key to headers
3305        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3306        
3307        // Generate request body for signing (if any)
3308        let body_string: Option<Vec<u8>> = None;
3309        
3310        // Sign the request
3311        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3312            Ok(sig) => sig,
3313            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3314        };
3315        
3316        // Add signature to query params
3317        query_params.push(("signature".to_string(), signature));
3318    }
3319
3320    // Apply all query parameters
3321    if !query_params.is_empty() {
3322        req_builder = req_builder.query(&query_params);
3323    }
3324
3325
3326    // Add user agent if configured
3327    if let Some(ref user_agent) = configuration.user_agent {
3328        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3329    }
3330
3331    // Apply all header parameters
3332    for (header_name, header_value) in header_params {
3333        req_builder = req_builder.header(&header_name, &header_value);
3334    }
3335
3336
3337    let req = req_builder.build()?;
3338    let resp = configuration.client.execute(req).await?;
3339
3340    let status = resp.status();
3341    let content_type = resp
3342        .headers()
3343        .get("content-type")
3344        .and_then(|v| v.to_str().ok())
3345        .unwrap_or("application/octet-stream");
3346    let content_type = super::ContentType::from(content_type);
3347
3348    if !status.is_client_error() && !status.is_server_error() {
3349        let content = resp.text().await?;
3350        match content_type {
3351            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3352            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;Vec&lt;models::GetKlinesV3200ResponseInnerInner&gt;&gt;`"))),
3353            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;Vec&lt;models::GetKlinesV3200ResponseInnerInner&gt;&gt;`")))),
3354        }
3355    } else {
3356        let content = resp.text().await?;
3357        let entity: Option<GetKlinesV3Error> = serde_json::from_str(&content).ok();
3358        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3359    }
3360}
3361
3362/// Retrieves allocations resulting from SOR order placement.
3363pub async fn get_my_allocations_v3(configuration: &configuration::Configuration, params: GetMyAllocationsV3Params) -> Result<Vec<models::GetMyAllocationsV3RespItem>, Error<GetMyAllocationsV3Error>> {
3364
3365    let uri_str = format!("{}/api/v3/myAllocations", configuration.base_path);
3366    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3367
3368    // Create a mutable vector for query parameters
3369    let mut query_params: Vec<(String, String)> = Vec::new();
3370
3371    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3372    if let Some(ref param_value) = params.start_time {
3373        query_params.push(("startTime".to_string(), param_value.to_string()));
3374    }
3375    if let Some(ref param_value) = params.end_time {
3376        query_params.push(("endTime".to_string(), param_value.to_string()));
3377    }
3378    if let Some(ref param_value) = params.from_allocation_id {
3379        query_params.push(("fromAllocationId".to_string(), param_value.to_string()));
3380    }
3381    if let Some(ref param_value) = params.limit {
3382        query_params.push(("limit".to_string(), param_value.to_string()));
3383    }
3384    if let Some(ref param_value) = params.order_id {
3385        query_params.push(("orderId".to_string(), param_value.to_string()));
3386    }
3387    if let Some(ref param_value) = params.recv_window {
3388        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3389    }
3390    if let Some(ref param_value) = params.timestamp {
3391        query_params.push(("timestamp".to_string(), param_value.to_string()));
3392    }
3393
3394    // Create header parameters collection
3395    let mut header_params = std::collections::HashMap::new();
3396
3397    // Handle Binance Auth first if configured
3398    if let Some(ref binance_auth) = configuration.binance_auth {
3399        // Add API key to headers
3400        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3401        
3402        // Generate request body for signing (if any)
3403        let body_string: Option<Vec<u8>> = None;
3404        
3405        // Sign the request
3406        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3407            Ok(sig) => sig,
3408            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3409        };
3410        
3411        // Add signature to query params
3412        query_params.push(("signature".to_string(), signature));
3413    }
3414
3415    // Apply all query parameters
3416    if !query_params.is_empty() {
3417        req_builder = req_builder.query(&query_params);
3418    }
3419
3420
3421    // Add user agent if configured
3422    if let Some(ref user_agent) = configuration.user_agent {
3423        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3424    }
3425
3426    // Apply all header parameters
3427    for (header_name, header_value) in header_params {
3428        req_builder = req_builder.header(&header_name, &header_value);
3429    }
3430
3431
3432    let req = req_builder.build()?;
3433    let resp = configuration.client.execute(req).await?;
3434
3435    let status = resp.status();
3436    let content_type = resp
3437        .headers()
3438        .get("content-type")
3439        .and_then(|v| v.to_str().ok())
3440        .unwrap_or("application/octet-stream");
3441    let content_type = super::ContentType::from(content_type);
3442
3443    if !status.is_client_error() && !status.is_server_error() {
3444        let content = resp.text().await?;
3445        match content_type {
3446            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3447            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMyAllocationsV3RespItem&gt;`"))),
3448            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::GetMyAllocationsV3RespItem&gt;`")))),
3449        }
3450    } else {
3451        let content = resp.text().await?;
3452        let entity: Option<GetMyAllocationsV3Error> = serde_json::from_str(&content).ok();
3453        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3454    }
3455}
3456
3457/// Displays the list of orders that were expired due to STP. These are the combinations supported: - symbol + preventedMatchId - symbol + orderId - symbol + orderId + fromPreventedMatchId (limit will default to 500) - symbol + orderId + fromPreventedMatchId + limit
3458pub async fn get_my_prevented_matches_v3(configuration: &configuration::Configuration, params: GetMyPreventedMatchesV3Params) -> Result<Vec<models::GetMyPreventedMatchesV3RespItem>, Error<GetMyPreventedMatchesV3Error>> {
3459
3460    let uri_str = format!("{}/api/v3/myPreventedMatches", configuration.base_path);
3461    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3462
3463    // Create a mutable vector for query parameters
3464    let mut query_params: Vec<(String, String)> = Vec::new();
3465
3466    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3467    if let Some(ref param_value) = params.prevented_match_id {
3468        query_params.push(("preventedMatchId".to_string(), param_value.to_string()));
3469    }
3470    if let Some(ref param_value) = params.order_id {
3471        query_params.push(("orderId".to_string(), param_value.to_string()));
3472    }
3473    if let Some(ref param_value) = params.from_prevented_match_id {
3474        query_params.push(("fromPreventedMatchId".to_string(), param_value.to_string()));
3475    }
3476    if let Some(ref param_value) = params.limit {
3477        query_params.push(("limit".to_string(), param_value.to_string()));
3478    }
3479    if let Some(ref param_value) = params.recv_window {
3480        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3481    }
3482    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3483
3484    // Create header parameters collection
3485    let mut header_params = std::collections::HashMap::new();
3486
3487    // Handle Binance Auth first if configured
3488    if let Some(ref binance_auth) = configuration.binance_auth {
3489        // Add API key to headers
3490        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3491        
3492        // Generate request body for signing (if any)
3493        let body_string: Option<Vec<u8>> = None;
3494        
3495        // Sign the request
3496        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3497            Ok(sig) => sig,
3498            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3499        };
3500        
3501        // Add signature to query params
3502        query_params.push(("signature".to_string(), signature));
3503    }
3504
3505    // Apply all query parameters
3506    if !query_params.is_empty() {
3507        req_builder = req_builder.query(&query_params);
3508    }
3509
3510
3511    // Add user agent if configured
3512    if let Some(ref user_agent) = configuration.user_agent {
3513        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3514    }
3515
3516    // Apply all header parameters
3517    for (header_name, header_value) in header_params {
3518        req_builder = req_builder.header(&header_name, &header_value);
3519    }
3520
3521
3522    let req = req_builder.build()?;
3523    let resp = configuration.client.execute(req).await?;
3524
3525    let status = resp.status();
3526    let content_type = resp
3527        .headers()
3528        .get("content-type")
3529        .and_then(|v| v.to_str().ok())
3530        .unwrap_or("application/octet-stream");
3531    let content_type = super::ContentType::from(content_type);
3532
3533    if !status.is_client_error() && !status.is_server_error() {
3534        let content = resp.text().await?;
3535        match content_type {
3536            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3537            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMyPreventedMatchesV3RespItem&gt;`"))),
3538            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::GetMyPreventedMatchesV3RespItem&gt;`")))),
3539        }
3540    } else {
3541        let content = resp.text().await?;
3542        let entity: Option<GetMyPreventedMatchesV3Error> = serde_json::from_str(&content).ok();
3543        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3544    }
3545}
3546
3547/// Get trades for a specific account and symbol.
3548pub async fn get_my_trades_v3(configuration: &configuration::Configuration, params: GetMyTradesV3Params) -> Result<Vec<models::GetMyTradesV3RespItem>, Error<GetMyTradesV3Error>> {
3549
3550    let uri_str = format!("{}/api/v3/myTrades", configuration.base_path);
3551    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3552
3553    // Create a mutable vector for query parameters
3554    let mut query_params: Vec<(String, String)> = Vec::new();
3555
3556    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3557    if let Some(ref param_value) = params.order_id {
3558        query_params.push(("orderId".to_string(), param_value.to_string()));
3559    }
3560    if let Some(ref param_value) = params.start_time {
3561        query_params.push(("startTime".to_string(), param_value.to_string()));
3562    }
3563    if let Some(ref param_value) = params.end_time {
3564        query_params.push(("endTime".to_string(), param_value.to_string()));
3565    }
3566    if let Some(ref param_value) = params.from_id {
3567        query_params.push(("fromId".to_string(), param_value.to_string()));
3568    }
3569    if let Some(ref param_value) = params.limit {
3570        query_params.push(("limit".to_string(), param_value.to_string()));
3571    }
3572    if let Some(ref param_value) = params.recv_window {
3573        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3574    }
3575    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3576
3577    // Create header parameters collection
3578    let mut header_params = std::collections::HashMap::new();
3579
3580    // Handle Binance Auth first if configured
3581    if let Some(ref binance_auth) = configuration.binance_auth {
3582        // Add API key to headers
3583        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3584        
3585        // Generate request body for signing (if any)
3586        let body_string: Option<Vec<u8>> = None;
3587        
3588        // Sign the request
3589        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3590            Ok(sig) => sig,
3591            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3592        };
3593        
3594        // Add signature to query params
3595        query_params.push(("signature".to_string(), signature));
3596    }
3597
3598    // Apply all query parameters
3599    if !query_params.is_empty() {
3600        req_builder = req_builder.query(&query_params);
3601    }
3602
3603
3604    // Add user agent if configured
3605    if let Some(ref user_agent) = configuration.user_agent {
3606        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3607    }
3608
3609    // Apply all header parameters
3610    for (header_name, header_value) in header_params {
3611        req_builder = req_builder.header(&header_name, &header_value);
3612    }
3613
3614
3615    let req = req_builder.build()?;
3616    let resp = configuration.client.execute(req).await?;
3617
3618    let status = resp.status();
3619    let content_type = resp
3620        .headers()
3621        .get("content-type")
3622        .and_then(|v| v.to_str().ok())
3623        .unwrap_or("application/octet-stream");
3624    let content_type = super::ContentType::from(content_type);
3625
3626    if !status.is_client_error() && !status.is_server_error() {
3627        let content = resp.text().await?;
3628        match content_type {
3629            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3630            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetMyTradesV3RespItem&gt;`"))),
3631            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::GetMyTradesV3RespItem&gt;`")))),
3632        }
3633    } else {
3634        let content = resp.text().await?;
3635        let entity: Option<GetMyTradesV3Error> = serde_json::from_str(&content).ok();
3636        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3637    }
3638}
3639
3640pub async fn get_open_order_list_v3(configuration: &configuration::Configuration, params: GetOpenOrderListV3Params) -> Result<Vec<models::GetOpenOrderListV3RespItem>, Error<GetOpenOrderListV3Error>> {
3641
3642    let uri_str = format!("{}/api/v3/openOrderList", configuration.base_path);
3643    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3644
3645    // Create a mutable vector for query parameters
3646    let mut query_params: Vec<(String, String)> = Vec::new();
3647
3648    if let Some(ref param_value) = params.recv_window {
3649        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3650    }
3651    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3652
3653    // Create header parameters collection
3654    let mut header_params = std::collections::HashMap::new();
3655
3656    // Handle Binance Auth first if configured
3657    if let Some(ref binance_auth) = configuration.binance_auth {
3658        // Add API key to headers
3659        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3660        
3661        // Generate request body for signing (if any)
3662        let body_string: Option<Vec<u8>> = None;
3663        
3664        // Sign the request
3665        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3666            Ok(sig) => sig,
3667            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3668        };
3669        
3670        // Add signature to query params
3671        query_params.push(("signature".to_string(), signature));
3672    }
3673
3674    // Apply all query parameters
3675    if !query_params.is_empty() {
3676        req_builder = req_builder.query(&query_params);
3677    }
3678
3679
3680    // Add user agent if configured
3681    if let Some(ref user_agent) = configuration.user_agent {
3682        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3683    }
3684
3685    // Apply all header parameters
3686    for (header_name, header_value) in header_params {
3687        req_builder = req_builder.header(&header_name, &header_value);
3688    }
3689
3690
3691    let req = req_builder.build()?;
3692    let resp = configuration.client.execute(req).await?;
3693
3694    let status = resp.status();
3695    let content_type = resp
3696        .headers()
3697        .get("content-type")
3698        .and_then(|v| v.to_str().ok())
3699        .unwrap_or("application/octet-stream");
3700    let content_type = super::ContentType::from(content_type);
3701
3702    if !status.is_client_error() && !status.is_server_error() {
3703        let content = resp.text().await?;
3704        match content_type {
3705            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3706            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetOpenOrderListV3RespItem&gt;`"))),
3707            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::GetOpenOrderListV3RespItem&gt;`")))),
3708        }
3709    } else {
3710        let content = resp.text().await?;
3711        let entity: Option<GetOpenOrderListV3Error> = serde_json::from_str(&content).ok();
3712        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3713    }
3714}
3715
3716/// Get all open orders on a symbol. Careful when accessing this with no symbol. Weight: 6 for a single symbol; 80 when the symbol parameter is omitted
3717pub async fn get_open_orders_v3(configuration: &configuration::Configuration, params: GetOpenOrdersV3Params) -> Result<Vec<models::GetOpenOrdersV3RespItem>, Error<GetOpenOrdersV3Error>> {
3718
3719    let uri_str = format!("{}/api/v3/openOrders", configuration.base_path);
3720    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3721
3722    // Create a mutable vector for query parameters
3723    let mut query_params: Vec<(String, String)> = Vec::new();
3724
3725    if let Some(ref param_value) = params.symbol {
3726        query_params.push(("symbol".to_string(), param_value.to_string()));
3727    }
3728    if let Some(ref param_value) = params.recv_window {
3729        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3730    }
3731    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3732
3733    // Create header parameters collection
3734    let mut header_params = std::collections::HashMap::new();
3735
3736    // Handle Binance Auth first if configured
3737    if let Some(ref binance_auth) = configuration.binance_auth {
3738        // Add API key to headers
3739        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3740        
3741        // Generate request body for signing (if any)
3742        let body_string: Option<Vec<u8>> = None;
3743        
3744        // Sign the request
3745        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3746            Ok(sig) => sig,
3747            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3748        };
3749        
3750        // Add signature to query params
3751        query_params.push(("signature".to_string(), signature));
3752    }
3753
3754    // Apply all query parameters
3755    if !query_params.is_empty() {
3756        req_builder = req_builder.query(&query_params);
3757    }
3758
3759
3760    // Add user agent if configured
3761    if let Some(ref user_agent) = configuration.user_agent {
3762        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3763    }
3764
3765    // Apply all header parameters
3766    for (header_name, header_value) in header_params {
3767        req_builder = req_builder.header(&header_name, &header_value);
3768    }
3769
3770
3771    let req = req_builder.build()?;
3772    let resp = configuration.client.execute(req).await?;
3773
3774    let status = resp.status();
3775    let content_type = resp
3776        .headers()
3777        .get("content-type")
3778        .and_then(|v| v.to_str().ok())
3779        .unwrap_or("application/octet-stream");
3780    let content_type = super::ContentType::from(content_type);
3781
3782    if !status.is_client_error() && !status.is_server_error() {
3783        let content = resp.text().await?;
3784        match content_type {
3785            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3786            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetOpenOrdersV3RespItem&gt;`"))),
3787            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::GetOpenOrdersV3RespItem&gt;`")))),
3788        }
3789    } else {
3790        let content = resp.text().await?;
3791        let entity: Option<GetOpenOrdersV3Error> = serde_json::from_str(&content).ok();
3792        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3793    }
3794}
3795
3796/// Retrieves a specific order list based on provided optional parameters.
3797pub async fn get_order_list_v3(configuration: &configuration::Configuration, params: GetOrderListV3Params) -> Result<models::GetOrderListV3Resp, Error<GetOrderListV3Error>> {
3798
3799    let uri_str = format!("{}/api/v3/orderList", configuration.base_path);
3800    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3801
3802    // Create a mutable vector for query parameters
3803    let mut query_params: Vec<(String, String)> = Vec::new();
3804
3805    if let Some(ref param_value) = params.order_list_id {
3806        query_params.push(("orderListId".to_string(), param_value.to_string()));
3807    }
3808    if let Some(ref param_value) = params.orig_client_order_id {
3809        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
3810    }
3811    if let Some(ref param_value) = params.recv_window {
3812        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3813    }
3814    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3815
3816    // Create header parameters collection
3817    let mut header_params = std::collections::HashMap::new();
3818
3819    // Handle Binance Auth first if configured
3820    if let Some(ref binance_auth) = configuration.binance_auth {
3821        // Add API key to headers
3822        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3823        
3824        // Generate request body for signing (if any)
3825        let body_string: Option<Vec<u8>> = None;
3826        
3827        // Sign the request
3828        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3829            Ok(sig) => sig,
3830            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3831        };
3832        
3833        // Add signature to query params
3834        query_params.push(("signature".to_string(), signature));
3835    }
3836
3837    // Apply all query parameters
3838    if !query_params.is_empty() {
3839        req_builder = req_builder.query(&query_params);
3840    }
3841
3842
3843    // Add user agent if configured
3844    if let Some(ref user_agent) = configuration.user_agent {
3845        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3846    }
3847
3848    // Apply all header parameters
3849    for (header_name, header_value) in header_params {
3850        req_builder = req_builder.header(&header_name, &header_value);
3851    }
3852
3853
3854    let req = req_builder.build()?;
3855    let resp = configuration.client.execute(req).await?;
3856
3857    let status = resp.status();
3858    let content_type = resp
3859        .headers()
3860        .get("content-type")
3861        .and_then(|v| v.to_str().ok())
3862        .unwrap_or("application/octet-stream");
3863    let content_type = super::ContentType::from(content_type);
3864
3865    if !status.is_client_error() && !status.is_server_error() {
3866        let content = resp.text().await?;
3867        match content_type {
3868            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3869            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrderListV3Resp`"))),
3870            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::GetOrderListV3Resp`")))),
3871        }
3872    } else {
3873        let content = resp.text().await?;
3874        let entity: Option<GetOrderListV3Error> = serde_json::from_str(&content).ok();
3875        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3876    }
3877}
3878
3879/// Check an order's status.
3880pub async fn get_order_v3(configuration: &configuration::Configuration, params: GetOrderV3Params) -> Result<models::GetOrderV3Resp, Error<GetOrderV3Error>> {
3881
3882    let uri_str = format!("{}/api/v3/order", configuration.base_path);
3883    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3884
3885    // Create a mutable vector for query parameters
3886    let mut query_params: Vec<(String, String)> = Vec::new();
3887
3888    query_params.push(("symbol".to_string(), params.symbol.to_string()));
3889    if let Some(ref param_value) = params.order_id {
3890        query_params.push(("orderId".to_string(), param_value.to_string()));
3891    }
3892    if let Some(ref param_value) = params.orig_client_order_id {
3893        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
3894    }
3895    if let Some(ref param_value) = params.recv_window {
3896        query_params.push(("recvWindow".to_string(), param_value.to_string()));
3897    }
3898    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3899
3900    // Create header parameters collection
3901    let mut header_params = std::collections::HashMap::new();
3902
3903    // Handle Binance Auth first if configured
3904    if let Some(ref binance_auth) = configuration.binance_auth {
3905        // Add API key to headers
3906        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3907        
3908        // Generate request body for signing (if any)
3909        let body_string: Option<Vec<u8>> = None;
3910        
3911        // Sign the request
3912        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3913            Ok(sig) => sig,
3914            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3915        };
3916        
3917        // Add signature to query params
3918        query_params.push(("signature".to_string(), signature));
3919    }
3920
3921    // Apply all query parameters
3922    if !query_params.is_empty() {
3923        req_builder = req_builder.query(&query_params);
3924    }
3925
3926
3927    // Add user agent if configured
3928    if let Some(ref user_agent) = configuration.user_agent {
3929        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3930    }
3931
3932    // Apply all header parameters
3933    for (header_name, header_value) in header_params {
3934        req_builder = req_builder.header(&header_name, &header_value);
3935    }
3936
3937
3938    let req = req_builder.build()?;
3939    let resp = configuration.client.execute(req).await?;
3940
3941    let status = resp.status();
3942    let content_type = resp
3943        .headers()
3944        .get("content-type")
3945        .and_then(|v| v.to_str().ok())
3946        .unwrap_or("application/octet-stream");
3947    let content_type = super::ContentType::from(content_type);
3948
3949    if !status.is_client_error() && !status.is_server_error() {
3950        let content = resp.text().await?;
3951        match content_type {
3952            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3953            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrderV3Resp`"))),
3954            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::GetOrderV3Resp`")))),
3955        }
3956    } else {
3957        let content = resp.text().await?;
3958        let entity: Option<GetOrderV3Error> = serde_json::from_str(&content).ok();
3959        Err(Error::ResponseError(ResponseContent { status, content, entity }))
3960    }
3961}
3962
3963/// Test connectivity to the Rest API.
3964pub async fn get_ping_v3(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<GetPingV3Error>> {
3965
3966    let uri_str = format!("{}/api/v3/ping", configuration.base_path);
3967    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3968
3969    // Create a mutable vector for query parameters
3970    let mut query_params: Vec<(String, String)> = Vec::new();
3971
3972
3973    // Create header parameters collection
3974    let mut header_params = std::collections::HashMap::new();
3975
3976    // Handle Binance Auth first if configured
3977    if let Some(ref binance_auth) = configuration.binance_auth {
3978        // Add API key to headers
3979        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3980        
3981        // Generate request body for signing (if any)
3982        let body_string: Option<Vec<u8>> = None;
3983        
3984        // Sign the request
3985        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3986            Ok(sig) => sig,
3987            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3988        };
3989        
3990        // Add signature to query params
3991        query_params.push(("signature".to_string(), signature));
3992    }
3993
3994    // Apply all query parameters
3995    if !query_params.is_empty() {
3996        req_builder = req_builder.query(&query_params);
3997    }
3998
3999
4000    // Add user agent if configured
4001    if let Some(ref user_agent) = configuration.user_agent {
4002        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4003    }
4004
4005    // Apply all header parameters
4006    for (header_name, header_value) in header_params {
4007        req_builder = req_builder.header(&header_name, &header_value);
4008    }
4009
4010
4011    let req = req_builder.build()?;
4012    let resp = configuration.client.execute(req).await?;
4013
4014    let status = resp.status();
4015    let content_type = resp
4016        .headers()
4017        .get("content-type")
4018        .and_then(|v| v.to_str().ok())
4019        .unwrap_or("application/octet-stream");
4020    let content_type = super::ContentType::from(content_type);
4021
4022    if !status.is_client_error() && !status.is_server_error() {
4023        let content = resp.text().await?;
4024        match content_type {
4025            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4026            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
4027            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
4028        }
4029    } else {
4030        let content = resp.text().await?;
4031        let entity: Option<GetPingV3Error> = serde_json::from_str(&content).ok();
4032        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4033    }
4034}
4035
4036/// Displays the user's unfilled order count for all intervals.
4037pub async fn get_rate_limit_order_v3(configuration: &configuration::Configuration, params: GetRateLimitOrderV3Params) -> Result<Vec<models::GetRateLimitOrderV3RespItem>, Error<GetRateLimitOrderV3Error>> {
4038
4039    let uri_str = format!("{}/api/v3/rateLimit/order", configuration.base_path);
4040    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4041
4042    // Create a mutable vector for query parameters
4043    let mut query_params: Vec<(String, String)> = Vec::new();
4044
4045    if let Some(ref param_value) = params.recv_window {
4046        query_params.push(("recvWindow".to_string(), param_value.to_string()));
4047    }
4048    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4049
4050    // Create header parameters collection
4051    let mut header_params = std::collections::HashMap::new();
4052
4053    // Handle Binance Auth first if configured
4054    if let Some(ref binance_auth) = configuration.binance_auth {
4055        // Add API key to headers
4056        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4057        
4058        // Generate request body for signing (if any)
4059        let body_string: Option<Vec<u8>> = None;
4060        
4061        // Sign the request
4062        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4063            Ok(sig) => sig,
4064            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4065        };
4066        
4067        // Add signature to query params
4068        query_params.push(("signature".to_string(), signature));
4069    }
4070
4071    // Apply all query parameters
4072    if !query_params.is_empty() {
4073        req_builder = req_builder.query(&query_params);
4074    }
4075
4076
4077    // Add user agent if configured
4078    if let Some(ref user_agent) = configuration.user_agent {
4079        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4080    }
4081
4082    // Apply all header parameters
4083    for (header_name, header_value) in header_params {
4084        req_builder = req_builder.header(&header_name, &header_value);
4085    }
4086
4087
4088    let req = req_builder.build()?;
4089    let resp = configuration.client.execute(req).await?;
4090
4091    let status = resp.status();
4092    let content_type = resp
4093        .headers()
4094        .get("content-type")
4095        .and_then(|v| v.to_str().ok())
4096        .unwrap_or("application/octet-stream");
4097    let content_type = super::ContentType::from(content_type);
4098
4099    if !status.is_client_error() && !status.is_server_error() {
4100        let content = resp.text().await?;
4101        match content_type {
4102            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4103            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetRateLimitOrderV3RespItem&gt;`"))),
4104            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::GetRateLimitOrderV3RespItem&gt;`")))),
4105        }
4106    } else {
4107        let content = resp.text().await?;
4108        let entity: Option<GetRateLimitOrderV3Error> = serde_json::from_str(&content).ok();
4109        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4110    }
4111}
4112
4113/// 24 hour rolling window price change statistics. Careful when accessing this with no symbol.
4114pub async fn get_ticker24hr_v3(configuration: &configuration::Configuration, params: GetTicker24hrV3Params) -> Result<models::SpotGetTicker24hrV3Resp, Error<GetTicker24hrV3Error>> {
4115
4116    let uri_str = format!("{}/api/v3/ticker/24hr", configuration.base_path);
4117    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4118
4119    // Create a mutable vector for query parameters
4120    let mut query_params: Vec<(String, String)> = Vec::new();
4121
4122    if let Some(ref param_value) = params.symbol {
4123        query_params.push(("symbol".to_string(), param_value.to_string()));
4124    }
4125    if let Some(ref param_value) = params.symbols {
4126        query_params.push(("symbols".to_string(), param_value.to_string()));
4127    }
4128    if let Some(ref param_value) = params.r#type {
4129        query_params.push(("type".to_string(), param_value.to_string()));
4130    }
4131
4132    // Create header parameters collection
4133    let mut header_params = std::collections::HashMap::new();
4134
4135    // Handle Binance Auth first if configured
4136    if let Some(ref binance_auth) = configuration.binance_auth {
4137        // Add API key to headers
4138        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4139        
4140        // Generate request body for signing (if any)
4141        let body_string: Option<Vec<u8>> = None;
4142        
4143        // Sign the request
4144        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4145            Ok(sig) => sig,
4146            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4147        };
4148        
4149        // Add signature to query params
4150        query_params.push(("signature".to_string(), signature));
4151    }
4152
4153    // Apply all query parameters
4154    if !query_params.is_empty() {
4155        req_builder = req_builder.query(&query_params);
4156    }
4157
4158
4159    // Add user agent if configured
4160    if let Some(ref user_agent) = configuration.user_agent {
4161        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4162    }
4163
4164    // Apply all header parameters
4165    for (header_name, header_value) in header_params {
4166        req_builder = req_builder.header(&header_name, &header_value);
4167    }
4168
4169
4170    let req = req_builder.build()?;
4171    let resp = configuration.client.execute(req).await?;
4172
4173    let status = resp.status();
4174    let content_type = resp
4175        .headers()
4176        .get("content-type")
4177        .and_then(|v| v.to_str().ok())
4178        .unwrap_or("application/octet-stream");
4179    let content_type = super::ContentType::from(content_type);
4180
4181    if !status.is_client_error() && !status.is_server_error() {
4182        let content = resp.text().await?;
4183        match content_type {
4184            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4185            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTicker24hrV3Resp`"))),
4186            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::SpotGetTicker24hrV3Resp`")))),
4187        }
4188    } else {
4189        let content = resp.text().await?;
4190        let entity: Option<GetTicker24hrV3Error> = serde_json::from_str(&content).ok();
4191        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4192    }
4193}
4194
4195/// Best price/qty on the order book for a symbol or symbols.
4196pub async fn get_ticker_book_ticker_v3(configuration: &configuration::Configuration, params: GetTickerBookTickerV3Params) -> Result<models::SpotGetTickerBookTickerV3Resp, Error<GetTickerBookTickerV3Error>> {
4197
4198    let uri_str = format!("{}/api/v3/ticker/bookTicker", configuration.base_path);
4199    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4200
4201    // Create a mutable vector for query parameters
4202    let mut query_params: Vec<(String, String)> = Vec::new();
4203
4204    if let Some(ref param_value) = params.symbol {
4205        query_params.push(("symbol".to_string(), param_value.to_string()));
4206    }
4207    if let Some(ref param_value) = params.symbols {
4208        query_params.push(("symbols".to_string(), param_value.to_string()));
4209    }
4210
4211    // Create header parameters collection
4212    let mut header_params = std::collections::HashMap::new();
4213
4214    // Handle Binance Auth first if configured
4215    if let Some(ref binance_auth) = configuration.binance_auth {
4216        // Add API key to headers
4217        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4218        
4219        // Generate request body for signing (if any)
4220        let body_string: Option<Vec<u8>> = None;
4221        
4222        // Sign the request
4223        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4224            Ok(sig) => sig,
4225            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4226        };
4227        
4228        // Add signature to query params
4229        query_params.push(("signature".to_string(), signature));
4230    }
4231
4232    // Apply all query parameters
4233    if !query_params.is_empty() {
4234        req_builder = req_builder.query(&query_params);
4235    }
4236
4237
4238    // Add user agent if configured
4239    if let Some(ref user_agent) = configuration.user_agent {
4240        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4241    }
4242
4243    // Apply all header parameters
4244    for (header_name, header_value) in header_params {
4245        req_builder = req_builder.header(&header_name, &header_value);
4246    }
4247
4248
4249    let req = req_builder.build()?;
4250    let resp = configuration.client.execute(req).await?;
4251
4252    let status = resp.status();
4253    let content_type = resp
4254        .headers()
4255        .get("content-type")
4256        .and_then(|v| v.to_str().ok())
4257        .unwrap_or("application/octet-stream");
4258    let content_type = super::ContentType::from(content_type);
4259
4260    if !status.is_client_error() && !status.is_server_error() {
4261        let content = resp.text().await?;
4262        match content_type {
4263            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4264            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerBookTickerV3Resp`"))),
4265            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::SpotGetTickerBookTickerV3Resp`")))),
4266        }
4267    } else {
4268        let content = resp.text().await?;
4269        let entity: Option<GetTickerBookTickerV3Error> = serde_json::from_str(&content).ok();
4270        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4271    }
4272}
4273
4274/// Latest price for a symbol or symbols.
4275pub async fn get_ticker_price_v3(configuration: &configuration::Configuration, params: GetTickerPriceV3Params) -> Result<models::SpotGetTickerPriceV3Resp, Error<GetTickerPriceV3Error>> {
4276
4277    let uri_str = format!("{}/api/v3/ticker/price", configuration.base_path);
4278    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4279
4280    // Create a mutable vector for query parameters
4281    let mut query_params: Vec<(String, String)> = Vec::new();
4282
4283    if let Some(ref param_value) = params.symbol {
4284        query_params.push(("symbol".to_string(), param_value.to_string()));
4285    }
4286    if let Some(ref param_value) = params.symbols {
4287        query_params.push(("symbols".to_string(), param_value.to_string()));
4288    }
4289
4290    // Create header parameters collection
4291    let mut header_params = std::collections::HashMap::new();
4292
4293    // Handle Binance Auth first if configured
4294    if let Some(ref binance_auth) = configuration.binance_auth {
4295        // Add API key to headers
4296        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4297        
4298        // Generate request body for signing (if any)
4299        let body_string: Option<Vec<u8>> = None;
4300        
4301        // Sign the request
4302        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4303            Ok(sig) => sig,
4304            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4305        };
4306        
4307        // Add signature to query params
4308        query_params.push(("signature".to_string(), signature));
4309    }
4310
4311    // Apply all query parameters
4312    if !query_params.is_empty() {
4313        req_builder = req_builder.query(&query_params);
4314    }
4315
4316
4317    // Add user agent if configured
4318    if let Some(ref user_agent) = configuration.user_agent {
4319        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4320    }
4321
4322    // Apply all header parameters
4323    for (header_name, header_value) in header_params {
4324        req_builder = req_builder.header(&header_name, &header_value);
4325    }
4326
4327
4328    let req = req_builder.build()?;
4329    let resp = configuration.client.execute(req).await?;
4330
4331    let status = resp.status();
4332    let content_type = resp
4333        .headers()
4334        .get("content-type")
4335        .and_then(|v| v.to_str().ok())
4336        .unwrap_or("application/octet-stream");
4337    let content_type = super::ContentType::from(content_type);
4338
4339    if !status.is_client_error() && !status.is_server_error() {
4340        let content = resp.text().await?;
4341        match content_type {
4342            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4343            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerPriceV3Resp`"))),
4344            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::SpotGetTickerPriceV3Resp`")))),
4345        }
4346    } else {
4347        let content = resp.text().await?;
4348        let entity: Option<GetTickerPriceV3Error> = serde_json::from_str(&content).ok();
4349        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4350    }
4351}
4352
4353/// Price change statistics for a trading day. 4 for each requested symbol.  The weight for this request will cap at 200 once the number of symbols in the request is more than 50.
4354pub async fn get_ticker_trading_day_v3(configuration: &configuration::Configuration, params: GetTickerTradingDayV3Params) -> Result<models::SpotGetTickerTradingDayV3Resp, Error<GetTickerTradingDayV3Error>> {
4355
4356    let uri_str = format!("{}/api/v3/ticker/tradingDay", configuration.base_path);
4357    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4358
4359    // Create a mutable vector for query parameters
4360    let mut query_params: Vec<(String, String)> = Vec::new();
4361
4362    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4363    query_params.push(("symbols".to_string(), params.symbols.to_string()));
4364    if let Some(ref param_value) = params.time_zone {
4365        query_params.push(("timeZone".to_string(), param_value.to_string()));
4366    }
4367    if let Some(ref param_value) = params.r#type {
4368        query_params.push(("type".to_string(), param_value.to_string()));
4369    }
4370
4371    // Create header parameters collection
4372    let mut header_params = std::collections::HashMap::new();
4373
4374    // Handle Binance Auth first if configured
4375    if let Some(ref binance_auth) = configuration.binance_auth {
4376        // Add API key to headers
4377        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4378        
4379        // Generate request body for signing (if any)
4380        let body_string: Option<Vec<u8>> = None;
4381        
4382        // Sign the request
4383        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4384            Ok(sig) => sig,
4385            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4386        };
4387        
4388        // Add signature to query params
4389        query_params.push(("signature".to_string(), signature));
4390    }
4391
4392    // Apply all query parameters
4393    if !query_params.is_empty() {
4394        req_builder = req_builder.query(&query_params);
4395    }
4396
4397
4398    // Add user agent if configured
4399    if let Some(ref user_agent) = configuration.user_agent {
4400        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4401    }
4402
4403    // Apply all header parameters
4404    for (header_name, header_value) in header_params {
4405        req_builder = req_builder.header(&header_name, &header_value);
4406    }
4407
4408
4409    let req = req_builder.build()?;
4410    let resp = configuration.client.execute(req).await?;
4411
4412    let status = resp.status();
4413    let content_type = resp
4414        .headers()
4415        .get("content-type")
4416        .and_then(|v| v.to_str().ok())
4417        .unwrap_or("application/octet-stream");
4418    let content_type = super::ContentType::from(content_type);
4419
4420    if !status.is_client_error() && !status.is_server_error() {
4421        let content = resp.text().await?;
4422        match content_type {
4423            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4424            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerTradingDayV3Resp`"))),
4425            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::SpotGetTickerTradingDayV3Resp`")))),
4426        }
4427    } else {
4428        let content = resp.text().await?;
4429        let entity: Option<GetTickerTradingDayV3Error> = serde_json::from_str(&content).ok();
4430        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4431    }
4432}
4433
4434/// Note: This endpoint is different from the GET /api/v3/ticker/24hr endpoint. The window used to compute statistics will be no more than 59999ms from the requested windowSize. openTime for /api/v3/ticker always starts on a minute, while the closeTime is the current time of the request. As such, the effective window will be up to 59999ms wider than windowSize. E.g. If the closeTime is 1641287867099 (January 04, 2022 09:17:47:099 UTC) , and the windowSize is 1d. the openTime will be: 1641201420000 (January 3, 2022, 09:17:00) 4 for each requested symbol regardless of windowSize.  The weight for this request will cap at 200 once the number of symbols in the request is more than 50.
4435pub async fn get_ticker_v3(configuration: &configuration::Configuration, params: GetTickerV3Params) -> Result<models::SpotGetTickerV3Resp, Error<GetTickerV3Error>> {
4436
4437    let uri_str = format!("{}/api/v3/ticker", configuration.base_path);
4438    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4439
4440    // Create a mutable vector for query parameters
4441    let mut query_params: Vec<(String, String)> = Vec::new();
4442
4443    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4444    query_params.push(("symbols".to_string(), params.symbols.to_string()));
4445    if let Some(ref param_value) = params.window_size {
4446        query_params.push(("windowSize".to_string(), param_value.to_string()));
4447    }
4448    if let Some(ref param_value) = params.r#type {
4449        query_params.push(("type".to_string(), param_value.to_string()));
4450    }
4451
4452    // Create header parameters collection
4453    let mut header_params = std::collections::HashMap::new();
4454
4455    // Handle Binance Auth first if configured
4456    if let Some(ref binance_auth) = configuration.binance_auth {
4457        // Add API key to headers
4458        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4459        
4460        // Generate request body for signing (if any)
4461        let body_string: Option<Vec<u8>> = None;
4462        
4463        // Sign the request
4464        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4465            Ok(sig) => sig,
4466            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4467        };
4468        
4469        // Add signature to query params
4470        query_params.push(("signature".to_string(), signature));
4471    }
4472
4473    // Apply all query parameters
4474    if !query_params.is_empty() {
4475        req_builder = req_builder.query(&query_params);
4476    }
4477
4478
4479    // Add user agent if configured
4480    if let Some(ref user_agent) = configuration.user_agent {
4481        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4482    }
4483
4484    // Apply all header parameters
4485    for (header_name, header_value) in header_params {
4486        req_builder = req_builder.header(&header_name, &header_value);
4487    }
4488
4489
4490    let req = req_builder.build()?;
4491    let resp = configuration.client.execute(req).await?;
4492
4493    let status = resp.status();
4494    let content_type = resp
4495        .headers()
4496        .get("content-type")
4497        .and_then(|v| v.to_str().ok())
4498        .unwrap_or("application/octet-stream");
4499    let content_type = super::ContentType::from(content_type);
4500
4501    if !status.is_client_error() && !status.is_server_error() {
4502        let content = resp.text().await?;
4503        match content_type {
4504            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4505            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerV3Resp`"))),
4506            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::SpotGetTickerV3Resp`")))),
4507        }
4508    } else {
4509        let content = resp.text().await?;
4510        let entity: Option<GetTickerV3Error> = serde_json::from_str(&content).ok();
4511        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4512    }
4513}
4514
4515/// Test connectivity to the Rest API and get the current server time.
4516pub async fn get_time_v3(configuration: &configuration::Configuration) -> Result<models::GetTimeV3Resp, Error<GetTimeV3Error>> {
4517
4518    let uri_str = format!("{}/api/v3/time", configuration.base_path);
4519    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4520
4521    // Create a mutable vector for query parameters
4522    let mut query_params: Vec<(String, String)> = Vec::new();
4523
4524
4525    // Create header parameters collection
4526    let mut header_params = std::collections::HashMap::new();
4527
4528    // Handle Binance Auth first if configured
4529    if let Some(ref binance_auth) = configuration.binance_auth {
4530        // Add API key to headers
4531        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4532        
4533        // Generate request body for signing (if any)
4534        let body_string: Option<Vec<u8>> = None;
4535        
4536        // Sign the request
4537        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4538            Ok(sig) => sig,
4539            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4540        };
4541        
4542        // Add signature to query params
4543        query_params.push(("signature".to_string(), signature));
4544    }
4545
4546    // Apply all query parameters
4547    if !query_params.is_empty() {
4548        req_builder = req_builder.query(&query_params);
4549    }
4550
4551
4552    // Add user agent if configured
4553    if let Some(ref user_agent) = configuration.user_agent {
4554        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4555    }
4556
4557    // Apply all header parameters
4558    for (header_name, header_value) in header_params {
4559        req_builder = req_builder.header(&header_name, &header_value);
4560    }
4561
4562
4563    let req = req_builder.build()?;
4564    let resp = configuration.client.execute(req).await?;
4565
4566    let status = resp.status();
4567    let content_type = resp
4568        .headers()
4569        .get("content-type")
4570        .and_then(|v| v.to_str().ok())
4571        .unwrap_or("application/octet-stream");
4572    let content_type = super::ContentType::from(content_type);
4573
4574    if !status.is_client_error() && !status.is_server_error() {
4575        let content = resp.text().await?;
4576        match content_type {
4577            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4578            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTimeV3Resp`"))),
4579            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::GetTimeV3Resp`")))),
4580        }
4581    } else {
4582        let content = resp.text().await?;
4583        let entity: Option<GetTimeV3Error> = serde_json::from_str(&content).ok();
4584        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4585    }
4586}
4587
4588/// Get recent trades.
4589pub async fn get_trades_v3(configuration: &configuration::Configuration, params: GetTradesV3Params) -> Result<Vec<models::GetTradesV3RespItem>, Error<GetTradesV3Error>> {
4590
4591    let uri_str = format!("{}/api/v3/trades", configuration.base_path);
4592    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4593
4594    // Create a mutable vector for query parameters
4595    let mut query_params: Vec<(String, String)> = Vec::new();
4596
4597    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4598    if let Some(ref param_value) = params.limit {
4599        query_params.push(("limit".to_string(), param_value.to_string()));
4600    }
4601
4602    // Create header parameters collection
4603    let mut header_params = std::collections::HashMap::new();
4604
4605    // Handle Binance Auth first if configured
4606    if let Some(ref binance_auth) = configuration.binance_auth {
4607        // Add API key to headers
4608        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4609        
4610        // Generate request body for signing (if any)
4611        let body_string: Option<Vec<u8>> = None;
4612        
4613        // Sign the request
4614        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4615            Ok(sig) => sig,
4616            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4617        };
4618        
4619        // Add signature to query params
4620        query_params.push(("signature".to_string(), signature));
4621    }
4622
4623    // Apply all query parameters
4624    if !query_params.is_empty() {
4625        req_builder = req_builder.query(&query_params);
4626    }
4627
4628
4629    // Add user agent if configured
4630    if let Some(ref user_agent) = configuration.user_agent {
4631        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4632    }
4633
4634    // Apply all header parameters
4635    for (header_name, header_value) in header_params {
4636        req_builder = req_builder.header(&header_name, &header_value);
4637    }
4638
4639
4640    let req = req_builder.build()?;
4641    let resp = configuration.client.execute(req).await?;
4642
4643    let status = resp.status();
4644    let content_type = resp
4645        .headers()
4646        .get("content-type")
4647        .and_then(|v| v.to_str().ok())
4648        .unwrap_or("application/octet-stream");
4649    let content_type = super::ContentType::from(content_type);
4650
4651    if !status.is_client_error() && !status.is_server_error() {
4652        let content = resp.text().await?;
4653        match content_type {
4654            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4655            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetTradesV3RespItem&gt;`"))),
4656            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::GetTradesV3RespItem&gt;`")))),
4657        }
4658    } else {
4659        let content = resp.text().await?;
4660        let entity: Option<GetTradesV3Error> = serde_json::from_str(&content).ok();
4661        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4662    }
4663}
4664
4665/// The request is similar to klines having the same parameters and response. uiKlines return modified kline data, optimized for presentation of candlestick charts.
4666pub async fn get_ui_klines_v3(configuration: &configuration::Configuration, params: GetUiKlinesV3Params) -> Result<Vec<Vec<models::GetKlinesV3200ResponseInnerInner>>, Error<GetUiKlinesV3Error>> {
4667
4668    let uri_str = format!("{}/api/v3/uiKlines", configuration.base_path);
4669    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4670
4671    // Create a mutable vector for query parameters
4672    let mut query_params: Vec<(String, String)> = Vec::new();
4673
4674    query_params.push(("symbol".to_string(), params.symbol.to_string()));
4675    query_params.push(("interval".to_string(), params.interval.to_string()));
4676    if let Some(ref param_value) = params.start_time {
4677        query_params.push(("startTime".to_string(), param_value.to_string()));
4678    }
4679    if let Some(ref param_value) = params.end_time {
4680        query_params.push(("endTime".to_string(), param_value.to_string()));
4681    }
4682    if let Some(ref param_value) = params.time_zone {
4683        query_params.push(("timeZone".to_string(), param_value.to_string()));
4684    }
4685    if let Some(ref param_value) = params.limit {
4686        query_params.push(("limit".to_string(), param_value.to_string()));
4687    }
4688
4689    // Create header parameters collection
4690    let mut header_params = std::collections::HashMap::new();
4691
4692    // Handle Binance Auth first if configured
4693    if let Some(ref binance_auth) = configuration.binance_auth {
4694        // Add API key to headers
4695        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4696        
4697        // Generate request body for signing (if any)
4698        let body_string: Option<Vec<u8>> = None;
4699        
4700        // Sign the request
4701        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4702            Ok(sig) => sig,
4703            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4704        };
4705        
4706        // Add signature to query params
4707        query_params.push(("signature".to_string(), signature));
4708    }
4709
4710    // Apply all query parameters
4711    if !query_params.is_empty() {
4712        req_builder = req_builder.query(&query_params);
4713    }
4714
4715
4716    // Add user agent if configured
4717    if let Some(ref user_agent) = configuration.user_agent {
4718        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4719    }
4720
4721    // Apply all header parameters
4722    for (header_name, header_value) in header_params {
4723        req_builder = req_builder.header(&header_name, &header_value);
4724    }
4725
4726
4727    let req = req_builder.build()?;
4728    let resp = configuration.client.execute(req).await?;
4729
4730    let status = resp.status();
4731    let content_type = resp
4732        .headers()
4733        .get("content-type")
4734        .and_then(|v| v.to_str().ok())
4735        .unwrap_or("application/octet-stream");
4736    let content_type = super::ContentType::from(content_type);
4737
4738    if !status.is_client_error() && !status.is_server_error() {
4739        let content = resp.text().await?;
4740        match content_type {
4741            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4742            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;Vec&lt;models::GetKlinesV3200ResponseInnerInner&gt;&gt;`"))),
4743            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;Vec&lt;models::GetKlinesV3200ResponseInnerInner&gt;&gt;`")))),
4744        }
4745    } else {
4746        let content = resp.text().await?;
4747        let entity: Option<GetUiKlinesV3Error> = serde_json::from_str(&content).ok();
4748        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4749    }
4750}
4751
4752/// 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 30 minutes.
4753pub async fn update_user_data_stream_v3(configuration: &configuration::Configuration, params: UpdateUserDataStreamV3Params) -> Result<serde_json::Value, Error<UpdateUserDataStreamV3Error>> {
4754
4755    let uri_str = format!("{}/api/v3/userDataStream", configuration.base_path);
4756    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
4757
4758    // Create a mutable vector for query parameters
4759    let mut query_params: Vec<(String, String)> = Vec::new();
4760
4761
4762    // Create header parameters collection
4763    let mut header_params = std::collections::HashMap::new();
4764
4765    // Handle Binance Auth first if configured
4766    if let Some(ref binance_auth) = configuration.binance_auth {
4767        // Add API key to headers
4768        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4769        
4770        // Generate request body for signing (if any)
4771        let body_string: Option<Vec<u8>> = None;
4772        
4773        // Sign the request
4774        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4775            Ok(sig) => sig,
4776            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4777        };
4778        
4779        // Add signature to query params
4780        query_params.push(("signature".to_string(), signature));
4781    }
4782
4783    // Apply all query parameters
4784    if !query_params.is_empty() {
4785        req_builder = req_builder.query(&query_params);
4786    }
4787
4788
4789    // Add user agent if configured
4790    if let Some(ref user_agent) = configuration.user_agent {
4791        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4792    }
4793
4794    // Apply all header parameters
4795    for (header_name, header_value) in header_params {
4796        req_builder = req_builder.header(&header_name, &header_value);
4797    }
4798
4799    let mut multipart_form_params = std::collections::HashMap::new();
4800    multipart_form_params.insert("listenKey", params.listen_key.to_string());
4801    req_builder = req_builder.form(&multipart_form_params);
4802
4803    let req = req_builder.build()?;
4804    let resp = configuration.client.execute(req).await?;
4805
4806    let status = resp.status();
4807    let content_type = resp
4808        .headers()
4809        .get("content-type")
4810        .and_then(|v| v.to_str().ok())
4811        .unwrap_or("application/octet-stream");
4812    let content_type = super::ContentType::from(content_type);
4813
4814    if !status.is_client_error() && !status.is_server_error() {
4815        let content = resp.text().await?;
4816        match content_type {
4817            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4818            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
4819            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`")))),
4820        }
4821    } else {
4822        let content = resp.text().await?;
4823        let entity: Option<UpdateUserDataStreamV3Error> = serde_json::from_str(&content).ok();
4824        Err(Error::ResponseError(ResponseContent { status, content, entity }))
4825    }
4826}
4827