1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::spot::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct CreateConvertAcceptQuoteV1Params {
20 pub quote_id: String,
21 pub timestamp: i64,
22 pub recv_window: Option<i64>
23}
24
25#[derive(Clone, Debug, Default)]
27pub struct CreateConvertGetQuoteV1Params {
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#[derive(Clone, Debug, Default)]
40pub struct CreateConvertLimitCancelOrderV1Params {
41 pub order_id: i64,
42 pub timestamp: i64,
43 pub recv_window: Option<i64>
44}
45
46#[derive(Clone, Debug, Default)]
48pub struct CreateConvertLimitPlaceOrderV1Params {
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#[derive(Clone, Debug, Default)]
63pub struct CreateConvertLimitQueryOpenOrdersV1Params {
64 pub timestamp: i64,
65 pub recv_window: Option<i64>
66}
67
68#[derive(Clone, Debug, Default)]
70pub struct GetConvertAssetInfoV1Params {
71 pub timestamp: i64,
72 pub recv_window: Option<i64>
74}
75
76#[derive(Clone, Debug, Default)]
78pub struct GetConvertExchangeInfoV1Params {
79 pub from_asset: Option<String>,
81 pub to_asset: Option<String>
83}
84
85#[derive(Clone, Debug, Default)]
87pub struct GetConvertOrderStatusV1Params {
88 pub order_id: Option<String>,
90 pub quote_id: Option<String>
92}
93
94#[derive(Clone, Debug, Default)]
96pub struct GetConvertTradeFlowV1Params {
97 pub start_time: i64,
98 pub end_time: i64,
99 pub timestamp: i64,
100 pub limit: Option<i32>,
102 pub recv_window: Option<i64>
103}
104
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum CreateConvertAcceptQuoteV1Error {
110 Status4XX(models::ApiError),
111 Status5XX(models::ApiError),
112 UnknownValue(serde_json::Value),
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum CreateConvertGetQuoteV1Error {
119 Status4XX(models::ApiError),
120 Status5XX(models::ApiError),
121 UnknownValue(serde_json::Value),
122}
123
124#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum CreateConvertLimitCancelOrderV1Error {
128 Status4XX(models::ApiError),
129 Status5XX(models::ApiError),
130 UnknownValue(serde_json::Value),
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum CreateConvertLimitPlaceOrderV1Error {
137 Status4XX(models::ApiError),
138 Status5XX(models::ApiError),
139 UnknownValue(serde_json::Value),
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(untagged)]
145pub enum CreateConvertLimitQueryOpenOrdersV1Error {
146 Status4XX(models::ApiError),
147 Status5XX(models::ApiError),
148 UnknownValue(serde_json::Value),
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum GetConvertAssetInfoV1Error {
155 Status4XX(models::ApiError),
156 Status5XX(models::ApiError),
157 UnknownValue(serde_json::Value),
158}
159
160#[derive(Debug, Clone, Serialize, Deserialize)]
162#[serde(untagged)]
163pub enum GetConvertExchangeInfoV1Error {
164 Status4XX(models::ApiError),
165 Status5XX(models::ApiError),
166 UnknownValue(serde_json::Value),
167}
168
169#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(untagged)]
172pub enum GetConvertOrderStatusV1Error {
173 Status4XX(models::ApiError),
174 Status5XX(models::ApiError),
175 UnknownValue(serde_json::Value),
176}
177
178#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum GetConvertTradeFlowV1Error {
182 Status4XX(models::ApiError),
183 Status5XX(models::ApiError),
184 UnknownValue(serde_json::Value),
185}
186
187
188pub async fn create_convert_accept_quote_v1(configuration: &configuration::Configuration, params: CreateConvertAcceptQuoteV1Params) -> Result<models::CreateConvertAcceptQuoteV1Resp, Error<CreateConvertAcceptQuoteV1Error>> {
190
191 let uri_str = format!("{}/sapi/v1/convert/acceptQuote", configuration.base_path);
192 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
193
194 let mut query_params: Vec<(String, String)> = Vec::new();
196
197
198 let mut header_params = std::collections::HashMap::new();
200
201 if let Some(ref binance_auth) = configuration.binance_auth {
203 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
205
206 let body_string: Option<Vec<u8>> = None;
208
209 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
211 Ok(sig) => sig,
212 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
213 };
214
215 query_params.push(("signature".to_string(), signature));
217 }
218
219 if !query_params.is_empty() {
221 req_builder = req_builder.query(&query_params);
222 }
223
224
225 if let Some(ref user_agent) = configuration.user_agent {
227 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
228 }
229
230 for (header_name, header_value) in header_params {
232 req_builder = req_builder.header(&header_name, &header_value);
233 }
234
235 let mut multipart_form_params = std::collections::HashMap::new();
236 multipart_form_params.insert("quoteId", params.quote_id.to_string());
237 if let Some(param_value) = params.recv_window {
238 multipart_form_params.insert("recvWindow", param_value.to_string());
239 }
240 multipart_form_params.insert("timestamp", params.timestamp.to_string());
241 req_builder = req_builder.form(&multipart_form_params);
242
243 let req = req_builder.build()?;
244 let resp = configuration.client.execute(req).await?;
245
246 let status = resp.status();
247 let content_type = resp
248 .headers()
249 .get("content-type")
250 .and_then(|v| v.to_str().ok())
251 .unwrap_or("application/octet-stream");
252 let content_type = super::ContentType::from(content_type);
253
254 if !status.is_client_error() && !status.is_server_error() {
255 let content = resp.text().await?;
256 match content_type {
257 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
258 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateConvertAcceptQuoteV1Resp`"))),
259 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::CreateConvertAcceptQuoteV1Resp`")))),
260 }
261 } else {
262 let content = resp.text().await?;
263 let entity: Option<CreateConvertAcceptQuoteV1Error> = serde_json::from_str(&content).ok();
264 Err(Error::ResponseError(ResponseContent { status, content, entity }))
265 }
266}
267
268pub async fn create_convert_get_quote_v1(configuration: &configuration::Configuration, params: CreateConvertGetQuoteV1Params) -> Result<models::CreateConvertGetQuoteV1Resp, Error<CreateConvertGetQuoteV1Error>> {
270
271 let uri_str = format!("{}/sapi/v1/convert/getQuote", configuration.base_path);
272 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
273
274 let mut query_params: Vec<(String, String)> = Vec::new();
276
277
278 let mut header_params = std::collections::HashMap::new();
280
281 if let Some(ref binance_auth) = configuration.binance_auth {
283 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
285
286 let body_string: Option<Vec<u8>> = None;
288
289 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
291 Ok(sig) => sig,
292 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
293 };
294
295 query_params.push(("signature".to_string(), signature));
297 }
298
299 if !query_params.is_empty() {
301 req_builder = req_builder.query(&query_params);
302 }
303
304
305 if let Some(ref user_agent) = configuration.user_agent {
307 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
308 }
309
310 for (header_name, header_value) in header_params {
312 req_builder = req_builder.header(&header_name, &header_value);
313 }
314
315 let mut multipart_form_params = std::collections::HashMap::new();
316 if let Some(param_value) = params.from_amount {
317 multipart_form_params.insert("fromAmount", param_value.to_string());
318 }
319 multipart_form_params.insert("fromAsset", params.from_asset.to_string());
320 if let Some(param_value) = params.recv_window {
321 multipart_form_params.insert("recvWindow", param_value.to_string());
322 }
323 multipart_form_params.insert("timestamp", params.timestamp.to_string());
324 if let Some(param_value) = params.to_amount {
325 multipart_form_params.insert("toAmount", param_value.to_string());
326 }
327 multipart_form_params.insert("toAsset", params.to_asset.to_string());
328 if let Some(param_value) = params.valid_time {
329 multipart_form_params.insert("validTime", param_value.to_string());
330 }
331 if let Some(param_value) = params.wallet_type {
332 multipart_form_params.insert("walletType", param_value.to_string());
333 }
334 req_builder = req_builder.form(&multipart_form_params);
335
336 let req = req_builder.build()?;
337 let resp = configuration.client.execute(req).await?;
338
339 let status = resp.status();
340 let content_type = resp
341 .headers()
342 .get("content-type")
343 .and_then(|v| v.to_str().ok())
344 .unwrap_or("application/octet-stream");
345 let content_type = super::ContentType::from(content_type);
346
347 if !status.is_client_error() && !status.is_server_error() {
348 let content = resp.text().await?;
349 match content_type {
350 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
351 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateConvertGetQuoteV1Resp`"))),
352 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::CreateConvertGetQuoteV1Resp`")))),
353 }
354 } else {
355 let content = resp.text().await?;
356 let entity: Option<CreateConvertGetQuoteV1Error> = serde_json::from_str(&content).ok();
357 Err(Error::ResponseError(ResponseContent { status, content, entity }))
358 }
359}
360
361pub async fn create_convert_limit_cancel_order_v1(configuration: &configuration::Configuration, params: CreateConvertLimitCancelOrderV1Params) -> Result<models::CreateConvertLimitCancelOrderV1Resp, Error<CreateConvertLimitCancelOrderV1Error>> {
363
364 let uri_str = format!("{}/sapi/v1/convert/limit/cancelOrder", configuration.base_path);
365 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
366
367 let mut query_params: Vec<(String, String)> = Vec::new();
369
370
371 let mut header_params = std::collections::HashMap::new();
373
374 if let Some(ref binance_auth) = configuration.binance_auth {
376 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
378
379 let body_string: Option<Vec<u8>> = None;
381
382 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
384 Ok(sig) => sig,
385 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
386 };
387
388 query_params.push(("signature".to_string(), signature));
390 }
391
392 if !query_params.is_empty() {
394 req_builder = req_builder.query(&query_params);
395 }
396
397
398 if let Some(ref user_agent) = configuration.user_agent {
400 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
401 }
402
403 for (header_name, header_value) in header_params {
405 req_builder = req_builder.header(&header_name, &header_value);
406 }
407
408 let mut multipart_form_params = std::collections::HashMap::new();
409 multipart_form_params.insert("orderId", params.order_id.to_string());
410 if let Some(param_value) = params.recv_window {
411 multipart_form_params.insert("recvWindow", param_value.to_string());
412 }
413 multipart_form_params.insert("timestamp", params.timestamp.to_string());
414 req_builder = req_builder.form(&multipart_form_params);
415
416 let req = req_builder.build()?;
417 let resp = configuration.client.execute(req).await?;
418
419 let status = resp.status();
420 let content_type = resp
421 .headers()
422 .get("content-type")
423 .and_then(|v| v.to_str().ok())
424 .unwrap_or("application/octet-stream");
425 let content_type = super::ContentType::from(content_type);
426
427 if !status.is_client_error() && !status.is_server_error() {
428 let content = resp.text().await?;
429 match content_type {
430 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
431 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateConvertLimitCancelOrderV1Resp`"))),
432 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::CreateConvertLimitCancelOrderV1Resp`")))),
433 }
434 } else {
435 let content = resp.text().await?;
436 let entity: Option<CreateConvertLimitCancelOrderV1Error> = serde_json::from_str(&content).ok();
437 Err(Error::ResponseError(ResponseContent { status, content, entity }))
438 }
439}
440
441pub async fn create_convert_limit_place_order_v1(configuration: &configuration::Configuration, params: CreateConvertLimitPlaceOrderV1Params) -> Result<models::CreateConvertLimitPlaceOrderV1Resp, Error<CreateConvertLimitPlaceOrderV1Error>> {
443
444 let uri_str = format!("{}/sapi/v1/convert/limit/placeOrder", configuration.base_path);
445 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
446
447 let mut query_params: Vec<(String, String)> = Vec::new();
449
450
451 let mut header_params = std::collections::HashMap::new();
453
454 if let Some(ref binance_auth) = configuration.binance_auth {
456 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
458
459 let body_string: Option<Vec<u8>> = None;
461
462 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
464 Ok(sig) => sig,
465 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
466 };
467
468 query_params.push(("signature".to_string(), signature));
470 }
471
472 if !query_params.is_empty() {
474 req_builder = req_builder.query(&query_params);
475 }
476
477
478 if let Some(ref user_agent) = configuration.user_agent {
480 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
481 }
482
483 for (header_name, header_value) in header_params {
485 req_builder = req_builder.header(&header_name, &header_value);
486 }
487
488 let mut multipart_form_params = std::collections::HashMap::new();
489 if let Some(param_value) = params.base_amount {
490 multipart_form_params.insert("baseAmount", param_value.to_string());
491 }
492 multipart_form_params.insert("baseAsset", params.base_asset.to_string());
493 multipart_form_params.insert("expiredType", params.expired_type.to_string());
494 multipart_form_params.insert("limitPrice", params.limit_price.to_string());
495 if let Some(param_value) = params.quote_amount {
496 multipart_form_params.insert("quoteAmount", param_value.to_string());
497 }
498 multipart_form_params.insert("quoteAsset", params.quote_asset.to_string());
499 if let Some(param_value) = params.recv_window {
500 multipart_form_params.insert("recvWindow", param_value.to_string());
501 }
502 multipart_form_params.insert("side", params.side.to_string());
503 multipart_form_params.insert("timestamp", params.timestamp.to_string());
504 if let Some(param_value) = params.wallet_type {
505 multipart_form_params.insert("walletType", param_value.to_string());
506 }
507 req_builder = req_builder.form(&multipart_form_params);
508
509 let req = req_builder.build()?;
510 let resp = configuration.client.execute(req).await?;
511
512 let status = resp.status();
513 let content_type = resp
514 .headers()
515 .get("content-type")
516 .and_then(|v| v.to_str().ok())
517 .unwrap_or("application/octet-stream");
518 let content_type = super::ContentType::from(content_type);
519
520 if !status.is_client_error() && !status.is_server_error() {
521 let content = resp.text().await?;
522 match content_type {
523 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
524 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateConvertLimitPlaceOrderV1Resp`"))),
525 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::CreateConvertLimitPlaceOrderV1Resp`")))),
526 }
527 } else {
528 let content = resp.text().await?;
529 let entity: Option<CreateConvertLimitPlaceOrderV1Error> = serde_json::from_str(&content).ok();
530 Err(Error::ResponseError(ResponseContent { status, content, entity }))
531 }
532}
533
534pub async fn create_convert_limit_query_open_orders_v1(configuration: &configuration::Configuration, params: CreateConvertLimitQueryOpenOrdersV1Params) -> Result<models::CreateConvertLimitQueryOpenOrdersV1Resp, Error<CreateConvertLimitQueryOpenOrdersV1Error>> {
536
537 let uri_str = format!("{}/sapi/v1/convert/limit/queryOpenOrders", configuration.base_path);
538 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
539
540 let mut query_params: Vec<(String, String)> = Vec::new();
542
543
544 let mut header_params = std::collections::HashMap::new();
546
547 if let Some(ref binance_auth) = configuration.binance_auth {
549 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
551
552 let body_string: Option<Vec<u8>> = None;
554
555 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
557 Ok(sig) => sig,
558 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
559 };
560
561 query_params.push(("signature".to_string(), signature));
563 }
564
565 if !query_params.is_empty() {
567 req_builder = req_builder.query(&query_params);
568 }
569
570
571 if let Some(ref user_agent) = configuration.user_agent {
573 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
574 }
575
576 for (header_name, header_value) in header_params {
578 req_builder = req_builder.header(&header_name, &header_value);
579 }
580
581 let mut multipart_form_params = std::collections::HashMap::new();
582 if let Some(param_value) = params.recv_window {
583 multipart_form_params.insert("recvWindow", param_value.to_string());
584 }
585 multipart_form_params.insert("timestamp", params.timestamp.to_string());
586 req_builder = req_builder.form(&multipart_form_params);
587
588 let req = req_builder.build()?;
589 let resp = configuration.client.execute(req).await?;
590
591 let status = resp.status();
592 let content_type = resp
593 .headers()
594 .get("content-type")
595 .and_then(|v| v.to_str().ok())
596 .unwrap_or("application/octet-stream");
597 let content_type = super::ContentType::from(content_type);
598
599 if !status.is_client_error() && !status.is_server_error() {
600 let content = resp.text().await?;
601 match content_type {
602 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
603 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateConvertLimitQueryOpenOrdersV1Resp`"))),
604 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::CreateConvertLimitQueryOpenOrdersV1Resp`")))),
605 }
606 } else {
607 let content = resp.text().await?;
608 let entity: Option<CreateConvertLimitQueryOpenOrdersV1Error> = serde_json::from_str(&content).ok();
609 Err(Error::ResponseError(ResponseContent { status, content, entity }))
610 }
611}
612
613pub async fn get_convert_asset_info_v1(configuration: &configuration::Configuration, params: GetConvertAssetInfoV1Params) -> Result<Vec<models::GetConvertAssetInfoV1RespItem>, Error<GetConvertAssetInfoV1Error>> {
615
616 let uri_str = format!("{}/sapi/v1/convert/assetInfo", configuration.base_path);
617 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
618
619 let mut query_params: Vec<(String, String)> = Vec::new();
621
622 if let Some(ref param_value) = params.recv_window {
623 query_params.push(("recvWindow".to_string(), param_value.to_string()));
624 }
625 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
626
627 let mut header_params = std::collections::HashMap::new();
629
630 if let Some(ref binance_auth) = configuration.binance_auth {
632 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
634
635 let body_string: Option<Vec<u8>> = None;
637
638 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
640 Ok(sig) => sig,
641 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
642 };
643
644 query_params.push(("signature".to_string(), signature));
646 }
647
648 if !query_params.is_empty() {
650 req_builder = req_builder.query(&query_params);
651 }
652
653
654 if let Some(ref user_agent) = configuration.user_agent {
656 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
657 }
658
659 for (header_name, header_value) in header_params {
661 req_builder = req_builder.header(&header_name, &header_value);
662 }
663
664
665 let req = req_builder.build()?;
666 let resp = configuration.client.execute(req).await?;
667
668 let status = resp.status();
669 let content_type = resp
670 .headers()
671 .get("content-type")
672 .and_then(|v| v.to_str().ok())
673 .unwrap_or("application/octet-stream");
674 let content_type = super::ContentType::from(content_type);
675
676 if !status.is_client_error() && !status.is_server_error() {
677 let content = resp.text().await?;
678 match content_type {
679 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
680 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetConvertAssetInfoV1RespItem>`"))),
681 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<models::GetConvertAssetInfoV1RespItem>`")))),
682 }
683 } else {
684 let content = resp.text().await?;
685 let entity: Option<GetConvertAssetInfoV1Error> = serde_json::from_str(&content).ok();
686 Err(Error::ResponseError(ResponseContent { status, content, entity }))
687 }
688}
689
690pub async fn get_convert_exchange_info_v1(configuration: &configuration::Configuration, params: GetConvertExchangeInfoV1Params) -> Result<Vec<models::GetConvertExchangeInfoV1RespItem>, Error<GetConvertExchangeInfoV1Error>> {
692
693 let uri_str = format!("{}/sapi/v1/convert/exchangeInfo", configuration.base_path);
694 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
695
696 let mut query_params: Vec<(String, String)> = Vec::new();
698
699 if let Some(ref param_value) = params.from_asset {
700 query_params.push(("fromAsset".to_string(), param_value.to_string()));
701 }
702 if let Some(ref param_value) = params.to_asset {
703 query_params.push(("toAsset".to_string(), param_value.to_string()));
704 }
705
706 let mut header_params = std::collections::HashMap::new();
708
709 if let Some(ref binance_auth) = configuration.binance_auth {
711 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
713
714 let body_string: Option<Vec<u8>> = None;
716
717 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
719 Ok(sig) => sig,
720 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
721 };
722
723 query_params.push(("signature".to_string(), signature));
725 }
726
727 if !query_params.is_empty() {
729 req_builder = req_builder.query(&query_params);
730 }
731
732
733 if let Some(ref user_agent) = configuration.user_agent {
735 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
736 }
737
738 for (header_name, header_value) in header_params {
740 req_builder = req_builder.header(&header_name, &header_value);
741 }
742
743
744 let req = req_builder.build()?;
745 let resp = configuration.client.execute(req).await?;
746
747 let status = resp.status();
748 let content_type = resp
749 .headers()
750 .get("content-type")
751 .and_then(|v| v.to_str().ok())
752 .unwrap_or("application/octet-stream");
753 let content_type = super::ContentType::from(content_type);
754
755 if !status.is_client_error() && !status.is_server_error() {
756 let content = resp.text().await?;
757 match content_type {
758 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
759 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetConvertExchangeInfoV1RespItem>`"))),
760 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<models::GetConvertExchangeInfoV1RespItem>`")))),
761 }
762 } else {
763 let content = resp.text().await?;
764 let entity: Option<GetConvertExchangeInfoV1Error> = serde_json::from_str(&content).ok();
765 Err(Error::ResponseError(ResponseContent { status, content, entity }))
766 }
767}
768
769pub async fn get_convert_order_status_v1(configuration: &configuration::Configuration, params: GetConvertOrderStatusV1Params) -> Result<models::GetConvertOrderStatusV1Resp, Error<GetConvertOrderStatusV1Error>> {
771
772 let uri_str = format!("{}/sapi/v1/convert/orderStatus", configuration.base_path);
773 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
774
775 let mut query_params: Vec<(String, String)> = Vec::new();
777
778 if let Some(ref param_value) = params.order_id {
779 query_params.push(("orderId".to_string(), param_value.to_string()));
780 }
781 if let Some(ref param_value) = params.quote_id {
782 query_params.push(("quoteId".to_string(), param_value.to_string()));
783 }
784
785 let mut header_params = std::collections::HashMap::new();
787
788 if let Some(ref binance_auth) = configuration.binance_auth {
790 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
792
793 let body_string: Option<Vec<u8>> = None;
795
796 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
798 Ok(sig) => sig,
799 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
800 };
801
802 query_params.push(("signature".to_string(), signature));
804 }
805
806 if !query_params.is_empty() {
808 req_builder = req_builder.query(&query_params);
809 }
810
811
812 if let Some(ref user_agent) = configuration.user_agent {
814 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
815 }
816
817 for (header_name, header_value) in header_params {
819 req_builder = req_builder.header(&header_name, &header_value);
820 }
821
822
823 let req = req_builder.build()?;
824 let resp = configuration.client.execute(req).await?;
825
826 let status = resp.status();
827 let content_type = resp
828 .headers()
829 .get("content-type")
830 .and_then(|v| v.to_str().ok())
831 .unwrap_or("application/octet-stream");
832 let content_type = super::ContentType::from(content_type);
833
834 if !status.is_client_error() && !status.is_server_error() {
835 let content = resp.text().await?;
836 match content_type {
837 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
838 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetConvertOrderStatusV1Resp`"))),
839 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::GetConvertOrderStatusV1Resp`")))),
840 }
841 } else {
842 let content = resp.text().await?;
843 let entity: Option<GetConvertOrderStatusV1Error> = serde_json::from_str(&content).ok();
844 Err(Error::ResponseError(ResponseContent { status, content, entity }))
845 }
846}
847
848pub async fn get_convert_trade_flow_v1(configuration: &configuration::Configuration, params: GetConvertTradeFlowV1Params) -> Result<models::GetConvertTradeFlowV1Resp, Error<GetConvertTradeFlowV1Error>> {
850
851 let uri_str = format!("{}/sapi/v1/convert/tradeFlow", configuration.base_path);
852 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
853
854 let mut query_params: Vec<(String, String)> = Vec::new();
856
857 query_params.push(("startTime".to_string(), params.start_time.to_string()));
858 query_params.push(("endTime".to_string(), params.end_time.to_string()));
859 if let Some(ref param_value) = params.limit {
860 query_params.push(("limit".to_string(), param_value.to_string()));
861 }
862 if let Some(ref param_value) = params.recv_window {
863 query_params.push(("recvWindow".to_string(), param_value.to_string()));
864 }
865 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
866
867 let mut header_params = std::collections::HashMap::new();
869
870 if let Some(ref binance_auth) = configuration.binance_auth {
872 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
874
875 let body_string: Option<Vec<u8>> = None;
877
878 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
880 Ok(sig) => sig,
881 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
882 };
883
884 query_params.push(("signature".to_string(), signature));
886 }
887
888 if !query_params.is_empty() {
890 req_builder = req_builder.query(&query_params);
891 }
892
893
894 if let Some(ref user_agent) = configuration.user_agent {
896 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
897 }
898
899 for (header_name, header_value) in header_params {
901 req_builder = req_builder.header(&header_name, &header_value);
902 }
903
904
905 let req = req_builder.build()?;
906 let resp = configuration.client.execute(req).await?;
907
908 let status = resp.status();
909 let content_type = resp
910 .headers()
911 .get("content-type")
912 .and_then(|v| v.to_str().ok())
913 .unwrap_or("application/octet-stream");
914 let content_type = super::ContentType::from(content_type);
915
916 if !status.is_client_error() && !status.is_server_error() {
917 let content = resp.text().await?;
918 match content_type {
919 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
920 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetConvertTradeFlowV1Resp`"))),
921 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::GetConvertTradeFlowV1Resp`")))),
922 }
923 } else {
924 let content = resp.text().await?;
925 let entity: Option<GetConvertTradeFlowV1Error> = serde_json::from_str(&content).ok();
926 Err(Error::ResponseError(ResponseContent { status, content, entity }))
927 }
928}
929