binance/derivatives/pmargin/apis/
account_api.rs

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