binance/convert/apis/
trade_api.rs

1/*
2 * Binance Convert API
3 *
4 * OpenAPI specification for Binance exchange - Convert 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::convert::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`convert_create_convert_accept_quote_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct ConvertCreateConvertAcceptQuoteV1Params {
20    pub quote_id: String,
21    pub timestamp: i64,
22    pub recv_window: Option<i64>
23}
24
25/// struct for passing parameters to the method [`convert_create_convert_get_quote_v1`]
26#[derive(Clone, Debug, Default)]
27pub struct ConvertCreateConvertGetQuoteV1Params {
28    pub from_asset: String,
29    pub timestamp: i64,
30    pub to_asset: String,
31    pub from_amount: Option<String>,
32    pub recv_window: Option<i64>,
33    pub to_amount: Option<String>,
34    pub valid_time: Option<String>,
35    pub wallet_type: Option<String>
36}
37
38/// struct for passing parameters to the method [`convert_create_convert_limit_cancel_order_v1`]
39#[derive(Clone, Debug, Default)]
40pub struct ConvertCreateConvertLimitCancelOrderV1Params {
41    pub order_id: i64,
42    pub timestamp: i64,
43    pub recv_window: Option<i64>
44}
45
46/// struct for passing parameters to the method [`convert_create_convert_limit_place_order_v1`]
47#[derive(Clone, Debug, Default)]
48pub struct ConvertCreateConvertLimitPlaceOrderV1Params {
49    pub base_asset: String,
50    pub expired_type: String,
51    pub limit_price: String,
52    pub quote_asset: String,
53    pub side: String,
54    pub timestamp: i64,
55    pub base_amount: Option<String>,
56    pub quote_amount: Option<String>,
57    pub recv_window: Option<i64>,
58    pub wallet_type: Option<String>
59}
60
61/// struct for passing parameters to the method [`convert_create_convert_limit_query_open_orders_v1`]
62#[derive(Clone, Debug, Default)]
63pub struct ConvertCreateConvertLimitQueryOpenOrdersV1Params {
64    pub timestamp: i64,
65    pub recv_window: Option<i64>
66}
67
68/// struct for passing parameters to the method [`convert_get_convert_order_status_v1`]
69#[derive(Clone, Debug, Default)]
70pub struct ConvertGetConvertOrderStatusV1Params {
71    /// Either orderId or quoteId is required
72    pub order_id: Option<String>,
73    /// Either orderId or quoteId is required
74    pub quote_id: Option<String>
75}
76
77/// struct for passing parameters to the method [`convert_get_convert_trade_flow_v1`]
78#[derive(Clone, Debug, Default)]
79pub struct ConvertGetConvertTradeFlowV1Params {
80    pub start_time: i64,
81    pub end_time: i64,
82    pub timestamp: i64,
83    /// Default 100, Max 1000
84    pub limit: Option<i32>,
85    pub recv_window: Option<i64>
86}
87
88
89/// struct for typed errors of method [`convert_create_convert_accept_quote_v1`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum ConvertCreateConvertAcceptQuoteV1Error {
93    Status4XX(models::ApiError),
94    Status5XX(models::ApiError),
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`convert_create_convert_get_quote_v1`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum ConvertCreateConvertGetQuoteV1Error {
102    Status4XX(models::ApiError),
103    Status5XX(models::ApiError),
104    UnknownValue(serde_json::Value),
105}
106
107/// struct for typed errors of method [`convert_create_convert_limit_cancel_order_v1`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum ConvertCreateConvertLimitCancelOrderV1Error {
111    Status4XX(models::ApiError),
112    Status5XX(models::ApiError),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`convert_create_convert_limit_place_order_v1`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ConvertCreateConvertLimitPlaceOrderV1Error {
120    Status4XX(models::ApiError),
121    Status5XX(models::ApiError),
122    UnknownValue(serde_json::Value),
123}
124
125/// struct for typed errors of method [`convert_create_convert_limit_query_open_orders_v1`]
126#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum ConvertCreateConvertLimitQueryOpenOrdersV1Error {
129    Status4XX(models::ApiError),
130    Status5XX(models::ApiError),
131    UnknownValue(serde_json::Value),
132}
133
134/// struct for typed errors of method [`convert_get_convert_order_status_v1`]
135#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(untagged)]
137pub enum ConvertGetConvertOrderStatusV1Error {
138    Status4XX(models::ApiError),
139    Status5XX(models::ApiError),
140    UnknownValue(serde_json::Value),
141}
142
143/// struct for typed errors of method [`convert_get_convert_trade_flow_v1`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum ConvertGetConvertTradeFlowV1Error {
147    Status4XX(models::ApiError),
148    Status5XX(models::ApiError),
149    UnknownValue(serde_json::Value),
150}
151
152
153/// Accept the offered quote by quote ID.
154pub async fn convert_create_convert_accept_quote_v1(configuration: &configuration::Configuration, params: ConvertCreateConvertAcceptQuoteV1Params) -> Result<models::ConvertCreateConvertAcceptQuoteV1Resp, Error<ConvertCreateConvertAcceptQuoteV1Error>> {
155
156    let uri_str = format!("{}/sapi/v1/convert/acceptQuote", configuration.base_path);
157    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
158
159    // Create a mutable vector for query parameters
160    let mut query_params: Vec<(String, String)> = Vec::new();
161
162
163    // Create header parameters collection
164    let mut header_params = std::collections::HashMap::new();
165
166    // Handle Binance Auth first if configured
167    if let Some(ref binance_auth) = configuration.binance_auth {
168        // Add API key to headers
169        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
170        
171        // Generate request body for signing (if any)
172        let body_string: Option<Vec<u8>> = None;
173        
174        // Sign the request
175        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
176            Ok(sig) => sig,
177            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
178        };
179        
180        // Add signature to query params
181        query_params.push(("signature".to_string(), signature));
182    }
183
184    // Apply all query parameters
185    if !query_params.is_empty() {
186        req_builder = req_builder.query(&query_params);
187    }
188
189
190    // Add user agent if configured
191    if let Some(ref user_agent) = configuration.user_agent {
192        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
193    }
194
195    // Apply all header parameters
196    for (header_name, header_value) in header_params {
197        req_builder = req_builder.header(&header_name, &header_value);
198    }
199
200    let mut multipart_form_params = std::collections::HashMap::new();
201    multipart_form_params.insert("quoteId", params.quote_id.to_string());
202    if let Some(param_value) = params.recv_window {
203        multipart_form_params.insert("recvWindow", param_value.to_string());
204    }
205    multipart_form_params.insert("timestamp", params.timestamp.to_string());
206    req_builder = req_builder.form(&multipart_form_params);
207
208    let req = req_builder.build()?;
209    let resp = configuration.client.execute(req).await?;
210
211    let status = resp.status();
212    let content_type = resp
213        .headers()
214        .get("content-type")
215        .and_then(|v| v.to_str().ok())
216        .unwrap_or("application/octet-stream");
217    let content_type = super::ContentType::from(content_type);
218
219    if !status.is_client_error() && !status.is_server_error() {
220        let content = resp.text().await?;
221        match content_type {
222            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
223            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConvertCreateConvertAcceptQuoteV1Resp`"))),
224            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::ConvertCreateConvertAcceptQuoteV1Resp`")))),
225        }
226    } else {
227        let content = resp.text().await?;
228        let entity: Option<ConvertCreateConvertAcceptQuoteV1Error> = serde_json::from_str(&content).ok();
229        Err(Error::ResponseError(ResponseContent { status, content, entity }))
230    }
231}
232
233/// Request a quote for the requested token pairs
234pub async fn convert_create_convert_get_quote_v1(configuration: &configuration::Configuration, params: ConvertCreateConvertGetQuoteV1Params) -> Result<models::ConvertCreateConvertGetQuoteV1Resp, Error<ConvertCreateConvertGetQuoteV1Error>> {
235
236    let uri_str = format!("{}/sapi/v1/convert/getQuote", configuration.base_path);
237    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
238
239    // Create a mutable vector for query parameters
240    let mut query_params: Vec<(String, String)> = Vec::new();
241
242
243    // Create header parameters collection
244    let mut header_params = std::collections::HashMap::new();
245
246    // Handle Binance Auth first if configured
247    if let Some(ref binance_auth) = configuration.binance_auth {
248        // Add API key to headers
249        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
250        
251        // Generate request body for signing (if any)
252        let body_string: Option<Vec<u8>> = None;
253        
254        // Sign the request
255        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
256            Ok(sig) => sig,
257            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
258        };
259        
260        // Add signature to query params
261        query_params.push(("signature".to_string(), signature));
262    }
263
264    // Apply all query parameters
265    if !query_params.is_empty() {
266        req_builder = req_builder.query(&query_params);
267    }
268
269
270    // Add user agent if configured
271    if let Some(ref user_agent) = configuration.user_agent {
272        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
273    }
274
275    // Apply all header parameters
276    for (header_name, header_value) in header_params {
277        req_builder = req_builder.header(&header_name, &header_value);
278    }
279
280    let mut multipart_form_params = std::collections::HashMap::new();
281    if let Some(param_value) = params.from_amount {
282        multipart_form_params.insert("fromAmount", param_value.to_string());
283    }
284    multipart_form_params.insert("fromAsset", params.from_asset.to_string());
285    if let Some(param_value) = params.recv_window {
286        multipart_form_params.insert("recvWindow", param_value.to_string());
287    }
288    multipart_form_params.insert("timestamp", params.timestamp.to_string());
289    if let Some(param_value) = params.to_amount {
290        multipart_form_params.insert("toAmount", param_value.to_string());
291    }
292    multipart_form_params.insert("toAsset", params.to_asset.to_string());
293    if let Some(param_value) = params.valid_time {
294        multipart_form_params.insert("validTime", param_value.to_string());
295    }
296    if let Some(param_value) = params.wallet_type {
297        multipart_form_params.insert("walletType", param_value.to_string());
298    }
299    req_builder = req_builder.form(&multipart_form_params);
300
301    let req = req_builder.build()?;
302    let resp = configuration.client.execute(req).await?;
303
304    let status = resp.status();
305    let content_type = resp
306        .headers()
307        .get("content-type")
308        .and_then(|v| v.to_str().ok())
309        .unwrap_or("application/octet-stream");
310    let content_type = super::ContentType::from(content_type);
311
312    if !status.is_client_error() && !status.is_server_error() {
313        let content = resp.text().await?;
314        match content_type {
315            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
316            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConvertCreateConvertGetQuoteV1Resp`"))),
317            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::ConvertCreateConvertGetQuoteV1Resp`")))),
318        }
319    } else {
320        let content = resp.text().await?;
321        let entity: Option<ConvertCreateConvertGetQuoteV1Error> = serde_json::from_str(&content).ok();
322        Err(Error::ResponseError(ResponseContent { status, content, entity }))
323    }
324}
325
326/// Enable users to cancel a limit order
327pub async fn convert_create_convert_limit_cancel_order_v1(configuration: &configuration::Configuration, params: ConvertCreateConvertLimitCancelOrderV1Params) -> Result<models::ConvertCreateConvertLimitCancelOrderV1Resp, Error<ConvertCreateConvertLimitCancelOrderV1Error>> {
328
329    let uri_str = format!("{}/sapi/v1/convert/limit/cancelOrder", configuration.base_path);
330    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
331
332    // Create a mutable vector for query parameters
333    let mut query_params: Vec<(String, String)> = Vec::new();
334
335
336    // Create header parameters collection
337    let mut header_params = std::collections::HashMap::new();
338
339    // Handle Binance Auth first if configured
340    if let Some(ref binance_auth) = configuration.binance_auth {
341        // Add API key to headers
342        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
343        
344        // Generate request body for signing (if any)
345        let body_string: Option<Vec<u8>> = None;
346        
347        // Sign the request
348        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
349            Ok(sig) => sig,
350            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
351        };
352        
353        // Add signature to query params
354        query_params.push(("signature".to_string(), signature));
355    }
356
357    // Apply all query parameters
358    if !query_params.is_empty() {
359        req_builder = req_builder.query(&query_params);
360    }
361
362
363    // Add user agent if configured
364    if let Some(ref user_agent) = configuration.user_agent {
365        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
366    }
367
368    // Apply all header parameters
369    for (header_name, header_value) in header_params {
370        req_builder = req_builder.header(&header_name, &header_value);
371    }
372
373    let mut multipart_form_params = std::collections::HashMap::new();
374    multipart_form_params.insert("orderId", params.order_id.to_string());
375    if let Some(param_value) = params.recv_window {
376        multipart_form_params.insert("recvWindow", param_value.to_string());
377    }
378    multipart_form_params.insert("timestamp", params.timestamp.to_string());
379    req_builder = req_builder.form(&multipart_form_params);
380
381    let req = req_builder.build()?;
382    let resp = configuration.client.execute(req).await?;
383
384    let status = resp.status();
385    let content_type = resp
386        .headers()
387        .get("content-type")
388        .and_then(|v| v.to_str().ok())
389        .unwrap_or("application/octet-stream");
390    let content_type = super::ContentType::from(content_type);
391
392    if !status.is_client_error() && !status.is_server_error() {
393        let content = resp.text().await?;
394        match content_type {
395            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
396            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConvertCreateConvertLimitCancelOrderV1Resp`"))),
397            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::ConvertCreateConvertLimitCancelOrderV1Resp`")))),
398        }
399    } else {
400        let content = resp.text().await?;
401        let entity: Option<ConvertCreateConvertLimitCancelOrderV1Error> = serde_json::from_str(&content).ok();
402        Err(Error::ResponseError(ResponseContent { status, content, entity }))
403    }
404}
405
406/// Enable users to place a limit order
407pub async fn convert_create_convert_limit_place_order_v1(configuration: &configuration::Configuration, params: ConvertCreateConvertLimitPlaceOrderV1Params) -> Result<models::ConvertCreateConvertLimitPlaceOrderV1Resp, Error<ConvertCreateConvertLimitPlaceOrderV1Error>> {
408
409    let uri_str = format!("{}/sapi/v1/convert/limit/placeOrder", configuration.base_path);
410    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
411
412    // Create a mutable vector for query parameters
413    let mut query_params: Vec<(String, String)> = Vec::new();
414
415
416    // Create header parameters collection
417    let mut header_params = std::collections::HashMap::new();
418
419    // Handle Binance Auth first if configured
420    if let Some(ref binance_auth) = configuration.binance_auth {
421        // Add API key to headers
422        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
423        
424        // Generate request body for signing (if any)
425        let body_string: Option<Vec<u8>> = None;
426        
427        // Sign the request
428        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
429            Ok(sig) => sig,
430            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
431        };
432        
433        // Add signature to query params
434        query_params.push(("signature".to_string(), signature));
435    }
436
437    // Apply all query parameters
438    if !query_params.is_empty() {
439        req_builder = req_builder.query(&query_params);
440    }
441
442
443    // Add user agent if configured
444    if let Some(ref user_agent) = configuration.user_agent {
445        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
446    }
447
448    // Apply all header parameters
449    for (header_name, header_value) in header_params {
450        req_builder = req_builder.header(&header_name, &header_value);
451    }
452
453    let mut multipart_form_params = std::collections::HashMap::new();
454    if let Some(param_value) = params.base_amount {
455        multipart_form_params.insert("baseAmount", param_value.to_string());
456    }
457    multipart_form_params.insert("baseAsset", params.base_asset.to_string());
458    multipart_form_params.insert("expiredType", params.expired_type.to_string());
459    multipart_form_params.insert("limitPrice", params.limit_price.to_string());
460    if let Some(param_value) = params.quote_amount {
461        multipart_form_params.insert("quoteAmount", param_value.to_string());
462    }
463    multipart_form_params.insert("quoteAsset", params.quote_asset.to_string());
464    if let Some(param_value) = params.recv_window {
465        multipart_form_params.insert("recvWindow", param_value.to_string());
466    }
467    multipart_form_params.insert("side", params.side.to_string());
468    multipart_form_params.insert("timestamp", params.timestamp.to_string());
469    if let Some(param_value) = params.wallet_type {
470        multipart_form_params.insert("walletType", param_value.to_string());
471    }
472    req_builder = req_builder.form(&multipart_form_params);
473
474    let req = req_builder.build()?;
475    let resp = configuration.client.execute(req).await?;
476
477    let status = resp.status();
478    let content_type = resp
479        .headers()
480        .get("content-type")
481        .and_then(|v| v.to_str().ok())
482        .unwrap_or("application/octet-stream");
483    let content_type = super::ContentType::from(content_type);
484
485    if !status.is_client_error() && !status.is_server_error() {
486        let content = resp.text().await?;
487        match content_type {
488            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
489            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConvertCreateConvertLimitPlaceOrderV1Resp`"))),
490            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::ConvertCreateConvertLimitPlaceOrderV1Resp`")))),
491        }
492    } else {
493        let content = resp.text().await?;
494        let entity: Option<ConvertCreateConvertLimitPlaceOrderV1Error> = serde_json::from_str(&content).ok();
495        Err(Error::ResponseError(ResponseContent { status, content, entity }))
496    }
497}
498
499/// Request a quote for the requested token pairs
500pub async fn convert_create_convert_limit_query_open_orders_v1(configuration: &configuration::Configuration, params: ConvertCreateConvertLimitQueryOpenOrdersV1Params) -> Result<models::ConvertCreateConvertLimitQueryOpenOrdersV1Resp, Error<ConvertCreateConvertLimitQueryOpenOrdersV1Error>> {
501
502    let uri_str = format!("{}/sapi/v1/convert/limit/queryOpenOrders", configuration.base_path);
503    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
504
505    // Create a mutable vector for query parameters
506    let mut query_params: Vec<(String, String)> = Vec::new();
507
508
509    // Create header parameters collection
510    let mut header_params = std::collections::HashMap::new();
511
512    // Handle Binance Auth first if configured
513    if let Some(ref binance_auth) = configuration.binance_auth {
514        // Add API key to headers
515        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
516        
517        // Generate request body for signing (if any)
518        let body_string: Option<Vec<u8>> = None;
519        
520        // Sign the request
521        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
522            Ok(sig) => sig,
523            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
524        };
525        
526        // Add signature to query params
527        query_params.push(("signature".to_string(), signature));
528    }
529
530    // Apply all query parameters
531    if !query_params.is_empty() {
532        req_builder = req_builder.query(&query_params);
533    }
534
535
536    // Add user agent if configured
537    if let Some(ref user_agent) = configuration.user_agent {
538        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
539    }
540
541    // Apply all header parameters
542    for (header_name, header_value) in header_params {
543        req_builder = req_builder.header(&header_name, &header_value);
544    }
545
546    let mut multipart_form_params = std::collections::HashMap::new();
547    if let Some(param_value) = params.recv_window {
548        multipart_form_params.insert("recvWindow", param_value.to_string());
549    }
550    multipart_form_params.insert("timestamp", params.timestamp.to_string());
551    req_builder = req_builder.form(&multipart_form_params);
552
553    let req = req_builder.build()?;
554    let resp = configuration.client.execute(req).await?;
555
556    let status = resp.status();
557    let content_type = resp
558        .headers()
559        .get("content-type")
560        .and_then(|v| v.to_str().ok())
561        .unwrap_or("application/octet-stream");
562    let content_type = super::ContentType::from(content_type);
563
564    if !status.is_client_error() && !status.is_server_error() {
565        let content = resp.text().await?;
566        match content_type {
567            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
568            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConvertCreateConvertLimitQueryOpenOrdersV1Resp`"))),
569            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::ConvertCreateConvertLimitQueryOpenOrdersV1Resp`")))),
570        }
571    } else {
572        let content = resp.text().await?;
573        let entity: Option<ConvertCreateConvertLimitQueryOpenOrdersV1Error> = serde_json::from_str(&content).ok();
574        Err(Error::ResponseError(ResponseContent { status, content, entity }))
575    }
576}
577
578/// Query order status by order ID.
579pub async fn convert_get_convert_order_status_v1(configuration: &configuration::Configuration, params: ConvertGetConvertOrderStatusV1Params) -> Result<models::ConvertGetConvertOrderStatusV1Resp, Error<ConvertGetConvertOrderStatusV1Error>> {
580
581    let uri_str = format!("{}/sapi/v1/convert/orderStatus", configuration.base_path);
582    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
583
584    // Create a mutable vector for query parameters
585    let mut query_params: Vec<(String, String)> = Vec::new();
586
587    if let Some(ref param_value) = params.order_id {
588        query_params.push(("orderId".to_string(), param_value.to_string()));
589    }
590    if let Some(ref param_value) = params.quote_id {
591        query_params.push(("quoteId".to_string(), param_value.to_string()));
592    }
593
594    // Create header parameters collection
595    let mut header_params = std::collections::HashMap::new();
596
597    // Handle Binance Auth first if configured
598    if let Some(ref binance_auth) = configuration.binance_auth {
599        // Add API key to headers
600        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
601        
602        // Generate request body for signing (if any)
603        let body_string: Option<Vec<u8>> = None;
604        
605        // Sign the request
606        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
607            Ok(sig) => sig,
608            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
609        };
610        
611        // Add signature to query params
612        query_params.push(("signature".to_string(), signature));
613    }
614
615    // Apply all query parameters
616    if !query_params.is_empty() {
617        req_builder = req_builder.query(&query_params);
618    }
619
620
621    // Add user agent if configured
622    if let Some(ref user_agent) = configuration.user_agent {
623        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
624    }
625
626    // Apply all header parameters
627    for (header_name, header_value) in header_params {
628        req_builder = req_builder.header(&header_name, &header_value);
629    }
630
631
632    let req = req_builder.build()?;
633    let resp = configuration.client.execute(req).await?;
634
635    let status = resp.status();
636    let content_type = resp
637        .headers()
638        .get("content-type")
639        .and_then(|v| v.to_str().ok())
640        .unwrap_or("application/octet-stream");
641    let content_type = super::ContentType::from(content_type);
642
643    if !status.is_client_error() && !status.is_server_error() {
644        let content = resp.text().await?;
645        match content_type {
646            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
647            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConvertGetConvertOrderStatusV1Resp`"))),
648            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::ConvertGetConvertOrderStatusV1Resp`")))),
649        }
650    } else {
651        let content = resp.text().await?;
652        let entity: Option<ConvertGetConvertOrderStatusV1Error> = serde_json::from_str(&content).ok();
653        Err(Error::ResponseError(ResponseContent { status, content, entity }))
654    }
655}
656
657/// Get Convert Trade History
658pub async fn convert_get_convert_trade_flow_v1(configuration: &configuration::Configuration, params: ConvertGetConvertTradeFlowV1Params) -> Result<models::ConvertGetConvertTradeFlowV1Resp, Error<ConvertGetConvertTradeFlowV1Error>> {
659
660    let uri_str = format!("{}/sapi/v1/convert/tradeFlow", configuration.base_path);
661    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
662
663    // Create a mutable vector for query parameters
664    let mut query_params: Vec<(String, String)> = Vec::new();
665
666    query_params.push(("startTime".to_string(), params.start_time.to_string()));
667    query_params.push(("endTime".to_string(), params.end_time.to_string()));
668    if let Some(ref param_value) = params.limit {
669        query_params.push(("limit".to_string(), param_value.to_string()));
670    }
671    if let Some(ref param_value) = params.recv_window {
672        query_params.push(("recvWindow".to_string(), param_value.to_string()));
673    }
674    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
675
676    // Create header parameters collection
677    let mut header_params = std::collections::HashMap::new();
678
679    // Handle Binance Auth first if configured
680    if let Some(ref binance_auth) = configuration.binance_auth {
681        // Add API key to headers
682        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
683        
684        // Generate request body for signing (if any)
685        let body_string: Option<Vec<u8>> = None;
686        
687        // Sign the request
688        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
689            Ok(sig) => sig,
690            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
691        };
692        
693        // Add signature to query params
694        query_params.push(("signature".to_string(), signature));
695    }
696
697    // Apply all query parameters
698    if !query_params.is_empty() {
699        req_builder = req_builder.query(&query_params);
700    }
701
702
703    // Add user agent if configured
704    if let Some(ref user_agent) = configuration.user_agent {
705        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
706    }
707
708    // Apply all header parameters
709    for (header_name, header_value) in header_params {
710        req_builder = req_builder.header(&header_name, &header_value);
711    }
712
713
714    let req = req_builder.build()?;
715    let resp = configuration.client.execute(req).await?;
716
717    let status = resp.status();
718    let content_type = resp
719        .headers()
720        .get("content-type")
721        .and_then(|v| v.to_str().ok())
722        .unwrap_or("application/octet-stream");
723    let content_type = super::ContentType::from(content_type);
724
725    if !status.is_client_error() && !status.is_server_error() {
726        let content = resp.text().await?;
727        match content_type {
728            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
729            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConvertGetConvertTradeFlowV1Resp`"))),
730            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::ConvertGetConvertTradeFlowV1Resp`")))),
731        }
732    } else {
733        let content = resp.text().await?;
734        let entity: Option<ConvertGetConvertTradeFlowV1Error> = serde_json::from_str(&content).ok();
735        Err(Error::ResponseError(ResponseContent { status, content, entity }))
736    }
737}
738