binance/umfutures/apis/
binance_link_api.rs

1/*
2 * Binance USD-M Futures API
3 *
4 * OpenAPI specification for Binance exchange - Umfutures API
5 *
6 * The version of the OpenAPI document: 0.2.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::umfutures::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`create_api_referral_customization_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateApiReferralCustomizationV1Params {
20    pub customer_id: String,
21    pub email: String,
22    pub timestamp: i64,
23    pub recv_window: Option<i64>
24}
25
26/// struct for passing parameters to the method [`create_api_referral_user_customization_papiv1`]
27#[derive(Clone, Debug, Default)]
28pub struct CreateApiReferralUserCustomizationPapiv1Params {
29    pub broker_id: String,
30    pub customer_id: String,
31    pub timestamp: i64,
32    pub recv_window: Option<i64>
33}
34
35/// struct for passing parameters to the method [`create_api_referral_user_customization_v1`]
36#[derive(Clone, Debug, Default)]
37pub struct CreateApiReferralUserCustomizationV1Params {
38    pub broker_id: String,
39    pub customer_id: String,
40    pub timestamp: i64,
41    pub recv_window: Option<i64>
42}
43
44/// struct for passing parameters to the method [`get_api_referral_customization_v1`]
45#[derive(Clone, Debug, Default)]
46pub struct GetApiReferralCustomizationV1Params {
47    pub timestamp: i64,
48    pub customer_id: Option<String>,
49    pub email: Option<String>,
50    /// default 1
51    pub page: Option<i64>,
52    /// items num of one page,default 100,max 1000
53    pub limit: Option<i64>,
54    pub recv_window: Option<i64>
55}
56
57/// struct for passing parameters to the method [`get_api_referral_if_new_user_papiv1`]
58#[derive(Clone, Debug, Default)]
59pub struct GetApiReferralIfNewUserPapiv1Params {
60    pub broker_id: String,
61    pub timestamp: i64,
62    /// 1:USDT-margined Futures,  2: Coin-margined Futures ; Default:1:USDT-margined Futures
63    pub r#type: Option<i32>,
64    pub recv_window: Option<i64>
65}
66
67/// struct for passing parameters to the method [`get_api_referral_if_new_user_v1`]
68#[derive(Clone, Debug, Default)]
69pub struct GetApiReferralIfNewUserV1Params {
70    pub broker_id: String,
71    pub timestamp: i64,
72    /// 1:USDT-margined Futures,2: Coin-margined Futures; Default:1:USDT-margined Futures
73    pub r#type: Option<i32>,
74    pub recv_window: Option<i64>
75}
76
77/// struct for passing parameters to the method [`get_api_referral_overview_v1`]
78#[derive(Clone, Debug, Default)]
79pub struct GetApiReferralOverviewV1Params {
80    pub timestamp: i64,
81    /// 1:USDT Margined Futures, 2:COIN Margined Futures Default: USDT Margined Futures
82    pub r#type: Option<i32>,
83    pub recv_window: Option<i64>
84}
85
86/// struct for passing parameters to the method [`get_api_referral_rebate_vol_v1`]
87#[derive(Clone, Debug, Default)]
88pub struct GetApiReferralRebateVolV1Params {
89    pub timestamp: i64,
90    /// 1:USDT Margined Futures, 2:COIN Margined Futures Default: USDT Margined Futures
91    pub r#type: Option<i32>,
92    pub start_time: Option<i64>,
93    pub end_time: Option<i64>,
94    /// default 500, max 1000
95    pub limit: Option<i32>,
96    pub recv_window: Option<i64>
97}
98
99/// struct for passing parameters to the method [`get_api_referral_trade_vol_v1`]
100#[derive(Clone, Debug, Default)]
101pub struct GetApiReferralTradeVolV1Params {
102    pub timestamp: i64,
103    /// 1:USDT Margined Futures, 2:COIN Margined Futures Default: USDT Margined Futures
104    pub r#type: Option<i32>,
105    pub start_time: Option<i64>,
106    pub end_time: Option<i64>,
107    /// default 500, max 1000
108    pub limit: Option<i32>,
109    pub recv_window: Option<i64>
110}
111
112/// struct for passing parameters to the method [`get_api_referral_trader_num_v1`]
113#[derive(Clone, Debug, Default)]
114pub struct GetApiReferralTraderNumV1Params {
115    pub timestamp: i64,
116    /// 1:USDT Margined Futures, 2:COIN Margined Futures Default: USDT Margined Futures
117    pub r#type: Option<i32>,
118    pub start_time: Option<i64>,
119    pub end_time: Option<i64>,
120    /// default 500, max 1000
121    pub limit: Option<i32>,
122    pub recv_window: Option<i64>
123}
124
125/// struct for passing parameters to the method [`get_api_referral_trader_summary_v1`]
126#[derive(Clone, Debug, Default)]
127pub struct GetApiReferralTraderSummaryV1Params {
128    pub timestamp: i64,
129    pub customer_id: Option<String>,
130    /// 1:USDT Margined Futures, 2:COIN Margined Futures Default: USDT Margined Futures
131    pub r#type: Option<i32>,
132    pub start_time: Option<i64>,
133    pub end_time: Option<i64>,
134    /// default 500, max 1000
135    pub limit: Option<i32>,
136    pub recv_window: Option<i64>
137}
138
139/// struct for passing parameters to the method [`get_api_referral_user_customization_papiv1`]
140#[derive(Clone, Debug, Default)]
141pub struct GetApiReferralUserCustomizationPapiv1Params {
142    pub broker_id: String,
143    pub timestamp: i64,
144    pub recv_window: Option<i64>
145}
146
147/// struct for passing parameters to the method [`get_api_referral_user_customization_v1`]
148#[derive(Clone, Debug, Default)]
149pub struct GetApiReferralUserCustomizationV1Params {
150    pub broker_id: String,
151    pub timestamp: i64,
152    pub recv_window: Option<i64>
153}
154
155/// struct for passing parameters to the method [`get_income_v1`]
156#[derive(Clone, Debug, Default)]
157pub struct GetIncomeV1Params {
158    pub timestamp: i64,
159    pub symbol: Option<String>,
160    /// &#34;TRANSFER&#34;,&#34;WELCOME_BONUS&#34;, &#34;REALIZED_PNL&#34;,&#34;FUNDING_FEE&#34;, &#34;COMMISSION&#34;, and &#34;INSURANCE_CLEAR&#34;
161    pub income_type: Option<String>,
162    /// Timestamp in ms to get funding from INCLUSIVE.
163    pub start_time: Option<i64>,
164    /// Timestamp in ms to get funding until INCLUSIVE.
165    pub end_time: Option<i64>,
166    /// Default 100; max 1000
167    pub limit: Option<i32>,
168    pub recv_window: Option<i64>
169}
170
171
172/// struct for typed errors of method [`create_api_referral_customization_v1`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum CreateApiReferralCustomizationV1Error {
176    Status4XX(models::ApiError),
177    Status5XX(models::ApiError),
178    UnknownValue(serde_json::Value),
179}
180
181/// struct for typed errors of method [`create_api_referral_user_customization_papiv1`]
182#[derive(Debug, Clone, Serialize, Deserialize)]
183#[serde(untagged)]
184pub enum CreateApiReferralUserCustomizationPapiv1Error {
185    Status4XX(models::ApiError),
186    Status5XX(models::ApiError),
187    UnknownValue(serde_json::Value),
188}
189
190/// struct for typed errors of method [`create_api_referral_user_customization_v1`]
191#[derive(Debug, Clone, Serialize, Deserialize)]
192#[serde(untagged)]
193pub enum CreateApiReferralUserCustomizationV1Error {
194    Status4XX(models::ApiError),
195    Status5XX(models::ApiError),
196    UnknownValue(serde_json::Value),
197}
198
199/// struct for typed errors of method [`get_api_referral_customization_v1`]
200#[derive(Debug, Clone, Serialize, Deserialize)]
201#[serde(untagged)]
202pub enum GetApiReferralCustomizationV1Error {
203    Status4XX(models::ApiError),
204    Status5XX(models::ApiError),
205    UnknownValue(serde_json::Value),
206}
207
208/// struct for typed errors of method [`get_api_referral_if_new_user_papiv1`]
209#[derive(Debug, Clone, Serialize, Deserialize)]
210#[serde(untagged)]
211pub enum GetApiReferralIfNewUserPapiv1Error {
212    Status4XX(models::ApiError),
213    Status5XX(models::ApiError),
214    UnknownValue(serde_json::Value),
215}
216
217/// struct for typed errors of method [`get_api_referral_if_new_user_v1`]
218#[derive(Debug, Clone, Serialize, Deserialize)]
219#[serde(untagged)]
220pub enum GetApiReferralIfNewUserV1Error {
221    Status4XX(models::ApiError),
222    Status5XX(models::ApiError),
223    UnknownValue(serde_json::Value),
224}
225
226/// struct for typed errors of method [`get_api_referral_overview_v1`]
227#[derive(Debug, Clone, Serialize, Deserialize)]
228#[serde(untagged)]
229pub enum GetApiReferralOverviewV1Error {
230    Status4XX(models::ApiError),
231    Status5XX(models::ApiError),
232    UnknownValue(serde_json::Value),
233}
234
235/// struct for typed errors of method [`get_api_referral_rebate_vol_v1`]
236#[derive(Debug, Clone, Serialize, Deserialize)]
237#[serde(untagged)]
238pub enum GetApiReferralRebateVolV1Error {
239    Status4XX(models::ApiError),
240    Status5XX(models::ApiError),
241    UnknownValue(serde_json::Value),
242}
243
244/// struct for typed errors of method [`get_api_referral_trade_vol_v1`]
245#[derive(Debug, Clone, Serialize, Deserialize)]
246#[serde(untagged)]
247pub enum GetApiReferralTradeVolV1Error {
248    Status4XX(models::ApiError),
249    Status5XX(models::ApiError),
250    UnknownValue(serde_json::Value),
251}
252
253/// struct for typed errors of method [`get_api_referral_trader_num_v1`]
254#[derive(Debug, Clone, Serialize, Deserialize)]
255#[serde(untagged)]
256pub enum GetApiReferralTraderNumV1Error {
257    Status4XX(models::ApiError),
258    Status5XX(models::ApiError),
259    UnknownValue(serde_json::Value),
260}
261
262/// struct for typed errors of method [`get_api_referral_trader_summary_v1`]
263#[derive(Debug, Clone, Serialize, Deserialize)]
264#[serde(untagged)]
265pub enum GetApiReferralTraderSummaryV1Error {
266    Status4XX(models::ApiError),
267    Status5XX(models::ApiError),
268    UnknownValue(serde_json::Value),
269}
270
271/// struct for typed errors of method [`get_api_referral_user_customization_papiv1`]
272#[derive(Debug, Clone, Serialize, Deserialize)]
273#[serde(untagged)]
274pub enum GetApiReferralUserCustomizationPapiv1Error {
275    Status4XX(models::ApiError),
276    Status5XX(models::ApiError),
277    UnknownValue(serde_json::Value),
278}
279
280/// struct for typed errors of method [`get_api_referral_user_customization_v1`]
281#[derive(Debug, Clone, Serialize, Deserialize)]
282#[serde(untagged)]
283pub enum GetApiReferralUserCustomizationV1Error {
284    Status4XX(models::ApiError),
285    Status5XX(models::ApiError),
286    UnknownValue(serde_json::Value),
287}
288
289/// struct for typed errors of method [`get_income_v1`]
290#[derive(Debug, Clone, Serialize, Deserialize)]
291#[serde(untagged)]
292pub enum GetIncomeV1Error {
293    Status4XX(models::ApiError),
294    Status5XX(models::ApiError),
295    UnknownValue(serde_json::Value),
296}
297
298
299/// - CustomerId must be unique
300pub async fn create_api_referral_customization_v1(configuration: &configuration::Configuration, params: CreateApiReferralCustomizationV1Params) -> Result<models::CreateApiReferralCustomizationV1Resp, Error<CreateApiReferralCustomizationV1Error>> {
301
302    let uri_str = format!("{}/fapi/v1/apiReferral/customization", configuration.base_path);
303    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
304
305    // Create a mutable vector for query parameters
306    let mut query_params: Vec<(String, String)> = Vec::new();
307
308
309    // Create header parameters collection
310    let mut header_params = std::collections::HashMap::new();
311
312    // Handle Binance Auth first if configured
313    if let Some(ref binance_auth) = configuration.binance_auth {
314        // Add API key to headers
315        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
316        
317        // Generate request body for signing (if any)
318        let body_string: Option<Vec<u8>> = None;
319        
320        // Sign the request
321        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
322            Ok(sig) => sig,
323            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
324        };
325        
326        // Add signature to query params
327        query_params.push(("signature".to_string(), signature));
328    }
329
330    // Apply all query parameters
331    if !query_params.is_empty() {
332        req_builder = req_builder.query(&query_params);
333    }
334
335
336    // Add user agent if configured
337    if let Some(ref user_agent) = configuration.user_agent {
338        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
339    }
340
341    // Apply all header parameters
342    for (header_name, header_value) in header_params {
343        req_builder = req_builder.header(&header_name, &header_value);
344    }
345
346    let mut multipart_form_params = std::collections::HashMap::new();
347    multipart_form_params.insert("customerId", params.customer_id.to_string());
348    multipart_form_params.insert("email", params.email.to_string());
349    if let Some(param_value) = params.recv_window {
350        multipart_form_params.insert("recvWindow", param_value.to_string());
351    }
352    multipart_form_params.insert("timestamp", params.timestamp.to_string());
353    req_builder = req_builder.form(&multipart_form_params);
354
355    let req = req_builder.build()?;
356    let resp = configuration.client.execute(req).await?;
357
358    let status = resp.status();
359    let content_type = resp
360        .headers()
361        .get("content-type")
362        .and_then(|v| v.to_str().ok())
363        .unwrap_or("application/octet-stream");
364    let content_type = super::ContentType::from(content_type);
365
366    if !status.is_client_error() && !status.is_server_error() {
367        let content = resp.text().await?;
368        match content_type {
369            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
370            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateApiReferralCustomizationV1Resp`"))),
371            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::CreateApiReferralCustomizationV1Resp`")))),
372        }
373    } else {
374        let content = resp.text().await?;
375        let entity: Option<CreateApiReferralCustomizationV1Error> = serde_json::from_str(&content).ok();
376        Err(Error::ResponseError(ResponseContent { status, content, entity }))
377    }
378}
379
380/// - CustomerId must be unique
381pub async fn create_api_referral_user_customization_papiv1(configuration: &configuration::Configuration, params: CreateApiReferralUserCustomizationPapiv1Params) -> Result<models::CreateApiReferralUserCustomizationV1Resp, Error<CreateApiReferralUserCustomizationPapiv1Error>> {
382
383    let uri_str = format!("{}/papi/v1/apiReferral/userCustomization", configuration.base_path);
384    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
385
386    // Create a mutable vector for query parameters
387    let mut query_params: Vec<(String, String)> = Vec::new();
388
389
390    // Create header parameters collection
391    let mut header_params = std::collections::HashMap::new();
392
393    // Handle Binance Auth first if configured
394    if let Some(ref binance_auth) = configuration.binance_auth {
395        // Add API key to headers
396        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
397        
398        // Generate request body for signing (if any)
399        let body_string: Option<Vec<u8>> = None;
400        
401        // Sign the request
402        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
403            Ok(sig) => sig,
404            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
405        };
406        
407        // Add signature to query params
408        query_params.push(("signature".to_string(), signature));
409    }
410
411    // Apply all query parameters
412    if !query_params.is_empty() {
413        req_builder = req_builder.query(&query_params);
414    }
415
416
417    // Add user agent if configured
418    if let Some(ref user_agent) = configuration.user_agent {
419        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
420    }
421
422    // Apply all header parameters
423    for (header_name, header_value) in header_params {
424        req_builder = req_builder.header(&header_name, &header_value);
425    }
426
427    let mut multipart_form_params = std::collections::HashMap::new();
428    multipart_form_params.insert("brokerId", params.broker_id.to_string());
429    multipart_form_params.insert("customerId", params.customer_id.to_string());
430    if let Some(param_value) = params.recv_window {
431        multipart_form_params.insert("recvWindow", param_value.to_string());
432    }
433    multipart_form_params.insert("timestamp", params.timestamp.to_string());
434    req_builder = req_builder.form(&multipart_form_params);
435
436    let req = req_builder.build()?;
437    let resp = configuration.client.execute(req).await?;
438
439    let status = resp.status();
440    let content_type = resp
441        .headers()
442        .get("content-type")
443        .and_then(|v| v.to_str().ok())
444        .unwrap_or("application/octet-stream");
445    let content_type = super::ContentType::from(content_type);
446
447    if !status.is_client_error() && !status.is_server_error() {
448        let content = resp.text().await?;
449        match content_type {
450            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
451            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateApiReferralUserCustomizationV1Resp`"))),
452            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::CreateApiReferralUserCustomizationV1Resp`")))),
453        }
454    } else {
455        let content = resp.text().await?;
456        let entity: Option<CreateApiReferralUserCustomizationPapiv1Error> = serde_json::from_str(&content).ok();
457        Err(Error::ResponseError(ResponseContent { status, content, entity }))
458    }
459}
460
461/// - CustomerId must be unique - If the user enabled Portfolio Margin, please user relevant /papi endpoint
462pub async fn create_api_referral_user_customization_v1(configuration: &configuration::Configuration, params: CreateApiReferralUserCustomizationV1Params) -> Result<models::CreateApiReferralUserCustomizationV1Resp, Error<CreateApiReferralUserCustomizationV1Error>> {
463
464    let uri_str = format!("{}/fapi/v1/apiReferral/userCustomization", configuration.base_path);
465    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
466
467    // Create a mutable vector for query parameters
468    let mut query_params: Vec<(String, String)> = Vec::new();
469
470
471    // Create header parameters collection
472    let mut header_params = std::collections::HashMap::new();
473
474    // Handle Binance Auth first if configured
475    if let Some(ref binance_auth) = configuration.binance_auth {
476        // Add API key to headers
477        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
478        
479        // Generate request body for signing (if any)
480        let body_string: Option<Vec<u8>> = None;
481        
482        // Sign the request
483        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
484            Ok(sig) => sig,
485            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
486        };
487        
488        // Add signature to query params
489        query_params.push(("signature".to_string(), signature));
490    }
491
492    // Apply all query parameters
493    if !query_params.is_empty() {
494        req_builder = req_builder.query(&query_params);
495    }
496
497
498    // Add user agent if configured
499    if let Some(ref user_agent) = configuration.user_agent {
500        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
501    }
502
503    // Apply all header parameters
504    for (header_name, header_value) in header_params {
505        req_builder = req_builder.header(&header_name, &header_value);
506    }
507
508    let mut multipart_form_params = std::collections::HashMap::new();
509    multipart_form_params.insert("brokerId", params.broker_id.to_string());
510    multipart_form_params.insert("customerId", params.customer_id.to_string());
511    if let Some(param_value) = params.recv_window {
512        multipart_form_params.insert("recvWindow", param_value.to_string());
513    }
514    multipart_form_params.insert("timestamp", params.timestamp.to_string());
515    req_builder = req_builder.form(&multipart_form_params);
516
517    let req = req_builder.build()?;
518    let resp = configuration.client.execute(req).await?;
519
520    let status = resp.status();
521    let content_type = resp
522        .headers()
523        .get("content-type")
524        .and_then(|v| v.to_str().ok())
525        .unwrap_or("application/octet-stream");
526    let content_type = super::ContentType::from(content_type);
527
528    if !status.is_client_error() && !status.is_server_error() {
529        let content = resp.text().await?;
530        match content_type {
531            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
532            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateApiReferralUserCustomizationV1Resp`"))),
533            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::CreateApiReferralUserCustomizationV1Resp`")))),
534        }
535    } else {
536        let content = resp.text().await?;
537        let entity: Option<CreateApiReferralUserCustomizationV1Error> = serde_json::from_str(&content).ok();
538        Err(Error::ResponseError(ResponseContent { status, content, entity }))
539    }
540}
541
542/// - CustomerId and email can not be sent at the same time
543pub async fn get_api_referral_customization_v1(configuration: &configuration::Configuration, params: GetApiReferralCustomizationV1Params) -> Result<Vec<models::GetApiReferralCustomizationV1RespItem>, Error<GetApiReferralCustomizationV1Error>> {
544
545    let uri_str = format!("{}/fapi/v1/apiReferral/customization", configuration.base_path);
546    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
547
548    // Create a mutable vector for query parameters
549    let mut query_params: Vec<(String, String)> = Vec::new();
550
551    if let Some(ref param_value) = params.customer_id {
552        query_params.push(("customerId".to_string(), param_value.to_string()));
553    }
554    if let Some(ref param_value) = params.email {
555        query_params.push(("email".to_string(), param_value.to_string()));
556    }
557    if let Some(ref param_value) = params.page {
558        query_params.push(("page".to_string(), param_value.to_string()));
559    }
560    if let Some(ref param_value) = params.limit {
561        query_params.push(("limit".to_string(), param_value.to_string()));
562    }
563    if let Some(ref param_value) = params.recv_window {
564        query_params.push(("recvWindow".to_string(), param_value.to_string()));
565    }
566    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
567
568    // Create header parameters collection
569    let mut header_params = std::collections::HashMap::new();
570
571    // Handle Binance Auth first if configured
572    if let Some(ref binance_auth) = configuration.binance_auth {
573        // Add API key to headers
574        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
575        
576        // Generate request body for signing (if any)
577        let body_string: Option<Vec<u8>> = None;
578        
579        // Sign the request
580        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
581            Ok(sig) => sig,
582            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
583        };
584        
585        // Add signature to query params
586        query_params.push(("signature".to_string(), signature));
587    }
588
589    // Apply all query parameters
590    if !query_params.is_empty() {
591        req_builder = req_builder.query(&query_params);
592    }
593
594
595    // Add user agent if configured
596    if let Some(ref user_agent) = configuration.user_agent {
597        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
598    }
599
600    // Apply all header parameters
601    for (header_name, header_value) in header_params {
602        req_builder = req_builder.header(&header_name, &header_value);
603    }
604
605
606    let req = req_builder.build()?;
607    let resp = configuration.client.execute(req).await?;
608
609    let status = resp.status();
610    let content_type = resp
611        .headers()
612        .get("content-type")
613        .and_then(|v| v.to_str().ok())
614        .unwrap_or("application/octet-stream");
615    let content_type = super::ContentType::from(content_type);
616
617    if !status.is_client_error() && !status.is_server_error() {
618        let content = resp.text().await?;
619        match content_type {
620            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
621            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetApiReferralCustomizationV1RespItem&gt;`"))),
622            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::GetApiReferralCustomizationV1RespItem&gt;`")))),
623        }
624    } else {
625        let content = resp.text().await?;
626        let entity: Option<GetApiReferralCustomizationV1Error> = serde_json::from_str(&content).ok();
627        Err(Error::ResponseError(ResponseContent { status, content, entity }))
628    }
629}
630
631pub async fn get_api_referral_if_new_user_papiv1(configuration: &configuration::Configuration, params: GetApiReferralIfNewUserPapiv1Params) -> Result<models::GetApiReferralIfNewUserV1Resp, Error<GetApiReferralIfNewUserPapiv1Error>> {
632
633    let uri_str = format!("{}/papi/v1/apiReferral/ifNewUser", configuration.base_path);
634    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
635
636    // Create a mutable vector for query parameters
637    let mut query_params: Vec<(String, String)> = Vec::new();
638
639    query_params.push(("brokerId".to_string(), params.broker_id.to_string()));
640    if let Some(ref param_value) = params.r#type {
641        query_params.push(("type".to_string(), param_value.to_string()));
642    }
643    if let Some(ref param_value) = params.recv_window {
644        query_params.push(("recvWindow".to_string(), param_value.to_string()));
645    }
646    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
647
648    // Create header parameters collection
649    let mut header_params = std::collections::HashMap::new();
650
651    // Handle Binance Auth first if configured
652    if let Some(ref binance_auth) = configuration.binance_auth {
653        // Add API key to headers
654        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
655        
656        // Generate request body for signing (if any)
657        let body_string: Option<Vec<u8>> = None;
658        
659        // Sign the request
660        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
661            Ok(sig) => sig,
662            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
663        };
664        
665        // Add signature to query params
666        query_params.push(("signature".to_string(), signature));
667    }
668
669    // Apply all query parameters
670    if !query_params.is_empty() {
671        req_builder = req_builder.query(&query_params);
672    }
673
674
675    // Add user agent if configured
676    if let Some(ref user_agent) = configuration.user_agent {
677        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
678    }
679
680    // Apply all header parameters
681    for (header_name, header_value) in header_params {
682        req_builder = req_builder.header(&header_name, &header_value);
683    }
684
685
686    let req = req_builder.build()?;
687    let resp = configuration.client.execute(req).await?;
688
689    let status = resp.status();
690    let content_type = resp
691        .headers()
692        .get("content-type")
693        .and_then(|v| v.to_str().ok())
694        .unwrap_or("application/octet-stream");
695    let content_type = super::ContentType::from(content_type);
696
697    if !status.is_client_error() && !status.is_server_error() {
698        let content = resp.text().await?;
699        match content_type {
700            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
701            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetApiReferralIfNewUserV1Resp`"))),
702            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::GetApiReferralIfNewUserV1Resp`")))),
703        }
704    } else {
705        let content = resp.text().await?;
706        let entity: Option<GetApiReferralIfNewUserPapiv1Error> = serde_json::from_str(&content).ok();
707        Err(Error::ResponseError(ResponseContent { status, content, entity }))
708    }
709}
710
711/// - If the user enabled Portfolio Margin, please user relevant /papi endpoint
712pub async fn get_api_referral_if_new_user_v1(configuration: &configuration::Configuration, params: GetApiReferralIfNewUserV1Params) -> Result<models::GetApiReferralIfNewUserV1Resp, Error<GetApiReferralIfNewUserV1Error>> {
713
714    let uri_str = format!("{}/fapi/v1/apiReferral/ifNewUser", configuration.base_path);
715    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
716
717    // Create a mutable vector for query parameters
718    let mut query_params: Vec<(String, String)> = Vec::new();
719
720    query_params.push(("brokerId".to_string(), params.broker_id.to_string()));
721    if let Some(ref param_value) = params.r#type {
722        query_params.push(("type".to_string(), param_value.to_string()));
723    }
724    if let Some(ref param_value) = params.recv_window {
725        query_params.push(("recvWindow".to_string(), param_value.to_string()));
726    }
727    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
728
729    // Create header parameters collection
730    let mut header_params = std::collections::HashMap::new();
731
732    // Handle Binance Auth first if configured
733    if let Some(ref binance_auth) = configuration.binance_auth {
734        // Add API key to headers
735        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
736        
737        // Generate request body for signing (if any)
738        let body_string: Option<Vec<u8>> = None;
739        
740        // Sign the request
741        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
742            Ok(sig) => sig,
743            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
744        };
745        
746        // Add signature to query params
747        query_params.push(("signature".to_string(), signature));
748    }
749
750    // Apply all query parameters
751    if !query_params.is_empty() {
752        req_builder = req_builder.query(&query_params);
753    }
754
755
756    // Add user agent if configured
757    if let Some(ref user_agent) = configuration.user_agent {
758        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
759    }
760
761    // Apply all header parameters
762    for (header_name, header_value) in header_params {
763        req_builder = req_builder.header(&header_name, &header_value);
764    }
765
766
767    let req = req_builder.build()?;
768    let resp = configuration.client.execute(req).await?;
769
770    let status = resp.status();
771    let content_type = resp
772        .headers()
773        .get("content-type")
774        .and_then(|v| v.to_str().ok())
775        .unwrap_or("application/octet-stream");
776    let content_type = super::ContentType::from(content_type);
777
778    if !status.is_client_error() && !status.is_server_error() {
779        let content = resp.text().await?;
780        match content_type {
781            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
782            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetApiReferralIfNewUserV1Resp`"))),
783            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::GetApiReferralIfNewUserV1Resp`")))),
784        }
785    } else {
786        let content = resp.text().await?;
787        let entity: Option<GetApiReferralIfNewUserV1Error> = serde_json::from_str(&content).ok();
788        Err(Error::ResponseError(ResponseContent { status, content, entity }))
789    }
790}
791
792pub async fn get_api_referral_overview_v1(configuration: &configuration::Configuration, params: GetApiReferralOverviewV1Params) -> Result<models::GetApiReferralOverviewV1Resp, Error<GetApiReferralOverviewV1Error>> {
793
794    let uri_str = format!("{}/fapi/v1/apiReferral/overview", configuration.base_path);
795    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
796
797    // Create a mutable vector for query parameters
798    let mut query_params: Vec<(String, String)> = Vec::new();
799
800    if let Some(ref param_value) = params.r#type {
801        query_params.push(("type".to_string(), param_value.to_string()));
802    }
803    if let Some(ref param_value) = params.recv_window {
804        query_params.push(("recvWindow".to_string(), param_value.to_string()));
805    }
806    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
807
808    // Create header parameters collection
809    let mut header_params = std::collections::HashMap::new();
810
811    // Handle Binance Auth first if configured
812    if let Some(ref binance_auth) = configuration.binance_auth {
813        // Add API key to headers
814        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
815        
816        // Generate request body for signing (if any)
817        let body_string: Option<Vec<u8>> = None;
818        
819        // Sign the request
820        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
821            Ok(sig) => sig,
822            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
823        };
824        
825        // Add signature to query params
826        query_params.push(("signature".to_string(), signature));
827    }
828
829    // Apply all query parameters
830    if !query_params.is_empty() {
831        req_builder = req_builder.query(&query_params);
832    }
833
834
835    // Add user agent if configured
836    if let Some(ref user_agent) = configuration.user_agent {
837        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
838    }
839
840    // Apply all header parameters
841    for (header_name, header_value) in header_params {
842        req_builder = req_builder.header(&header_name, &header_value);
843    }
844
845
846    let req = req_builder.build()?;
847    let resp = configuration.client.execute(req).await?;
848
849    let status = resp.status();
850    let content_type = resp
851        .headers()
852        .get("content-type")
853        .and_then(|v| v.to_str().ok())
854        .unwrap_or("application/octet-stream");
855    let content_type = super::ContentType::from(content_type);
856
857    if !status.is_client_error() && !status.is_server_error() {
858        let content = resp.text().await?;
859        match content_type {
860            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
861            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetApiReferralOverviewV1Resp`"))),
862            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::GetApiReferralOverviewV1Resp`")))),
863        }
864    } else {
865        let content = resp.text().await?;
866        let entity: Option<GetApiReferralOverviewV1Error> = serde_json::from_str(&content).ok();
867        Err(Error::ResponseError(ResponseContent { status, content, entity }))
868    }
869}
870
871pub async fn get_api_referral_rebate_vol_v1(configuration: &configuration::Configuration, params: GetApiReferralRebateVolV1Params) -> Result<Vec<models::GetApiReferralRebateVolV1RespItem>, Error<GetApiReferralRebateVolV1Error>> {
872
873    let uri_str = format!("{}/fapi/v1/apiReferral/rebateVol", configuration.base_path);
874    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
875
876    // Create a mutable vector for query parameters
877    let mut query_params: Vec<(String, String)> = Vec::new();
878
879    if let Some(ref param_value) = params.r#type {
880        query_params.push(("type".to_string(), param_value.to_string()));
881    }
882    if let Some(ref param_value) = params.start_time {
883        query_params.push(("startTime".to_string(), param_value.to_string()));
884    }
885    if let Some(ref param_value) = params.end_time {
886        query_params.push(("endTime".to_string(), param_value.to_string()));
887    }
888    if let Some(ref param_value) = params.limit {
889        query_params.push(("limit".to_string(), param_value.to_string()));
890    }
891    if let Some(ref param_value) = params.recv_window {
892        query_params.push(("recvWindow".to_string(), param_value.to_string()));
893    }
894    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
895
896    // Create header parameters collection
897    let mut header_params = std::collections::HashMap::new();
898
899    // Handle Binance Auth first if configured
900    if let Some(ref binance_auth) = configuration.binance_auth {
901        // Add API key to headers
902        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
903        
904        // Generate request body for signing (if any)
905        let body_string: Option<Vec<u8>> = None;
906        
907        // Sign the request
908        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
909            Ok(sig) => sig,
910            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
911        };
912        
913        // Add signature to query params
914        query_params.push(("signature".to_string(), signature));
915    }
916
917    // Apply all query parameters
918    if !query_params.is_empty() {
919        req_builder = req_builder.query(&query_params);
920    }
921
922
923    // Add user agent if configured
924    if let Some(ref user_agent) = configuration.user_agent {
925        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
926    }
927
928    // Apply all header parameters
929    for (header_name, header_value) in header_params {
930        req_builder = req_builder.header(&header_name, &header_value);
931    }
932
933
934    let req = req_builder.build()?;
935    let resp = configuration.client.execute(req).await?;
936
937    let status = resp.status();
938    let content_type = resp
939        .headers()
940        .get("content-type")
941        .and_then(|v| v.to_str().ok())
942        .unwrap_or("application/octet-stream");
943    let content_type = super::ContentType::from(content_type);
944
945    if !status.is_client_error() && !status.is_server_error() {
946        let content = resp.text().await?;
947        match content_type {
948            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
949            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetApiReferralRebateVolV1RespItem&gt;`"))),
950            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::GetApiReferralRebateVolV1RespItem&gt;`")))),
951        }
952    } else {
953        let content = resp.text().await?;
954        let entity: Option<GetApiReferralRebateVolV1Error> = serde_json::from_str(&content).ok();
955        Err(Error::ResponseError(ResponseContent { status, content, entity }))
956    }
957}
958
959pub async fn get_api_referral_trade_vol_v1(configuration: &configuration::Configuration, params: GetApiReferralTradeVolV1Params) -> Result<Vec<models::GetApiReferralTradeVolV1RespItem>, Error<GetApiReferralTradeVolV1Error>> {
960
961    let uri_str = format!("{}/fapi/v1/apiReferral/tradeVol", configuration.base_path);
962    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
963
964    // Create a mutable vector for query parameters
965    let mut query_params: Vec<(String, String)> = Vec::new();
966
967    if let Some(ref param_value) = params.r#type {
968        query_params.push(("type".to_string(), param_value.to_string()));
969    }
970    if let Some(ref param_value) = params.start_time {
971        query_params.push(("startTime".to_string(), param_value.to_string()));
972    }
973    if let Some(ref param_value) = params.end_time {
974        query_params.push(("endTime".to_string(), param_value.to_string()));
975    }
976    if let Some(ref param_value) = params.limit {
977        query_params.push(("limit".to_string(), param_value.to_string()));
978    }
979    if let Some(ref param_value) = params.recv_window {
980        query_params.push(("recvWindow".to_string(), param_value.to_string()));
981    }
982    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
983
984    // Create header parameters collection
985    let mut header_params = std::collections::HashMap::new();
986
987    // Handle Binance Auth first if configured
988    if let Some(ref binance_auth) = configuration.binance_auth {
989        // Add API key to headers
990        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
991        
992        // Generate request body for signing (if any)
993        let body_string: Option<Vec<u8>> = None;
994        
995        // Sign the request
996        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
997            Ok(sig) => sig,
998            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
999        };
1000        
1001        // Add signature to query params
1002        query_params.push(("signature".to_string(), signature));
1003    }
1004
1005    // Apply all query parameters
1006    if !query_params.is_empty() {
1007        req_builder = req_builder.query(&query_params);
1008    }
1009
1010
1011    // Add user agent if configured
1012    if let Some(ref user_agent) = configuration.user_agent {
1013        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1014    }
1015
1016    // Apply all header parameters
1017    for (header_name, header_value) in header_params {
1018        req_builder = req_builder.header(&header_name, &header_value);
1019    }
1020
1021
1022    let req = req_builder.build()?;
1023    let resp = configuration.client.execute(req).await?;
1024
1025    let status = resp.status();
1026    let content_type = resp
1027        .headers()
1028        .get("content-type")
1029        .and_then(|v| v.to_str().ok())
1030        .unwrap_or("application/octet-stream");
1031    let content_type = super::ContentType::from(content_type);
1032
1033    if !status.is_client_error() && !status.is_server_error() {
1034        let content = resp.text().await?;
1035        match content_type {
1036            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1037            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetApiReferralTradeVolV1RespItem&gt;`"))),
1038            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::GetApiReferralTradeVolV1RespItem&gt;`")))),
1039        }
1040    } else {
1041        let content = resp.text().await?;
1042        let entity: Option<GetApiReferralTradeVolV1Error> = serde_json::from_str(&content).ok();
1043        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1044    }
1045}
1046
1047pub async fn get_api_referral_trader_num_v1(configuration: &configuration::Configuration, params: GetApiReferralTraderNumV1Params) -> Result<Vec<models::GetApiReferralTraderNumV1RespItem>, Error<GetApiReferralTraderNumV1Error>> {
1048
1049    let uri_str = format!("{}/fapi/v1/apiReferral/traderNum", configuration.base_path);
1050    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1051
1052    // Create a mutable vector for query parameters
1053    let mut query_params: Vec<(String, String)> = Vec::new();
1054
1055    if let Some(ref param_value) = params.r#type {
1056        query_params.push(("type".to_string(), param_value.to_string()));
1057    }
1058    if let Some(ref param_value) = params.start_time {
1059        query_params.push(("startTime".to_string(), param_value.to_string()));
1060    }
1061    if let Some(ref param_value) = params.end_time {
1062        query_params.push(("endTime".to_string(), param_value.to_string()));
1063    }
1064    if let Some(ref param_value) = params.limit {
1065        query_params.push(("limit".to_string(), param_value.to_string()));
1066    }
1067    if let Some(ref param_value) = params.recv_window {
1068        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1069    }
1070    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1071
1072    // Create header parameters collection
1073    let mut header_params = std::collections::HashMap::new();
1074
1075    // Handle Binance Auth first if configured
1076    if let Some(ref binance_auth) = configuration.binance_auth {
1077        // Add API key to headers
1078        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1079        
1080        // Generate request body for signing (if any)
1081        let body_string: Option<Vec<u8>> = None;
1082        
1083        // Sign the request
1084        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1085            Ok(sig) => sig,
1086            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1087        };
1088        
1089        // Add signature to query params
1090        query_params.push(("signature".to_string(), signature));
1091    }
1092
1093    // Apply all query parameters
1094    if !query_params.is_empty() {
1095        req_builder = req_builder.query(&query_params);
1096    }
1097
1098
1099    // Add user agent if configured
1100    if let Some(ref user_agent) = configuration.user_agent {
1101        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1102    }
1103
1104    // Apply all header parameters
1105    for (header_name, header_value) in header_params {
1106        req_builder = req_builder.header(&header_name, &header_value);
1107    }
1108
1109
1110    let req = req_builder.build()?;
1111    let resp = configuration.client.execute(req).await?;
1112
1113    let status = resp.status();
1114    let content_type = resp
1115        .headers()
1116        .get("content-type")
1117        .and_then(|v| v.to_str().ok())
1118        .unwrap_or("application/octet-stream");
1119    let content_type = super::ContentType::from(content_type);
1120
1121    if !status.is_client_error() && !status.is_server_error() {
1122        let content = resp.text().await?;
1123        match content_type {
1124            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1125            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetApiReferralTraderNumV1RespItem&gt;`"))),
1126            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::GetApiReferralTraderNumV1RespItem&gt;`")))),
1127        }
1128    } else {
1129        let content = resp.text().await?;
1130        let entity: Option<GetApiReferralTraderNumV1Error> = serde_json::from_str(&content).ok();
1131        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1132    }
1133}
1134
1135pub async fn get_api_referral_trader_summary_v1(configuration: &configuration::Configuration, params: GetApiReferralTraderSummaryV1Params) -> Result<Vec<models::GetApiReferralTraderSummaryV1RespItem>, Error<GetApiReferralTraderSummaryV1Error>> {
1136
1137    let uri_str = format!("{}/fapi/v1/apiReferral/traderSummary", configuration.base_path);
1138    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1139
1140    // Create a mutable vector for query parameters
1141    let mut query_params: Vec<(String, String)> = Vec::new();
1142
1143    if let Some(ref param_value) = params.customer_id {
1144        query_params.push(("customerId".to_string(), param_value.to_string()));
1145    }
1146    if let Some(ref param_value) = params.r#type {
1147        query_params.push(("type".to_string(), param_value.to_string()));
1148    }
1149    if let Some(ref param_value) = params.start_time {
1150        query_params.push(("startTime".to_string(), param_value.to_string()));
1151    }
1152    if let Some(ref param_value) = params.end_time {
1153        query_params.push(("endTime".to_string(), param_value.to_string()));
1154    }
1155    if let Some(ref param_value) = params.limit {
1156        query_params.push(("limit".to_string(), param_value.to_string()));
1157    }
1158    if let Some(ref param_value) = params.recv_window {
1159        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1160    }
1161    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1162
1163    // Create header parameters collection
1164    let mut header_params = std::collections::HashMap::new();
1165
1166    // Handle Binance Auth first if configured
1167    if let Some(ref binance_auth) = configuration.binance_auth {
1168        // Add API key to headers
1169        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1170        
1171        // Generate request body for signing (if any)
1172        let body_string: Option<Vec<u8>> = None;
1173        
1174        // Sign the request
1175        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1176            Ok(sig) => sig,
1177            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1178        };
1179        
1180        // Add signature to query params
1181        query_params.push(("signature".to_string(), signature));
1182    }
1183
1184    // Apply all query parameters
1185    if !query_params.is_empty() {
1186        req_builder = req_builder.query(&query_params);
1187    }
1188
1189
1190    // Add user agent if configured
1191    if let Some(ref user_agent) = configuration.user_agent {
1192        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1193    }
1194
1195    // Apply all header parameters
1196    for (header_name, header_value) in header_params {
1197        req_builder = req_builder.header(&header_name, &header_value);
1198    }
1199
1200
1201    let req = req_builder.build()?;
1202    let resp = configuration.client.execute(req).await?;
1203
1204    let status = resp.status();
1205    let content_type = resp
1206        .headers()
1207        .get("content-type")
1208        .and_then(|v| v.to_str().ok())
1209        .unwrap_or("application/octet-stream");
1210    let content_type = super::ContentType::from(content_type);
1211
1212    if !status.is_client_error() && !status.is_server_error() {
1213        let content = resp.text().await?;
1214        match content_type {
1215            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1216            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetApiReferralTraderSummaryV1RespItem&gt;`"))),
1217            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::GetApiReferralTraderSummaryV1RespItem&gt;`")))),
1218        }
1219    } else {
1220        let content = resp.text().await?;
1221        let entity: Option<GetApiReferralTraderSummaryV1Error> = serde_json::from_str(&content).ok();
1222        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1223    }
1224}
1225
1226pub async fn get_api_referral_user_customization_papiv1(configuration: &configuration::Configuration, params: GetApiReferralUserCustomizationPapiv1Params) -> Result<models::GetApiReferralUserCustomizationV1Resp, Error<GetApiReferralUserCustomizationPapiv1Error>> {
1227
1228    let uri_str = format!("{}/papi/v1/apiReferral/userCustomization", configuration.base_path);
1229    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1230
1231    // Create a mutable vector for query parameters
1232    let mut query_params: Vec<(String, String)> = Vec::new();
1233
1234    query_params.push(("brokerId".to_string(), params.broker_id.to_string()));
1235    if let Some(ref param_value) = params.recv_window {
1236        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1237    }
1238    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1239
1240    // Create header parameters collection
1241    let mut header_params = std::collections::HashMap::new();
1242
1243    // Handle Binance Auth first if configured
1244    if let Some(ref binance_auth) = configuration.binance_auth {
1245        // Add API key to headers
1246        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1247        
1248        // Generate request body for signing (if any)
1249        let body_string: Option<Vec<u8>> = None;
1250        
1251        // Sign the request
1252        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1253            Ok(sig) => sig,
1254            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1255        };
1256        
1257        // Add signature to query params
1258        query_params.push(("signature".to_string(), signature));
1259    }
1260
1261    // Apply all query parameters
1262    if !query_params.is_empty() {
1263        req_builder = req_builder.query(&query_params);
1264    }
1265
1266
1267    // Add user agent if configured
1268    if let Some(ref user_agent) = configuration.user_agent {
1269        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1270    }
1271
1272    // Apply all header parameters
1273    for (header_name, header_value) in header_params {
1274        req_builder = req_builder.header(&header_name, &header_value);
1275    }
1276
1277
1278    let req = req_builder.build()?;
1279    let resp = configuration.client.execute(req).await?;
1280
1281    let status = resp.status();
1282    let content_type = resp
1283        .headers()
1284        .get("content-type")
1285        .and_then(|v| v.to_str().ok())
1286        .unwrap_or("application/octet-stream");
1287    let content_type = super::ContentType::from(content_type);
1288
1289    if !status.is_client_error() && !status.is_server_error() {
1290        let content = resp.text().await?;
1291        match content_type {
1292            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1293            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetApiReferralUserCustomizationV1Resp`"))),
1294            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::GetApiReferralUserCustomizationV1Resp`")))),
1295        }
1296    } else {
1297        let content = resp.text().await?;
1298        let entity: Option<GetApiReferralUserCustomizationPapiv1Error> = serde_json::from_str(&content).ok();
1299        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1300    }
1301}
1302
1303/// - CustomerId must be unique - If the user enabled Portfolio Margin, please user relevant /papi endpoint
1304pub async fn get_api_referral_user_customization_v1(configuration: &configuration::Configuration, params: GetApiReferralUserCustomizationV1Params) -> Result<models::GetApiReferralUserCustomizationV1Resp, Error<GetApiReferralUserCustomizationV1Error>> {
1305
1306    let uri_str = format!("{}/fapi/v1/apiReferral/userCustomization", configuration.base_path);
1307    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1308
1309    // Create a mutable vector for query parameters
1310    let mut query_params: Vec<(String, String)> = Vec::new();
1311
1312    query_params.push(("brokerId".to_string(), params.broker_id.to_string()));
1313    if let Some(ref param_value) = params.recv_window {
1314        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1315    }
1316    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1317
1318    // Create header parameters collection
1319    let mut header_params = std::collections::HashMap::new();
1320
1321    // Handle Binance Auth first if configured
1322    if let Some(ref binance_auth) = configuration.binance_auth {
1323        // Add API key to headers
1324        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1325        
1326        // Generate request body for signing (if any)
1327        let body_string: Option<Vec<u8>> = None;
1328        
1329        // Sign the request
1330        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1331            Ok(sig) => sig,
1332            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1333        };
1334        
1335        // Add signature to query params
1336        query_params.push(("signature".to_string(), signature));
1337    }
1338
1339    // Apply all query parameters
1340    if !query_params.is_empty() {
1341        req_builder = req_builder.query(&query_params);
1342    }
1343
1344
1345    // Add user agent if configured
1346    if let Some(ref user_agent) = configuration.user_agent {
1347        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1348    }
1349
1350    // Apply all header parameters
1351    for (header_name, header_value) in header_params {
1352        req_builder = req_builder.header(&header_name, &header_value);
1353    }
1354
1355
1356    let req = req_builder.build()?;
1357    let resp = configuration.client.execute(req).await?;
1358
1359    let status = resp.status();
1360    let content_type = resp
1361        .headers()
1362        .get("content-type")
1363        .and_then(|v| v.to_str().ok())
1364        .unwrap_or("application/octet-stream");
1365    let content_type = super::ContentType::from(content_type);
1366
1367    if !status.is_client_error() && !status.is_server_error() {
1368        let content = resp.text().await?;
1369        match content_type {
1370            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1371            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetApiReferralUserCustomizationV1Resp`"))),
1372            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::GetApiReferralUserCustomizationV1Resp`")))),
1373        }
1374    } else {
1375        let content = resp.text().await?;
1376        let entity: Option<GetApiReferralUserCustomizationV1Error> = serde_json::from_str(&content).ok();
1377        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1378    }
1379}
1380
1381/// - If incomeType  is not sent, all kinds of flow will be returned - If startTime and endTime are not sent, the most recent limit datas will be returned. - If the number of data between startTime and endTime is larger than limit, response will be return as startTime + limit.
1382pub async fn get_income_v1(configuration: &configuration::Configuration, params: GetIncomeV1Params) -> Result<Vec<models::GetIncomeV1RespItem>, Error<GetIncomeV1Error>> {
1383
1384    let uri_str = format!("{}/fapi/v1/income", configuration.base_path);
1385    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1386
1387    // Create a mutable vector for query parameters
1388    let mut query_params: Vec<(String, String)> = Vec::new();
1389
1390    if let Some(ref param_value) = params.symbol {
1391        query_params.push(("symbol".to_string(), param_value.to_string()));
1392    }
1393    if let Some(ref param_value) = params.income_type {
1394        query_params.push(("incomeType".to_string(), param_value.to_string()));
1395    }
1396    if let Some(ref param_value) = params.start_time {
1397        query_params.push(("startTime".to_string(), param_value.to_string()));
1398    }
1399    if let Some(ref param_value) = params.end_time {
1400        query_params.push(("endTime".to_string(), param_value.to_string()));
1401    }
1402    if let Some(ref param_value) = params.limit {
1403        query_params.push(("limit".to_string(), param_value.to_string()));
1404    }
1405    if let Some(ref param_value) = params.recv_window {
1406        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1407    }
1408    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1409
1410    // Create header parameters collection
1411    let mut header_params = std::collections::HashMap::new();
1412
1413    // Handle Binance Auth first if configured
1414    if let Some(ref binance_auth) = configuration.binance_auth {
1415        // Add API key to headers
1416        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1417        
1418        // Generate request body for signing (if any)
1419        let body_string: Option<Vec<u8>> = None;
1420        
1421        // Sign the request
1422        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1423            Ok(sig) => sig,
1424            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1425        };
1426        
1427        // Add signature to query params
1428        query_params.push(("signature".to_string(), signature));
1429    }
1430
1431    // Apply all query parameters
1432    if !query_params.is_empty() {
1433        req_builder = req_builder.query(&query_params);
1434    }
1435
1436
1437    // Add user agent if configured
1438    if let Some(ref user_agent) = configuration.user_agent {
1439        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1440    }
1441
1442    // Apply all header parameters
1443    for (header_name, header_value) in header_params {
1444        req_builder = req_builder.header(&header_name, &header_value);
1445    }
1446
1447
1448    let req = req_builder.build()?;
1449    let resp = configuration.client.execute(req).await?;
1450
1451    let status = resp.status();
1452    let content_type = resp
1453        .headers()
1454        .get("content-type")
1455        .and_then(|v| v.to_str().ok())
1456        .unwrap_or("application/octet-stream");
1457    let content_type = super::ContentType::from(content_type);
1458
1459    if !status.is_client_error() && !status.is_server_error() {
1460        let content = resp.text().await?;
1461        match content_type {
1462            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1463            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GetIncomeV1RespItem&gt;`"))),
1464            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::GetIncomeV1RespItem&gt;`")))),
1465        }
1466    } else {
1467        let content = resp.text().await?;
1468        let entity: Option<GetIncomeV1Error> = serde_json::from_str(&content).ok();
1469        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1470    }
1471}
1472