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 SpotGetAggTradesV3Params {
20 pub symbol: String,
21 pub from_id: Option<i64>,
23 pub start_time: Option<i64>,
25 pub end_time: Option<i64>,
27 pub limit: Option<i32>
29}
30
31#[derive(Clone, Debug, Default)]
33pub struct SpotGetAvgPriceV3Params {
34 pub symbol: String
35}
36
37#[derive(Clone, Debug, Default)]
39pub struct SpotGetDepthV3Params {
40 pub symbol: String,
41 pub limit: Option<i32>
43}
44
45#[derive(Clone, Debug, Default)]
47pub struct SpotGetHistoricalTradesV3Params {
48 pub symbol: String,
49 pub limit: Option<i32>,
51 pub from_id: Option<i64>
53}
54
55#[derive(Clone, Debug, Default)]
57pub struct SpotGetKlinesV3Params {
58 pub symbol: String,
59 pub interval: String,
60 pub start_time: Option<i64>,
61 pub end_time: Option<i64>,
62 pub time_zone: Option<String>,
64 pub limit: Option<i32>
66}
67
68#[derive(Clone, Debug, Default)]
70pub struct SpotGetTicker24hrV3Params {
71 pub symbol: Option<String>,
73 pub symbols: Option<String>,
75 pub r#type: Option<String>
77}
78
79#[derive(Clone, Debug, Default)]
81pub struct SpotGetTickerBookTickerV3Params {
82 pub symbol: Option<String>,
84 pub symbols: Option<String>
86}
87
88#[derive(Clone, Debug, Default)]
90pub struct SpotGetTickerPriceV3Params {
91 pub symbol: Option<String>,
93 pub symbols: Option<String>
95}
96
97#[derive(Clone, Debug, Default)]
99pub struct SpotGetTickerTradingDayV3Params {
100 pub symbol: String,
102 pub symbols: String,
104 pub time_zone: Option<String>,
106 pub r#type: Option<String>
108}
109
110#[derive(Clone, Debug, Default)]
112pub struct SpotGetTickerV3Params {
113 pub symbol: String,
115 pub symbols: String,
117 pub window_size: Option<String>,
119 pub r#type: Option<String>
121}
122
123#[derive(Clone, Debug, Default)]
125pub struct SpotGetTradesV3Params {
126 pub symbol: String,
127 pub limit: Option<i32>
129}
130
131#[derive(Clone, Debug, Default)]
133pub struct SpotGetUiKlinesV3Params {
134 pub symbol: String,
135 pub interval: String,
137 pub start_time: Option<i64>,
138 pub end_time: Option<i64>,
139 pub time_zone: Option<String>,
141 pub limit: Option<i32>
143}
144
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum SpotGetAggTradesV3Error {
150 Status4XX(models::ApiError),
151 Status5XX(models::ApiError),
152 UnknownValue(serde_json::Value),
153}
154
155#[derive(Debug, Clone, Serialize, Deserialize)]
157#[serde(untagged)]
158pub enum SpotGetAvgPriceV3Error {
159 Status4XX(models::ApiError),
160 Status5XX(models::ApiError),
161 UnknownValue(serde_json::Value),
162}
163
164#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum SpotGetDepthV3Error {
168 Status4XX(models::ApiError),
169 Status5XX(models::ApiError),
170 UnknownValue(serde_json::Value),
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(untagged)]
176pub enum SpotGetHistoricalTradesV3Error {
177 Status4XX(models::ApiError),
178 Status5XX(models::ApiError),
179 UnknownValue(serde_json::Value),
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize)]
184#[serde(untagged)]
185pub enum SpotGetKlinesV3Error {
186 Status4XX(models::ApiError),
187 Status5XX(models::ApiError),
188 UnknownValue(serde_json::Value),
189}
190
191#[derive(Debug, Clone, Serialize, Deserialize)]
193#[serde(untagged)]
194pub enum SpotGetTicker24hrV3Error {
195 Status4XX(models::ApiError),
196 Status5XX(models::ApiError),
197 UnknownValue(serde_json::Value),
198}
199
200#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum SpotGetTickerBookTickerV3Error {
204 Status4XX(models::ApiError),
205 Status5XX(models::ApiError),
206 UnknownValue(serde_json::Value),
207}
208
209#[derive(Debug, Clone, Serialize, Deserialize)]
211#[serde(untagged)]
212pub enum SpotGetTickerPriceV3Error {
213 Status4XX(models::ApiError),
214 Status5XX(models::ApiError),
215 UnknownValue(serde_json::Value),
216}
217
218#[derive(Debug, Clone, Serialize, Deserialize)]
220#[serde(untagged)]
221pub enum SpotGetTickerTradingDayV3Error {
222 Status4XX(models::ApiError),
223 Status5XX(models::ApiError),
224 UnknownValue(serde_json::Value),
225}
226
227#[derive(Debug, Clone, Serialize, Deserialize)]
229#[serde(untagged)]
230pub enum SpotGetTickerV3Error {
231 Status4XX(models::ApiError),
232 Status5XX(models::ApiError),
233 UnknownValue(serde_json::Value),
234}
235
236#[derive(Debug, Clone, Serialize, Deserialize)]
238#[serde(untagged)]
239pub enum SpotGetTradesV3Error {
240 Status4XX(models::ApiError),
241 Status5XX(models::ApiError),
242 UnknownValue(serde_json::Value),
243}
244
245#[derive(Debug, Clone, Serialize, Deserialize)]
247#[serde(untagged)]
248pub enum SpotGetUiKlinesV3Error {
249 Status4XX(models::ApiError),
250 Status5XX(models::ApiError),
251 UnknownValue(serde_json::Value),
252}
253
254
255pub async fn spot_get_agg_trades_v3(configuration: &configuration::Configuration, params: SpotGetAggTradesV3Params) -> Result<Vec<models::SpotGetAggTradesV3RespItem>, Error<SpotGetAggTradesV3Error>> {
257
258 let uri_str = format!("{}/api/v3/aggTrades", configuration.base_path);
259 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
260
261 let mut query_params: Vec<(String, String)> = Vec::new();
263
264 query_params.push(("symbol".to_string(), params.symbol.to_string()));
265 if let Some(ref param_value) = params.from_id {
266 query_params.push(("fromId".to_string(), param_value.to_string()));
267 }
268 if let Some(ref param_value) = params.start_time {
269 query_params.push(("startTime".to_string(), param_value.to_string()));
270 }
271 if let Some(ref param_value) = params.end_time {
272 query_params.push(("endTime".to_string(), param_value.to_string()));
273 }
274 if let Some(ref param_value) = params.limit {
275 query_params.push(("limit".to_string(), param_value.to_string()));
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
316 let req = req_builder.build()?;
317 let resp = configuration.client.execute(req).await?;
318
319 let status = resp.status();
320 let content_type = resp
321 .headers()
322 .get("content-type")
323 .and_then(|v| v.to_str().ok())
324 .unwrap_or("application/octet-stream");
325 let content_type = super::ContentType::from(content_type);
326
327 if !status.is_client_error() && !status.is_server_error() {
328 let content = resp.text().await?;
329 match content_type {
330 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
331 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SpotGetAggTradesV3RespItem>`"))),
332 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::SpotGetAggTradesV3RespItem>`")))),
333 }
334 } else {
335 let content = resp.text().await?;
336 let entity: Option<SpotGetAggTradesV3Error> = serde_json::from_str(&content).ok();
337 Err(Error::ResponseError(ResponseContent { status, content, entity }))
338 }
339}
340
341pub async fn spot_get_avg_price_v3(configuration: &configuration::Configuration, params: SpotGetAvgPriceV3Params) -> Result<models::SpotGetAvgPriceV3Resp, Error<SpotGetAvgPriceV3Error>> {
343
344 let uri_str = format!("{}/api/v3/avgPrice", configuration.base_path);
345 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
346
347 let mut query_params: Vec<(String, String)> = Vec::new();
349
350 query_params.push(("symbol".to_string(), params.symbol.to_string()));
351
352 let mut header_params = std::collections::HashMap::new();
354
355 if let Some(ref binance_auth) = configuration.binance_auth {
357 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
359
360 let body_string: Option<Vec<u8>> = None;
362
363 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
365 Ok(sig) => sig,
366 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
367 };
368
369 query_params.push(("signature".to_string(), signature));
371 }
372
373 if !query_params.is_empty() {
375 req_builder = req_builder.query(&query_params);
376 }
377
378
379 if let Some(ref user_agent) = configuration.user_agent {
381 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
382 }
383
384 for (header_name, header_value) in header_params {
386 req_builder = req_builder.header(&header_name, &header_value);
387 }
388
389
390 let req = req_builder.build()?;
391 let resp = configuration.client.execute(req).await?;
392
393 let status = resp.status();
394 let content_type = resp
395 .headers()
396 .get("content-type")
397 .and_then(|v| v.to_str().ok())
398 .unwrap_or("application/octet-stream");
399 let content_type = super::ContentType::from(content_type);
400
401 if !status.is_client_error() && !status.is_server_error() {
402 let content = resp.text().await?;
403 match content_type {
404 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
405 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetAvgPriceV3Resp`"))),
406 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::SpotGetAvgPriceV3Resp`")))),
407 }
408 } else {
409 let content = resp.text().await?;
410 let entity: Option<SpotGetAvgPriceV3Error> = serde_json::from_str(&content).ok();
411 Err(Error::ResponseError(ResponseContent { status, content, entity }))
412 }
413}
414
415pub async fn spot_get_depth_v3(configuration: &configuration::Configuration, params: SpotGetDepthV3Params) -> Result<models::SpotGetDepthV3Resp, Error<SpotGetDepthV3Error>> {
416
417 let uri_str = format!("{}/api/v3/depth", configuration.base_path);
418 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
419
420 let mut query_params: Vec<(String, String)> = Vec::new();
422
423 query_params.push(("symbol".to_string(), params.symbol.to_string()));
424 if let Some(ref param_value) = params.limit {
425 query_params.push(("limit".to_string(), param_value.to_string()));
426 }
427
428 let mut header_params = std::collections::HashMap::new();
430
431 if let Some(ref binance_auth) = configuration.binance_auth {
433 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
435
436 let body_string: Option<Vec<u8>> = None;
438
439 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
441 Ok(sig) => sig,
442 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
443 };
444
445 query_params.push(("signature".to_string(), signature));
447 }
448
449 if !query_params.is_empty() {
451 req_builder = req_builder.query(&query_params);
452 }
453
454
455 if let Some(ref user_agent) = configuration.user_agent {
457 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
458 }
459
460 for (header_name, header_value) in header_params {
462 req_builder = req_builder.header(&header_name, &header_value);
463 }
464
465
466 let req = req_builder.build()?;
467 let resp = configuration.client.execute(req).await?;
468
469 let status = resp.status();
470 let content_type = resp
471 .headers()
472 .get("content-type")
473 .and_then(|v| v.to_str().ok())
474 .unwrap_or("application/octet-stream");
475 let content_type = super::ContentType::from(content_type);
476
477 if !status.is_client_error() && !status.is_server_error() {
478 let content = resp.text().await?;
479 match content_type {
480 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
481 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetDepthV3Resp`"))),
482 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::SpotGetDepthV3Resp`")))),
483 }
484 } else {
485 let content = resp.text().await?;
486 let entity: Option<SpotGetDepthV3Error> = serde_json::from_str(&content).ok();
487 Err(Error::ResponseError(ResponseContent { status, content, entity }))
488 }
489}
490
491pub async fn spot_get_historical_trades_v3(configuration: &configuration::Configuration, params: SpotGetHistoricalTradesV3Params) -> Result<Vec<models::SpotGetHistoricalTradesV3RespItem>, Error<SpotGetHistoricalTradesV3Error>> {
493
494 let uri_str = format!("{}/api/v3/historicalTrades", configuration.base_path);
495 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
496
497 let mut query_params: Vec<(String, String)> = Vec::new();
499
500 query_params.push(("symbol".to_string(), params.symbol.to_string()));
501 if let Some(ref param_value) = params.limit {
502 query_params.push(("limit".to_string(), param_value.to_string()));
503 }
504 if let Some(ref param_value) = params.from_id {
505 query_params.push(("fromId".to_string(), param_value.to_string()));
506 }
507
508 let mut header_params = std::collections::HashMap::new();
510
511 if let Some(ref binance_auth) = configuration.binance_auth {
513 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
515
516 let body_string: Option<Vec<u8>> = None;
518
519 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
521 Ok(sig) => sig,
522 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
523 };
524
525 query_params.push(("signature".to_string(), signature));
527 }
528
529 if !query_params.is_empty() {
531 req_builder = req_builder.query(&query_params);
532 }
533
534
535 if let Some(ref user_agent) = configuration.user_agent {
537 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
538 }
539
540 for (header_name, header_value) in header_params {
542 req_builder = req_builder.header(&header_name, &header_value);
543 }
544
545
546 let req = req_builder.build()?;
547 let resp = configuration.client.execute(req).await?;
548
549 let status = resp.status();
550 let content_type = resp
551 .headers()
552 .get("content-type")
553 .and_then(|v| v.to_str().ok())
554 .unwrap_or("application/octet-stream");
555 let content_type = super::ContentType::from(content_type);
556
557 if !status.is_client_error() && !status.is_server_error() {
558 let content = resp.text().await?;
559 match content_type {
560 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
561 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SpotGetHistoricalTradesV3RespItem>`"))),
562 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::SpotGetHistoricalTradesV3RespItem>`")))),
563 }
564 } else {
565 let content = resp.text().await?;
566 let entity: Option<SpotGetHistoricalTradesV3Error> = serde_json::from_str(&content).ok();
567 Err(Error::ResponseError(ResponseContent { status, content, entity }))
568 }
569}
570
571pub async fn spot_get_klines_v3(configuration: &configuration::Configuration, params: SpotGetKlinesV3Params) -> Result<Vec<Vec<models::SpotGetKlinesV3200ResponseInnerInner>>, Error<SpotGetKlinesV3Error>> {
573
574 let uri_str = format!("{}/api/v3/klines", configuration.base_path);
575 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
576
577 let mut query_params: Vec<(String, String)> = Vec::new();
579
580 query_params.push(("symbol".to_string(), params.symbol.to_string()));
581 query_params.push(("interval".to_string(), params.interval.to_string()));
582 if let Some(ref param_value) = params.start_time {
583 query_params.push(("startTime".to_string(), param_value.to_string()));
584 }
585 if let Some(ref param_value) = params.end_time {
586 query_params.push(("endTime".to_string(), param_value.to_string()));
587 }
588 if let Some(ref param_value) = params.time_zone {
589 query_params.push(("timeZone".to_string(), param_value.to_string()));
590 }
591 if let Some(ref param_value) = params.limit {
592 query_params.push(("limit".to_string(), param_value.to_string()));
593 }
594
595 let mut header_params = std::collections::HashMap::new();
597
598 if let Some(ref binance_auth) = configuration.binance_auth {
600 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
602
603 let body_string: Option<Vec<u8>> = None;
605
606 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
608 Ok(sig) => sig,
609 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
610 };
611
612 query_params.push(("signature".to_string(), signature));
614 }
615
616 if !query_params.is_empty() {
618 req_builder = req_builder.query(&query_params);
619 }
620
621
622 if let Some(ref user_agent) = configuration.user_agent {
624 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
625 }
626
627 for (header_name, header_value) in header_params {
629 req_builder = req_builder.header(&header_name, &header_value);
630 }
631
632
633 let req = req_builder.build()?;
634 let resp = configuration.client.execute(req).await?;
635
636 let status = resp.status();
637 let content_type = resp
638 .headers()
639 .get("content-type")
640 .and_then(|v| v.to_str().ok())
641 .unwrap_or("application/octet-stream");
642 let content_type = super::ContentType::from(content_type);
643
644 if !status.is_client_error() && !status.is_server_error() {
645 let content = resp.text().await?;
646 match content_type {
647 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
648 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::SpotGetKlinesV3200ResponseInnerInner>>`"))),
649 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<Vec<models::SpotGetKlinesV3200ResponseInnerInner>>`")))),
650 }
651 } else {
652 let content = resp.text().await?;
653 let entity: Option<SpotGetKlinesV3Error> = serde_json::from_str(&content).ok();
654 Err(Error::ResponseError(ResponseContent { status, content, entity }))
655 }
656}
657
658pub async fn spot_get_ticker24hr_v3(configuration: &configuration::Configuration, params: SpotGetTicker24hrV3Params) -> Result<models::SpotGetTicker24hrV3Resp, Error<SpotGetTicker24hrV3Error>> {
660
661 let uri_str = format!("{}/api/v3/ticker/24hr", configuration.base_path);
662 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
663
664 let mut query_params: Vec<(String, String)> = Vec::new();
666
667 if let Some(ref param_value) = params.symbol {
668 query_params.push(("symbol".to_string(), param_value.to_string()));
669 }
670 if let Some(ref param_value) = params.symbols {
671 query_params.push(("symbols".to_string(), param_value.to_string()));
672 }
673 if let Some(ref param_value) = params.r#type {
674 query_params.push(("type".to_string(), param_value.to_string()));
675 }
676
677 let mut header_params = std::collections::HashMap::new();
679
680 if let Some(ref binance_auth) = configuration.binance_auth {
682 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
684
685 let body_string: Option<Vec<u8>> = None;
687
688 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
690 Ok(sig) => sig,
691 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
692 };
693
694 query_params.push(("signature".to_string(), signature));
696 }
697
698 if !query_params.is_empty() {
700 req_builder = req_builder.query(&query_params);
701 }
702
703
704 if let Some(ref user_agent) = configuration.user_agent {
706 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
707 }
708
709 for (header_name, header_value) in header_params {
711 req_builder = req_builder.header(&header_name, &header_value);
712 }
713
714
715 let req = req_builder.build()?;
716 let resp = configuration.client.execute(req).await?;
717
718 let status = resp.status();
719 let content_type = resp
720 .headers()
721 .get("content-type")
722 .and_then(|v| v.to_str().ok())
723 .unwrap_or("application/octet-stream");
724 let content_type = super::ContentType::from(content_type);
725
726 if !status.is_client_error() && !status.is_server_error() {
727 let content = resp.text().await?;
728 match content_type {
729 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
730 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTicker24hrV3Resp`"))),
731 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::SpotGetTicker24hrV3Resp`")))),
732 }
733 } else {
734 let content = resp.text().await?;
735 let entity: Option<SpotGetTicker24hrV3Error> = serde_json::from_str(&content).ok();
736 Err(Error::ResponseError(ResponseContent { status, content, entity }))
737 }
738}
739
740pub async fn spot_get_ticker_book_ticker_v3(configuration: &configuration::Configuration, params: SpotGetTickerBookTickerV3Params) -> Result<models::SpotGetTickerBookTickerV3Resp, Error<SpotGetTickerBookTickerV3Error>> {
742
743 let uri_str = format!("{}/api/v3/ticker/bookTicker", configuration.base_path);
744 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
745
746 let mut query_params: Vec<(String, String)> = Vec::new();
748
749 if let Some(ref param_value) = params.symbol {
750 query_params.push(("symbol".to_string(), param_value.to_string()));
751 }
752 if let Some(ref param_value) = params.symbols {
753 query_params.push(("symbols".to_string(), param_value.to_string()));
754 }
755
756 let mut header_params = std::collections::HashMap::new();
758
759 if let Some(ref binance_auth) = configuration.binance_auth {
761 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
763
764 let body_string: Option<Vec<u8>> = None;
766
767 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
769 Ok(sig) => sig,
770 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
771 };
772
773 query_params.push(("signature".to_string(), signature));
775 }
776
777 if !query_params.is_empty() {
779 req_builder = req_builder.query(&query_params);
780 }
781
782
783 if let Some(ref user_agent) = configuration.user_agent {
785 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
786 }
787
788 for (header_name, header_value) in header_params {
790 req_builder = req_builder.header(&header_name, &header_value);
791 }
792
793
794 let req = req_builder.build()?;
795 let resp = configuration.client.execute(req).await?;
796
797 let status = resp.status();
798 let content_type = resp
799 .headers()
800 .get("content-type")
801 .and_then(|v| v.to_str().ok())
802 .unwrap_or("application/octet-stream");
803 let content_type = super::ContentType::from(content_type);
804
805 if !status.is_client_error() && !status.is_server_error() {
806 let content = resp.text().await?;
807 match content_type {
808 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
809 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerBookTickerV3Resp`"))),
810 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::SpotGetTickerBookTickerV3Resp`")))),
811 }
812 } else {
813 let content = resp.text().await?;
814 let entity: Option<SpotGetTickerBookTickerV3Error> = serde_json::from_str(&content).ok();
815 Err(Error::ResponseError(ResponseContent { status, content, entity }))
816 }
817}
818
819pub async fn spot_get_ticker_price_v3(configuration: &configuration::Configuration, params: SpotGetTickerPriceV3Params) -> Result<models::SpotGetTickerPriceV3Resp, Error<SpotGetTickerPriceV3Error>> {
821
822 let uri_str = format!("{}/api/v3/ticker/price", configuration.base_path);
823 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
824
825 let mut query_params: Vec<(String, String)> = Vec::new();
827
828 if let Some(ref param_value) = params.symbol {
829 query_params.push(("symbol".to_string(), param_value.to_string()));
830 }
831 if let Some(ref param_value) = params.symbols {
832 query_params.push(("symbols".to_string(), param_value.to_string()));
833 }
834
835 let mut header_params = std::collections::HashMap::new();
837
838 if let Some(ref binance_auth) = configuration.binance_auth {
840 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
842
843 let body_string: Option<Vec<u8>> = None;
845
846 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
848 Ok(sig) => sig,
849 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
850 };
851
852 query_params.push(("signature".to_string(), signature));
854 }
855
856 if !query_params.is_empty() {
858 req_builder = req_builder.query(&query_params);
859 }
860
861
862 if let Some(ref user_agent) = configuration.user_agent {
864 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
865 }
866
867 for (header_name, header_value) in header_params {
869 req_builder = req_builder.header(&header_name, &header_value);
870 }
871
872
873 let req = req_builder.build()?;
874 let resp = configuration.client.execute(req).await?;
875
876 let status = resp.status();
877 let content_type = resp
878 .headers()
879 .get("content-type")
880 .and_then(|v| v.to_str().ok())
881 .unwrap_or("application/octet-stream");
882 let content_type = super::ContentType::from(content_type);
883
884 if !status.is_client_error() && !status.is_server_error() {
885 let content = resp.text().await?;
886 match content_type {
887 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
888 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerPriceV3Resp`"))),
889 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::SpotGetTickerPriceV3Resp`")))),
890 }
891 } else {
892 let content = resp.text().await?;
893 let entity: Option<SpotGetTickerPriceV3Error> = serde_json::from_str(&content).ok();
894 Err(Error::ResponseError(ResponseContent { status, content, entity }))
895 }
896}
897
898pub async fn spot_get_ticker_trading_day_v3(configuration: &configuration::Configuration, params: SpotGetTickerTradingDayV3Params) -> Result<models::SpotGetTickerTradingDayV3Resp, Error<SpotGetTickerTradingDayV3Error>> {
900
901 let uri_str = format!("{}/api/v3/ticker/tradingDay", configuration.base_path);
902 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
903
904 let mut query_params: Vec<(String, String)> = Vec::new();
906
907 query_params.push(("symbol".to_string(), params.symbol.to_string()));
908 query_params.push(("symbols".to_string(), params.symbols.to_string()));
909 if let Some(ref param_value) = params.time_zone {
910 query_params.push(("timeZone".to_string(), param_value.to_string()));
911 }
912 if let Some(ref param_value) = params.r#type {
913 query_params.push(("type".to_string(), param_value.to_string()));
914 }
915
916 let mut header_params = std::collections::HashMap::new();
918
919 if let Some(ref binance_auth) = configuration.binance_auth {
921 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
923
924 let body_string: Option<Vec<u8>> = None;
926
927 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
929 Ok(sig) => sig,
930 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
931 };
932
933 query_params.push(("signature".to_string(), signature));
935 }
936
937 if !query_params.is_empty() {
939 req_builder = req_builder.query(&query_params);
940 }
941
942
943 if let Some(ref user_agent) = configuration.user_agent {
945 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
946 }
947
948 for (header_name, header_value) in header_params {
950 req_builder = req_builder.header(&header_name, &header_value);
951 }
952
953
954 let req = req_builder.build()?;
955 let resp = configuration.client.execute(req).await?;
956
957 let status = resp.status();
958 let content_type = resp
959 .headers()
960 .get("content-type")
961 .and_then(|v| v.to_str().ok())
962 .unwrap_or("application/octet-stream");
963 let content_type = super::ContentType::from(content_type);
964
965 if !status.is_client_error() && !status.is_server_error() {
966 let content = resp.text().await?;
967 match content_type {
968 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
969 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerTradingDayV3Resp`"))),
970 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::SpotGetTickerTradingDayV3Resp`")))),
971 }
972 } else {
973 let content = resp.text().await?;
974 let entity: Option<SpotGetTickerTradingDayV3Error> = serde_json::from_str(&content).ok();
975 Err(Error::ResponseError(ResponseContent { status, content, entity }))
976 }
977}
978
979pub async fn spot_get_ticker_v3(configuration: &configuration::Configuration, params: SpotGetTickerV3Params) -> Result<models::SpotGetTickerV3Resp, Error<SpotGetTickerV3Error>> {
981
982 let uri_str = format!("{}/api/v3/ticker", configuration.base_path);
983 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
984
985 let mut query_params: Vec<(String, String)> = Vec::new();
987
988 query_params.push(("symbol".to_string(), params.symbol.to_string()));
989 query_params.push(("symbols".to_string(), params.symbols.to_string()));
990 if let Some(ref param_value) = params.window_size {
991 query_params.push(("windowSize".to_string(), param_value.to_string()));
992 }
993 if let Some(ref param_value) = params.r#type {
994 query_params.push(("type".to_string(), param_value.to_string()));
995 }
996
997 let mut header_params = std::collections::HashMap::new();
999
1000 if let Some(ref binance_auth) = configuration.binance_auth {
1002 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1004
1005 let body_string: Option<Vec<u8>> = None;
1007
1008 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1010 Ok(sig) => sig,
1011 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1012 };
1013
1014 query_params.push(("signature".to_string(), signature));
1016 }
1017
1018 if !query_params.is_empty() {
1020 req_builder = req_builder.query(&query_params);
1021 }
1022
1023
1024 if let Some(ref user_agent) = configuration.user_agent {
1026 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1027 }
1028
1029 for (header_name, header_value) in header_params {
1031 req_builder = req_builder.header(&header_name, &header_value);
1032 }
1033
1034
1035 let req = req_builder.build()?;
1036 let resp = configuration.client.execute(req).await?;
1037
1038 let status = resp.status();
1039 let content_type = resp
1040 .headers()
1041 .get("content-type")
1042 .and_then(|v| v.to_str().ok())
1043 .unwrap_or("application/octet-stream");
1044 let content_type = super::ContentType::from(content_type);
1045
1046 if !status.is_client_error() && !status.is_server_error() {
1047 let content = resp.text().await?;
1048 match content_type {
1049 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1050 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerV3Resp`"))),
1051 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::SpotGetTickerV3Resp`")))),
1052 }
1053 } else {
1054 let content = resp.text().await?;
1055 let entity: Option<SpotGetTickerV3Error> = serde_json::from_str(&content).ok();
1056 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1057 }
1058}
1059
1060pub async fn spot_get_trades_v3(configuration: &configuration::Configuration, params: SpotGetTradesV3Params) -> Result<Vec<models::SpotGetTradesV3RespItem>, Error<SpotGetTradesV3Error>> {
1062
1063 let uri_str = format!("{}/api/v3/trades", configuration.base_path);
1064 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1065
1066 let mut query_params: Vec<(String, String)> = Vec::new();
1068
1069 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1070 if let Some(ref param_value) = params.limit {
1071 query_params.push(("limit".to_string(), param_value.to_string()));
1072 }
1073
1074 let mut header_params = std::collections::HashMap::new();
1076
1077 if let Some(ref binance_auth) = configuration.binance_auth {
1079 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1081
1082 let body_string: Option<Vec<u8>> = None;
1084
1085 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1087 Ok(sig) => sig,
1088 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1089 };
1090
1091 query_params.push(("signature".to_string(), signature));
1093 }
1094
1095 if !query_params.is_empty() {
1097 req_builder = req_builder.query(&query_params);
1098 }
1099
1100
1101 if let Some(ref user_agent) = configuration.user_agent {
1103 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1104 }
1105
1106 for (header_name, header_value) in header_params {
1108 req_builder = req_builder.header(&header_name, &header_value);
1109 }
1110
1111
1112 let req = req_builder.build()?;
1113 let resp = configuration.client.execute(req).await?;
1114
1115 let status = resp.status();
1116 let content_type = resp
1117 .headers()
1118 .get("content-type")
1119 .and_then(|v| v.to_str().ok())
1120 .unwrap_or("application/octet-stream");
1121 let content_type = super::ContentType::from(content_type);
1122
1123 if !status.is_client_error() && !status.is_server_error() {
1124 let content = resp.text().await?;
1125 match content_type {
1126 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1127 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SpotGetTradesV3RespItem>`"))),
1128 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::SpotGetTradesV3RespItem>`")))),
1129 }
1130 } else {
1131 let content = resp.text().await?;
1132 let entity: Option<SpotGetTradesV3Error> = serde_json::from_str(&content).ok();
1133 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1134 }
1135}
1136
1137pub async fn spot_get_ui_klines_v3(configuration: &configuration::Configuration, params: SpotGetUiKlinesV3Params) -> Result<Vec<Vec<models::SpotGetKlinesV3200ResponseInnerInner>>, Error<SpotGetUiKlinesV3Error>> {
1139
1140 let uri_str = format!("{}/api/v3/uiKlines", configuration.base_path);
1141 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1142
1143 let mut query_params: Vec<(String, String)> = Vec::new();
1145
1146 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1147 query_params.push(("interval".to_string(), params.interval.to_string()));
1148 if let Some(ref param_value) = params.start_time {
1149 query_params.push(("startTime".to_string(), param_value.to_string()));
1150 }
1151 if let Some(ref param_value) = params.end_time {
1152 query_params.push(("endTime".to_string(), param_value.to_string()));
1153 }
1154 if let Some(ref param_value) = params.time_zone {
1155 query_params.push(("timeZone".to_string(), param_value.to_string()));
1156 }
1157 if let Some(ref param_value) = params.limit {
1158 query_params.push(("limit".to_string(), param_value.to_string()));
1159 }
1160
1161 let mut header_params = std::collections::HashMap::new();
1163
1164 if let Some(ref binance_auth) = configuration.binance_auth {
1166 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1168
1169 let body_string: Option<Vec<u8>> = None;
1171
1172 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1174 Ok(sig) => sig,
1175 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1176 };
1177
1178 query_params.push(("signature".to_string(), signature));
1180 }
1181
1182 if !query_params.is_empty() {
1184 req_builder = req_builder.query(&query_params);
1185 }
1186
1187
1188 if let Some(ref user_agent) = configuration.user_agent {
1190 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1191 }
1192
1193 for (header_name, header_value) in header_params {
1195 req_builder = req_builder.header(&header_name, &header_value);
1196 }
1197
1198
1199 let req = req_builder.build()?;
1200 let resp = configuration.client.execute(req).await?;
1201
1202 let status = resp.status();
1203 let content_type = resp
1204 .headers()
1205 .get("content-type")
1206 .and_then(|v| v.to_str().ok())
1207 .unwrap_or("application/octet-stream");
1208 let content_type = super::ContentType::from(content_type);
1209
1210 if !status.is_client_error() && !status.is_server_error() {
1211 let content = resp.text().await?;
1212 match content_type {
1213 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1214 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::SpotGetKlinesV3200ResponseInnerInner>>`"))),
1215 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<Vec<models::SpotGetKlinesV3200ResponseInnerInner>>`")))),
1216 }
1217 } else {
1218 let content = resp.text().await?;
1219 let entity: Option<SpotGetUiKlinesV3Error> = serde_json::from_str(&content).ok();
1220 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1221 }
1222}
1223