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 SpotGetAccountCommissionV3Params {
20 pub symbol: String
21}
22
23#[derive(Clone, Debug, Default)]
25pub struct SpotGetAccountV3Params {
26 pub timestamp: i64,
27 pub omit_zero_balances: Option<bool>,
29 pub recv_window: Option<i64>
31}
32
33#[derive(Clone, Debug, Default)]
35pub struct SpotGetMyAllocationsV3Params {
36 pub symbol: String,
37 pub start_time: Option<i64>,
38 pub end_time: Option<i64>,
39 pub from_allocation_id: Option<i32>,
40 pub limit: Option<i32>,
42 pub order_id: Option<i64>,
43 pub recv_window: Option<i64>,
45 pub timestamp: Option<i64>
46}
47
48#[derive(Clone, Debug, Default)]
50pub struct SpotGetMyPreventedMatchesV3Params {
51 pub symbol: String,
52 pub timestamp: i64,
53 pub prevented_match_id: Option<i64>,
54 pub order_id: Option<i64>,
55 pub from_prevented_match_id: Option<i64>,
56 pub limit: Option<i32>,
58 pub recv_window: Option<i64>
60}
61
62#[derive(Clone, Debug, Default)]
64pub struct SpotGetMyTradesV3Params {
65 pub symbol: String,
66 pub timestamp: i64,
67 pub order_id: Option<i64>,
69 pub start_time: Option<i64>,
70 pub end_time: Option<i64>,
71 pub from_id: Option<i64>,
73 pub limit: Option<i32>,
75 pub recv_window: Option<i64>
77}
78
79#[derive(Clone, Debug, Default)]
81pub struct SpotGetRateLimitOrderV3Params {
82 pub timestamp: i64,
83 pub recv_window: Option<i64>
85}
86
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum SpotGetAccountCommissionV3Error {
92 Status4XX(models::ApiError),
93 Status5XX(models::ApiError),
94 UnknownValue(serde_json::Value),
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum SpotGetAccountV3Error {
101 Status4XX(models::ApiError),
102 Status5XX(models::ApiError),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum SpotGetMyAllocationsV3Error {
110 Status4XX(models::ApiError),
111 Status5XX(models::ApiError),
112 UnknownValue(serde_json::Value),
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum SpotGetMyPreventedMatchesV3Error {
119 Status4XX(models::ApiError),
120 Status5XX(models::ApiError),
121 UnknownValue(serde_json::Value),
122}
123
124#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum SpotGetMyTradesV3Error {
128 Status4XX(models::ApiError),
129 Status5XX(models::ApiError),
130 UnknownValue(serde_json::Value),
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum SpotGetRateLimitOrderV3Error {
137 Status4XX(models::ApiError),
138 Status5XX(models::ApiError),
139 UnknownValue(serde_json::Value),
140}
141
142
143pub async fn spot_get_account_commission_v3(configuration: &configuration::Configuration, params: SpotGetAccountCommissionV3Params) -> Result<models::SpotGetAccountCommissionV3Resp, Error<SpotGetAccountCommissionV3Error>> {
145
146 let uri_str = format!("{}/api/v3/account/commission", configuration.base_path);
147 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
148
149 let mut query_params: Vec<(String, String)> = Vec::new();
151
152 query_params.push(("symbol".to_string(), params.symbol.to_string()));
153
154 let mut header_params = std::collections::HashMap::new();
156
157 if let Some(ref binance_auth) = configuration.binance_auth {
159 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
161
162 let body_string: Option<Vec<u8>> = None;
164
165 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
167 Ok(sig) => sig,
168 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
169 };
170
171 query_params.push(("signature".to_string(), signature));
173 }
174
175 if !query_params.is_empty() {
177 req_builder = req_builder.query(&query_params);
178 }
179
180
181 if let Some(ref user_agent) = configuration.user_agent {
183 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
184 }
185
186 for (header_name, header_value) in header_params {
188 req_builder = req_builder.header(&header_name, &header_value);
189 }
190
191
192 let req = req_builder.build()?;
193 let resp = configuration.client.execute(req).await?;
194
195 let status = resp.status();
196 let content_type = resp
197 .headers()
198 .get("content-type")
199 .and_then(|v| v.to_str().ok())
200 .unwrap_or("application/octet-stream");
201 let content_type = super::ContentType::from(content_type);
202
203 if !status.is_client_error() && !status.is_server_error() {
204 let content = resp.text().await?;
205 match content_type {
206 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
207 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetAccountCommissionV3Resp`"))),
208 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetAccountCommissionV3Resp`")))),
209 }
210 } else {
211 let content = resp.text().await?;
212 let entity: Option<SpotGetAccountCommissionV3Error> = serde_json::from_str(&content).ok();
213 Err(Error::ResponseError(ResponseContent { status, content, entity }))
214 }
215}
216
217pub async fn spot_get_account_v3(configuration: &configuration::Configuration, params: SpotGetAccountV3Params) -> Result<models::SpotGetAccountV3Resp, Error<SpotGetAccountV3Error>> {
219
220 let uri_str = format!("{}/api/v3/account", configuration.base_path);
221 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
222
223 let mut query_params: Vec<(String, String)> = Vec::new();
225
226 if let Some(ref param_value) = params.omit_zero_balances {
227 query_params.push(("omitZeroBalances".to_string(), param_value.to_string()));
228 }
229 if let Some(ref param_value) = params.recv_window {
230 query_params.push(("recvWindow".to_string(), param_value.to_string()));
231 }
232 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
233
234 let mut header_params = std::collections::HashMap::new();
236
237 if let Some(ref binance_auth) = configuration.binance_auth {
239 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
241
242 let body_string: Option<Vec<u8>> = None;
244
245 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
247 Ok(sig) => sig,
248 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
249 };
250
251 query_params.push(("signature".to_string(), signature));
253 }
254
255 if !query_params.is_empty() {
257 req_builder = req_builder.query(&query_params);
258 }
259
260
261 if let Some(ref user_agent) = configuration.user_agent {
263 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
264 }
265
266 for (header_name, header_value) in header_params {
268 req_builder = req_builder.header(&header_name, &header_value);
269 }
270
271
272 let req = req_builder.build()?;
273 let resp = configuration.client.execute(req).await?;
274
275 let status = resp.status();
276 let content_type = resp
277 .headers()
278 .get("content-type")
279 .and_then(|v| v.to_str().ok())
280 .unwrap_or("application/octet-stream");
281 let content_type = super::ContentType::from(content_type);
282
283 if !status.is_client_error() && !status.is_server_error() {
284 let content = resp.text().await?;
285 match content_type {
286 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
287 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetAccountV3Resp`"))),
288 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetAccountV3Resp`")))),
289 }
290 } else {
291 let content = resp.text().await?;
292 let entity: Option<SpotGetAccountV3Error> = serde_json::from_str(&content).ok();
293 Err(Error::ResponseError(ResponseContent { status, content, entity }))
294 }
295}
296
297pub async fn spot_get_my_allocations_v3(configuration: &configuration::Configuration, params: SpotGetMyAllocationsV3Params) -> Result<Vec<models::SpotGetMyAllocationsV3RespItem>, Error<SpotGetMyAllocationsV3Error>> {
299
300 let uri_str = format!("{}/api/v3/myAllocations", configuration.base_path);
301 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
302
303 let mut query_params: Vec<(String, String)> = Vec::new();
305
306 query_params.push(("symbol".to_string(), params.symbol.to_string()));
307 if let Some(ref param_value) = params.start_time {
308 query_params.push(("startTime".to_string(), param_value.to_string()));
309 }
310 if let Some(ref param_value) = params.end_time {
311 query_params.push(("endTime".to_string(), param_value.to_string()));
312 }
313 if let Some(ref param_value) = params.from_allocation_id {
314 query_params.push(("fromAllocationId".to_string(), param_value.to_string()));
315 }
316 if let Some(ref param_value) = params.limit {
317 query_params.push(("limit".to_string(), param_value.to_string()));
318 }
319 if let Some(ref param_value) = params.order_id {
320 query_params.push(("orderId".to_string(), param_value.to_string()));
321 }
322 if let Some(ref param_value) = params.recv_window {
323 query_params.push(("recvWindow".to_string(), param_value.to_string()));
324 }
325 if let Some(ref param_value) = params.timestamp {
326 query_params.push(("timestamp".to_string(), param_value.to_string()));
327 }
328
329 let mut header_params = std::collections::HashMap::new();
331
332 if let Some(ref binance_auth) = configuration.binance_auth {
334 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
336
337 let body_string: Option<Vec<u8>> = None;
339
340 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
342 Ok(sig) => sig,
343 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
344 };
345
346 query_params.push(("signature".to_string(), signature));
348 }
349
350 if !query_params.is_empty() {
352 req_builder = req_builder.query(&query_params);
353 }
354
355
356 if let Some(ref user_agent) = configuration.user_agent {
358 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
359 }
360
361 for (header_name, header_value) in header_params {
363 req_builder = req_builder.header(&header_name, &header_value);
364 }
365
366
367 let req = req_builder.build()?;
368 let resp = configuration.client.execute(req).await?;
369
370 let status = resp.status();
371 let content_type = resp
372 .headers()
373 .get("content-type")
374 .and_then(|v| v.to_str().ok())
375 .unwrap_or("application/octet-stream");
376 let content_type = super::ContentType::from(content_type);
377
378 if !status.is_client_error() && !status.is_server_error() {
379 let content = resp.text().await?;
380 match content_type {
381 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
382 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SpotGetMyAllocationsV3RespItem>`"))),
383 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::SpotGetMyAllocationsV3RespItem>`")))),
384 }
385 } else {
386 let content = resp.text().await?;
387 let entity: Option<SpotGetMyAllocationsV3Error> = serde_json::from_str(&content).ok();
388 Err(Error::ResponseError(ResponseContent { status, content, entity }))
389 }
390}
391
392pub async fn spot_get_my_prevented_matches_v3(configuration: &configuration::Configuration, params: SpotGetMyPreventedMatchesV3Params) -> Result<Vec<models::SpotGetMyPreventedMatchesV3RespItem>, Error<SpotGetMyPreventedMatchesV3Error>> {
394
395 let uri_str = format!("{}/api/v3/myPreventedMatches", configuration.base_path);
396 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
397
398 let mut query_params: Vec<(String, String)> = Vec::new();
400
401 query_params.push(("symbol".to_string(), params.symbol.to_string()));
402 if let Some(ref param_value) = params.prevented_match_id {
403 query_params.push(("preventedMatchId".to_string(), param_value.to_string()));
404 }
405 if let Some(ref param_value) = params.order_id {
406 query_params.push(("orderId".to_string(), param_value.to_string()));
407 }
408 if let Some(ref param_value) = params.from_prevented_match_id {
409 query_params.push(("fromPreventedMatchId".to_string(), param_value.to_string()));
410 }
411 if let Some(ref param_value) = params.limit {
412 query_params.push(("limit".to_string(), param_value.to_string()));
413 }
414 if let Some(ref param_value) = params.recv_window {
415 query_params.push(("recvWindow".to_string(), param_value.to_string()));
416 }
417 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
418
419 let mut header_params = std::collections::HashMap::new();
421
422 if let Some(ref binance_auth) = configuration.binance_auth {
424 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
426
427 let body_string: Option<Vec<u8>> = None;
429
430 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
432 Ok(sig) => sig,
433 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
434 };
435
436 query_params.push(("signature".to_string(), signature));
438 }
439
440 if !query_params.is_empty() {
442 req_builder = req_builder.query(&query_params);
443 }
444
445
446 if let Some(ref user_agent) = configuration.user_agent {
448 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
449 }
450
451 for (header_name, header_value) in header_params {
453 req_builder = req_builder.header(&header_name, &header_value);
454 }
455
456
457 let req = req_builder.build()?;
458 let resp = configuration.client.execute(req).await?;
459
460 let status = resp.status();
461 let content_type = resp
462 .headers()
463 .get("content-type")
464 .and_then(|v| v.to_str().ok())
465 .unwrap_or("application/octet-stream");
466 let content_type = super::ContentType::from(content_type);
467
468 if !status.is_client_error() && !status.is_server_error() {
469 let content = resp.text().await?;
470 match content_type {
471 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
472 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SpotGetMyPreventedMatchesV3RespItem>`"))),
473 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::SpotGetMyPreventedMatchesV3RespItem>`")))),
474 }
475 } else {
476 let content = resp.text().await?;
477 let entity: Option<SpotGetMyPreventedMatchesV3Error> = serde_json::from_str(&content).ok();
478 Err(Error::ResponseError(ResponseContent { status, content, entity }))
479 }
480}
481
482pub async fn spot_get_my_trades_v3(configuration: &configuration::Configuration, params: SpotGetMyTradesV3Params) -> Result<Vec<models::SpotGetMyTradesV3RespItem>, Error<SpotGetMyTradesV3Error>> {
484
485 let uri_str = format!("{}/api/v3/myTrades", configuration.base_path);
486 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
487
488 let mut query_params: Vec<(String, String)> = Vec::new();
490
491 query_params.push(("symbol".to_string(), params.symbol.to_string()));
492 if let Some(ref param_value) = params.order_id {
493 query_params.push(("orderId".to_string(), param_value.to_string()));
494 }
495 if let Some(ref param_value) = params.start_time {
496 query_params.push(("startTime".to_string(), param_value.to_string()));
497 }
498 if let Some(ref param_value) = params.end_time {
499 query_params.push(("endTime".to_string(), param_value.to_string()));
500 }
501 if let Some(ref param_value) = params.from_id {
502 query_params.push(("fromId".to_string(), param_value.to_string()));
503 }
504 if let Some(ref param_value) = params.limit {
505 query_params.push(("limit".to_string(), param_value.to_string()));
506 }
507 if let Some(ref param_value) = params.recv_window {
508 query_params.push(("recvWindow".to_string(), param_value.to_string()));
509 }
510 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
511
512 let mut header_params = std::collections::HashMap::new();
514
515 if let Some(ref binance_auth) = configuration.binance_auth {
517 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
519
520 let body_string: Option<Vec<u8>> = None;
522
523 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
525 Ok(sig) => sig,
526 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
527 };
528
529 query_params.push(("signature".to_string(), signature));
531 }
532
533 if !query_params.is_empty() {
535 req_builder = req_builder.query(&query_params);
536 }
537
538
539 if let Some(ref user_agent) = configuration.user_agent {
541 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
542 }
543
544 for (header_name, header_value) in header_params {
546 req_builder = req_builder.header(&header_name, &header_value);
547 }
548
549
550 let req = req_builder.build()?;
551 let resp = configuration.client.execute(req).await?;
552
553 let status = resp.status();
554 let content_type = resp
555 .headers()
556 .get("content-type")
557 .and_then(|v| v.to_str().ok())
558 .unwrap_or("application/octet-stream");
559 let content_type = super::ContentType::from(content_type);
560
561 if !status.is_client_error() && !status.is_server_error() {
562 let content = resp.text().await?;
563 match content_type {
564 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
565 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SpotGetMyTradesV3RespItem>`"))),
566 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::SpotGetMyTradesV3RespItem>`")))),
567 }
568 } else {
569 let content = resp.text().await?;
570 let entity: Option<SpotGetMyTradesV3Error> = serde_json::from_str(&content).ok();
571 Err(Error::ResponseError(ResponseContent { status, content, entity }))
572 }
573}
574
575pub async fn spot_get_rate_limit_order_v3(configuration: &configuration::Configuration, params: SpotGetRateLimitOrderV3Params) -> Result<Vec<models::SpotGetRateLimitOrderV3RespItem>, Error<SpotGetRateLimitOrderV3Error>> {
577
578 let uri_str = format!("{}/api/v3/rateLimit/order", configuration.base_path);
579 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
580
581 let mut query_params: Vec<(String, String)> = Vec::new();
583
584 if let Some(ref param_value) = params.recv_window {
585 query_params.push(("recvWindow".to_string(), param_value.to_string()));
586 }
587 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
588
589 let mut header_params = std::collections::HashMap::new();
591
592 if let Some(ref binance_auth) = configuration.binance_auth {
594 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
596
597 let body_string: Option<Vec<u8>> = None;
599
600 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
602 Ok(sig) => sig,
603 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
604 };
605
606 query_params.push(("signature".to_string(), signature));
608 }
609
610 if !query_params.is_empty() {
612 req_builder = req_builder.query(&query_params);
613 }
614
615
616 if let Some(ref user_agent) = configuration.user_agent {
618 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
619 }
620
621 for (header_name, header_value) in header_params {
623 req_builder = req_builder.header(&header_name, &header_value);
624 }
625
626
627 let req = req_builder.build()?;
628 let resp = configuration.client.execute(req).await?;
629
630 let status = resp.status();
631 let content_type = resp
632 .headers()
633 .get("content-type")
634 .and_then(|v| v.to_str().ok())
635 .unwrap_or("application/octet-stream");
636 let content_type = super::ContentType::from(content_type);
637
638 if !status.is_client_error() && !status.is_server_error() {
639 let content = resp.text().await?;
640 match content_type {
641 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
642 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::SpotGetRateLimitOrderV3RespItem>`"))),
643 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::SpotGetRateLimitOrderV3RespItem>`")))),
644 }
645 } else {
646 let content = resp.text().await?;
647 let entity: Option<SpotGetRateLimitOrderV3Error> = serde_json::from_str(&content).ok();
648 Err(Error::ResponseError(ResponseContent { status, content, entity }))
649 }
650}
651