binance/margin/apis/
trade_api.rs

1/*
2 * Binance Margin Trading API
3 *
4 * OpenAPI specification for Binance exchange - Margin API
5 *
6 * The version of the OpenAPI document: 0.1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::margin::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`margin_create_margin_api_key_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct MarginCreateMarginApiKeyV1Params {
20    pub api_name: String,
21    pub timestamp: i64,
22    pub ip: Option<String>,
23    pub permission_mode: Option<String>,
24    pub public_key: Option<String>,
25    pub recv_window: Option<i64>,
26    pub symbol: Option<String>
27}
28
29/// struct for passing parameters to the method [`margin_create_margin_exchange_small_liability_v1`]
30#[derive(Clone, Debug, Default)]
31pub struct MarginCreateMarginExchangeSmallLiabilityV1Params {
32    pub asset_names: Vec<String>,
33    pub timestamp: i64,
34    pub recv_window: Option<i64>
35}
36
37/// struct for passing parameters to the method [`margin_create_margin_manual_liquidation_v1`]
38#[derive(Clone, Debug, Default)]
39pub struct MarginCreateMarginManualLiquidationV1Params {
40    pub timestamp: i64,
41    pub r#type: String,
42    pub recv_window: Option<i64>,
43    pub symbol: Option<String>
44}
45
46/// struct for passing parameters to the method [`margin_create_margin_order_oco_v1`]
47#[derive(Clone, Debug, Default)]
48pub struct MarginCreateMarginOrderOcoV1Params {
49    pub price: String,
50    pub quantity: String,
51    pub side: String,
52    pub stop_price: String,
53    pub symbol: String,
54    pub timestamp: i64,
55    pub auto_repay_at_cancel: Option<bool>,
56    pub is_isolated: Option<String>,
57    pub limit_client_order_id: Option<String>,
58    pub limit_iceberg_qty: Option<String>,
59    pub list_client_order_id: Option<String>,
60    pub new_order_resp_type: Option<String>,
61    pub recv_window: Option<i64>,
62    pub self_trade_prevention_mode: Option<String>,
63    pub side_effect_type: Option<String>,
64    pub stop_client_order_id: Option<String>,
65    pub stop_iceberg_qty: Option<String>,
66    pub stop_limit_price: Option<String>,
67    pub stop_limit_time_in_force: Option<String>
68}
69
70/// struct for passing parameters to the method [`margin_create_margin_order_oto_v1`]
71#[derive(Clone, Debug, Default)]
72pub struct MarginCreateMarginOrderOtoV1Params {
73    pub pending_quantity: String,
74    pub pending_side: String,
75    pub pending_type: String,
76    pub symbol: String,
77    pub working_iceberg_qty: String,
78    pub working_price: String,
79    pub working_quantity: String,
80    pub working_side: String,
81    pub working_type: String,
82    pub auto_repay_at_cancel: Option<bool>,
83    pub is_isolated: Option<String>,
84    pub list_client_order_id: Option<String>,
85    pub new_order_resp_type: Option<String>,
86    pub pending_client_order_id: Option<String>,
87    pub pending_iceberg_qty: Option<String>,
88    pub pending_price: Option<String>,
89    pub pending_stop_price: Option<String>,
90    pub pending_time_in_force: Option<String>,
91    pub pending_trailing_delta: Option<String>,
92    pub self_trade_prevention_mode: Option<String>,
93    pub side_effect_type: Option<String>,
94    pub working_client_order_id: Option<String>,
95    pub working_time_in_force: Option<String>
96}
97
98/// struct for passing parameters to the method [`margin_create_margin_order_otoco_v1`]
99#[derive(Clone, Debug, Default)]
100pub struct MarginCreateMarginOrderOtocoV1Params {
101    pub pending_above_type: String,
102    pub pending_quantity: String,
103    pub pending_side: String,
104    pub symbol: String,
105    pub working_price: String,
106    pub working_quantity: String,
107    pub working_side: String,
108    pub working_type: String,
109    pub auto_repay_at_cancel: Option<bool>,
110    pub is_isolated: Option<String>,
111    pub list_client_order_id: Option<String>,
112    pub new_order_resp_type: Option<String>,
113    pub pending_above_client_order_id: Option<String>,
114    pub pending_above_iceberg_qty: Option<String>,
115    pub pending_above_price: Option<String>,
116    pub pending_above_stop_price: Option<String>,
117    pub pending_above_time_in_force: Option<String>,
118    pub pending_above_trailing_delta: Option<String>,
119    pub pending_below_client_order_id: Option<String>,
120    pub pending_below_iceberg_qty: Option<String>,
121    pub pending_below_price: Option<String>,
122    pub pending_below_stop_price: Option<String>,
123    pub pending_below_time_in_force: Option<String>,
124    pub pending_below_trailing_delta: Option<String>,
125    pub pending_below_type: Option<String>,
126    pub self_trade_prevention_mode: Option<String>,
127    pub side_effect_type: Option<String>,
128    pub working_client_order_id: Option<String>,
129    pub working_iceberg_qty: Option<String>,
130    pub working_time_in_force: Option<String>
131}
132
133/// struct for passing parameters to the method [`margin_create_margin_order_v1`]
134#[derive(Clone, Debug, Default)]
135pub struct MarginCreateMarginOrderV1Params {
136    pub side: String,
137    pub symbol: String,
138    pub timestamp: i64,
139    pub r#type: String,
140    pub auto_repay_at_cancel: Option<bool>,
141    pub iceberg_qty: Option<String>,
142    pub is_isolated: Option<String>,
143    pub new_client_order_id: Option<String>,
144    pub new_order_resp_type: Option<String>,
145    pub price: Option<String>,
146    pub quantity: Option<String>,
147    pub quote_order_qty: Option<String>,
148    pub recv_window: Option<i64>,
149    pub self_trade_prevention_mode: Option<String>,
150    pub side_effect_type: Option<String>,
151    pub stop_price: Option<String>,
152    pub time_in_force: Option<String>
153}
154
155/// struct for passing parameters to the method [`margin_delete_margin_api_key_v1`]
156#[derive(Clone, Debug, Default)]
157pub struct MarginDeleteMarginApiKeyV1Params {
158    pub timestamp: i64,
159    pub api_key: Option<String>,
160    pub api_name: Option<String>,
161    /// isolated margin pair
162    pub symbol: Option<String>,
163    /// The value cannot be greater than `60000`
164    pub recv_window: Option<i64>
165}
166
167/// struct for passing parameters to the method [`margin_delete_margin_open_orders_v1`]
168#[derive(Clone, Debug, Default)]
169pub struct MarginDeleteMarginOpenOrdersV1Params {
170    pub symbol: String,
171    pub timestamp: i64,
172    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
173    pub is_isolated: Option<String>,
174    /// The value cannot be greater than `60000`
175    pub recv_window: Option<i64>
176}
177
178/// struct for passing parameters to the method [`margin_delete_margin_order_list_v1`]
179#[derive(Clone, Debug, Default)]
180pub struct MarginDeleteMarginOrderListV1Params {
181    pub symbol: String,
182    pub timestamp: i64,
183    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
184    pub is_isolated: Option<String>,
185    /// Either `orderListId` or `listClientOrderId` must be provided
186    pub order_list_id: Option<i64>,
187    /// Either `orderListId` or `listClientOrderId` must be provided
188    pub list_client_order_id: Option<String>,
189    /// Used to uniquely identify this cancel. Automatically generated by default
190    pub new_client_order_id: Option<String>,
191    /// The value cannot be greater than `60000`
192    pub recv_window: Option<i64>
193}
194
195/// struct for passing parameters to the method [`margin_delete_margin_order_v1`]
196#[derive(Clone, Debug, Default)]
197pub struct MarginDeleteMarginOrderV1Params {
198    pub symbol: String,
199    pub timestamp: i64,
200    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
201    pub is_isolated: Option<String>,
202    pub order_id: Option<i64>,
203    pub orig_client_order_id: Option<String>,
204    /// Used to uniquely identify this cancel. Automatically generated by default.
205    pub new_client_order_id: Option<String>,
206    /// The value cannot be greater than `60000`
207    pub recv_window: Option<i64>
208}
209
210/// struct for passing parameters to the method [`margin_get_margin_all_order_list_v1`]
211#[derive(Clone, Debug, Default)]
212pub struct MarginGetMarginAllOrderListV1Params {
213    pub timestamp: i64,
214    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
215    pub is_isolated: Option<String>,
216    /// mandatory for isolated margin, not supported for cross margin
217    pub symbol: Option<String>,
218    /// If supplied, neither `startTime` or `endTime` can be provided
219    pub from_id: Option<i64>,
220    pub start_time: Option<i64>,
221    pub end_time: Option<i64>,
222    /// Default Value: 500; Max Value: 1000
223    pub limit: Option<i32>,
224    /// The value cannot be greater than `60000`
225    pub recv_window: Option<i64>
226}
227
228/// struct for passing parameters to the method [`margin_get_margin_all_orders_v1`]
229#[derive(Clone, Debug, Default)]
230pub struct MarginGetMarginAllOrdersV1Params {
231    pub symbol: String,
232    pub timestamp: i64,
233    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
234    pub is_isolated: Option<String>,
235    pub order_id: Option<i64>,
236    pub start_time: Option<i64>,
237    pub end_time: Option<i64>,
238    /// Default 500; max 500.
239    pub limit: Option<i32>,
240    /// The value cannot be greater than `60000`
241    pub recv_window: Option<i64>
242}
243
244/// struct for passing parameters to the method [`margin_get_margin_api_key_list_v1`]
245#[derive(Clone, Debug, Default)]
246pub struct MarginGetMarginApiKeyListV1Params {
247    pub timestamp: i64,
248    /// isolated margin pair
249    pub symbol: Option<String>,
250    /// The value cannot be greater than `60000`
251    pub recv_window: Option<i64>
252}
253
254/// struct for passing parameters to the method [`margin_get_margin_api_key_v1`]
255#[derive(Clone, Debug, Default)]
256pub struct MarginGetMarginApiKeyV1Params {
257    pub api_key: String,
258    pub timestamp: i64,
259    /// isolated margin pair
260    pub symbol: Option<String>,
261    /// The value cannot be greater than `60000`
262    pub recv_window: Option<i64>
263}
264
265/// struct for passing parameters to the method [`margin_get_margin_exchange_small_liability_history_v1`]
266#[derive(Clone, Debug, Default)]
267pub struct MarginGetMarginExchangeSmallLiabilityHistoryV1Params {
268    /// Currently querying page. Start from 1. Default:1
269    pub current: i32,
270    /// Default:10, Max:100
271    pub size: i32,
272    pub timestamp: i64,
273    /// Default: 30 days from current timestamp
274    pub start_time: Option<i64>,
275    /// Default: present timestamp
276    pub end_time: Option<i64>,
277    pub recv_window: Option<i64>
278}
279
280/// struct for passing parameters to the method [`margin_get_margin_exchange_small_liability_v1`]
281#[derive(Clone, Debug, Default)]
282pub struct MarginGetMarginExchangeSmallLiabilityV1Params {
283    pub timestamp: i64,
284    pub recv_window: Option<i64>
285}
286
287/// struct for passing parameters to the method [`margin_get_margin_force_liquidation_rec_v1`]
288#[derive(Clone, Debug, Default)]
289pub struct MarginGetMarginForceLiquidationRecV1Params {
290    pub timestamp: i64,
291    pub start_time: Option<i64>,
292    pub end_time: Option<i64>,
293    pub isolated_symbol: Option<String>,
294    /// Currently querying page. Start from 1. Default:1
295    pub current: Option<i64>,
296    /// Default:10 Max:100
297    pub size: Option<i64>,
298    /// The value cannot be greater than `60000`
299    pub recv_window: Option<i64>
300}
301
302/// struct for passing parameters to the method [`margin_get_margin_my_trades_v1`]
303#[derive(Clone, Debug, Default)]
304pub struct MarginGetMarginMyTradesV1Params {
305    pub symbol: String,
306    pub timestamp: i64,
307    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
308    pub is_isolated: Option<String>,
309    pub order_id: Option<i64>,
310    pub start_time: Option<i64>,
311    pub end_time: Option<i64>,
312    /// TradeId to fetch from. Default gets most recent trades.
313    pub from_id: Option<i64>,
314    /// Default 500; max 1000.
315    pub limit: Option<i32>,
316    /// The value cannot be greater than `60000`
317    pub recv_window: Option<i64>
318}
319
320/// struct for passing parameters to the method [`margin_get_margin_open_order_list_v1`]
321#[derive(Clone, Debug, Default)]
322pub struct MarginGetMarginOpenOrderListV1Params {
323    pub timestamp: i64,
324    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
325    pub is_isolated: Option<String>,
326    /// mandatory for isolated margin, not supported for cross margin
327    pub symbol: Option<String>,
328    /// The value cannot be greater than `60000`
329    pub recv_window: Option<i64>
330}
331
332/// struct for passing parameters to the method [`margin_get_margin_open_orders_v1`]
333#[derive(Clone, Debug, Default)]
334pub struct MarginGetMarginOpenOrdersV1Params {
335    pub timestamp: i64,
336    pub symbol: Option<String>,
337    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
338    pub is_isolated: Option<String>,
339    /// The value cannot be greater than `60000`
340    pub recv_window: Option<i64>
341}
342
343/// struct for passing parameters to the method [`margin_get_margin_order_list_v1`]
344#[derive(Clone, Debug, Default)]
345pub struct MarginGetMarginOrderListV1Params {
346    pub timestamp: i64,
347    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
348    pub is_isolated: Option<String>,
349    /// mandatory for isolated margin, not supported for cross margin
350    pub symbol: Option<String>,
351    /// Either `orderListId` or `origClientOrderId` must be provided
352    pub order_list_id: Option<i64>,
353    /// Either `orderListId` or `origClientOrderId` must be provided
354    pub orig_client_order_id: Option<String>,
355    /// The value cannot be greater than `60000`
356    pub recv_window: Option<i64>
357}
358
359/// struct for passing parameters to the method [`margin_get_margin_order_v1`]
360#[derive(Clone, Debug, Default)]
361pub struct MarginGetMarginOrderV1Params {
362    pub symbol: String,
363    pub timestamp: i64,
364    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
365    pub is_isolated: Option<String>,
366    pub order_id: Option<i64>,
367    pub orig_client_order_id: Option<String>,
368    /// The value cannot be greater than `60000`
369    pub recv_window: Option<i64>
370}
371
372/// struct for passing parameters to the method [`margin_get_margin_rate_limit_order_v1`]
373#[derive(Clone, Debug, Default)]
374pub struct MarginGetMarginRateLimitOrderV1Params {
375    pub timestamp: i64,
376    /// for isolated margin or not, &#34;TRUE&#34;, &#34;FALSE&#34;,default &#34;FALSE&#34;
377    pub is_isolated: Option<String>,
378    /// isolated symbol, mandatory for isolated margin
379    pub symbol: Option<String>,
380    /// The value cannot be greater than `60000`
381    pub recv_window: Option<i64>
382}
383
384/// struct for passing parameters to the method [`margin_update_margin_api_key_ip_v1`]
385#[derive(Clone, Debug, Default)]
386pub struct MarginUpdateMarginApiKeyIpV1Params {
387    pub api_key: String,
388    pub ip: String,
389    pub timestamp: i64,
390    pub recv_window: Option<i64>,
391    pub symbol: Option<String>
392}
393
394
395/// struct for typed errors of method [`margin_create_margin_api_key_v1`]
396#[derive(Debug, Clone, Serialize, Deserialize)]
397#[serde(untagged)]
398pub enum MarginCreateMarginApiKeyV1Error {
399    Status4XX(models::ApiError),
400    Status5XX(models::ApiError),
401    UnknownValue(serde_json::Value),
402}
403
404/// struct for typed errors of method [`margin_create_margin_exchange_small_liability_v1`]
405#[derive(Debug, Clone, Serialize, Deserialize)]
406#[serde(untagged)]
407pub enum MarginCreateMarginExchangeSmallLiabilityV1Error {
408    Status4XX(models::ApiError),
409    Status5XX(models::ApiError),
410    UnknownValue(serde_json::Value),
411}
412
413/// struct for typed errors of method [`margin_create_margin_manual_liquidation_v1`]
414#[derive(Debug, Clone, Serialize, Deserialize)]
415#[serde(untagged)]
416pub enum MarginCreateMarginManualLiquidationV1Error {
417    Status4XX(models::ApiError),
418    Status5XX(models::ApiError),
419    UnknownValue(serde_json::Value),
420}
421
422/// struct for typed errors of method [`margin_create_margin_order_oco_v1`]
423#[derive(Debug, Clone, Serialize, Deserialize)]
424#[serde(untagged)]
425pub enum MarginCreateMarginOrderOcoV1Error {
426    Status4XX(models::ApiError),
427    Status5XX(models::ApiError),
428    UnknownValue(serde_json::Value),
429}
430
431/// struct for typed errors of method [`margin_create_margin_order_oto_v1`]
432#[derive(Debug, Clone, Serialize, Deserialize)]
433#[serde(untagged)]
434pub enum MarginCreateMarginOrderOtoV1Error {
435    Status4XX(models::ApiError),
436    Status5XX(models::ApiError),
437    UnknownValue(serde_json::Value),
438}
439
440/// struct for typed errors of method [`margin_create_margin_order_otoco_v1`]
441#[derive(Debug, Clone, Serialize, Deserialize)]
442#[serde(untagged)]
443pub enum MarginCreateMarginOrderOtocoV1Error {
444    Status4XX(models::ApiError),
445    Status5XX(models::ApiError),
446    UnknownValue(serde_json::Value),
447}
448
449/// struct for typed errors of method [`margin_create_margin_order_v1`]
450#[derive(Debug, Clone, Serialize, Deserialize)]
451#[serde(untagged)]
452pub enum MarginCreateMarginOrderV1Error {
453    Status4XX(models::ApiError),
454    Status5XX(models::ApiError),
455    UnknownValue(serde_json::Value),
456}
457
458/// struct for typed errors of method [`margin_delete_margin_api_key_v1`]
459#[derive(Debug, Clone, Serialize, Deserialize)]
460#[serde(untagged)]
461pub enum MarginDeleteMarginApiKeyV1Error {
462    Status4XX(models::ApiError),
463    Status5XX(models::ApiError),
464    UnknownValue(serde_json::Value),
465}
466
467/// struct for typed errors of method [`margin_delete_margin_open_orders_v1`]
468#[derive(Debug, Clone, Serialize, Deserialize)]
469#[serde(untagged)]
470pub enum MarginDeleteMarginOpenOrdersV1Error {
471    Status4XX(models::ApiError),
472    Status5XX(models::ApiError),
473    UnknownValue(serde_json::Value),
474}
475
476/// struct for typed errors of method [`margin_delete_margin_order_list_v1`]
477#[derive(Debug, Clone, Serialize, Deserialize)]
478#[serde(untagged)]
479pub enum MarginDeleteMarginOrderListV1Error {
480    Status4XX(models::ApiError),
481    Status5XX(models::ApiError),
482    UnknownValue(serde_json::Value),
483}
484
485/// struct for typed errors of method [`margin_delete_margin_order_v1`]
486#[derive(Debug, Clone, Serialize, Deserialize)]
487#[serde(untagged)]
488pub enum MarginDeleteMarginOrderV1Error {
489    Status4XX(models::ApiError),
490    Status5XX(models::ApiError),
491    UnknownValue(serde_json::Value),
492}
493
494/// struct for typed errors of method [`margin_get_margin_all_order_list_v1`]
495#[derive(Debug, Clone, Serialize, Deserialize)]
496#[serde(untagged)]
497pub enum MarginGetMarginAllOrderListV1Error {
498    Status4XX(models::ApiError),
499    Status5XX(models::ApiError),
500    UnknownValue(serde_json::Value),
501}
502
503/// struct for typed errors of method [`margin_get_margin_all_orders_v1`]
504#[derive(Debug, Clone, Serialize, Deserialize)]
505#[serde(untagged)]
506pub enum MarginGetMarginAllOrdersV1Error {
507    Status4XX(models::ApiError),
508    Status5XX(models::ApiError),
509    UnknownValue(serde_json::Value),
510}
511
512/// struct for typed errors of method [`margin_get_margin_api_key_list_v1`]
513#[derive(Debug, Clone, Serialize, Deserialize)]
514#[serde(untagged)]
515pub enum MarginGetMarginApiKeyListV1Error {
516    Status4XX(models::ApiError),
517    Status5XX(models::ApiError),
518    UnknownValue(serde_json::Value),
519}
520
521/// struct for typed errors of method [`margin_get_margin_api_key_v1`]
522#[derive(Debug, Clone, Serialize, Deserialize)]
523#[serde(untagged)]
524pub enum MarginGetMarginApiKeyV1Error {
525    Status4XX(models::ApiError),
526    Status5XX(models::ApiError),
527    UnknownValue(serde_json::Value),
528}
529
530/// struct for typed errors of method [`margin_get_margin_exchange_small_liability_history_v1`]
531#[derive(Debug, Clone, Serialize, Deserialize)]
532#[serde(untagged)]
533pub enum MarginGetMarginExchangeSmallLiabilityHistoryV1Error {
534    Status4XX(models::ApiError),
535    Status5XX(models::ApiError),
536    UnknownValue(serde_json::Value),
537}
538
539/// struct for typed errors of method [`margin_get_margin_exchange_small_liability_v1`]
540#[derive(Debug, Clone, Serialize, Deserialize)]
541#[serde(untagged)]
542pub enum MarginGetMarginExchangeSmallLiabilityV1Error {
543    Status4XX(models::ApiError),
544    Status5XX(models::ApiError),
545    UnknownValue(serde_json::Value),
546}
547
548/// struct for typed errors of method [`margin_get_margin_force_liquidation_rec_v1`]
549#[derive(Debug, Clone, Serialize, Deserialize)]
550#[serde(untagged)]
551pub enum MarginGetMarginForceLiquidationRecV1Error {
552    Status4XX(models::ApiError),
553    Status5XX(models::ApiError),
554    UnknownValue(serde_json::Value),
555}
556
557/// struct for typed errors of method [`margin_get_margin_my_trades_v1`]
558#[derive(Debug, Clone, Serialize, Deserialize)]
559#[serde(untagged)]
560pub enum MarginGetMarginMyTradesV1Error {
561    Status4XX(models::ApiError),
562    Status5XX(models::ApiError),
563    UnknownValue(serde_json::Value),
564}
565
566/// struct for typed errors of method [`margin_get_margin_open_order_list_v1`]
567#[derive(Debug, Clone, Serialize, Deserialize)]
568#[serde(untagged)]
569pub enum MarginGetMarginOpenOrderListV1Error {
570    Status4XX(models::ApiError),
571    Status5XX(models::ApiError),
572    UnknownValue(serde_json::Value),
573}
574
575/// struct for typed errors of method [`margin_get_margin_open_orders_v1`]
576#[derive(Debug, Clone, Serialize, Deserialize)]
577#[serde(untagged)]
578pub enum MarginGetMarginOpenOrdersV1Error {
579    Status4XX(models::ApiError),
580    Status5XX(models::ApiError),
581    UnknownValue(serde_json::Value),
582}
583
584/// struct for typed errors of method [`margin_get_margin_order_list_v1`]
585#[derive(Debug, Clone, Serialize, Deserialize)]
586#[serde(untagged)]
587pub enum MarginGetMarginOrderListV1Error {
588    Status4XX(models::ApiError),
589    Status5XX(models::ApiError),
590    UnknownValue(serde_json::Value),
591}
592
593/// struct for typed errors of method [`margin_get_margin_order_v1`]
594#[derive(Debug, Clone, Serialize, Deserialize)]
595#[serde(untagged)]
596pub enum MarginGetMarginOrderV1Error {
597    Status4XX(models::ApiError),
598    Status5XX(models::ApiError),
599    UnknownValue(serde_json::Value),
600}
601
602/// struct for typed errors of method [`margin_get_margin_rate_limit_order_v1`]
603#[derive(Debug, Clone, Serialize, Deserialize)]
604#[serde(untagged)]
605pub enum MarginGetMarginRateLimitOrderV1Error {
606    Status4XX(models::ApiError),
607    Status5XX(models::ApiError),
608    UnknownValue(serde_json::Value),
609}
610
611/// struct for typed errors of method [`margin_update_margin_api_key_ip_v1`]
612#[derive(Debug, Clone, Serialize, Deserialize)]
613#[serde(untagged)]
614pub enum MarginUpdateMarginApiKeyIpV1Error {
615    Status4XX(models::ApiError),
616    Status5XX(models::ApiError),
617    UnknownValue(serde_json::Value),
618}
619
620
621/// **Binance Margin offers low-latency trading through a special key, available exclusively to users with VIP level 4 or higher. **
622pub async fn margin_create_margin_api_key_v1(configuration: &configuration::Configuration, params: MarginCreateMarginApiKeyV1Params) -> Result<models::MarginCreateMarginApiKeyV1Resp, Error<MarginCreateMarginApiKeyV1Error>> {
623
624    let uri_str = format!("{}/sapi/v1/margin/apiKey", configuration.base_path);
625    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
626
627    // Create a mutable vector for query parameters
628    let mut query_params: Vec<(String, String)> = Vec::new();
629
630
631    // Create header parameters collection
632    let mut header_params = std::collections::HashMap::new();
633
634    // Handle Binance Auth first if configured
635    if let Some(ref binance_auth) = configuration.binance_auth {
636        // Add API key to headers
637        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
638        
639        // Generate request body for signing (if any)
640        let body_string: Option<Vec<u8>> = None;
641        
642        // Sign the request
643        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
644            Ok(sig) => sig,
645            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
646        };
647        
648        // Add signature to query params
649        query_params.push(("signature".to_string(), signature));
650    }
651
652    // Apply all query parameters
653    if !query_params.is_empty() {
654        req_builder = req_builder.query(&query_params);
655    }
656
657
658    // Add user agent if configured
659    if let Some(ref user_agent) = configuration.user_agent {
660        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
661    }
662
663    // Apply all header parameters
664    for (header_name, header_value) in header_params {
665        req_builder = req_builder.header(&header_name, &header_value);
666    }
667
668    let mut multipart_form_params = std::collections::HashMap::new();
669    multipart_form_params.insert("apiName", params.api_name.to_string());
670    if let Some(param_value) = params.ip {
671        multipart_form_params.insert("ip", param_value.to_string());
672    }
673    if let Some(param_value) = params.permission_mode {
674        multipart_form_params.insert("permissionMode", param_value.to_string());
675    }
676    if let Some(param_value) = params.public_key {
677        multipart_form_params.insert("publicKey", param_value.to_string());
678    }
679    if let Some(param_value) = params.recv_window {
680        multipart_form_params.insert("recvWindow", param_value.to_string());
681    }
682    if let Some(param_value) = params.symbol {
683        multipart_form_params.insert("symbol", param_value.to_string());
684    }
685    multipart_form_params.insert("timestamp", params.timestamp.to_string());
686    req_builder = req_builder.form(&multipart_form_params);
687
688    let req = req_builder.build()?;
689    let resp = configuration.client.execute(req).await?;
690
691    let status = resp.status();
692    let content_type = resp
693        .headers()
694        .get("content-type")
695        .and_then(|v| v.to_str().ok())
696        .unwrap_or("application/octet-stream");
697    let content_type = super::ContentType::from(content_type);
698
699    if !status.is_client_error() && !status.is_server_error() {
700        let content = resp.text().await?;
701        match content_type {
702            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
703            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginApiKeyV1Resp`"))),
704            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::MarginCreateMarginApiKeyV1Resp`")))),
705        }
706    } else {
707        let content = resp.text().await?;
708        let entity: Option<MarginCreateMarginApiKeyV1Error> = serde_json::from_str(&content).ok();
709        Err(Error::ResponseError(ResponseContent { status, content, entity }))
710    }
711}
712
713/// Small Liability Exchange
714pub async fn margin_create_margin_exchange_small_liability_v1(configuration: &configuration::Configuration, params: MarginCreateMarginExchangeSmallLiabilityV1Params) -> Result<models::MarginCreateMarginExchangeSmallLiabilityV1Resp, Error<MarginCreateMarginExchangeSmallLiabilityV1Error>> {
715
716    let uri_str = format!("{}/sapi/v1/margin/exchange-small-liability", configuration.base_path);
717    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
718
719    // Create a mutable vector for query parameters
720    let mut query_params: Vec<(String, String)> = Vec::new();
721
722
723    // Create header parameters collection
724    let mut header_params = std::collections::HashMap::new();
725
726    // Handle Binance Auth first if configured
727    if let Some(ref binance_auth) = configuration.binance_auth {
728        // Add API key to headers
729        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
730        
731        // Generate request body for signing (if any)
732        let body_string: Option<Vec<u8>> = None;
733        
734        // Sign the request
735        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
736            Ok(sig) => sig,
737            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
738        };
739        
740        // Add signature to query params
741        query_params.push(("signature".to_string(), signature));
742    }
743
744    // Apply all query parameters
745    if !query_params.is_empty() {
746        req_builder = req_builder.query(&query_params);
747    }
748
749
750    // Add user agent if configured
751    if let Some(ref user_agent) = configuration.user_agent {
752        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
753    }
754
755    // Apply all header parameters
756    for (header_name, header_value) in header_params {
757        req_builder = req_builder.header(&header_name, &header_value);
758    }
759
760    let mut multipart_form_params = std::collections::HashMap::new();
761    multipart_form_params.insert("assetNames", params.asset_names.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
762    if let Some(param_value) = params.recv_window {
763        multipart_form_params.insert("recvWindow", param_value.to_string());
764    }
765    multipart_form_params.insert("timestamp", params.timestamp.to_string());
766    req_builder = req_builder.form(&multipart_form_params);
767
768    let req = req_builder.build()?;
769    let resp = configuration.client.execute(req).await?;
770
771    let status = resp.status();
772    let content_type = resp
773        .headers()
774        .get("content-type")
775        .and_then(|v| v.to_str().ok())
776        .unwrap_or("application/octet-stream");
777    let content_type = super::ContentType::from(content_type);
778
779    if !status.is_client_error() && !status.is_server_error() {
780        let content = resp.text().await?;
781        match content_type {
782            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
783            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginExchangeSmallLiabilityV1Resp`"))),
784            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::MarginCreateMarginExchangeSmallLiabilityV1Resp`")))),
785        }
786    } else {
787        let content = resp.text().await?;
788        let entity: Option<MarginCreateMarginExchangeSmallLiabilityV1Error> = serde_json::from_str(&content).ok();
789        Err(Error::ResponseError(ResponseContent { status, content, entity }))
790    }
791}
792
793/// Margin Manual Liquidation
794pub async fn margin_create_margin_manual_liquidation_v1(configuration: &configuration::Configuration, params: MarginCreateMarginManualLiquidationV1Params) -> Result<models::MarginCreateMarginManualLiquidationV1Resp, Error<MarginCreateMarginManualLiquidationV1Error>> {
795
796    let uri_str = format!("{}/sapi/v1/margin/manual-liquidation", configuration.base_path);
797    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
798
799    // Create a mutable vector for query parameters
800    let mut query_params: Vec<(String, String)> = Vec::new();
801
802
803    // Create header parameters collection
804    let mut header_params = std::collections::HashMap::new();
805
806    // Handle Binance Auth first if configured
807    if let Some(ref binance_auth) = configuration.binance_auth {
808        // Add API key to headers
809        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
810        
811        // Generate request body for signing (if any)
812        let body_string: Option<Vec<u8>> = None;
813        
814        // Sign the request
815        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
816            Ok(sig) => sig,
817            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
818        };
819        
820        // Add signature to query params
821        query_params.push(("signature".to_string(), signature));
822    }
823
824    // Apply all query parameters
825    if !query_params.is_empty() {
826        req_builder = req_builder.query(&query_params);
827    }
828
829
830    // Add user agent if configured
831    if let Some(ref user_agent) = configuration.user_agent {
832        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
833    }
834
835    // Apply all header parameters
836    for (header_name, header_value) in header_params {
837        req_builder = req_builder.header(&header_name, &header_value);
838    }
839
840    let mut multipart_form_params = std::collections::HashMap::new();
841    if let Some(param_value) = params.recv_window {
842        multipart_form_params.insert("recvWindow", param_value.to_string());
843    }
844    if let Some(param_value) = params.symbol {
845        multipart_form_params.insert("symbol", param_value.to_string());
846    }
847    multipart_form_params.insert("timestamp", params.timestamp.to_string());
848    multipart_form_params.insert("type", params.r#type.to_string());
849    req_builder = req_builder.form(&multipart_form_params);
850
851    let req = req_builder.build()?;
852    let resp = configuration.client.execute(req).await?;
853
854    let status = resp.status();
855    let content_type = resp
856        .headers()
857        .get("content-type")
858        .and_then(|v| v.to_str().ok())
859        .unwrap_or("application/octet-stream");
860    let content_type = super::ContentType::from(content_type);
861
862    if !status.is_client_error() && !status.is_server_error() {
863        let content = resp.text().await?;
864        match content_type {
865            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
866            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginManualLiquidationV1Resp`"))),
867            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::MarginCreateMarginManualLiquidationV1Resp`")))),
868        }
869    } else {
870        let content = resp.text().await?;
871        let entity: Option<MarginCreateMarginManualLiquidationV1Error> = serde_json::from_str(&content).ok();
872        Err(Error::ResponseError(ResponseContent { status, content, entity }))
873    }
874}
875
876/// Send in a new OCO for a margin account
877pub async fn margin_create_margin_order_oco_v1(configuration: &configuration::Configuration, params: MarginCreateMarginOrderOcoV1Params) -> Result<models::MarginCreateMarginOrderOcoV1Resp, Error<MarginCreateMarginOrderOcoV1Error>> {
878
879    let uri_str = format!("{}/sapi/v1/margin/order/oco", configuration.base_path);
880    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
881
882    // Create a mutable vector for query parameters
883    let mut query_params: Vec<(String, String)> = Vec::new();
884
885
886    // Create header parameters collection
887    let mut header_params = std::collections::HashMap::new();
888
889    // Handle Binance Auth first if configured
890    if let Some(ref binance_auth) = configuration.binance_auth {
891        // Add API key to headers
892        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
893        
894        // Generate request body for signing (if any)
895        let body_string: Option<Vec<u8>> = None;
896        
897        // Sign the request
898        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
899            Ok(sig) => sig,
900            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
901        };
902        
903        // Add signature to query params
904        query_params.push(("signature".to_string(), signature));
905    }
906
907    // Apply all query parameters
908    if !query_params.is_empty() {
909        req_builder = req_builder.query(&query_params);
910    }
911
912
913    // Add user agent if configured
914    if let Some(ref user_agent) = configuration.user_agent {
915        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
916    }
917
918    // Apply all header parameters
919    for (header_name, header_value) in header_params {
920        req_builder = req_builder.header(&header_name, &header_value);
921    }
922
923    let mut multipart_form_params = std::collections::HashMap::new();
924    if let Some(param_value) = params.auto_repay_at_cancel {
925        multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
926    }
927    if let Some(param_value) = params.is_isolated {
928        multipart_form_params.insert("isIsolated", param_value.to_string());
929    }
930    if let Some(param_value) = params.limit_client_order_id {
931        multipart_form_params.insert("limitClientOrderId", param_value.to_string());
932    }
933    if let Some(param_value) = params.limit_iceberg_qty {
934        multipart_form_params.insert("limitIcebergQty", param_value.to_string());
935    }
936    if let Some(param_value) = params.list_client_order_id {
937        multipart_form_params.insert("listClientOrderId", param_value.to_string());
938    }
939    if let Some(param_value) = params.new_order_resp_type {
940        multipart_form_params.insert("newOrderRespType", param_value.to_string());
941    }
942    multipart_form_params.insert("price", params.price.to_string());
943    multipart_form_params.insert("quantity", params.quantity.to_string());
944    if let Some(param_value) = params.recv_window {
945        multipart_form_params.insert("recvWindow", param_value.to_string());
946    }
947    if let Some(param_value) = params.self_trade_prevention_mode {
948        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
949    }
950    multipart_form_params.insert("side", params.side.to_string());
951    if let Some(param_value) = params.side_effect_type {
952        multipart_form_params.insert("sideEffectType", param_value.to_string());
953    }
954    if let Some(param_value) = params.stop_client_order_id {
955        multipart_form_params.insert("stopClientOrderId", param_value.to_string());
956    }
957    if let Some(param_value) = params.stop_iceberg_qty {
958        multipart_form_params.insert("stopIcebergQty", param_value.to_string());
959    }
960    if let Some(param_value) = params.stop_limit_price {
961        multipart_form_params.insert("stopLimitPrice", param_value.to_string());
962    }
963    if let Some(param_value) = params.stop_limit_time_in_force {
964        multipart_form_params.insert("stopLimitTimeInForce", param_value.to_string());
965    }
966    multipart_form_params.insert("stopPrice", params.stop_price.to_string());
967    multipart_form_params.insert("symbol", params.symbol.to_string());
968    multipart_form_params.insert("timestamp", params.timestamp.to_string());
969    req_builder = req_builder.form(&multipart_form_params);
970
971    let req = req_builder.build()?;
972    let resp = configuration.client.execute(req).await?;
973
974    let status = resp.status();
975    let content_type = resp
976        .headers()
977        .get("content-type")
978        .and_then(|v| v.to_str().ok())
979        .unwrap_or("application/octet-stream");
980    let content_type = super::ContentType::from(content_type);
981
982    if !status.is_client_error() && !status.is_server_error() {
983        let content = resp.text().await?;
984        match content_type {
985            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
986            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginOrderOcoV1Resp`"))),
987            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::MarginCreateMarginOrderOcoV1Resp`")))),
988        }
989    } else {
990        let content = resp.text().await?;
991        let entity: Option<MarginCreateMarginOrderOcoV1Error> = serde_json::from_str(&content).ok();
992        Err(Error::ResponseError(ResponseContent { status, content, entity }))
993    }
994}
995
996/// Post a new OTO order for margin account:
997pub async fn margin_create_margin_order_oto_v1(configuration: &configuration::Configuration, params: MarginCreateMarginOrderOtoV1Params) -> Result<models::MarginCreateMarginOrderOtoV1Resp, Error<MarginCreateMarginOrderOtoV1Error>> {
998
999    let uri_str = format!("{}/sapi/v1/margin/order/oto", configuration.base_path);
1000    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1001
1002    // Create a mutable vector for query parameters
1003    let mut query_params: Vec<(String, String)> = Vec::new();
1004
1005
1006    // Create header parameters collection
1007    let mut header_params = std::collections::HashMap::new();
1008
1009    // Handle Binance Auth first if configured
1010    if let Some(ref binance_auth) = configuration.binance_auth {
1011        // Add API key to headers
1012        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1013        
1014        // Generate request body for signing (if any)
1015        let body_string: Option<Vec<u8>> = None;
1016        
1017        // Sign the request
1018        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1019            Ok(sig) => sig,
1020            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1021        };
1022        
1023        // Add signature to query params
1024        query_params.push(("signature".to_string(), signature));
1025    }
1026
1027    // Apply all query parameters
1028    if !query_params.is_empty() {
1029        req_builder = req_builder.query(&query_params);
1030    }
1031
1032
1033    // Add user agent if configured
1034    if let Some(ref user_agent) = configuration.user_agent {
1035        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1036    }
1037
1038    // Apply all header parameters
1039    for (header_name, header_value) in header_params {
1040        req_builder = req_builder.header(&header_name, &header_value);
1041    }
1042
1043    let mut multipart_form_params = std::collections::HashMap::new();
1044    if let Some(param_value) = params.auto_repay_at_cancel {
1045        multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
1046    }
1047    if let Some(param_value) = params.is_isolated {
1048        multipart_form_params.insert("isIsolated", param_value.to_string());
1049    }
1050    if let Some(param_value) = params.list_client_order_id {
1051        multipart_form_params.insert("listClientOrderId", param_value.to_string());
1052    }
1053    if let Some(param_value) = params.new_order_resp_type {
1054        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1055    }
1056    if let Some(param_value) = params.pending_client_order_id {
1057        multipart_form_params.insert("pendingClientOrderId", param_value.to_string());
1058    }
1059    if let Some(param_value) = params.pending_iceberg_qty {
1060        multipart_form_params.insert("pendingIcebergQty", param_value.to_string());
1061    }
1062    if let Some(param_value) = params.pending_price {
1063        multipart_form_params.insert("pendingPrice", param_value.to_string());
1064    }
1065    multipart_form_params.insert("pendingQuantity", params.pending_quantity.to_string());
1066    multipart_form_params.insert("pendingSide", params.pending_side.to_string());
1067    if let Some(param_value) = params.pending_stop_price {
1068        multipart_form_params.insert("pendingStopPrice", param_value.to_string());
1069    }
1070    if let Some(param_value) = params.pending_time_in_force {
1071        multipart_form_params.insert("pendingTimeInForce", param_value.to_string());
1072    }
1073    if let Some(param_value) = params.pending_trailing_delta {
1074        multipart_form_params.insert("pendingTrailingDelta", param_value.to_string());
1075    }
1076    multipart_form_params.insert("pendingType", params.pending_type.to_string());
1077    if let Some(param_value) = params.self_trade_prevention_mode {
1078        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1079    }
1080    if let Some(param_value) = params.side_effect_type {
1081        multipart_form_params.insert("sideEffectType", param_value.to_string());
1082    }
1083    multipart_form_params.insert("symbol", params.symbol.to_string());
1084    if let Some(param_value) = params.working_client_order_id {
1085        multipart_form_params.insert("workingClientOrderId", param_value.to_string());
1086    }
1087    multipart_form_params.insert("workingIcebergQty", params.working_iceberg_qty.to_string());
1088    multipart_form_params.insert("workingPrice", params.working_price.to_string());
1089    multipart_form_params.insert("workingQuantity", params.working_quantity.to_string());
1090    multipart_form_params.insert("workingSide", params.working_side.to_string());
1091    if let Some(param_value) = params.working_time_in_force {
1092        multipart_form_params.insert("workingTimeInForce", param_value.to_string());
1093    }
1094    multipart_form_params.insert("workingType", params.working_type.to_string());
1095    req_builder = req_builder.form(&multipart_form_params);
1096
1097    let req = req_builder.build()?;
1098    let resp = configuration.client.execute(req).await?;
1099
1100    let status = resp.status();
1101    let content_type = resp
1102        .headers()
1103        .get("content-type")
1104        .and_then(|v| v.to_str().ok())
1105        .unwrap_or("application/octet-stream");
1106    let content_type = super::ContentType::from(content_type);
1107
1108    if !status.is_client_error() && !status.is_server_error() {
1109        let content = resp.text().await?;
1110        match content_type {
1111            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1112            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginOrderOtoV1Resp`"))),
1113            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::MarginCreateMarginOrderOtoV1Resp`")))),
1114        }
1115    } else {
1116        let content = resp.text().await?;
1117        let entity: Option<MarginCreateMarginOrderOtoV1Error> = serde_json::from_str(&content).ok();
1118        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1119    }
1120}
1121
1122/// Post a new OTOCO order for margin account:
1123pub async fn margin_create_margin_order_otoco_v1(configuration: &configuration::Configuration, params: MarginCreateMarginOrderOtocoV1Params) -> Result<models::MarginCreateMarginOrderOtocoV1Resp, Error<MarginCreateMarginOrderOtocoV1Error>> {
1124
1125    let uri_str = format!("{}/sapi/v1/margin/order/otoco", configuration.base_path);
1126    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1127
1128    // Create a mutable vector for query parameters
1129    let mut query_params: Vec<(String, String)> = Vec::new();
1130
1131
1132    // Create header parameters collection
1133    let mut header_params = std::collections::HashMap::new();
1134
1135    // Handle Binance Auth first if configured
1136    if let Some(ref binance_auth) = configuration.binance_auth {
1137        // Add API key to headers
1138        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1139        
1140        // Generate request body for signing (if any)
1141        let body_string: Option<Vec<u8>> = None;
1142        
1143        // Sign the request
1144        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1145            Ok(sig) => sig,
1146            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1147        };
1148        
1149        // Add signature to query params
1150        query_params.push(("signature".to_string(), signature));
1151    }
1152
1153    // Apply all query parameters
1154    if !query_params.is_empty() {
1155        req_builder = req_builder.query(&query_params);
1156    }
1157
1158
1159    // Add user agent if configured
1160    if let Some(ref user_agent) = configuration.user_agent {
1161        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1162    }
1163
1164    // Apply all header parameters
1165    for (header_name, header_value) in header_params {
1166        req_builder = req_builder.header(&header_name, &header_value);
1167    }
1168
1169    let mut multipart_form_params = std::collections::HashMap::new();
1170    if let Some(param_value) = params.auto_repay_at_cancel {
1171        multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
1172    }
1173    if let Some(param_value) = params.is_isolated {
1174        multipart_form_params.insert("isIsolated", param_value.to_string());
1175    }
1176    if let Some(param_value) = params.list_client_order_id {
1177        multipart_form_params.insert("listClientOrderId", param_value.to_string());
1178    }
1179    if let Some(param_value) = params.new_order_resp_type {
1180        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1181    }
1182    if let Some(param_value) = params.pending_above_client_order_id {
1183        multipart_form_params.insert("pendingAboveClientOrderId", param_value.to_string());
1184    }
1185    if let Some(param_value) = params.pending_above_iceberg_qty {
1186        multipart_form_params.insert("pendingAboveIcebergQty", param_value.to_string());
1187    }
1188    if let Some(param_value) = params.pending_above_price {
1189        multipart_form_params.insert("pendingAbovePrice", param_value.to_string());
1190    }
1191    if let Some(param_value) = params.pending_above_stop_price {
1192        multipart_form_params.insert("pendingAboveStopPrice", param_value.to_string());
1193    }
1194    if let Some(param_value) = params.pending_above_time_in_force {
1195        multipart_form_params.insert("pendingAboveTimeInForce", param_value.to_string());
1196    }
1197    if let Some(param_value) = params.pending_above_trailing_delta {
1198        multipart_form_params.insert("pendingAboveTrailingDelta", param_value.to_string());
1199    }
1200    multipart_form_params.insert("pendingAboveType", params.pending_above_type.to_string());
1201    if let Some(param_value) = params.pending_below_client_order_id {
1202        multipart_form_params.insert("pendingBelowClientOrderId", param_value.to_string());
1203    }
1204    if let Some(param_value) = params.pending_below_iceberg_qty {
1205        multipart_form_params.insert("pendingBelowIcebergQty", param_value.to_string());
1206    }
1207    if let Some(param_value) = params.pending_below_price {
1208        multipart_form_params.insert("pendingBelowPrice", param_value.to_string());
1209    }
1210    if let Some(param_value) = params.pending_below_stop_price {
1211        multipart_form_params.insert("pendingBelowStopPrice", param_value.to_string());
1212    }
1213    if let Some(param_value) = params.pending_below_time_in_force {
1214        multipart_form_params.insert("pendingBelowTimeInForce", param_value.to_string());
1215    }
1216    if let Some(param_value) = params.pending_below_trailing_delta {
1217        multipart_form_params.insert("pendingBelowTrailingDelta", param_value.to_string());
1218    }
1219    if let Some(param_value) = params.pending_below_type {
1220        multipart_form_params.insert("pendingBelowType", param_value.to_string());
1221    }
1222    multipart_form_params.insert("pendingQuantity", params.pending_quantity.to_string());
1223    multipart_form_params.insert("pendingSide", params.pending_side.to_string());
1224    if let Some(param_value) = params.self_trade_prevention_mode {
1225        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1226    }
1227    if let Some(param_value) = params.side_effect_type {
1228        multipart_form_params.insert("sideEffectType", param_value.to_string());
1229    }
1230    multipart_form_params.insert("symbol", params.symbol.to_string());
1231    if let Some(param_value) = params.working_client_order_id {
1232        multipart_form_params.insert("workingClientOrderId", param_value.to_string());
1233    }
1234    if let Some(param_value) = params.working_iceberg_qty {
1235        multipart_form_params.insert("workingIcebergQty", param_value.to_string());
1236    }
1237    multipart_form_params.insert("workingPrice", params.working_price.to_string());
1238    multipart_form_params.insert("workingQuantity", params.working_quantity.to_string());
1239    multipart_form_params.insert("workingSide", params.working_side.to_string());
1240    if let Some(param_value) = params.working_time_in_force {
1241        multipart_form_params.insert("workingTimeInForce", param_value.to_string());
1242    }
1243    multipart_form_params.insert("workingType", params.working_type.to_string());
1244    req_builder = req_builder.form(&multipart_form_params);
1245
1246    let req = req_builder.build()?;
1247    let resp = configuration.client.execute(req).await?;
1248
1249    let status = resp.status();
1250    let content_type = resp
1251        .headers()
1252        .get("content-type")
1253        .and_then(|v| v.to_str().ok())
1254        .unwrap_or("application/octet-stream");
1255    let content_type = super::ContentType::from(content_type);
1256
1257    if !status.is_client_error() && !status.is_server_error() {
1258        let content = resp.text().await?;
1259        match content_type {
1260            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1261            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginOrderOtocoV1Resp`"))),
1262            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::MarginCreateMarginOrderOtocoV1Resp`")))),
1263        }
1264    } else {
1265        let content = resp.text().await?;
1266        let entity: Option<MarginCreateMarginOrderOtocoV1Error> = serde_json::from_str(&content).ok();
1267        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1268    }
1269}
1270
1271/// Post a new order for margin account.
1272pub async fn margin_create_margin_order_v1(configuration: &configuration::Configuration, params: MarginCreateMarginOrderV1Params) -> Result<models::MarginCreateMarginOrderV1Resp, Error<MarginCreateMarginOrderV1Error>> {
1273
1274    let uri_str = format!("{}/sapi/v1/margin/order", configuration.base_path);
1275    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1276
1277    // Create a mutable vector for query parameters
1278    let mut query_params: Vec<(String, String)> = Vec::new();
1279
1280
1281    // Create header parameters collection
1282    let mut header_params = std::collections::HashMap::new();
1283
1284    // Handle Binance Auth first if configured
1285    if let Some(ref binance_auth) = configuration.binance_auth {
1286        // Add API key to headers
1287        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1288        
1289        // Generate request body for signing (if any)
1290        let body_string: Option<Vec<u8>> = None;
1291        
1292        // Sign the request
1293        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1294            Ok(sig) => sig,
1295            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1296        };
1297        
1298        // Add signature to query params
1299        query_params.push(("signature".to_string(), signature));
1300    }
1301
1302    // Apply all query parameters
1303    if !query_params.is_empty() {
1304        req_builder = req_builder.query(&query_params);
1305    }
1306
1307
1308    // Add user agent if configured
1309    if let Some(ref user_agent) = configuration.user_agent {
1310        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1311    }
1312
1313    // Apply all header parameters
1314    for (header_name, header_value) in header_params {
1315        req_builder = req_builder.header(&header_name, &header_value);
1316    }
1317
1318    let mut multipart_form_params = std::collections::HashMap::new();
1319    if let Some(param_value) = params.auto_repay_at_cancel {
1320        multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
1321    }
1322    if let Some(param_value) = params.iceberg_qty {
1323        multipart_form_params.insert("icebergQty", param_value.to_string());
1324    }
1325    if let Some(param_value) = params.is_isolated {
1326        multipart_form_params.insert("isIsolated", param_value.to_string());
1327    }
1328    if let Some(param_value) = params.new_client_order_id {
1329        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1330    }
1331    if let Some(param_value) = params.new_order_resp_type {
1332        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1333    }
1334    if let Some(param_value) = params.price {
1335        multipart_form_params.insert("price", param_value.to_string());
1336    }
1337    if let Some(param_value) = params.quantity {
1338        multipart_form_params.insert("quantity", param_value.to_string());
1339    }
1340    if let Some(param_value) = params.quote_order_qty {
1341        multipart_form_params.insert("quoteOrderQty", param_value.to_string());
1342    }
1343    if let Some(param_value) = params.recv_window {
1344        multipart_form_params.insert("recvWindow", param_value.to_string());
1345    }
1346    if let Some(param_value) = params.self_trade_prevention_mode {
1347        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1348    }
1349    multipart_form_params.insert("side", params.side.to_string());
1350    if let Some(param_value) = params.side_effect_type {
1351        multipart_form_params.insert("sideEffectType", param_value.to_string());
1352    }
1353    if let Some(param_value) = params.stop_price {
1354        multipart_form_params.insert("stopPrice", param_value.to_string());
1355    }
1356    multipart_form_params.insert("symbol", params.symbol.to_string());
1357    if let Some(param_value) = params.time_in_force {
1358        multipart_form_params.insert("timeInForce", param_value.to_string());
1359    }
1360    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1361    multipart_form_params.insert("type", params.r#type.to_string());
1362    req_builder = req_builder.form(&multipart_form_params);
1363
1364    let req = req_builder.build()?;
1365    let resp = configuration.client.execute(req).await?;
1366
1367    let status = resp.status();
1368    let content_type = resp
1369        .headers()
1370        .get("content-type")
1371        .and_then(|v| v.to_str().ok())
1372        .unwrap_or("application/octet-stream");
1373    let content_type = super::ContentType::from(content_type);
1374
1375    if !status.is_client_error() && !status.is_server_error() {
1376        let content = resp.text().await?;
1377        match content_type {
1378            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1379            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginOrderV1Resp`"))),
1380            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::MarginCreateMarginOrderV1Resp`")))),
1381        }
1382    } else {
1383        let content = resp.text().await?;
1384        let entity: Option<MarginCreateMarginOrderV1Error> = serde_json::from_str(&content).ok();
1385        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1386    }
1387}
1388
1389/// This only applies to Special Key for Low Latency Trading.
1390pub async fn margin_delete_margin_api_key_v1(configuration: &configuration::Configuration, params: MarginDeleteMarginApiKeyV1Params) -> Result<serde_json::Value, Error<MarginDeleteMarginApiKeyV1Error>> {
1391
1392    let uri_str = format!("{}/sapi/v1/margin/apiKey", configuration.base_path);
1393    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1394
1395    // Create a mutable vector for query parameters
1396    let mut query_params: Vec<(String, String)> = Vec::new();
1397
1398    if let Some(ref param_value) = params.api_key {
1399        query_params.push(("apiKey".to_string(), param_value.to_string()));
1400    }
1401    if let Some(ref param_value) = params.api_name {
1402        query_params.push(("apiName".to_string(), param_value.to_string()));
1403    }
1404    if let Some(ref param_value) = params.symbol {
1405        query_params.push(("symbol".to_string(), param_value.to_string()));
1406    }
1407    if let Some(ref param_value) = params.recv_window {
1408        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1409    }
1410    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1411
1412    // Create header parameters collection
1413    let mut header_params = std::collections::HashMap::new();
1414
1415    // Handle Binance Auth first if configured
1416    if let Some(ref binance_auth) = configuration.binance_auth {
1417        // Add API key to headers
1418        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1419        
1420        // Generate request body for signing (if any)
1421        let body_string: Option<Vec<u8>> = None;
1422        
1423        // Sign the request
1424        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1425            Ok(sig) => sig,
1426            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1427        };
1428        
1429        // Add signature to query params
1430        query_params.push(("signature".to_string(), signature));
1431    }
1432
1433    // Apply all query parameters
1434    if !query_params.is_empty() {
1435        req_builder = req_builder.query(&query_params);
1436    }
1437
1438
1439    // Add user agent if configured
1440    if let Some(ref user_agent) = configuration.user_agent {
1441        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1442    }
1443
1444    // Apply all header parameters
1445    for (header_name, header_value) in header_params {
1446        req_builder = req_builder.header(&header_name, &header_value);
1447    }
1448
1449
1450    let req = req_builder.build()?;
1451    let resp = configuration.client.execute(req).await?;
1452
1453    let status = resp.status();
1454    let content_type = resp
1455        .headers()
1456        .get("content-type")
1457        .and_then(|v| v.to_str().ok())
1458        .unwrap_or("application/octet-stream");
1459    let content_type = super::ContentType::from(content_type);
1460
1461    if !status.is_client_error() && !status.is_server_error() {
1462        let content = resp.text().await?;
1463        match content_type {
1464            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1465            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
1466            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`")))),
1467        }
1468    } else {
1469        let content = resp.text().await?;
1470        let entity: Option<MarginDeleteMarginApiKeyV1Error> = serde_json::from_str(&content).ok();
1471        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1472    }
1473}
1474
1475/// Cancels all active orders on a symbol for margin account. This includes OCO orders.
1476pub async fn margin_delete_margin_open_orders_v1(configuration: &configuration::Configuration, params: MarginDeleteMarginOpenOrdersV1Params) -> Result<Vec<models::MarginDeleteMarginOpenOrdersV1RespItem>, Error<MarginDeleteMarginOpenOrdersV1Error>> {
1477
1478    let uri_str = format!("{}/sapi/v1/margin/openOrders", configuration.base_path);
1479    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1480
1481    // Create a mutable vector for query parameters
1482    let mut query_params: Vec<(String, String)> = Vec::new();
1483
1484    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1485    if let Some(ref param_value) = params.is_isolated {
1486        query_params.push(("isIsolated".to_string(), param_value.to_string()));
1487    }
1488    if let Some(ref param_value) = params.recv_window {
1489        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1490    }
1491    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1492
1493    // Create header parameters collection
1494    let mut header_params = std::collections::HashMap::new();
1495
1496    // Handle Binance Auth first if configured
1497    if let Some(ref binance_auth) = configuration.binance_auth {
1498        // Add API key to headers
1499        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1500        
1501        // Generate request body for signing (if any)
1502        let body_string: Option<Vec<u8>> = None;
1503        
1504        // Sign the request
1505        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1506            Ok(sig) => sig,
1507            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1508        };
1509        
1510        // Add signature to query params
1511        query_params.push(("signature".to_string(), signature));
1512    }
1513
1514    // Apply all query parameters
1515    if !query_params.is_empty() {
1516        req_builder = req_builder.query(&query_params);
1517    }
1518
1519
1520    // Add user agent if configured
1521    if let Some(ref user_agent) = configuration.user_agent {
1522        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1523    }
1524
1525    // Apply all header parameters
1526    for (header_name, header_value) in header_params {
1527        req_builder = req_builder.header(&header_name, &header_value);
1528    }
1529
1530
1531    let req = req_builder.build()?;
1532    let resp = configuration.client.execute(req).await?;
1533
1534    let status = resp.status();
1535    let content_type = resp
1536        .headers()
1537        .get("content-type")
1538        .and_then(|v| v.to_str().ok())
1539        .unwrap_or("application/octet-stream");
1540    let content_type = super::ContentType::from(content_type);
1541
1542    if !status.is_client_error() && !status.is_server_error() {
1543        let content = resp.text().await?;
1544        match content_type {
1545            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1546            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginDeleteMarginOpenOrdersV1RespItem&gt;`"))),
1547            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::MarginDeleteMarginOpenOrdersV1RespItem&gt;`")))),
1548        }
1549    } else {
1550        let content = resp.text().await?;
1551        let entity: Option<MarginDeleteMarginOpenOrdersV1Error> = serde_json::from_str(&content).ok();
1552        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1553    }
1554}
1555
1556/// Cancel an entire Order List for a margin account.
1557pub async fn margin_delete_margin_order_list_v1(configuration: &configuration::Configuration, params: MarginDeleteMarginOrderListV1Params) -> Result<models::MarginDeleteMarginOrderListV1Resp, Error<MarginDeleteMarginOrderListV1Error>> {
1558
1559    let uri_str = format!("{}/sapi/v1/margin/orderList", configuration.base_path);
1560    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1561
1562    // Create a mutable vector for query parameters
1563    let mut query_params: Vec<(String, String)> = Vec::new();
1564
1565    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1566    if let Some(ref param_value) = params.is_isolated {
1567        query_params.push(("isIsolated".to_string(), param_value.to_string()));
1568    }
1569    if let Some(ref param_value) = params.order_list_id {
1570        query_params.push(("orderListId".to_string(), param_value.to_string()));
1571    }
1572    if let Some(ref param_value) = params.list_client_order_id {
1573        query_params.push(("listClientOrderId".to_string(), param_value.to_string()));
1574    }
1575    if let Some(ref param_value) = params.new_client_order_id {
1576        query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
1577    }
1578    if let Some(ref param_value) = params.recv_window {
1579        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1580    }
1581    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1582
1583    // Create header parameters collection
1584    let mut header_params = std::collections::HashMap::new();
1585
1586    // Handle Binance Auth first if configured
1587    if let Some(ref binance_auth) = configuration.binance_auth {
1588        // Add API key to headers
1589        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1590        
1591        // Generate request body for signing (if any)
1592        let body_string: Option<Vec<u8>> = None;
1593        
1594        // Sign the request
1595        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1596            Ok(sig) => sig,
1597            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1598        };
1599        
1600        // Add signature to query params
1601        query_params.push(("signature".to_string(), signature));
1602    }
1603
1604    // Apply all query parameters
1605    if !query_params.is_empty() {
1606        req_builder = req_builder.query(&query_params);
1607    }
1608
1609
1610    // Add user agent if configured
1611    if let Some(ref user_agent) = configuration.user_agent {
1612        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1613    }
1614
1615    // Apply all header parameters
1616    for (header_name, header_value) in header_params {
1617        req_builder = req_builder.header(&header_name, &header_value);
1618    }
1619
1620
1621    let req = req_builder.build()?;
1622    let resp = configuration.client.execute(req).await?;
1623
1624    let status = resp.status();
1625    let content_type = resp
1626        .headers()
1627        .get("content-type")
1628        .and_then(|v| v.to_str().ok())
1629        .unwrap_or("application/octet-stream");
1630    let content_type = super::ContentType::from(content_type);
1631
1632    if !status.is_client_error() && !status.is_server_error() {
1633        let content = resp.text().await?;
1634        match content_type {
1635            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1636            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginDeleteMarginOrderListV1Resp`"))),
1637            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::MarginDeleteMarginOrderListV1Resp`")))),
1638        }
1639    } else {
1640        let content = resp.text().await?;
1641        let entity: Option<MarginDeleteMarginOrderListV1Error> = serde_json::from_str(&content).ok();
1642        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1643    }
1644}
1645
1646/// Cancel an active order for margin account.
1647pub async fn margin_delete_margin_order_v1(configuration: &configuration::Configuration, params: MarginDeleteMarginOrderV1Params) -> Result<models::MarginDeleteMarginOrderV1Resp, Error<MarginDeleteMarginOrderV1Error>> {
1648
1649    let uri_str = format!("{}/sapi/v1/margin/order", configuration.base_path);
1650    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1651
1652    // Create a mutable vector for query parameters
1653    let mut query_params: Vec<(String, String)> = Vec::new();
1654
1655    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1656    if let Some(ref param_value) = params.is_isolated {
1657        query_params.push(("isIsolated".to_string(), param_value.to_string()));
1658    }
1659    if let Some(ref param_value) = params.order_id {
1660        query_params.push(("orderId".to_string(), param_value.to_string()));
1661    }
1662    if let Some(ref param_value) = params.orig_client_order_id {
1663        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
1664    }
1665    if let Some(ref param_value) = params.new_client_order_id {
1666        query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
1667    }
1668    if let Some(ref param_value) = params.recv_window {
1669        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1670    }
1671    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1672
1673    // Create header parameters collection
1674    let mut header_params = std::collections::HashMap::new();
1675
1676    // Handle Binance Auth first if configured
1677    if let Some(ref binance_auth) = configuration.binance_auth {
1678        // Add API key to headers
1679        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1680        
1681        // Generate request body for signing (if any)
1682        let body_string: Option<Vec<u8>> = None;
1683        
1684        // Sign the request
1685        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1686            Ok(sig) => sig,
1687            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1688        };
1689        
1690        // Add signature to query params
1691        query_params.push(("signature".to_string(), signature));
1692    }
1693
1694    // Apply all query parameters
1695    if !query_params.is_empty() {
1696        req_builder = req_builder.query(&query_params);
1697    }
1698
1699
1700    // Add user agent if configured
1701    if let Some(ref user_agent) = configuration.user_agent {
1702        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1703    }
1704
1705    // Apply all header parameters
1706    for (header_name, header_value) in header_params {
1707        req_builder = req_builder.header(&header_name, &header_value);
1708    }
1709
1710
1711    let req = req_builder.build()?;
1712    let resp = configuration.client.execute(req).await?;
1713
1714    let status = resp.status();
1715    let content_type = resp
1716        .headers()
1717        .get("content-type")
1718        .and_then(|v| v.to_str().ok())
1719        .unwrap_or("application/octet-stream");
1720    let content_type = super::ContentType::from(content_type);
1721
1722    if !status.is_client_error() && !status.is_server_error() {
1723        let content = resp.text().await?;
1724        match content_type {
1725            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1726            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginDeleteMarginOrderV1Resp`"))),
1727            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::MarginDeleteMarginOrderV1Resp`")))),
1728        }
1729    } else {
1730        let content = resp.text().await?;
1731        let entity: Option<MarginDeleteMarginOrderV1Error> = serde_json::from_str(&content).ok();
1732        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1733    }
1734}
1735
1736/// Retrieves all OCO for a specific margin account based on provided optional parameters
1737pub async fn margin_get_margin_all_order_list_v1(configuration: &configuration::Configuration, params: MarginGetMarginAllOrderListV1Params) -> Result<Vec<models::MarginGetMarginAllOrderListV1RespItem>, Error<MarginGetMarginAllOrderListV1Error>> {
1738
1739    let uri_str = format!("{}/sapi/v1/margin/allOrderList", configuration.base_path);
1740    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1741
1742    // Create a mutable vector for query parameters
1743    let mut query_params: Vec<(String, String)> = Vec::new();
1744
1745    if let Some(ref param_value) = params.is_isolated {
1746        query_params.push(("isIsolated".to_string(), param_value.to_string()));
1747    }
1748    if let Some(ref param_value) = params.symbol {
1749        query_params.push(("symbol".to_string(), param_value.to_string()));
1750    }
1751    if let Some(ref param_value) = params.from_id {
1752        query_params.push(("fromId".to_string(), param_value.to_string()));
1753    }
1754    if let Some(ref param_value) = params.start_time {
1755        query_params.push(("startTime".to_string(), param_value.to_string()));
1756    }
1757    if let Some(ref param_value) = params.end_time {
1758        query_params.push(("endTime".to_string(), param_value.to_string()));
1759    }
1760    if let Some(ref param_value) = params.limit {
1761        query_params.push(("limit".to_string(), param_value.to_string()));
1762    }
1763    if let Some(ref param_value) = params.recv_window {
1764        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1765    }
1766    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1767
1768    // Create header parameters collection
1769    let mut header_params = std::collections::HashMap::new();
1770
1771    // Handle Binance Auth first if configured
1772    if let Some(ref binance_auth) = configuration.binance_auth {
1773        // Add API key to headers
1774        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1775        
1776        // Generate request body for signing (if any)
1777        let body_string: Option<Vec<u8>> = None;
1778        
1779        // Sign the request
1780        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1781            Ok(sig) => sig,
1782            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1783        };
1784        
1785        // Add signature to query params
1786        query_params.push(("signature".to_string(), signature));
1787    }
1788
1789    // Apply all query parameters
1790    if !query_params.is_empty() {
1791        req_builder = req_builder.query(&query_params);
1792    }
1793
1794
1795    // Add user agent if configured
1796    if let Some(ref user_agent) = configuration.user_agent {
1797        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1798    }
1799
1800    // Apply all header parameters
1801    for (header_name, header_value) in header_params {
1802        req_builder = req_builder.header(&header_name, &header_value);
1803    }
1804
1805
1806    let req = req_builder.build()?;
1807    let resp = configuration.client.execute(req).await?;
1808
1809    let status = resp.status();
1810    let content_type = resp
1811        .headers()
1812        .get("content-type")
1813        .and_then(|v| v.to_str().ok())
1814        .unwrap_or("application/octet-stream");
1815    let content_type = super::ContentType::from(content_type);
1816
1817    if !status.is_client_error() && !status.is_server_error() {
1818        let content = resp.text().await?;
1819        match content_type {
1820            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1821            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginAllOrderListV1RespItem&gt;`"))),
1822            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::MarginGetMarginAllOrderListV1RespItem&gt;`")))),
1823        }
1824    } else {
1825        let content = resp.text().await?;
1826        let entity: Option<MarginGetMarginAllOrderListV1Error> = serde_json::from_str(&content).ok();
1827        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1828    }
1829}
1830
1831/// Query Margin Account's All Orders
1832pub async fn margin_get_margin_all_orders_v1(configuration: &configuration::Configuration, params: MarginGetMarginAllOrdersV1Params) -> Result<Vec<models::MarginGetMarginAllOrdersV1RespItem>, Error<MarginGetMarginAllOrdersV1Error>> {
1833
1834    let uri_str = format!("{}/sapi/v1/margin/allOrders", configuration.base_path);
1835    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1836
1837    // Create a mutable vector for query parameters
1838    let mut query_params: Vec<(String, String)> = Vec::new();
1839
1840    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1841    if let Some(ref param_value) = params.is_isolated {
1842        query_params.push(("isIsolated".to_string(), param_value.to_string()));
1843    }
1844    if let Some(ref param_value) = params.order_id {
1845        query_params.push(("orderId".to_string(), param_value.to_string()));
1846    }
1847    if let Some(ref param_value) = params.start_time {
1848        query_params.push(("startTime".to_string(), param_value.to_string()));
1849    }
1850    if let Some(ref param_value) = params.end_time {
1851        query_params.push(("endTime".to_string(), param_value.to_string()));
1852    }
1853    if let Some(ref param_value) = params.limit {
1854        query_params.push(("limit".to_string(), param_value.to_string()));
1855    }
1856    if let Some(ref param_value) = params.recv_window {
1857        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1858    }
1859    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1860
1861    // Create header parameters collection
1862    let mut header_params = std::collections::HashMap::new();
1863
1864    // Handle Binance Auth first if configured
1865    if let Some(ref binance_auth) = configuration.binance_auth {
1866        // Add API key to headers
1867        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1868        
1869        // Generate request body for signing (if any)
1870        let body_string: Option<Vec<u8>> = None;
1871        
1872        // Sign the request
1873        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1874            Ok(sig) => sig,
1875            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1876        };
1877        
1878        // Add signature to query params
1879        query_params.push(("signature".to_string(), signature));
1880    }
1881
1882    // Apply all query parameters
1883    if !query_params.is_empty() {
1884        req_builder = req_builder.query(&query_params);
1885    }
1886
1887
1888    // Add user agent if configured
1889    if let Some(ref user_agent) = configuration.user_agent {
1890        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1891    }
1892
1893    // Apply all header parameters
1894    for (header_name, header_value) in header_params {
1895        req_builder = req_builder.header(&header_name, &header_value);
1896    }
1897
1898
1899    let req = req_builder.build()?;
1900    let resp = configuration.client.execute(req).await?;
1901
1902    let status = resp.status();
1903    let content_type = resp
1904        .headers()
1905        .get("content-type")
1906        .and_then(|v| v.to_str().ok())
1907        .unwrap_or("application/octet-stream");
1908    let content_type = super::ContentType::from(content_type);
1909
1910    if !status.is_client_error() && !status.is_server_error() {
1911        let content = resp.text().await?;
1912        match content_type {
1913            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1914            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginAllOrdersV1RespItem&gt;`"))),
1915            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::MarginGetMarginAllOrdersV1RespItem&gt;`")))),
1916        }
1917    } else {
1918        let content = resp.text().await?;
1919        let entity: Option<MarginGetMarginAllOrdersV1Error> = serde_json::from_str(&content).ok();
1920        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1921    }
1922}
1923
1924/// This only applies to Special Key for Low Latency Trading.
1925pub async fn margin_get_margin_api_key_list_v1(configuration: &configuration::Configuration, params: MarginGetMarginApiKeyListV1Params) -> Result<Vec<models::MarginGetMarginApiKeyListV1RespItem>, Error<MarginGetMarginApiKeyListV1Error>> {
1926
1927    let uri_str = format!("{}/sapi/v1/margin/api-key-list", configuration.base_path);
1928    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1929
1930    // Create a mutable vector for query parameters
1931    let mut query_params: Vec<(String, String)> = Vec::new();
1932
1933    if let Some(ref param_value) = params.symbol {
1934        query_params.push(("symbol".to_string(), param_value.to_string()));
1935    }
1936    if let Some(ref param_value) = params.recv_window {
1937        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1938    }
1939    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1940
1941    // Create header parameters collection
1942    let mut header_params = std::collections::HashMap::new();
1943
1944    // Handle Binance Auth first if configured
1945    if let Some(ref binance_auth) = configuration.binance_auth {
1946        // Add API key to headers
1947        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1948        
1949        // Generate request body for signing (if any)
1950        let body_string: Option<Vec<u8>> = None;
1951        
1952        // Sign the request
1953        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1954            Ok(sig) => sig,
1955            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1956        };
1957        
1958        // Add signature to query params
1959        query_params.push(("signature".to_string(), signature));
1960    }
1961
1962    // Apply all query parameters
1963    if !query_params.is_empty() {
1964        req_builder = req_builder.query(&query_params);
1965    }
1966
1967
1968    // Add user agent if configured
1969    if let Some(ref user_agent) = configuration.user_agent {
1970        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1971    }
1972
1973    // Apply all header parameters
1974    for (header_name, header_value) in header_params {
1975        req_builder = req_builder.header(&header_name, &header_value);
1976    }
1977
1978
1979    let req = req_builder.build()?;
1980    let resp = configuration.client.execute(req).await?;
1981
1982    let status = resp.status();
1983    let content_type = resp
1984        .headers()
1985        .get("content-type")
1986        .and_then(|v| v.to_str().ok())
1987        .unwrap_or("application/octet-stream");
1988    let content_type = super::ContentType::from(content_type);
1989
1990    if !status.is_client_error() && !status.is_server_error() {
1991        let content = resp.text().await?;
1992        match content_type {
1993            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1994            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginApiKeyListV1RespItem&gt;`"))),
1995            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::MarginGetMarginApiKeyListV1RespItem&gt;`")))),
1996        }
1997    } else {
1998        let content = resp.text().await?;
1999        let entity: Option<MarginGetMarginApiKeyListV1Error> = serde_json::from_str(&content).ok();
2000        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2001    }
2002}
2003
2004/// Query Special Key Information.
2005pub async fn margin_get_margin_api_key_v1(configuration: &configuration::Configuration, params: MarginGetMarginApiKeyV1Params) -> Result<models::MarginGetMarginApiKeyV1Resp, Error<MarginGetMarginApiKeyV1Error>> {
2006
2007    let uri_str = format!("{}/sapi/v1/margin/apiKey", configuration.base_path);
2008    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2009
2010    // Create a mutable vector for query parameters
2011    let mut query_params: Vec<(String, String)> = Vec::new();
2012
2013    query_params.push(("apiKey".to_string(), params.api_key.to_string()));
2014    if let Some(ref param_value) = params.symbol {
2015        query_params.push(("symbol".to_string(), param_value.to_string()));
2016    }
2017    if let Some(ref param_value) = params.recv_window {
2018        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2019    }
2020    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2021
2022    // Create header parameters collection
2023    let mut header_params = std::collections::HashMap::new();
2024
2025    // Handle Binance Auth first if configured
2026    if let Some(ref binance_auth) = configuration.binance_auth {
2027        // Add API key to headers
2028        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2029        
2030        // Generate request body for signing (if any)
2031        let body_string: Option<Vec<u8>> = None;
2032        
2033        // Sign the request
2034        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2035            Ok(sig) => sig,
2036            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2037        };
2038        
2039        // Add signature to query params
2040        query_params.push(("signature".to_string(), signature));
2041    }
2042
2043    // Apply all query parameters
2044    if !query_params.is_empty() {
2045        req_builder = req_builder.query(&query_params);
2046    }
2047
2048
2049    // Add user agent if configured
2050    if let Some(ref user_agent) = configuration.user_agent {
2051        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2052    }
2053
2054    // Apply all header parameters
2055    for (header_name, header_value) in header_params {
2056        req_builder = req_builder.header(&header_name, &header_value);
2057    }
2058
2059
2060    let req = req_builder.build()?;
2061    let resp = configuration.client.execute(req).await?;
2062
2063    let status = resp.status();
2064    let content_type = resp
2065        .headers()
2066        .get("content-type")
2067        .and_then(|v| v.to_str().ok())
2068        .unwrap_or("application/octet-stream");
2069    let content_type = super::ContentType::from(content_type);
2070
2071    if !status.is_client_error() && !status.is_server_error() {
2072        let content = resp.text().await?;
2073        match content_type {
2074            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2075            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginApiKeyV1Resp`"))),
2076            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::MarginGetMarginApiKeyV1Resp`")))),
2077        }
2078    } else {
2079        let content = resp.text().await?;
2080        let entity: Option<MarginGetMarginApiKeyV1Error> = serde_json::from_str(&content).ok();
2081        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2082    }
2083}
2084
2085/// Get Small liability Exchange History
2086pub async fn margin_get_margin_exchange_small_liability_history_v1(configuration: &configuration::Configuration, params: MarginGetMarginExchangeSmallLiabilityHistoryV1Params) -> Result<models::MarginGetMarginExchangeSmallLiabilityHistoryV1Resp, Error<MarginGetMarginExchangeSmallLiabilityHistoryV1Error>> {
2087
2088    let uri_str = format!("{}/sapi/v1/margin/exchange-small-liability-history", configuration.base_path);
2089    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2090
2091    // Create a mutable vector for query parameters
2092    let mut query_params: Vec<(String, String)> = Vec::new();
2093
2094    query_params.push(("current".to_string(), params.current.to_string()));
2095    query_params.push(("size".to_string(), params.size.to_string()));
2096    if let Some(ref param_value) = params.start_time {
2097        query_params.push(("startTime".to_string(), param_value.to_string()));
2098    }
2099    if let Some(ref param_value) = params.end_time {
2100        query_params.push(("endTime".to_string(), param_value.to_string()));
2101    }
2102    if let Some(ref param_value) = params.recv_window {
2103        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2104    }
2105    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2106
2107    // Create header parameters collection
2108    let mut header_params = std::collections::HashMap::new();
2109
2110    // Handle Binance Auth first if configured
2111    if let Some(ref binance_auth) = configuration.binance_auth {
2112        // Add API key to headers
2113        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2114        
2115        // Generate request body for signing (if any)
2116        let body_string: Option<Vec<u8>> = None;
2117        
2118        // Sign the request
2119        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2120            Ok(sig) => sig,
2121            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2122        };
2123        
2124        // Add signature to query params
2125        query_params.push(("signature".to_string(), signature));
2126    }
2127
2128    // Apply all query parameters
2129    if !query_params.is_empty() {
2130        req_builder = req_builder.query(&query_params);
2131    }
2132
2133
2134    // Add user agent if configured
2135    if let Some(ref user_agent) = configuration.user_agent {
2136        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2137    }
2138
2139    // Apply all header parameters
2140    for (header_name, header_value) in header_params {
2141        req_builder = req_builder.header(&header_name, &header_value);
2142    }
2143
2144
2145    let req = req_builder.build()?;
2146    let resp = configuration.client.execute(req).await?;
2147
2148    let status = resp.status();
2149    let content_type = resp
2150        .headers()
2151        .get("content-type")
2152        .and_then(|v| v.to_str().ok())
2153        .unwrap_or("application/octet-stream");
2154    let content_type = super::ContentType::from(content_type);
2155
2156    if !status.is_client_error() && !status.is_server_error() {
2157        let content = resp.text().await?;
2158        match content_type {
2159            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2160            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginExchangeSmallLiabilityHistoryV1Resp`"))),
2161            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::MarginGetMarginExchangeSmallLiabilityHistoryV1Resp`")))),
2162        }
2163    } else {
2164        let content = resp.text().await?;
2165        let entity: Option<MarginGetMarginExchangeSmallLiabilityHistoryV1Error> = serde_json::from_str(&content).ok();
2166        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2167    }
2168}
2169
2170/// Query the coins which can be small liability exchange
2171pub async fn margin_get_margin_exchange_small_liability_v1(configuration: &configuration::Configuration, params: MarginGetMarginExchangeSmallLiabilityV1Params) -> Result<Vec<models::MarginGetMarginExchangeSmallLiabilityV1RespItem>, Error<MarginGetMarginExchangeSmallLiabilityV1Error>> {
2172
2173    let uri_str = format!("{}/sapi/v1/margin/exchange-small-liability", configuration.base_path);
2174    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2175
2176    // Create a mutable vector for query parameters
2177    let mut query_params: Vec<(String, String)> = Vec::new();
2178
2179    if let Some(ref param_value) = params.recv_window {
2180        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2181    }
2182    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2183
2184    // Create header parameters collection
2185    let mut header_params = std::collections::HashMap::new();
2186
2187    // Handle Binance Auth first if configured
2188    if let Some(ref binance_auth) = configuration.binance_auth {
2189        // Add API key to headers
2190        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2191        
2192        // Generate request body for signing (if any)
2193        let body_string: Option<Vec<u8>> = None;
2194        
2195        // Sign the request
2196        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2197            Ok(sig) => sig,
2198            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2199        };
2200        
2201        // Add signature to query params
2202        query_params.push(("signature".to_string(), signature));
2203    }
2204
2205    // Apply all query parameters
2206    if !query_params.is_empty() {
2207        req_builder = req_builder.query(&query_params);
2208    }
2209
2210
2211    // Add user agent if configured
2212    if let Some(ref user_agent) = configuration.user_agent {
2213        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2214    }
2215
2216    // Apply all header parameters
2217    for (header_name, header_value) in header_params {
2218        req_builder = req_builder.header(&header_name, &header_value);
2219    }
2220
2221
2222    let req = req_builder.build()?;
2223    let resp = configuration.client.execute(req).await?;
2224
2225    let status = resp.status();
2226    let content_type = resp
2227        .headers()
2228        .get("content-type")
2229        .and_then(|v| v.to_str().ok())
2230        .unwrap_or("application/octet-stream");
2231    let content_type = super::ContentType::from(content_type);
2232
2233    if !status.is_client_error() && !status.is_server_error() {
2234        let content = resp.text().await?;
2235        match content_type {
2236            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2237            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginExchangeSmallLiabilityV1RespItem&gt;`"))),
2238            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::MarginGetMarginExchangeSmallLiabilityV1RespItem&gt;`")))),
2239        }
2240    } else {
2241        let content = resp.text().await?;
2242        let entity: Option<MarginGetMarginExchangeSmallLiabilityV1Error> = serde_json::from_str(&content).ok();
2243        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2244    }
2245}
2246
2247/// Get Force Liquidation Record
2248pub async fn margin_get_margin_force_liquidation_rec_v1(configuration: &configuration::Configuration, params: MarginGetMarginForceLiquidationRecV1Params) -> Result<models::MarginGetMarginForceLiquidationRecV1Resp, Error<MarginGetMarginForceLiquidationRecV1Error>> {
2249
2250    let uri_str = format!("{}/sapi/v1/margin/forceLiquidationRec", configuration.base_path);
2251    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2252
2253    // Create a mutable vector for query parameters
2254    let mut query_params: Vec<(String, String)> = Vec::new();
2255
2256    if let Some(ref param_value) = params.start_time {
2257        query_params.push(("startTime".to_string(), param_value.to_string()));
2258    }
2259    if let Some(ref param_value) = params.end_time {
2260        query_params.push(("endTime".to_string(), param_value.to_string()));
2261    }
2262    if let Some(ref param_value) = params.isolated_symbol {
2263        query_params.push(("isolatedSymbol".to_string(), param_value.to_string()));
2264    }
2265    if let Some(ref param_value) = params.current {
2266        query_params.push(("current".to_string(), param_value.to_string()));
2267    }
2268    if let Some(ref param_value) = params.size {
2269        query_params.push(("size".to_string(), param_value.to_string()));
2270    }
2271    if let Some(ref param_value) = params.recv_window {
2272        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2273    }
2274    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2275
2276    // Create header parameters collection
2277    let mut header_params = std::collections::HashMap::new();
2278
2279    // Handle Binance Auth first if configured
2280    if let Some(ref binance_auth) = configuration.binance_auth {
2281        // Add API key to headers
2282        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2283        
2284        // Generate request body for signing (if any)
2285        let body_string: Option<Vec<u8>> = None;
2286        
2287        // Sign the request
2288        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2289            Ok(sig) => sig,
2290            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2291        };
2292        
2293        // Add signature to query params
2294        query_params.push(("signature".to_string(), signature));
2295    }
2296
2297    // Apply all query parameters
2298    if !query_params.is_empty() {
2299        req_builder = req_builder.query(&query_params);
2300    }
2301
2302
2303    // Add user agent if configured
2304    if let Some(ref user_agent) = configuration.user_agent {
2305        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2306    }
2307
2308    // Apply all header parameters
2309    for (header_name, header_value) in header_params {
2310        req_builder = req_builder.header(&header_name, &header_value);
2311    }
2312
2313
2314    let req = req_builder.build()?;
2315    let resp = configuration.client.execute(req).await?;
2316
2317    let status = resp.status();
2318    let content_type = resp
2319        .headers()
2320        .get("content-type")
2321        .and_then(|v| v.to_str().ok())
2322        .unwrap_or("application/octet-stream");
2323    let content_type = super::ContentType::from(content_type);
2324
2325    if !status.is_client_error() && !status.is_server_error() {
2326        let content = resp.text().await?;
2327        match content_type {
2328            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2329            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginForceLiquidationRecV1Resp`"))),
2330            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::MarginGetMarginForceLiquidationRecV1Resp`")))),
2331        }
2332    } else {
2333        let content = resp.text().await?;
2334        let entity: Option<MarginGetMarginForceLiquidationRecV1Error> = serde_json::from_str(&content).ok();
2335        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2336    }
2337}
2338
2339/// Query Margin Account's Trade List
2340pub async fn margin_get_margin_my_trades_v1(configuration: &configuration::Configuration, params: MarginGetMarginMyTradesV1Params) -> Result<Vec<models::MarginGetMarginMyTradesV1RespItem>, Error<MarginGetMarginMyTradesV1Error>> {
2341
2342    let uri_str = format!("{}/sapi/v1/margin/myTrades", configuration.base_path);
2343    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2344
2345    // Create a mutable vector for query parameters
2346    let mut query_params: Vec<(String, String)> = Vec::new();
2347
2348    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2349    if let Some(ref param_value) = params.is_isolated {
2350        query_params.push(("isIsolated".to_string(), param_value.to_string()));
2351    }
2352    if let Some(ref param_value) = params.order_id {
2353        query_params.push(("orderId".to_string(), param_value.to_string()));
2354    }
2355    if let Some(ref param_value) = params.start_time {
2356        query_params.push(("startTime".to_string(), param_value.to_string()));
2357    }
2358    if let Some(ref param_value) = params.end_time {
2359        query_params.push(("endTime".to_string(), param_value.to_string()));
2360    }
2361    if let Some(ref param_value) = params.from_id {
2362        query_params.push(("fromId".to_string(), param_value.to_string()));
2363    }
2364    if let Some(ref param_value) = params.limit {
2365        query_params.push(("limit".to_string(), param_value.to_string()));
2366    }
2367    if let Some(ref param_value) = params.recv_window {
2368        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2369    }
2370    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2371
2372    // Create header parameters collection
2373    let mut header_params = std::collections::HashMap::new();
2374
2375    // Handle Binance Auth first if configured
2376    if let Some(ref binance_auth) = configuration.binance_auth {
2377        // Add API key to headers
2378        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2379        
2380        // Generate request body for signing (if any)
2381        let body_string: Option<Vec<u8>> = None;
2382        
2383        // Sign the request
2384        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2385            Ok(sig) => sig,
2386            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2387        };
2388        
2389        // Add signature to query params
2390        query_params.push(("signature".to_string(), signature));
2391    }
2392
2393    // Apply all query parameters
2394    if !query_params.is_empty() {
2395        req_builder = req_builder.query(&query_params);
2396    }
2397
2398
2399    // Add user agent if configured
2400    if let Some(ref user_agent) = configuration.user_agent {
2401        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2402    }
2403
2404    // Apply all header parameters
2405    for (header_name, header_value) in header_params {
2406        req_builder = req_builder.header(&header_name, &header_value);
2407    }
2408
2409
2410    let req = req_builder.build()?;
2411    let resp = configuration.client.execute(req).await?;
2412
2413    let status = resp.status();
2414    let content_type = resp
2415        .headers()
2416        .get("content-type")
2417        .and_then(|v| v.to_str().ok())
2418        .unwrap_or("application/octet-stream");
2419    let content_type = super::ContentType::from(content_type);
2420
2421    if !status.is_client_error() && !status.is_server_error() {
2422        let content = resp.text().await?;
2423        match content_type {
2424            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2425            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginMyTradesV1RespItem&gt;`"))),
2426            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::MarginGetMarginMyTradesV1RespItem&gt;`")))),
2427        }
2428    } else {
2429        let content = resp.text().await?;
2430        let entity: Option<MarginGetMarginMyTradesV1Error> = serde_json::from_str(&content).ok();
2431        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2432    }
2433}
2434
2435/// Query Margin Account's Open OCO
2436pub async fn margin_get_margin_open_order_list_v1(configuration: &configuration::Configuration, params: MarginGetMarginOpenOrderListV1Params) -> Result<Vec<models::MarginGetMarginOpenOrderListV1RespItem>, Error<MarginGetMarginOpenOrderListV1Error>> {
2437
2438    let uri_str = format!("{}/sapi/v1/margin/openOrderList", configuration.base_path);
2439    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2440
2441    // Create a mutable vector for query parameters
2442    let mut query_params: Vec<(String, String)> = Vec::new();
2443
2444    if let Some(ref param_value) = params.is_isolated {
2445        query_params.push(("isIsolated".to_string(), param_value.to_string()));
2446    }
2447    if let Some(ref param_value) = params.symbol {
2448        query_params.push(("symbol".to_string(), param_value.to_string()));
2449    }
2450    if let Some(ref param_value) = params.recv_window {
2451        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2452    }
2453    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2454
2455    // Create header parameters collection
2456    let mut header_params = std::collections::HashMap::new();
2457
2458    // Handle Binance Auth first if configured
2459    if let Some(ref binance_auth) = configuration.binance_auth {
2460        // Add API key to headers
2461        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2462        
2463        // Generate request body for signing (if any)
2464        let body_string: Option<Vec<u8>> = None;
2465        
2466        // Sign the request
2467        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2468            Ok(sig) => sig,
2469            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2470        };
2471        
2472        // Add signature to query params
2473        query_params.push(("signature".to_string(), signature));
2474    }
2475
2476    // Apply all query parameters
2477    if !query_params.is_empty() {
2478        req_builder = req_builder.query(&query_params);
2479    }
2480
2481
2482    // Add user agent if configured
2483    if let Some(ref user_agent) = configuration.user_agent {
2484        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2485    }
2486
2487    // Apply all header parameters
2488    for (header_name, header_value) in header_params {
2489        req_builder = req_builder.header(&header_name, &header_value);
2490    }
2491
2492
2493    let req = req_builder.build()?;
2494    let resp = configuration.client.execute(req).await?;
2495
2496    let status = resp.status();
2497    let content_type = resp
2498        .headers()
2499        .get("content-type")
2500        .and_then(|v| v.to_str().ok())
2501        .unwrap_or("application/octet-stream");
2502    let content_type = super::ContentType::from(content_type);
2503
2504    if !status.is_client_error() && !status.is_server_error() {
2505        let content = resp.text().await?;
2506        match content_type {
2507            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2508            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginOpenOrderListV1RespItem&gt;`"))),
2509            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::MarginGetMarginOpenOrderListV1RespItem&gt;`")))),
2510        }
2511    } else {
2512        let content = resp.text().await?;
2513        let entity: Option<MarginGetMarginOpenOrderListV1Error> = serde_json::from_str(&content).ok();
2514        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2515    }
2516}
2517
2518/// Query Margin Account's Open Orders
2519pub async fn margin_get_margin_open_orders_v1(configuration: &configuration::Configuration, params: MarginGetMarginOpenOrdersV1Params) -> Result<Vec<models::MarginGetMarginOpenOrdersV1RespItem>, Error<MarginGetMarginOpenOrdersV1Error>> {
2520
2521    let uri_str = format!("{}/sapi/v1/margin/openOrders", configuration.base_path);
2522    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2523
2524    // Create a mutable vector for query parameters
2525    let mut query_params: Vec<(String, String)> = Vec::new();
2526
2527    if let Some(ref param_value) = params.symbol {
2528        query_params.push(("symbol".to_string(), param_value.to_string()));
2529    }
2530    if let Some(ref param_value) = params.is_isolated {
2531        query_params.push(("isIsolated".to_string(), param_value.to_string()));
2532    }
2533    if let Some(ref param_value) = params.recv_window {
2534        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2535    }
2536    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2537
2538    // Create header parameters collection
2539    let mut header_params = std::collections::HashMap::new();
2540
2541    // Handle Binance Auth first if configured
2542    if let Some(ref binance_auth) = configuration.binance_auth {
2543        // Add API key to headers
2544        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2545        
2546        // Generate request body for signing (if any)
2547        let body_string: Option<Vec<u8>> = None;
2548        
2549        // Sign the request
2550        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2551            Ok(sig) => sig,
2552            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2553        };
2554        
2555        // Add signature to query params
2556        query_params.push(("signature".to_string(), signature));
2557    }
2558
2559    // Apply all query parameters
2560    if !query_params.is_empty() {
2561        req_builder = req_builder.query(&query_params);
2562    }
2563
2564
2565    // Add user agent if configured
2566    if let Some(ref user_agent) = configuration.user_agent {
2567        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2568    }
2569
2570    // Apply all header parameters
2571    for (header_name, header_value) in header_params {
2572        req_builder = req_builder.header(&header_name, &header_value);
2573    }
2574
2575
2576    let req = req_builder.build()?;
2577    let resp = configuration.client.execute(req).await?;
2578
2579    let status = resp.status();
2580    let content_type = resp
2581        .headers()
2582        .get("content-type")
2583        .and_then(|v| v.to_str().ok())
2584        .unwrap_or("application/octet-stream");
2585    let content_type = super::ContentType::from(content_type);
2586
2587    if !status.is_client_error() && !status.is_server_error() {
2588        let content = resp.text().await?;
2589        match content_type {
2590            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2591            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginOpenOrdersV1RespItem&gt;`"))),
2592            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginOpenOrdersV1RespItem&gt;`")))),
2593        }
2594    } else {
2595        let content = resp.text().await?;
2596        let entity: Option<MarginGetMarginOpenOrdersV1Error> = serde_json::from_str(&content).ok();
2597        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2598    }
2599}
2600
2601/// Retrieves a specific OCO based on provided optional parameters
2602pub async fn margin_get_margin_order_list_v1(configuration: &configuration::Configuration, params: MarginGetMarginOrderListV1Params) -> Result<models::MarginGetMarginOrderListV1Resp, Error<MarginGetMarginOrderListV1Error>> {
2603
2604    let uri_str = format!("{}/sapi/v1/margin/orderList", configuration.base_path);
2605    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2606
2607    // Create a mutable vector for query parameters
2608    let mut query_params: Vec<(String, String)> = Vec::new();
2609
2610    if let Some(ref param_value) = params.is_isolated {
2611        query_params.push(("isIsolated".to_string(), param_value.to_string()));
2612    }
2613    if let Some(ref param_value) = params.symbol {
2614        query_params.push(("symbol".to_string(), param_value.to_string()));
2615    }
2616    if let Some(ref param_value) = params.order_list_id {
2617        query_params.push(("orderListId".to_string(), param_value.to_string()));
2618    }
2619    if let Some(ref param_value) = params.orig_client_order_id {
2620        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2621    }
2622    if let Some(ref param_value) = params.recv_window {
2623        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2624    }
2625    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2626
2627    // Create header parameters collection
2628    let mut header_params = std::collections::HashMap::new();
2629
2630    // Handle Binance Auth first if configured
2631    if let Some(ref binance_auth) = configuration.binance_auth {
2632        // Add API key to headers
2633        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2634        
2635        // Generate request body for signing (if any)
2636        let body_string: Option<Vec<u8>> = None;
2637        
2638        // Sign the request
2639        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2640            Ok(sig) => sig,
2641            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2642        };
2643        
2644        // Add signature to query params
2645        query_params.push(("signature".to_string(), signature));
2646    }
2647
2648    // Apply all query parameters
2649    if !query_params.is_empty() {
2650        req_builder = req_builder.query(&query_params);
2651    }
2652
2653
2654    // Add user agent if configured
2655    if let Some(ref user_agent) = configuration.user_agent {
2656        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2657    }
2658
2659    // Apply all header parameters
2660    for (header_name, header_value) in header_params {
2661        req_builder = req_builder.header(&header_name, &header_value);
2662    }
2663
2664
2665    let req = req_builder.build()?;
2666    let resp = configuration.client.execute(req).await?;
2667
2668    let status = resp.status();
2669    let content_type = resp
2670        .headers()
2671        .get("content-type")
2672        .and_then(|v| v.to_str().ok())
2673        .unwrap_or("application/octet-stream");
2674    let content_type = super::ContentType::from(content_type);
2675
2676    if !status.is_client_error() && !status.is_server_error() {
2677        let content = resp.text().await?;
2678        match content_type {
2679            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2680            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginOrderListV1Resp`"))),
2681            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::MarginGetMarginOrderListV1Resp`")))),
2682        }
2683    } else {
2684        let content = resp.text().await?;
2685        let entity: Option<MarginGetMarginOrderListV1Error> = serde_json::from_str(&content).ok();
2686        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2687    }
2688}
2689
2690/// Query Margin Account's Order
2691pub async fn margin_get_margin_order_v1(configuration: &configuration::Configuration, params: MarginGetMarginOrderV1Params) -> Result<models::MarginGetMarginOrderV1Resp, Error<MarginGetMarginOrderV1Error>> {
2692
2693    let uri_str = format!("{}/sapi/v1/margin/order", configuration.base_path);
2694    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2695
2696    // Create a mutable vector for query parameters
2697    let mut query_params: Vec<(String, String)> = Vec::new();
2698
2699    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2700    if let Some(ref param_value) = params.is_isolated {
2701        query_params.push(("isIsolated".to_string(), param_value.to_string()));
2702    }
2703    if let Some(ref param_value) = params.order_id {
2704        query_params.push(("orderId".to_string(), param_value.to_string()));
2705    }
2706    if let Some(ref param_value) = params.orig_client_order_id {
2707        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2708    }
2709    if let Some(ref param_value) = params.recv_window {
2710        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2711    }
2712    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2713
2714    // Create header parameters collection
2715    let mut header_params = std::collections::HashMap::new();
2716
2717    // Handle Binance Auth first if configured
2718    if let Some(ref binance_auth) = configuration.binance_auth {
2719        // Add API key to headers
2720        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2721        
2722        // Generate request body for signing (if any)
2723        let body_string: Option<Vec<u8>> = None;
2724        
2725        // Sign the request
2726        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2727            Ok(sig) => sig,
2728            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2729        };
2730        
2731        // Add signature to query params
2732        query_params.push(("signature".to_string(), signature));
2733    }
2734
2735    // Apply all query parameters
2736    if !query_params.is_empty() {
2737        req_builder = req_builder.query(&query_params);
2738    }
2739
2740
2741    // Add user agent if configured
2742    if let Some(ref user_agent) = configuration.user_agent {
2743        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2744    }
2745
2746    // Apply all header parameters
2747    for (header_name, header_value) in header_params {
2748        req_builder = req_builder.header(&header_name, &header_value);
2749    }
2750
2751
2752    let req = req_builder.build()?;
2753    let resp = configuration.client.execute(req).await?;
2754
2755    let status = resp.status();
2756    let content_type = resp
2757        .headers()
2758        .get("content-type")
2759        .and_then(|v| v.to_str().ok())
2760        .unwrap_or("application/octet-stream");
2761    let content_type = super::ContentType::from(content_type);
2762
2763    if !status.is_client_error() && !status.is_server_error() {
2764        let content = resp.text().await?;
2765        match content_type {
2766            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2767            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginOrderV1Resp`"))),
2768            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::MarginGetMarginOrderV1Resp`")))),
2769        }
2770    } else {
2771        let content = resp.text().await?;
2772        let entity: Option<MarginGetMarginOrderV1Error> = serde_json::from_str(&content).ok();
2773        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2774    }
2775}
2776
2777/// Displays the user's current margin order count usage for all intervals.
2778pub async fn margin_get_margin_rate_limit_order_v1(configuration: &configuration::Configuration, params: MarginGetMarginRateLimitOrderV1Params) -> Result<Vec<models::MarginGetMarginRateLimitOrderV1RespItem>, Error<MarginGetMarginRateLimitOrderV1Error>> {
2779
2780    let uri_str = format!("{}/sapi/v1/margin/rateLimit/order", configuration.base_path);
2781    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2782
2783    // Create a mutable vector for query parameters
2784    let mut query_params: Vec<(String, String)> = Vec::new();
2785
2786    if let Some(ref param_value) = params.is_isolated {
2787        query_params.push(("isIsolated".to_string(), param_value.to_string()));
2788    }
2789    if let Some(ref param_value) = params.symbol {
2790        query_params.push(("symbol".to_string(), param_value.to_string()));
2791    }
2792    if let Some(ref param_value) = params.recv_window {
2793        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2794    }
2795    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2796
2797    // Create header parameters collection
2798    let mut header_params = std::collections::HashMap::new();
2799
2800    // Handle Binance Auth first if configured
2801    if let Some(ref binance_auth) = configuration.binance_auth {
2802        // Add API key to headers
2803        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2804        
2805        // Generate request body for signing (if any)
2806        let body_string: Option<Vec<u8>> = None;
2807        
2808        // Sign the request
2809        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2810            Ok(sig) => sig,
2811            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2812        };
2813        
2814        // Add signature to query params
2815        query_params.push(("signature".to_string(), signature));
2816    }
2817
2818    // Apply all query parameters
2819    if !query_params.is_empty() {
2820        req_builder = req_builder.query(&query_params);
2821    }
2822
2823
2824    // Add user agent if configured
2825    if let Some(ref user_agent) = configuration.user_agent {
2826        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2827    }
2828
2829    // Apply all header parameters
2830    for (header_name, header_value) in header_params {
2831        req_builder = req_builder.header(&header_name, &header_value);
2832    }
2833
2834
2835    let req = req_builder.build()?;
2836    let resp = configuration.client.execute(req).await?;
2837
2838    let status = resp.status();
2839    let content_type = resp
2840        .headers()
2841        .get("content-type")
2842        .and_then(|v| v.to_str().ok())
2843        .unwrap_or("application/octet-stream");
2844    let content_type = super::ContentType::from(content_type);
2845
2846    if !status.is_client_error() && !status.is_server_error() {
2847        let content = resp.text().await?;
2848        match content_type {
2849            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2850            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MarginGetMarginRateLimitOrderV1RespItem&gt;`"))),
2851            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::MarginGetMarginRateLimitOrderV1RespItem&gt;`")))),
2852        }
2853    } else {
2854        let content = resp.text().await?;
2855        let entity: Option<MarginGetMarginRateLimitOrderV1Error> = serde_json::from_str(&content).ok();
2856        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2857    }
2858}
2859
2860/// Edit ip restriction. This only applies to Special Key for Low Latency Trading.
2861pub async fn margin_update_margin_api_key_ip_v1(configuration: &configuration::Configuration, params: MarginUpdateMarginApiKeyIpV1Params) -> Result<serde_json::Value, Error<MarginUpdateMarginApiKeyIpV1Error>> {
2862
2863    let uri_str = format!("{}/sapi/v1/margin/apiKey/ip", configuration.base_path);
2864    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
2865
2866    // Create a mutable vector for query parameters
2867    let mut query_params: Vec<(String, String)> = Vec::new();
2868
2869
2870    // Create header parameters collection
2871    let mut header_params = std::collections::HashMap::new();
2872
2873    // Handle Binance Auth first if configured
2874    if let Some(ref binance_auth) = configuration.binance_auth {
2875        // Add API key to headers
2876        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2877        
2878        // Generate request body for signing (if any)
2879        let body_string: Option<Vec<u8>> = None;
2880        
2881        // Sign the request
2882        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2883            Ok(sig) => sig,
2884            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2885        };
2886        
2887        // Add signature to query params
2888        query_params.push(("signature".to_string(), signature));
2889    }
2890
2891    // Apply all query parameters
2892    if !query_params.is_empty() {
2893        req_builder = req_builder.query(&query_params);
2894    }
2895
2896
2897    // Add user agent if configured
2898    if let Some(ref user_agent) = configuration.user_agent {
2899        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2900    }
2901
2902    // Apply all header parameters
2903    for (header_name, header_value) in header_params {
2904        req_builder = req_builder.header(&header_name, &header_value);
2905    }
2906
2907    let mut multipart_form_params = std::collections::HashMap::new();
2908    multipart_form_params.insert("apiKey", params.api_key.to_string());
2909    multipart_form_params.insert("ip", params.ip.to_string());
2910    if let Some(param_value) = params.recv_window {
2911        multipart_form_params.insert("recvWindow", param_value.to_string());
2912    }
2913    if let Some(param_value) = params.symbol {
2914        multipart_form_params.insert("symbol", param_value.to_string());
2915    }
2916    multipart_form_params.insert("timestamp", params.timestamp.to_string());
2917    req_builder = req_builder.form(&multipart_form_params);
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 `serde_json::Value`"))),
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 `serde_json::Value`")))),
2936        }
2937    } else {
2938        let content = resp.text().await?;
2939        let entity: Option<MarginUpdateMarginApiKeyIpV1Error> = serde_json::from_str(&content).ok();
2940        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2941    }
2942}
2943