1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::wallet::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct WalletCreateAccountDisableFastWithdrawSwitchV1Params {
20 pub timestamp: i64,
21 pub recv_window: Option<i64>
22}
23
24#[derive(Clone, Debug, Default)]
26pub struct WalletCreateAccountEnableFastWithdrawSwitchV1Params {
27 pub timestamp: i64,
28 pub recv_window: Option<i64>
29}
30
31#[derive(Clone, Debug, Default)]
33pub struct WalletGetAccountApiRestrictionsV1Params {
34 pub timestamp: i64,
35 pub recv_window: Option<i64>
36}
37
38#[derive(Clone, Debug, Default)]
40pub struct WalletGetAccountApiTradingStatusV1Params {
41 pub timestamp: i64,
42 pub recv_window: Option<i64>
43}
44
45#[derive(Clone, Debug, Default)]
47pub struct WalletGetAccountInfoV1Params {
48 pub timestamp: i64,
49 pub recv_window: Option<i64>
50}
51
52#[derive(Clone, Debug, Default)]
54pub struct WalletGetAccountSnapshotV1Params {
55 pub r#type: String,
57 pub timestamp: i64,
58 pub start_time: Option<i64>,
59 pub end_time: Option<i64>,
60 pub limit: Option<i32>,
62 pub recv_window: Option<i64>
63}
64
65#[derive(Clone, Debug, Default)]
67pub struct WalletGetAccountStatusV1Params {
68 pub timestamp: i64,
69 pub recv_window: Option<i64>
70}
71
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum WalletCreateAccountDisableFastWithdrawSwitchV1Error {
77 Status4XX(models::ApiError),
78 Status5XX(models::ApiError),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum WalletCreateAccountEnableFastWithdrawSwitchV1Error {
86 Status4XX(models::ApiError),
87 Status5XX(models::ApiError),
88 UnknownValue(serde_json::Value),
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum WalletGetAccountApiRestrictionsV1Error {
95 Status4XX(models::ApiError),
96 Status5XX(models::ApiError),
97 UnknownValue(serde_json::Value),
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum WalletGetAccountApiTradingStatusV1Error {
104 Status4XX(models::ApiError),
105 Status5XX(models::ApiError),
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum WalletGetAccountInfoV1Error {
113 Status4XX(models::ApiError),
114 Status5XX(models::ApiError),
115 UnknownValue(serde_json::Value),
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum WalletGetAccountSnapshotV1Error {
122 Status4XX(models::ApiError),
123 Status5XX(models::ApiError),
124 UnknownValue(serde_json::Value),
125}
126
127#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum WalletGetAccountStatusV1Error {
131 Status4XX(models::ApiError),
132 Status5XX(models::ApiError),
133 UnknownValue(serde_json::Value),
134}
135
136
137pub async fn wallet_create_account_disable_fast_withdraw_switch_v1(configuration: &configuration::Configuration, params: WalletCreateAccountDisableFastWithdrawSwitchV1Params) -> Result<serde_json::Value, Error<WalletCreateAccountDisableFastWithdrawSwitchV1Error>> {
138
139 let uri_str = format!("{}/sapi/v1/account/disableFastWithdrawSwitch", configuration.base_path);
140 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
141
142 let mut query_params: Vec<(String, String)> = Vec::new();
144
145
146 let mut header_params = std::collections::HashMap::new();
148
149 if let Some(ref binance_auth) = configuration.binance_auth {
151 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
153
154 let body_string: Option<Vec<u8>> = None;
156
157 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
159 Ok(sig) => sig,
160 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
161 };
162
163 query_params.push(("signature".to_string(), signature));
165 }
166
167 if !query_params.is_empty() {
169 req_builder = req_builder.query(&query_params);
170 }
171
172
173 if let Some(ref user_agent) = configuration.user_agent {
175 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
176 }
177
178 for (header_name, header_value) in header_params {
180 req_builder = req_builder.header(&header_name, &header_value);
181 }
182
183 let mut multipart_form_params = std::collections::HashMap::new();
184 if let Some(param_value) = params.recv_window {
185 multipart_form_params.insert("recvWindow", param_value.to_string());
186 }
187 multipart_form_params.insert("timestamp", params.timestamp.to_string());
188 req_builder = req_builder.form(&multipart_form_params);
189
190 let req = req_builder.build()?;
191 let resp = configuration.client.execute(req).await?;
192
193 let status = resp.status();
194 let content_type = resp
195 .headers()
196 .get("content-type")
197 .and_then(|v| v.to_str().ok())
198 .unwrap_or("application/octet-stream");
199 let content_type = super::ContentType::from(content_type);
200
201 if !status.is_client_error() && !status.is_server_error() {
202 let content = resp.text().await?;
203 match content_type {
204 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
205 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
206 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
207 }
208 } else {
209 let content = resp.text().await?;
210 let entity: Option<WalletCreateAccountDisableFastWithdrawSwitchV1Error> = serde_json::from_str(&content).ok();
211 Err(Error::ResponseError(ResponseContent { status, content, entity }))
212 }
213}
214
215pub async fn wallet_create_account_enable_fast_withdraw_switch_v1(configuration: &configuration::Configuration, params: WalletCreateAccountEnableFastWithdrawSwitchV1Params) -> Result<serde_json::Value, Error<WalletCreateAccountEnableFastWithdrawSwitchV1Error>> {
217
218 let uri_str = format!("{}/sapi/v1/account/enableFastWithdrawSwitch", configuration.base_path);
219 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
220
221 let mut query_params: Vec<(String, String)> = Vec::new();
223
224
225 let mut header_params = std::collections::HashMap::new();
227
228 if let Some(ref binance_auth) = configuration.binance_auth {
230 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
232
233 let body_string: Option<Vec<u8>> = None;
235
236 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
238 Ok(sig) => sig,
239 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
240 };
241
242 query_params.push(("signature".to_string(), signature));
244 }
245
246 if !query_params.is_empty() {
248 req_builder = req_builder.query(&query_params);
249 }
250
251
252 if let Some(ref user_agent) = configuration.user_agent {
254 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255 }
256
257 for (header_name, header_value) in header_params {
259 req_builder = req_builder.header(&header_name, &header_value);
260 }
261
262 let mut multipart_form_params = std::collections::HashMap::new();
263 if let Some(param_value) = params.recv_window {
264 multipart_form_params.insert("recvWindow", param_value.to_string());
265 }
266 multipart_form_params.insert("timestamp", params.timestamp.to_string());
267 req_builder = req_builder.form(&multipart_form_params);
268
269 let req = req_builder.build()?;
270 let resp = configuration.client.execute(req).await?;
271
272 let status = resp.status();
273 let content_type = resp
274 .headers()
275 .get("content-type")
276 .and_then(|v| v.to_str().ok())
277 .unwrap_or("application/octet-stream");
278 let content_type = super::ContentType::from(content_type);
279
280 if !status.is_client_error() && !status.is_server_error() {
281 let content = resp.text().await?;
282 match content_type {
283 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
284 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
285 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
286 }
287 } else {
288 let content = resp.text().await?;
289 let entity: Option<WalletCreateAccountEnableFastWithdrawSwitchV1Error> = serde_json::from_str(&content).ok();
290 Err(Error::ResponseError(ResponseContent { status, content, entity }))
291 }
292}
293
294pub async fn wallet_get_account_api_restrictions_v1(configuration: &configuration::Configuration, params: WalletGetAccountApiRestrictionsV1Params) -> Result<models::WalletGetAccountApiRestrictionsV1Resp, Error<WalletGetAccountApiRestrictionsV1Error>> {
296
297 let uri_str = format!("{}/sapi/v1/account/apiRestrictions", configuration.base_path);
298 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
299
300 let mut query_params: Vec<(String, String)> = Vec::new();
302
303 if let Some(ref param_value) = params.recv_window {
304 query_params.push(("recvWindow".to_string(), param_value.to_string()));
305 }
306 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
307
308 let mut header_params = std::collections::HashMap::new();
310
311 if let Some(ref binance_auth) = configuration.binance_auth {
313 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
315
316 let body_string: Option<Vec<u8>> = None;
318
319 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
321 Ok(sig) => sig,
322 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
323 };
324
325 query_params.push(("signature".to_string(), signature));
327 }
328
329 if !query_params.is_empty() {
331 req_builder = req_builder.query(&query_params);
332 }
333
334
335 if let Some(ref user_agent) = configuration.user_agent {
337 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
338 }
339
340 for (header_name, header_value) in header_params {
342 req_builder = req_builder.header(&header_name, &header_value);
343 }
344
345
346 let req = req_builder.build()?;
347 let resp = configuration.client.execute(req).await?;
348
349 let status = resp.status();
350 let content_type = resp
351 .headers()
352 .get("content-type")
353 .and_then(|v| v.to_str().ok())
354 .unwrap_or("application/octet-stream");
355 let content_type = super::ContentType::from(content_type);
356
357 if !status.is_client_error() && !status.is_server_error() {
358 let content = resp.text().await?;
359 match content_type {
360 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
361 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountApiRestrictionsV1Resp`"))),
362 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::WalletGetAccountApiRestrictionsV1Resp`")))),
363 }
364 } else {
365 let content = resp.text().await?;
366 let entity: Option<WalletGetAccountApiRestrictionsV1Error> = serde_json::from_str(&content).ok();
367 Err(Error::ResponseError(ResponseContent { status, content, entity }))
368 }
369}
370
371pub async fn wallet_get_account_api_trading_status_v1(configuration: &configuration::Configuration, params: WalletGetAccountApiTradingStatusV1Params) -> Result<models::WalletGetAccountApiTradingStatusV1Resp, Error<WalletGetAccountApiTradingStatusV1Error>> {
373
374 let uri_str = format!("{}/sapi/v1/account/apiTradingStatus", configuration.base_path);
375 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
376
377 let mut query_params: Vec<(String, String)> = Vec::new();
379
380 if let Some(ref param_value) = params.recv_window {
381 query_params.push(("recvWindow".to_string(), param_value.to_string()));
382 }
383 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
384
385 let mut header_params = std::collections::HashMap::new();
387
388 if let Some(ref binance_auth) = configuration.binance_auth {
390 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
392
393 let body_string: Option<Vec<u8>> = None;
395
396 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
398 Ok(sig) => sig,
399 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
400 };
401
402 query_params.push(("signature".to_string(), signature));
404 }
405
406 if !query_params.is_empty() {
408 req_builder = req_builder.query(&query_params);
409 }
410
411
412 if let Some(ref user_agent) = configuration.user_agent {
414 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
415 }
416
417 for (header_name, header_value) in header_params {
419 req_builder = req_builder.header(&header_name, &header_value);
420 }
421
422
423 let req = req_builder.build()?;
424 let resp = configuration.client.execute(req).await?;
425
426 let status = resp.status();
427 let content_type = resp
428 .headers()
429 .get("content-type")
430 .and_then(|v| v.to_str().ok())
431 .unwrap_or("application/octet-stream");
432 let content_type = super::ContentType::from(content_type);
433
434 if !status.is_client_error() && !status.is_server_error() {
435 let content = resp.text().await?;
436 match content_type {
437 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
438 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountApiTradingStatusV1Resp`"))),
439 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::WalletGetAccountApiTradingStatusV1Resp`")))),
440 }
441 } else {
442 let content = resp.text().await?;
443 let entity: Option<WalletGetAccountApiTradingStatusV1Error> = serde_json::from_str(&content).ok();
444 Err(Error::ResponseError(ResponseContent { status, content, entity }))
445 }
446}
447
448pub async fn wallet_get_account_info_v1(configuration: &configuration::Configuration, params: WalletGetAccountInfoV1Params) -> Result<models::WalletGetAccountInfoV1Resp, Error<WalletGetAccountInfoV1Error>> {
450
451 let uri_str = format!("{}/sapi/v1/account/info", configuration.base_path);
452 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
453
454 let mut query_params: Vec<(String, String)> = Vec::new();
456
457 if let Some(ref param_value) = params.recv_window {
458 query_params.push(("recvWindow".to_string(), param_value.to_string()));
459 }
460 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
461
462 let mut header_params = std::collections::HashMap::new();
464
465 if let Some(ref binance_auth) = configuration.binance_auth {
467 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
469
470 let body_string: Option<Vec<u8>> = None;
472
473 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
475 Ok(sig) => sig,
476 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
477 };
478
479 query_params.push(("signature".to_string(), signature));
481 }
482
483 if !query_params.is_empty() {
485 req_builder = req_builder.query(&query_params);
486 }
487
488
489 if let Some(ref user_agent) = configuration.user_agent {
491 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
492 }
493
494 for (header_name, header_value) in header_params {
496 req_builder = req_builder.header(&header_name, &header_value);
497 }
498
499
500 let req = req_builder.build()?;
501 let resp = configuration.client.execute(req).await?;
502
503 let status = resp.status();
504 let content_type = resp
505 .headers()
506 .get("content-type")
507 .and_then(|v| v.to_str().ok())
508 .unwrap_or("application/octet-stream");
509 let content_type = super::ContentType::from(content_type);
510
511 if !status.is_client_error() && !status.is_server_error() {
512 let content = resp.text().await?;
513 match content_type {
514 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
515 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountInfoV1Resp`"))),
516 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::WalletGetAccountInfoV1Resp`")))),
517 }
518 } else {
519 let content = resp.text().await?;
520 let entity: Option<WalletGetAccountInfoV1Error> = serde_json::from_str(&content).ok();
521 Err(Error::ResponseError(ResponseContent { status, content, entity }))
522 }
523}
524
525pub async fn wallet_get_account_snapshot_v1(configuration: &configuration::Configuration, params: WalletGetAccountSnapshotV1Params) -> Result<models::WalletGetAccountSnapshotV1Resp, Error<WalletGetAccountSnapshotV1Error>> {
527
528 let uri_str = format!("{}/sapi/v1/accountSnapshot", configuration.base_path);
529 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
530
531 let mut query_params: Vec<(String, String)> = Vec::new();
533
534 query_params.push(("type".to_string(), params.r#type.to_string()));
535 if let Some(ref param_value) = params.start_time {
536 query_params.push(("startTime".to_string(), param_value.to_string()));
537 }
538 if let Some(ref param_value) = params.end_time {
539 query_params.push(("endTime".to_string(), param_value.to_string()));
540 }
541 if let Some(ref param_value) = params.limit {
542 query_params.push(("limit".to_string(), param_value.to_string()));
543 }
544 if let Some(ref param_value) = params.recv_window {
545 query_params.push(("recvWindow".to_string(), param_value.to_string()));
546 }
547 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
548
549 let mut header_params = std::collections::HashMap::new();
551
552 if let Some(ref binance_auth) = configuration.binance_auth {
554 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
556
557 let body_string: Option<Vec<u8>> = None;
559
560 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
562 Ok(sig) => sig,
563 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
564 };
565
566 query_params.push(("signature".to_string(), signature));
568 }
569
570 if !query_params.is_empty() {
572 req_builder = req_builder.query(&query_params);
573 }
574
575
576 if let Some(ref user_agent) = configuration.user_agent {
578 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
579 }
580
581 for (header_name, header_value) in header_params {
583 req_builder = req_builder.header(&header_name, &header_value);
584 }
585
586
587 let req = req_builder.build()?;
588 let resp = configuration.client.execute(req).await?;
589
590 let status = resp.status();
591 let content_type = resp
592 .headers()
593 .get("content-type")
594 .and_then(|v| v.to_str().ok())
595 .unwrap_or("application/octet-stream");
596 let content_type = super::ContentType::from(content_type);
597
598 if !status.is_client_error() && !status.is_server_error() {
599 let content = resp.text().await?;
600 match content_type {
601 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
602 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountSnapshotV1Resp`"))),
603 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::WalletGetAccountSnapshotV1Resp`")))),
604 }
605 } else {
606 let content = resp.text().await?;
607 let entity: Option<WalletGetAccountSnapshotV1Error> = serde_json::from_str(&content).ok();
608 Err(Error::ResponseError(ResponseContent { status, content, entity }))
609 }
610}
611
612pub async fn wallet_get_account_status_v1(configuration: &configuration::Configuration, params: WalletGetAccountStatusV1Params) -> Result<models::WalletGetAccountStatusV1Resp, Error<WalletGetAccountStatusV1Error>> {
614
615 let uri_str = format!("{}/sapi/v1/account/status", configuration.base_path);
616 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
617
618 let mut query_params: Vec<(String, String)> = Vec::new();
620
621 if let Some(ref param_value) = params.recv_window {
622 query_params.push(("recvWindow".to_string(), param_value.to_string()));
623 }
624 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
625
626 let mut header_params = std::collections::HashMap::new();
628
629 if let Some(ref binance_auth) = configuration.binance_auth {
631 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
633
634 let body_string: Option<Vec<u8>> = None;
636
637 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
639 Ok(sig) => sig,
640 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
641 };
642
643 query_params.push(("signature".to_string(), signature));
645 }
646
647 if !query_params.is_empty() {
649 req_builder = req_builder.query(&query_params);
650 }
651
652
653 if let Some(ref user_agent) = configuration.user_agent {
655 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
656 }
657
658 for (header_name, header_value) in header_params {
660 req_builder = req_builder.header(&header_name, &header_value);
661 }
662
663
664 let req = req_builder.build()?;
665 let resp = configuration.client.execute(req).await?;
666
667 let status = resp.status();
668 let content_type = resp
669 .headers()
670 .get("content-type")
671 .and_then(|v| v.to_str().ok())
672 .unwrap_or("application/octet-stream");
673 let content_type = super::ContentType::from(content_type);
674
675 if !status.is_client_error() && !status.is_server_error() {
676 let content = resp.text().await?;
677 match content_type {
678 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
679 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WalletGetAccountStatusV1Resp`"))),
680 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::WalletGetAccountStatusV1Resp`")))),
681 }
682 } else {
683 let content = resp.text().await?;
684 let entity: Option<WalletGetAccountStatusV1Error> = serde_json::from_str(&content).ok();
685 Err(Error::ResponseError(ResponseContent { status, content, entity }))
686 }
687}
688