binance/spot/apis/
account_api.rs

1/*
2 * Binance Spot API
3 *
4 * OpenAPI specification for Binance exchange - Spot API
5 *
6 * The version of the OpenAPI document: 0.1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::spot::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`spot_get_account_commission_v3`]
18#[derive(Clone, Debug, Default)]
19pub struct SpotGetAccountCommissionV3Params {
20    pub symbol: String
21}
22
23/// struct for passing parameters to the method [`spot_get_account_v3`]
24#[derive(Clone, Debug, Default)]
25pub struct SpotGetAccountV3Params {
26    pub timestamp: i64,
27    /// When set to `true`, emits only the non-zero balances of an account. <br/>Default value: `false`
28    pub omit_zero_balances: Option<bool>,
29    /// The value cannot be greater than `60000`
30    pub recv_window: Option<i64>
31}
32
33/// struct for passing parameters to the method [`spot_get_my_allocations_v3`]
34#[derive(Clone, Debug, Default)]
35pub struct SpotGetMyAllocationsV3Params {
36    pub symbol: String,
37    pub start_time: Option<i64>,
38    pub end_time: Option<i64>,
39    pub from_allocation_id: Option<i32>,
40    /// Default 500;Max 1000
41    pub limit: Option<i32>,
42    pub order_id: Option<i64>,
43    /// The value cannot be greater than `60000`.
44    pub recv_window: Option<i64>,
45    pub timestamp: Option<i64>
46}
47
48/// struct for passing parameters to the method [`spot_get_my_prevented_matches_v3`]
49#[derive(Clone, Debug, Default)]
50pub struct SpotGetMyPreventedMatchesV3Params {
51    pub symbol: String,
52    pub timestamp: i64,
53    pub prevented_match_id: Option<i64>,
54    pub order_id: Option<i64>,
55    pub from_prevented_match_id: Option<i64>,
56    /// Default: `500`; Max: `1000`
57    pub limit: Option<i32>,
58    /// The value cannot be greater than `60000`
59    pub recv_window: Option<i64>
60}
61
62/// struct for passing parameters to the method [`spot_get_my_trades_v3`]
63#[derive(Clone, Debug, Default)]
64pub struct SpotGetMyTradesV3Params {
65    pub symbol: String,
66    pub timestamp: i64,
67    /// This can only be used in combination with `symbol`.
68    pub order_id: Option<i64>,
69    pub start_time: Option<i64>,
70    pub end_time: Option<i64>,
71    /// TradeId to fetch from. Default gets most recent trades.
72    pub from_id: Option<i64>,
73    /// Default 500; max 1000.
74    pub limit: Option<i32>,
75    /// The value cannot be greater than `60000`
76    pub recv_window: Option<i64>
77}
78
79/// struct for passing parameters to the method [`spot_get_rate_limit_order_v3`]
80#[derive(Clone, Debug, Default)]
81pub struct SpotGetRateLimitOrderV3Params {
82    pub timestamp: i64,
83    /// The value cannot be greater than `60000`
84    pub recv_window: Option<i64>
85}
86
87
88/// struct for typed errors of method [`spot_get_account_commission_v3`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum SpotGetAccountCommissionV3Error {
92    Status4XX(models::ApiError),
93    Status5XX(models::ApiError),
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`spot_get_account_v3`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum SpotGetAccountV3Error {
101    Status4XX(models::ApiError),
102    Status5XX(models::ApiError),
103    UnknownValue(serde_json::Value),
104}
105
106/// struct for typed errors of method [`spot_get_my_allocations_v3`]
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum SpotGetMyAllocationsV3Error {
110    Status4XX(models::ApiError),
111    Status5XX(models::ApiError),
112    UnknownValue(serde_json::Value),
113}
114
115/// struct for typed errors of method [`spot_get_my_prevented_matches_v3`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum SpotGetMyPreventedMatchesV3Error {
119    Status4XX(models::ApiError),
120    Status5XX(models::ApiError),
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`spot_get_my_trades_v3`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum SpotGetMyTradesV3Error {
128    Status4XX(models::ApiError),
129    Status5XX(models::ApiError),
130    UnknownValue(serde_json::Value),
131}
132
133/// struct for typed errors of method [`spot_get_rate_limit_order_v3`]
134#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum SpotGetRateLimitOrderV3Error {
137    Status4XX(models::ApiError),
138    Status5XX(models::ApiError),
139    UnknownValue(serde_json::Value),
140}
141
142
143/// Get current account commission rates.
144pub async fn spot_get_account_commission_v3(configuration: &configuration::Configuration, params: SpotGetAccountCommissionV3Params) -> Result<models::SpotGetAccountCommissionV3Resp, Error<SpotGetAccountCommissionV3Error>> {
145
146    let uri_str = format!("{}/api/v3/account/commission", configuration.base_path);
147    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
148
149    // Create a mutable vector for query parameters
150    let mut query_params: Vec<(String, String)> = Vec::new();
151
152    query_params.push(("symbol".to_string(), params.symbol.to_string()));
153
154    // Create header parameters collection
155    let mut header_params = std::collections::HashMap::new();
156
157    // Handle Binance Auth first if configured
158    if let Some(ref binance_auth) = configuration.binance_auth {
159        // Add API key to headers
160        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
161        
162        // Generate request body for signing (if any)
163        let body_string: Option<Vec<u8>> = None;
164        
165        // Sign the request
166        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
167            Ok(sig) => sig,
168            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
169        };
170        
171        // Add signature to query params
172        query_params.push(("signature".to_string(), signature));
173    }
174
175    // Apply all query parameters
176    if !query_params.is_empty() {
177        req_builder = req_builder.query(&query_params);
178    }
179
180
181    // Add user agent if configured
182    if let Some(ref user_agent) = configuration.user_agent {
183        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
184    }
185
186    // Apply all header parameters
187    for (header_name, header_value) in header_params {
188        req_builder = req_builder.header(&header_name, &header_value);
189    }
190
191
192    let req = req_builder.build()?;
193    let resp = configuration.client.execute(req).await?;
194
195    let status = resp.status();
196    let content_type = resp
197        .headers()
198        .get("content-type")
199        .and_then(|v| v.to_str().ok())
200        .unwrap_or("application/octet-stream");
201    let content_type = super::ContentType::from(content_type);
202
203    if !status.is_client_error() && !status.is_server_error() {
204        let content = resp.text().await?;
205        match content_type {
206            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
207            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetAccountCommissionV3Resp`"))),
208            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::SpotGetAccountCommissionV3Resp`")))),
209        }
210    } else {
211        let content = resp.text().await?;
212        let entity: Option<SpotGetAccountCommissionV3Error> = serde_json::from_str(&content).ok();
213        Err(Error::ResponseError(ResponseContent { status, content, entity }))
214    }
215}
216
217/// Get current account information.
218pub async fn spot_get_account_v3(configuration: &configuration::Configuration, params: SpotGetAccountV3Params) -> Result<models::SpotGetAccountV3Resp, Error<SpotGetAccountV3Error>> {
219
220    let uri_str = format!("{}/api/v3/account", configuration.base_path);
221    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
222
223    // Create a mutable vector for query parameters
224    let mut query_params: Vec<(String, String)> = Vec::new();
225
226    if let Some(ref param_value) = params.omit_zero_balances {
227        query_params.push(("omitZeroBalances".to_string(), param_value.to_string()));
228    }
229    if let Some(ref param_value) = params.recv_window {
230        query_params.push(("recvWindow".to_string(), param_value.to_string()));
231    }
232    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
233
234    // Create header parameters collection
235    let mut header_params = std::collections::HashMap::new();
236
237    // Handle Binance Auth first if configured
238    if let Some(ref binance_auth) = configuration.binance_auth {
239        // Add API key to headers
240        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
241        
242        // Generate request body for signing (if any)
243        let body_string: Option<Vec<u8>> = None;
244        
245        // Sign the request
246        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
247            Ok(sig) => sig,
248            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
249        };
250        
251        // Add signature to query params
252        query_params.push(("signature".to_string(), signature));
253    }
254
255    // Apply all query parameters
256    if !query_params.is_empty() {
257        req_builder = req_builder.query(&query_params);
258    }
259
260
261    // Add user agent if configured
262    if let Some(ref user_agent) = configuration.user_agent {
263        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
264    }
265
266    // Apply all header parameters
267    for (header_name, header_value) in header_params {
268        req_builder = req_builder.header(&header_name, &header_value);
269    }
270
271
272    let req = req_builder.build()?;
273    let resp = configuration.client.execute(req).await?;
274
275    let status = resp.status();
276    let content_type = resp
277        .headers()
278        .get("content-type")
279        .and_then(|v| v.to_str().ok())
280        .unwrap_or("application/octet-stream");
281    let content_type = super::ContentType::from(content_type);
282
283    if !status.is_client_error() && !status.is_server_error() {
284        let content = resp.text().await?;
285        match content_type {
286            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
287            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetAccountV3Resp`"))),
288            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::SpotGetAccountV3Resp`")))),
289        }
290    } else {
291        let content = resp.text().await?;
292        let entity: Option<SpotGetAccountV3Error> = serde_json::from_str(&content).ok();
293        Err(Error::ResponseError(ResponseContent { status, content, entity }))
294    }
295}
296
297/// Retrieves allocations resulting from SOR order placement.
298pub async fn spot_get_my_allocations_v3(configuration: &configuration::Configuration, params: SpotGetMyAllocationsV3Params) -> Result<Vec<models::SpotGetMyAllocationsV3RespItem>, Error<SpotGetMyAllocationsV3Error>> {
299
300    let uri_str = format!("{}/api/v3/myAllocations", configuration.base_path);
301    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
302
303    // Create a mutable vector for query parameters
304    let mut query_params: Vec<(String, String)> = Vec::new();
305
306    query_params.push(("symbol".to_string(), params.symbol.to_string()));
307    if let Some(ref param_value) = params.start_time {
308        query_params.push(("startTime".to_string(), param_value.to_string()));
309    }
310    if let Some(ref param_value) = params.end_time {
311        query_params.push(("endTime".to_string(), param_value.to_string()));
312    }
313    if let Some(ref param_value) = params.from_allocation_id {
314        query_params.push(("fromAllocationId".to_string(), param_value.to_string()));
315    }
316    if let Some(ref param_value) = params.limit {
317        query_params.push(("limit".to_string(), param_value.to_string()));
318    }
319    if let Some(ref param_value) = params.order_id {
320        query_params.push(("orderId".to_string(), param_value.to_string()));
321    }
322    if let Some(ref param_value) = params.recv_window {
323        query_params.push(("recvWindow".to_string(), param_value.to_string()));
324    }
325    if let Some(ref param_value) = params.timestamp {
326        query_params.push(("timestamp".to_string(), param_value.to_string()));
327    }
328
329    // Create header parameters collection
330    let mut header_params = std::collections::HashMap::new();
331
332    // Handle Binance Auth first if configured
333    if let Some(ref binance_auth) = configuration.binance_auth {
334        // Add API key to headers
335        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
336        
337        // Generate request body for signing (if any)
338        let body_string: Option<Vec<u8>> = None;
339        
340        // Sign the request
341        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
342            Ok(sig) => sig,
343            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
344        };
345        
346        // Add signature to query params
347        query_params.push(("signature".to_string(), signature));
348    }
349
350    // Apply all query parameters
351    if !query_params.is_empty() {
352        req_builder = req_builder.query(&query_params);
353    }
354
355
356    // Add user agent if configured
357    if let Some(ref user_agent) = configuration.user_agent {
358        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
359    }
360
361    // Apply all header parameters
362    for (header_name, header_value) in header_params {
363        req_builder = req_builder.header(&header_name, &header_value);
364    }
365
366
367    let req = req_builder.build()?;
368    let resp = configuration.client.execute(req).await?;
369
370    let status = resp.status();
371    let content_type = resp
372        .headers()
373        .get("content-type")
374        .and_then(|v| v.to_str().ok())
375        .unwrap_or("application/octet-stream");
376    let content_type = super::ContentType::from(content_type);
377
378    if !status.is_client_error() && !status.is_server_error() {
379        let content = resp.text().await?;
380        match content_type {
381            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
382            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetMyAllocationsV3RespItem&gt;`"))),
383            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::SpotGetMyAllocationsV3RespItem&gt;`")))),
384        }
385    } else {
386        let content = resp.text().await?;
387        let entity: Option<SpotGetMyAllocationsV3Error> = serde_json::from_str(&content).ok();
388        Err(Error::ResponseError(ResponseContent { status, content, entity }))
389    }
390}
391
392/// Displays the list of orders that were expired due to STP. These are the combinations supported: - symbol + preventedMatchId - symbol + orderId - symbol + orderId + fromPreventedMatchId (limit will default to 500) - symbol + orderId + fromPreventedMatchId + limit
393pub async fn spot_get_my_prevented_matches_v3(configuration: &configuration::Configuration, params: SpotGetMyPreventedMatchesV3Params) -> Result<Vec<models::SpotGetMyPreventedMatchesV3RespItem>, Error<SpotGetMyPreventedMatchesV3Error>> {
394
395    let uri_str = format!("{}/api/v3/myPreventedMatches", configuration.base_path);
396    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
397
398    // Create a mutable vector for query parameters
399    let mut query_params: Vec<(String, String)> = Vec::new();
400
401    query_params.push(("symbol".to_string(), params.symbol.to_string()));
402    if let Some(ref param_value) = params.prevented_match_id {
403        query_params.push(("preventedMatchId".to_string(), param_value.to_string()));
404    }
405    if let Some(ref param_value) = params.order_id {
406        query_params.push(("orderId".to_string(), param_value.to_string()));
407    }
408    if let Some(ref param_value) = params.from_prevented_match_id {
409        query_params.push(("fromPreventedMatchId".to_string(), param_value.to_string()));
410    }
411    if let Some(ref param_value) = params.limit {
412        query_params.push(("limit".to_string(), param_value.to_string()));
413    }
414    if let Some(ref param_value) = params.recv_window {
415        query_params.push(("recvWindow".to_string(), param_value.to_string()));
416    }
417    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
418
419    // Create header parameters collection
420    let mut header_params = std::collections::HashMap::new();
421
422    // Handle Binance Auth first if configured
423    if let Some(ref binance_auth) = configuration.binance_auth {
424        // Add API key to headers
425        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
426        
427        // Generate request body for signing (if any)
428        let body_string: Option<Vec<u8>> = None;
429        
430        // Sign the request
431        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
432            Ok(sig) => sig,
433            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
434        };
435        
436        // Add signature to query params
437        query_params.push(("signature".to_string(), signature));
438    }
439
440    // Apply all query parameters
441    if !query_params.is_empty() {
442        req_builder = req_builder.query(&query_params);
443    }
444
445
446    // Add user agent if configured
447    if let Some(ref user_agent) = configuration.user_agent {
448        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
449    }
450
451    // Apply all header parameters
452    for (header_name, header_value) in header_params {
453        req_builder = req_builder.header(&header_name, &header_value);
454    }
455
456
457    let req = req_builder.build()?;
458    let resp = configuration.client.execute(req).await?;
459
460    let status = resp.status();
461    let content_type = resp
462        .headers()
463        .get("content-type")
464        .and_then(|v| v.to_str().ok())
465        .unwrap_or("application/octet-stream");
466    let content_type = super::ContentType::from(content_type);
467
468    if !status.is_client_error() && !status.is_server_error() {
469        let content = resp.text().await?;
470        match content_type {
471            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
472            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetMyPreventedMatchesV3RespItem&gt;`"))),
473            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::SpotGetMyPreventedMatchesV3RespItem&gt;`")))),
474        }
475    } else {
476        let content = resp.text().await?;
477        let entity: Option<SpotGetMyPreventedMatchesV3Error> = serde_json::from_str(&content).ok();
478        Err(Error::ResponseError(ResponseContent { status, content, entity }))
479    }
480}
481
482/// Get trades for a specific account and symbol.
483pub async fn spot_get_my_trades_v3(configuration: &configuration::Configuration, params: SpotGetMyTradesV3Params) -> Result<Vec<models::SpotGetMyTradesV3RespItem>, Error<SpotGetMyTradesV3Error>> {
484
485    let uri_str = format!("{}/api/v3/myTrades", configuration.base_path);
486    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
487
488    // Create a mutable vector for query parameters
489    let mut query_params: Vec<(String, String)> = Vec::new();
490
491    query_params.push(("symbol".to_string(), params.symbol.to_string()));
492    if let Some(ref param_value) = params.order_id {
493        query_params.push(("orderId".to_string(), param_value.to_string()));
494    }
495    if let Some(ref param_value) = params.start_time {
496        query_params.push(("startTime".to_string(), param_value.to_string()));
497    }
498    if let Some(ref param_value) = params.end_time {
499        query_params.push(("endTime".to_string(), param_value.to_string()));
500    }
501    if let Some(ref param_value) = params.from_id {
502        query_params.push(("fromId".to_string(), param_value.to_string()));
503    }
504    if let Some(ref param_value) = params.limit {
505        query_params.push(("limit".to_string(), param_value.to_string()));
506    }
507    if let Some(ref param_value) = params.recv_window {
508        query_params.push(("recvWindow".to_string(), param_value.to_string()));
509    }
510    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
511
512    // Create header parameters collection
513    let mut header_params = std::collections::HashMap::new();
514
515    // Handle Binance Auth first if configured
516    if let Some(ref binance_auth) = configuration.binance_auth {
517        // Add API key to headers
518        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
519        
520        // Generate request body for signing (if any)
521        let body_string: Option<Vec<u8>> = None;
522        
523        // Sign the request
524        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
525            Ok(sig) => sig,
526            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
527        };
528        
529        // Add signature to query params
530        query_params.push(("signature".to_string(), signature));
531    }
532
533    // Apply all query parameters
534    if !query_params.is_empty() {
535        req_builder = req_builder.query(&query_params);
536    }
537
538
539    // Add user agent if configured
540    if let Some(ref user_agent) = configuration.user_agent {
541        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
542    }
543
544    // Apply all header parameters
545    for (header_name, header_value) in header_params {
546        req_builder = req_builder.header(&header_name, &header_value);
547    }
548
549
550    let req = req_builder.build()?;
551    let resp = configuration.client.execute(req).await?;
552
553    let status = resp.status();
554    let content_type = resp
555        .headers()
556        .get("content-type")
557        .and_then(|v| v.to_str().ok())
558        .unwrap_or("application/octet-stream");
559    let content_type = super::ContentType::from(content_type);
560
561    if !status.is_client_error() && !status.is_server_error() {
562        let content = resp.text().await?;
563        match content_type {
564            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
565            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetMyTradesV3RespItem&gt;`"))),
566            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::SpotGetMyTradesV3RespItem&gt;`")))),
567        }
568    } else {
569        let content = resp.text().await?;
570        let entity: Option<SpotGetMyTradesV3Error> = serde_json::from_str(&content).ok();
571        Err(Error::ResponseError(ResponseContent { status, content, entity }))
572    }
573}
574
575/// Displays the user's unfilled order count for all intervals.
576pub async fn spot_get_rate_limit_order_v3(configuration: &configuration::Configuration, params: SpotGetRateLimitOrderV3Params) -> Result<Vec<models::SpotGetRateLimitOrderV3RespItem>, Error<SpotGetRateLimitOrderV3Error>> {
577
578    let uri_str = format!("{}/api/v3/rateLimit/order", configuration.base_path);
579    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
580
581    // Create a mutable vector for query parameters
582    let mut query_params: Vec<(String, String)> = Vec::new();
583
584    if let Some(ref param_value) = params.recv_window {
585        query_params.push(("recvWindow".to_string(), param_value.to_string()));
586    }
587    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
588
589    // Create header parameters collection
590    let mut header_params = std::collections::HashMap::new();
591
592    // Handle Binance Auth first if configured
593    if let Some(ref binance_auth) = configuration.binance_auth {
594        // Add API key to headers
595        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
596        
597        // Generate request body for signing (if any)
598        let body_string: Option<Vec<u8>> = None;
599        
600        // Sign the request
601        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
602            Ok(sig) => sig,
603            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
604        };
605        
606        // Add signature to query params
607        query_params.push(("signature".to_string(), signature));
608    }
609
610    // Apply all query parameters
611    if !query_params.is_empty() {
612        req_builder = req_builder.query(&query_params);
613    }
614
615
616    // Add user agent if configured
617    if let Some(ref user_agent) = configuration.user_agent {
618        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
619    }
620
621    // Apply all header parameters
622    for (header_name, header_value) in header_params {
623        req_builder = req_builder.header(&header_name, &header_value);
624    }
625
626
627    let req = req_builder.build()?;
628    let resp = configuration.client.execute(req).await?;
629
630    let status = resp.status();
631    let content_type = resp
632        .headers()
633        .get("content-type")
634        .and_then(|v| v.to_str().ok())
635        .unwrap_or("application/octet-stream");
636    let content_type = super::ContentType::from(content_type);
637
638    if !status.is_client_error() && !status.is_server_error() {
639        let content = resp.text().await?;
640        match content_type {
641            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
642            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetRateLimitOrderV3RespItem&gt;`"))),
643            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::SpotGetRateLimitOrderV3RespItem&gt;`")))),
644        }
645    } else {
646        let content = resp.text().await?;
647        let entity: Option<SpotGetRateLimitOrderV3Error> = serde_json::from_str(&content).ok();
648        Err(Error::ResponseError(ResponseContent { status, content, entity }))
649    }
650}
651