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 CreatePortfolioAssetCollectionV1Params {
20 pub asset: String,
21 pub timestamp: i64,
22 pub recv_window: Option<i64>
23}
24
25#[derive(Clone, Debug, Default)]
27pub struct CreatePortfolioAutoCollectionV1Params {
28 pub timestamp: i64,
29 pub recv_window: Option<i64>
30}
31
32#[derive(Clone, Debug, Default)]
34pub struct CreatePortfolioBnbTransferV1Params {
35 pub amount: String,
36 pub timestamp: i64,
37 pub transfer_side: String,
38 pub recv_window: Option<i64>
39}
40
41#[derive(Clone, Debug, Default)]
43pub struct CreatePortfolioMintV1Params {
44 pub amount: String,
45 pub from_asset: String,
46 pub target_asset: String,
47 pub timestamp: i64,
48 pub recv_window: Option<i64>
49}
50
51#[derive(Clone, Debug, Default)]
53pub struct CreatePortfolioRedeemV1Params {
54 pub amount: String,
55 pub from_asset: String,
56 pub target_asset: String,
57 pub timestamp: i64,
58 pub recv_window: Option<i64>
59}
60
61#[derive(Clone, Debug, Default)]
63pub struct CreatePortfolioRepayFuturesNegativeBalanceV1Params {
64 pub timestamp: i64,
65 pub from: Option<String>,
66 pub recv_window: Option<i64>
67}
68
69#[derive(Clone, Debug, Default)]
71pub struct CreatePortfolioRepayFuturesSwitchV1Params {
72 pub auto_repay: String,
73 pub timestamp: i64,
74 pub recv_window: Option<i64>
75}
76
77#[derive(Clone, Debug, Default)]
79pub struct CreatePortfolioRepayV1Params {
80 pub timestamp: i64,
81 pub from: Option<String>,
82 pub recv_window: Option<i64>
83}
84
85#[derive(Clone, Debug, Default)]
87pub struct GetPortfolioAccountV1Params {
88 pub timestamp: i64,
89 pub recv_window: Option<i64>
90}
91
92#[derive(Clone, Debug, Default)]
94pub struct GetPortfolioAccountV2Params {
95 pub timestamp: i64,
96 pub recv_window: Option<i64>
97}
98
99#[derive(Clone, Debug, Default)]
101pub struct GetPortfolioAssetIndexPriceV1Params {
102 pub asset: Option<String>
103}
104
105#[derive(Clone, Debug, Default)]
107pub struct GetPortfolioBalanceV1Params {
108 pub timestamp: i64,
109 pub asset: Option<String>,
110 pub recv_window: Option<i64>
111}
112
113#[derive(Clone, Debug, Default)]
115pub struct GetPortfolioCollateralRateV2Params {
116 pub timestamp: i64,
117 pub recv_window: Option<i64>
118}
119
120#[derive(Clone, Debug, Default)]
122pub struct GetPortfolioInterestHistoryV1Params {
123 pub timestamp: i64,
124 pub asset: Option<String>,
125 pub start_time: Option<i64>,
126 pub end_time: Option<i64>,
127 pub size: Option<i64>,
129 pub recv_window: Option<i64>
130}
131
132#[derive(Clone, Debug, Default)]
134pub struct GetPortfolioPmLoanHistoryV1Params {
135 pub timestamp: i64,
136 pub start_time: Option<i64>,
137 pub end_time: Option<i64>,
138 pub current: Option<i64>,
140 pub size: Option<i64>,
142 pub recv_window: Option<i64>
143}
144
145#[derive(Clone, Debug, Default)]
147pub struct GetPortfolioPmLoanV1Params {
148 pub timestamp: i64,
149 pub recv_window: Option<i64>
150}
151
152#[derive(Clone, Debug, Default)]
154pub struct GetPortfolioRepayFuturesSwitchV1Params {
155 pub timestamp: i64,
156 pub recv_window: Option<i64>
157}
158
159
160#[derive(Debug, Clone, Serialize, Deserialize)]
162#[serde(untagged)]
163pub enum CreatePortfolioAssetCollectionV1Error {
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 CreatePortfolioAutoCollectionV1Error {
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 CreatePortfolioBnbTransferV1Error {
182 Status4XX(models::ApiError),
183 Status5XX(models::ApiError),
184 UnknownValue(serde_json::Value),
185}
186
187#[derive(Debug, Clone, Serialize, Deserialize)]
189#[serde(untagged)]
190pub enum CreatePortfolioMintV1Error {
191 Status4XX(models::ApiError),
192 Status5XX(models::ApiError),
193 UnknownValue(serde_json::Value),
194}
195
196#[derive(Debug, Clone, Serialize, Deserialize)]
198#[serde(untagged)]
199pub enum CreatePortfolioRedeemV1Error {
200 Status4XX(models::ApiError),
201 Status5XX(models::ApiError),
202 UnknownValue(serde_json::Value),
203}
204
205#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(untagged)]
208pub enum CreatePortfolioRepayFuturesNegativeBalanceV1Error {
209 Status4XX(models::ApiError),
210 Status5XX(models::ApiError),
211 UnknownValue(serde_json::Value),
212}
213
214#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum CreatePortfolioRepayFuturesSwitchV1Error {
218 Status4XX(models::ApiError),
219 Status5XX(models::ApiError),
220 UnknownValue(serde_json::Value),
221}
222
223#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum CreatePortfolioRepayV1Error {
227 Status4XX(models::ApiError),
228 Status5XX(models::ApiError),
229 UnknownValue(serde_json::Value),
230}
231
232#[derive(Debug, Clone, Serialize, Deserialize)]
234#[serde(untagged)]
235pub enum GetPortfolioAccountV1Error {
236 Status4XX(models::ApiError),
237 Status5XX(models::ApiError),
238 UnknownValue(serde_json::Value),
239}
240
241#[derive(Debug, Clone, Serialize, Deserialize)]
243#[serde(untagged)]
244pub enum GetPortfolioAccountV2Error {
245 Status4XX(models::ApiError),
246 Status5XX(models::ApiError),
247 UnknownValue(serde_json::Value),
248}
249
250#[derive(Debug, Clone, Serialize, Deserialize)]
252#[serde(untagged)]
253pub enum GetPortfolioAssetIndexPriceV1Error {
254 Status4XX(models::ApiError),
255 Status5XX(models::ApiError),
256 UnknownValue(serde_json::Value),
257}
258
259#[derive(Debug, Clone, Serialize, Deserialize)]
261#[serde(untagged)]
262pub enum GetPortfolioBalanceV1Error {
263 Status4XX(models::ApiError),
264 Status5XX(models::ApiError),
265 UnknownValue(serde_json::Value),
266}
267
268#[derive(Debug, Clone, Serialize, Deserialize)]
270#[serde(untagged)]
271pub enum GetPortfolioCollateralRateV1Error {
272 Status4XX(models::ApiError),
273 Status5XX(models::ApiError),
274 UnknownValue(serde_json::Value),
275}
276
277#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum GetPortfolioCollateralRateV2Error {
281 Status4XX(models::ApiError),
282 Status5XX(models::ApiError),
283 UnknownValue(serde_json::Value),
284}
285
286#[derive(Debug, Clone, Serialize, Deserialize)]
288#[serde(untagged)]
289pub enum GetPortfolioInterestHistoryV1Error {
290 Status4XX(models::ApiError),
291 Status5XX(models::ApiError),
292 UnknownValue(serde_json::Value),
293}
294
295#[derive(Debug, Clone, Serialize, Deserialize)]
297#[serde(untagged)]
298pub enum GetPortfolioMarginAssetLeverageV1Error {
299 Status4XX(models::ApiError),
300 Status5XX(models::ApiError),
301 UnknownValue(serde_json::Value),
302}
303
304#[derive(Debug, Clone, Serialize, Deserialize)]
306#[serde(untagged)]
307pub enum GetPortfolioPmLoanHistoryV1Error {
308 Status4XX(models::ApiError),
309 Status5XX(models::ApiError),
310 UnknownValue(serde_json::Value),
311}
312
313#[derive(Debug, Clone, Serialize, Deserialize)]
315#[serde(untagged)]
316pub enum GetPortfolioPmLoanV1Error {
317 Status4XX(models::ApiError),
318 Status5XX(models::ApiError),
319 UnknownValue(serde_json::Value),
320}
321
322#[derive(Debug, Clone, Serialize, Deserialize)]
324#[serde(untagged)]
325pub enum GetPortfolioRepayFuturesSwitchV1Error {
326 Status4XX(models::ApiError),
327 Status5XX(models::ApiError),
328 UnknownValue(serde_json::Value),
329}
330
331
332pub async fn create_portfolio_asset_collection_v1(configuration: &configuration::Configuration, params: CreatePortfolioAssetCollectionV1Params) -> Result<models::CreatePortfolioAssetCollectionV1Resp, Error<CreatePortfolioAssetCollectionV1Error>> {
334
335 let uri_str = format!("{}/sapi/v1/portfolio/asset-collection", configuration.base_path);
336 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
337
338 let mut query_params: Vec<(String, String)> = Vec::new();
340
341
342 let mut header_params = std::collections::HashMap::new();
344
345 if let Some(ref binance_auth) = configuration.binance_auth {
347 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
349
350 let body_string: Option<Vec<u8>> = None;
352
353 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
355 Ok(sig) => sig,
356 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
357 };
358
359 query_params.push(("signature".to_string(), signature));
361 }
362
363 if !query_params.is_empty() {
365 req_builder = req_builder.query(&query_params);
366 }
367
368
369 if let Some(ref user_agent) = configuration.user_agent {
371 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
372 }
373
374 for (header_name, header_value) in header_params {
376 req_builder = req_builder.header(&header_name, &header_value);
377 }
378
379 let mut multipart_form_params = std::collections::HashMap::new();
380 multipart_form_params.insert("asset", params.asset.to_string());
381 if let Some(param_value) = params.recv_window {
382 multipart_form_params.insert("recvWindow", param_value.to_string());
383 }
384 multipart_form_params.insert("timestamp", params.timestamp.to_string());
385 req_builder = req_builder.form(&multipart_form_params);
386
387 let req = req_builder.build()?;
388 let resp = configuration.client.execute(req).await?;
389
390 let status = resp.status();
391 let content_type = resp
392 .headers()
393 .get("content-type")
394 .and_then(|v| v.to_str().ok())
395 .unwrap_or("application/octet-stream");
396 let content_type = super::ContentType::from(content_type);
397
398 if !status.is_client_error() && !status.is_server_error() {
399 let content = resp.text().await?;
400 match content_type {
401 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
402 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePortfolioAssetCollectionV1Resp`"))),
403 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::CreatePortfolioAssetCollectionV1Resp`")))),
404 }
405 } else {
406 let content = resp.text().await?;
407 let entity: Option<CreatePortfolioAssetCollectionV1Error> = serde_json::from_str(&content).ok();
408 Err(Error::ResponseError(ResponseContent { status, content, entity }))
409 }
410}
411
412pub async fn create_portfolio_auto_collection_v1(configuration: &configuration::Configuration, params: CreatePortfolioAutoCollectionV1Params) -> Result<models::CreatePortfolioAutoCollectionV1Resp, Error<CreatePortfolioAutoCollectionV1Error>> {
414
415 let uri_str = format!("{}/sapi/v1/portfolio/auto-collection", configuration.base_path);
416 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
417
418 let mut query_params: Vec<(String, String)> = Vec::new();
420
421
422 let mut header_params = std::collections::HashMap::new();
424
425 if let Some(ref binance_auth) = configuration.binance_auth {
427 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
429
430 let body_string: Option<Vec<u8>> = None;
432
433 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
435 Ok(sig) => sig,
436 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
437 };
438
439 query_params.push(("signature".to_string(), signature));
441 }
442
443 if !query_params.is_empty() {
445 req_builder = req_builder.query(&query_params);
446 }
447
448
449 if let Some(ref user_agent) = configuration.user_agent {
451 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
452 }
453
454 for (header_name, header_value) in header_params {
456 req_builder = req_builder.header(&header_name, &header_value);
457 }
458
459 let mut multipart_form_params = std::collections::HashMap::new();
460 if let Some(param_value) = params.recv_window {
461 multipart_form_params.insert("recvWindow", param_value.to_string());
462 }
463 multipart_form_params.insert("timestamp", params.timestamp.to_string());
464 req_builder = req_builder.form(&multipart_form_params);
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::CreatePortfolioAutoCollectionV1Resp`"))),
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::CreatePortfolioAutoCollectionV1Resp`")))),
483 }
484 } else {
485 let content = resp.text().await?;
486 let entity: Option<CreatePortfolioAutoCollectionV1Error> = serde_json::from_str(&content).ok();
487 Err(Error::ResponseError(ResponseContent { status, content, entity }))
488 }
489}
490
491pub async fn create_portfolio_bnb_transfer_v1(configuration: &configuration::Configuration, params: CreatePortfolioBnbTransferV1Params) -> Result<models::CreatePortfolioBnbTransferV1Resp, Error<CreatePortfolioBnbTransferV1Error>> {
493
494 let uri_str = format!("{}/sapi/v1/portfolio/bnb-transfer", configuration.base_path);
495 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
496
497 let mut query_params: Vec<(String, String)> = Vec::new();
499
500
501 let mut header_params = std::collections::HashMap::new();
503
504 if let Some(ref binance_auth) = configuration.binance_auth {
506 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
508
509 let body_string: Option<Vec<u8>> = None;
511
512 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
514 Ok(sig) => sig,
515 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
516 };
517
518 query_params.push(("signature".to_string(), signature));
520 }
521
522 if !query_params.is_empty() {
524 req_builder = req_builder.query(&query_params);
525 }
526
527
528 if let Some(ref user_agent) = configuration.user_agent {
530 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
531 }
532
533 for (header_name, header_value) in header_params {
535 req_builder = req_builder.header(&header_name, &header_value);
536 }
537
538 let mut multipart_form_params = std::collections::HashMap::new();
539 multipart_form_params.insert("amount", params.amount.to_string());
540 if let Some(param_value) = params.recv_window {
541 multipart_form_params.insert("recvWindow", param_value.to_string());
542 }
543 multipart_form_params.insert("timestamp", params.timestamp.to_string());
544 multipart_form_params.insert("transferSide", params.transfer_side.to_string());
545 req_builder = req_builder.form(&multipart_form_params);
546
547 let req = req_builder.build()?;
548 let resp = configuration.client.execute(req).await?;
549
550 let status = resp.status();
551 let content_type = resp
552 .headers()
553 .get("content-type")
554 .and_then(|v| v.to_str().ok())
555 .unwrap_or("application/octet-stream");
556 let content_type = super::ContentType::from(content_type);
557
558 if !status.is_client_error() && !status.is_server_error() {
559 let content = resp.text().await?;
560 match content_type {
561 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
562 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePortfolioBnbTransferV1Resp`"))),
563 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::CreatePortfolioBnbTransferV1Resp`")))),
564 }
565 } else {
566 let content = resp.text().await?;
567 let entity: Option<CreatePortfolioBnbTransferV1Error> = serde_json::from_str(&content).ok();
568 Err(Error::ResponseError(ResponseContent { status, content, entity }))
569 }
570}
571
572pub async fn create_portfolio_mint_v1(configuration: &configuration::Configuration, params: CreatePortfolioMintV1Params) -> Result<models::CreatePortfolioMintV1Resp, Error<CreatePortfolioMintV1Error>> {
574
575 let uri_str = format!("{}/sapi/v1/portfolio/mint", configuration.base_path);
576 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
577
578 let mut query_params: Vec<(String, String)> = Vec::new();
580
581
582 let mut header_params = std::collections::HashMap::new();
584
585 if let Some(ref binance_auth) = configuration.binance_auth {
587 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
589
590 let body_string: Option<Vec<u8>> = None;
592
593 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
595 Ok(sig) => sig,
596 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
597 };
598
599 query_params.push(("signature".to_string(), signature));
601 }
602
603 if !query_params.is_empty() {
605 req_builder = req_builder.query(&query_params);
606 }
607
608
609 if let Some(ref user_agent) = configuration.user_agent {
611 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
612 }
613
614 for (header_name, header_value) in header_params {
616 req_builder = req_builder.header(&header_name, &header_value);
617 }
618
619 let mut multipart_form_params = std::collections::HashMap::new();
620 multipart_form_params.insert("amount", params.amount.to_string());
621 multipart_form_params.insert("fromAsset", params.from_asset.to_string());
622 if let Some(param_value) = params.recv_window {
623 multipart_form_params.insert("recvWindow", param_value.to_string());
624 }
625 multipart_form_params.insert("targetAsset", params.target_asset.to_string());
626 multipart_form_params.insert("timestamp", params.timestamp.to_string());
627 req_builder = req_builder.form(&multipart_form_params);
628
629 let req = req_builder.build()?;
630 let resp = configuration.client.execute(req).await?;
631
632 let status = resp.status();
633 let content_type = resp
634 .headers()
635 .get("content-type")
636 .and_then(|v| v.to_str().ok())
637 .unwrap_or("application/octet-stream");
638 let content_type = super::ContentType::from(content_type);
639
640 if !status.is_client_error() && !status.is_server_error() {
641 let content = resp.text().await?;
642 match content_type {
643 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
644 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePortfolioMintV1Resp`"))),
645 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::CreatePortfolioMintV1Resp`")))),
646 }
647 } else {
648 let content = resp.text().await?;
649 let entity: Option<CreatePortfolioMintV1Error> = serde_json::from_str(&content).ok();
650 Err(Error::ResponseError(ResponseContent { status, content, entity }))
651 }
652}
653
654pub async fn create_portfolio_redeem_v1(configuration: &configuration::Configuration, params: CreatePortfolioRedeemV1Params) -> Result<models::CreatePortfolioRedeemV1Resp, Error<CreatePortfolioRedeemV1Error>> {
656
657 let uri_str = format!("{}/sapi/v1/portfolio/redeem", configuration.base_path);
658 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
659
660 let mut query_params: Vec<(String, String)> = Vec::new();
662
663
664 let mut header_params = std::collections::HashMap::new();
666
667 if let Some(ref binance_auth) = configuration.binance_auth {
669 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
671
672 let body_string: Option<Vec<u8>> = None;
674
675 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
677 Ok(sig) => sig,
678 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
679 };
680
681 query_params.push(("signature".to_string(), signature));
683 }
684
685 if !query_params.is_empty() {
687 req_builder = req_builder.query(&query_params);
688 }
689
690
691 if let Some(ref user_agent) = configuration.user_agent {
693 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
694 }
695
696 for (header_name, header_value) in header_params {
698 req_builder = req_builder.header(&header_name, &header_value);
699 }
700
701 let mut multipart_form_params = std::collections::HashMap::new();
702 multipart_form_params.insert("amount", params.amount.to_string());
703 multipart_form_params.insert("fromAsset", params.from_asset.to_string());
704 if let Some(param_value) = params.recv_window {
705 multipart_form_params.insert("recvWindow", param_value.to_string());
706 }
707 multipart_form_params.insert("targetAsset", params.target_asset.to_string());
708 multipart_form_params.insert("timestamp", params.timestamp.to_string());
709 req_builder = req_builder.form(&multipart_form_params);
710
711 let req = req_builder.build()?;
712 let resp = configuration.client.execute(req).await?;
713
714 let status = resp.status();
715 let content_type = resp
716 .headers()
717 .get("content-type")
718 .and_then(|v| v.to_str().ok())
719 .unwrap_or("application/octet-stream");
720 let content_type = super::ContentType::from(content_type);
721
722 if !status.is_client_error() && !status.is_server_error() {
723 let content = resp.text().await?;
724 match content_type {
725 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
726 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePortfolioRedeemV1Resp`"))),
727 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::CreatePortfolioRedeemV1Resp`")))),
728 }
729 } else {
730 let content = resp.text().await?;
731 let entity: Option<CreatePortfolioRedeemV1Error> = serde_json::from_str(&content).ok();
732 Err(Error::ResponseError(ResponseContent { status, content, entity }))
733 }
734}
735
736pub async fn create_portfolio_repay_futures_negative_balance_v1(configuration: &configuration::Configuration, params: CreatePortfolioRepayFuturesNegativeBalanceV1Params) -> Result<models::CreatePortfolioRepayFuturesNegativeBalanceV1Resp, Error<CreatePortfolioRepayFuturesNegativeBalanceV1Error>> {
738
739 let uri_str = format!("{}/sapi/v1/portfolio/repay-futures-negative-balance", configuration.base_path);
740 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
741
742 let mut query_params: Vec<(String, String)> = Vec::new();
744
745
746 let mut header_params = std::collections::HashMap::new();
748
749 if let Some(ref binance_auth) = configuration.binance_auth {
751 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
753
754 let body_string: Option<Vec<u8>> = None;
756
757 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
759 Ok(sig) => sig,
760 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
761 };
762
763 query_params.push(("signature".to_string(), signature));
765 }
766
767 if !query_params.is_empty() {
769 req_builder = req_builder.query(&query_params);
770 }
771
772
773 if let Some(ref user_agent) = configuration.user_agent {
775 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
776 }
777
778 for (header_name, header_value) in header_params {
780 req_builder = req_builder.header(&header_name, &header_value);
781 }
782
783 let mut multipart_form_params = std::collections::HashMap::new();
784 if let Some(param_value) = params.from {
785 multipart_form_params.insert("from", param_value.to_string());
786 }
787 if let Some(param_value) = params.recv_window {
788 multipart_form_params.insert("recvWindow", param_value.to_string());
789 }
790 multipart_form_params.insert("timestamp", params.timestamp.to_string());
791 req_builder = req_builder.form(&multipart_form_params);
792
793 let req = req_builder.build()?;
794 let resp = configuration.client.execute(req).await?;
795
796 let status = resp.status();
797 let content_type = resp
798 .headers()
799 .get("content-type")
800 .and_then(|v| v.to_str().ok())
801 .unwrap_or("application/octet-stream");
802 let content_type = super::ContentType::from(content_type);
803
804 if !status.is_client_error() && !status.is_server_error() {
805 let content = resp.text().await?;
806 match content_type {
807 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
808 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePortfolioRepayFuturesNegativeBalanceV1Resp`"))),
809 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::CreatePortfolioRepayFuturesNegativeBalanceV1Resp`")))),
810 }
811 } else {
812 let content = resp.text().await?;
813 let entity: Option<CreatePortfolioRepayFuturesNegativeBalanceV1Error> = serde_json::from_str(&content).ok();
814 Err(Error::ResponseError(ResponseContent { status, content, entity }))
815 }
816}
817
818pub async fn create_portfolio_repay_futures_switch_v1(configuration: &configuration::Configuration, params: CreatePortfolioRepayFuturesSwitchV1Params) -> Result<models::CreatePortfolioRepayFuturesSwitchV1Resp, Error<CreatePortfolioRepayFuturesSwitchV1Error>> {
820
821 let uri_str = format!("{}/sapi/v1/portfolio/repay-futures-switch", configuration.base_path);
822 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
823
824 let mut query_params: Vec<(String, String)> = Vec::new();
826
827
828 let mut header_params = std::collections::HashMap::new();
830
831 if let Some(ref binance_auth) = configuration.binance_auth {
833 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
835
836 let body_string: Option<Vec<u8>> = None;
838
839 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
841 Ok(sig) => sig,
842 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
843 };
844
845 query_params.push(("signature".to_string(), signature));
847 }
848
849 if !query_params.is_empty() {
851 req_builder = req_builder.query(&query_params);
852 }
853
854
855 if let Some(ref user_agent) = configuration.user_agent {
857 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
858 }
859
860 for (header_name, header_value) in header_params {
862 req_builder = req_builder.header(&header_name, &header_value);
863 }
864
865 let mut multipart_form_params = std::collections::HashMap::new();
866 multipart_form_params.insert("autoRepay", params.auto_repay.to_string());
867 if let Some(param_value) = params.recv_window {
868 multipart_form_params.insert("recvWindow", param_value.to_string());
869 }
870 multipart_form_params.insert("timestamp", params.timestamp.to_string());
871 req_builder = req_builder.form(&multipart_form_params);
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::CreatePortfolioRepayFuturesSwitchV1Resp`"))),
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::CreatePortfolioRepayFuturesSwitchV1Resp`")))),
890 }
891 } else {
892 let content = resp.text().await?;
893 let entity: Option<CreatePortfolioRepayFuturesSwitchV1Error> = serde_json::from_str(&content).ok();
894 Err(Error::ResponseError(ResponseContent { status, content, entity }))
895 }
896}
897
898pub async fn create_portfolio_repay_v1(configuration: &configuration::Configuration, params: CreatePortfolioRepayV1Params) -> Result<models::CreatePortfolioRepayV1Resp, Error<CreatePortfolioRepayV1Error>> {
900
901 let uri_str = format!("{}/sapi/v1/portfolio/repay", configuration.base_path);
902 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
903
904 let mut query_params: Vec<(String, String)> = Vec::new();
906
907
908 let mut header_params = std::collections::HashMap::new();
910
911 if let Some(ref binance_auth) = configuration.binance_auth {
913 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
915
916 let body_string: Option<Vec<u8>> = None;
918
919 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
921 Ok(sig) => sig,
922 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
923 };
924
925 query_params.push(("signature".to_string(), signature));
927 }
928
929 if !query_params.is_empty() {
931 req_builder = req_builder.query(&query_params);
932 }
933
934
935 if let Some(ref user_agent) = configuration.user_agent {
937 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
938 }
939
940 for (header_name, header_value) in header_params {
942 req_builder = req_builder.header(&header_name, &header_value);
943 }
944
945 let mut multipart_form_params = std::collections::HashMap::new();
946 if let Some(param_value) = params.from {
947 multipart_form_params.insert("from", param_value.to_string());
948 }
949 if let Some(param_value) = params.recv_window {
950 multipart_form_params.insert("recvWindow", param_value.to_string());
951 }
952 multipart_form_params.insert("timestamp", params.timestamp.to_string());
953 req_builder = req_builder.form(&multipart_form_params);
954
955 let req = req_builder.build()?;
956 let resp = configuration.client.execute(req).await?;
957
958 let status = resp.status();
959 let content_type = resp
960 .headers()
961 .get("content-type")
962 .and_then(|v| v.to_str().ok())
963 .unwrap_or("application/octet-stream");
964 let content_type = super::ContentType::from(content_type);
965
966 if !status.is_client_error() && !status.is_server_error() {
967 let content = resp.text().await?;
968 match content_type {
969 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
970 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePortfolioRepayV1Resp`"))),
971 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::CreatePortfolioRepayV1Resp`")))),
972 }
973 } else {
974 let content = resp.text().await?;
975 let entity: Option<CreatePortfolioRepayV1Error> = serde_json::from_str(&content).ok();
976 Err(Error::ResponseError(ResponseContent { status, content, entity }))
977 }
978}
979
980pub async fn get_portfolio_account_v1(configuration: &configuration::Configuration, params: GetPortfolioAccountV1Params) -> Result<models::GetPortfolioAccountV1Resp, Error<GetPortfolioAccountV1Error>> {
982
983 let uri_str = format!("{}/sapi/v1/portfolio/account", configuration.base_path);
984 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
985
986 let mut query_params: Vec<(String, String)> = Vec::new();
988
989 if let Some(ref param_value) = params.recv_window {
990 query_params.push(("recvWindow".to_string(), param_value.to_string()));
991 }
992 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
993
994 let mut header_params = std::collections::HashMap::new();
996
997 if let Some(ref binance_auth) = configuration.binance_auth {
999 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1001
1002 let body_string: Option<Vec<u8>> = None;
1004
1005 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1007 Ok(sig) => sig,
1008 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1009 };
1010
1011 query_params.push(("signature".to_string(), signature));
1013 }
1014
1015 if !query_params.is_empty() {
1017 req_builder = req_builder.query(&query_params);
1018 }
1019
1020
1021 if let Some(ref user_agent) = configuration.user_agent {
1023 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1024 }
1025
1026 for (header_name, header_value) in header_params {
1028 req_builder = req_builder.header(&header_name, &header_value);
1029 }
1030
1031
1032 let req = req_builder.build()?;
1033 let resp = configuration.client.execute(req).await?;
1034
1035 let status = resp.status();
1036 let content_type = resp
1037 .headers()
1038 .get("content-type")
1039 .and_then(|v| v.to_str().ok())
1040 .unwrap_or("application/octet-stream");
1041 let content_type = super::ContentType::from(content_type);
1042
1043 if !status.is_client_error() && !status.is_server_error() {
1044 let content = resp.text().await?;
1045 match content_type {
1046 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1047 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPortfolioAccountV1Resp`"))),
1048 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::GetPortfolioAccountV1Resp`")))),
1049 }
1050 } else {
1051 let content = resp.text().await?;
1052 let entity: Option<GetPortfolioAccountV1Error> = serde_json::from_str(&content).ok();
1053 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1054 }
1055}
1056
1057pub async fn get_portfolio_account_v2(configuration: &configuration::Configuration, params: GetPortfolioAccountV2Params) -> Result<(), Error<GetPortfolioAccountV2Error>> {
1059
1060 let uri_str = format!("{}/sapi/v2/portfolio/account", configuration.base_path);
1061 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1062
1063 let mut query_params: Vec<(String, String)> = Vec::new();
1065
1066 if let Some(ref param_value) = params.recv_window {
1067 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1068 }
1069 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1070
1071 let mut header_params = std::collections::HashMap::new();
1073
1074 if let Some(ref binance_auth) = configuration.binance_auth {
1076 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1078
1079 let body_string: Option<Vec<u8>> = None;
1081
1082 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1084 Ok(sig) => sig,
1085 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1086 };
1087
1088 query_params.push(("signature".to_string(), signature));
1090 }
1091
1092 if !query_params.is_empty() {
1094 req_builder = req_builder.query(&query_params);
1095 }
1096
1097
1098 if let Some(ref user_agent) = configuration.user_agent {
1100 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1101 }
1102
1103 for (header_name, header_value) in header_params {
1105 req_builder = req_builder.header(&header_name, &header_value);
1106 }
1107
1108
1109 let req = req_builder.build()?;
1110 let resp = configuration.client.execute(req).await?;
1111
1112 let status = resp.status();
1113
1114 if !status.is_client_error() && !status.is_server_error() {
1115 Ok(())
1116 } else {
1117 let content = resp.text().await?;
1118 let entity: Option<GetPortfolioAccountV2Error> = serde_json::from_str(&content).ok();
1119 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1120 }
1121}
1122
1123pub async fn get_portfolio_asset_index_price_v1(configuration: &configuration::Configuration, params: GetPortfolioAssetIndexPriceV1Params) -> Result<Vec<models::GetPortfolioAssetIndexPriceV1RespItem>, Error<GetPortfolioAssetIndexPriceV1Error>> {
1125
1126 let uri_str = format!("{}/sapi/v1/portfolio/asset-index-price", configuration.base_path);
1127 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1128
1129 let mut query_params: Vec<(String, String)> = Vec::new();
1131
1132 if let Some(ref param_value) = params.asset {
1133 query_params.push(("asset".to_string(), param_value.to_string()));
1134 }
1135
1136 let mut header_params = std::collections::HashMap::new();
1138
1139 if let Some(ref binance_auth) = configuration.binance_auth {
1141 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1143
1144 let body_string: Option<Vec<u8>> = None;
1146
1147 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1149 Ok(sig) => sig,
1150 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1151 };
1152
1153 query_params.push(("signature".to_string(), signature));
1155 }
1156
1157 if !query_params.is_empty() {
1159 req_builder = req_builder.query(&query_params);
1160 }
1161
1162
1163 if let Some(ref user_agent) = configuration.user_agent {
1165 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1166 }
1167
1168 for (header_name, header_value) in header_params {
1170 req_builder = req_builder.header(&header_name, &header_value);
1171 }
1172
1173
1174 let req = req_builder.build()?;
1175 let resp = configuration.client.execute(req).await?;
1176
1177 let status = resp.status();
1178 let content_type = resp
1179 .headers()
1180 .get("content-type")
1181 .and_then(|v| v.to_str().ok())
1182 .unwrap_or("application/octet-stream");
1183 let content_type = super::ContentType::from(content_type);
1184
1185 if !status.is_client_error() && !status.is_server_error() {
1186 let content = resp.text().await?;
1187 match content_type {
1188 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1189 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPortfolioAssetIndexPriceV1RespItem>`"))),
1190 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::GetPortfolioAssetIndexPriceV1RespItem>`")))),
1191 }
1192 } else {
1193 let content = resp.text().await?;
1194 let entity: Option<GetPortfolioAssetIndexPriceV1Error> = serde_json::from_str(&content).ok();
1195 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1196 }
1197}
1198
1199pub async fn get_portfolio_balance_v1(configuration: &configuration::Configuration, params: GetPortfolioBalanceV1Params) -> Result<Vec<models::GetPortfolioBalanceV1RespItem>, Error<GetPortfolioBalanceV1Error>> {
1201
1202 let uri_str = format!("{}/sapi/v1/portfolio/balance", configuration.base_path);
1203 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1204
1205 let mut query_params: Vec<(String, String)> = Vec::new();
1207
1208 if let Some(ref param_value) = params.asset {
1209 query_params.push(("asset".to_string(), param_value.to_string()));
1210 }
1211 if let Some(ref param_value) = params.recv_window {
1212 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1213 }
1214 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1215
1216 let mut header_params = std::collections::HashMap::new();
1218
1219 if let Some(ref binance_auth) = configuration.binance_auth {
1221 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1223
1224 let body_string: Option<Vec<u8>> = None;
1226
1227 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1229 Ok(sig) => sig,
1230 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1231 };
1232
1233 query_params.push(("signature".to_string(), signature));
1235 }
1236
1237 if !query_params.is_empty() {
1239 req_builder = req_builder.query(&query_params);
1240 }
1241
1242
1243 if let Some(ref user_agent) = configuration.user_agent {
1245 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1246 }
1247
1248 for (header_name, header_value) in header_params {
1250 req_builder = req_builder.header(&header_name, &header_value);
1251 }
1252
1253
1254 let req = req_builder.build()?;
1255 let resp = configuration.client.execute(req).await?;
1256
1257 let status = resp.status();
1258 let content_type = resp
1259 .headers()
1260 .get("content-type")
1261 .and_then(|v| v.to_str().ok())
1262 .unwrap_or("application/octet-stream");
1263 let content_type = super::ContentType::from(content_type);
1264
1265 if !status.is_client_error() && !status.is_server_error() {
1266 let content = resp.text().await?;
1267 match content_type {
1268 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1269 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPortfolioBalanceV1RespItem>`"))),
1270 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::GetPortfolioBalanceV1RespItem>`")))),
1271 }
1272 } else {
1273 let content = resp.text().await?;
1274 let entity: Option<GetPortfolioBalanceV1Error> = serde_json::from_str(&content).ok();
1275 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1276 }
1277}
1278
1279pub async fn get_portfolio_collateral_rate_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetPortfolioCollateralRateV1RespItem>, Error<GetPortfolioCollateralRateV1Error>> {
1281
1282 let uri_str = format!("{}/sapi/v1/portfolio/collateralRate", configuration.base_path);
1283 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1284
1285 let mut query_params: Vec<(String, String)> = Vec::new();
1287
1288
1289 let mut header_params = std::collections::HashMap::new();
1291
1292 if let Some(ref binance_auth) = configuration.binance_auth {
1294 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1296
1297 let body_string: Option<Vec<u8>> = None;
1299
1300 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1302 Ok(sig) => sig,
1303 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1304 };
1305
1306 query_params.push(("signature".to_string(), signature));
1308 }
1309
1310 if !query_params.is_empty() {
1312 req_builder = req_builder.query(&query_params);
1313 }
1314
1315
1316 if let Some(ref user_agent) = configuration.user_agent {
1318 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1319 }
1320
1321 for (header_name, header_value) in header_params {
1323 req_builder = req_builder.header(&header_name, &header_value);
1324 }
1325
1326
1327 let req = req_builder.build()?;
1328 let resp = configuration.client.execute(req).await?;
1329
1330 let status = resp.status();
1331 let content_type = resp
1332 .headers()
1333 .get("content-type")
1334 .and_then(|v| v.to_str().ok())
1335 .unwrap_or("application/octet-stream");
1336 let content_type = super::ContentType::from(content_type);
1337
1338 if !status.is_client_error() && !status.is_server_error() {
1339 let content = resp.text().await?;
1340 match content_type {
1341 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1342 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPortfolioCollateralRateV1RespItem>`"))),
1343 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::GetPortfolioCollateralRateV1RespItem>`")))),
1344 }
1345 } else {
1346 let content = resp.text().await?;
1347 let entity: Option<GetPortfolioCollateralRateV1Error> = serde_json::from_str(&content).ok();
1348 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1349 }
1350}
1351
1352pub async fn get_portfolio_collateral_rate_v2(configuration: &configuration::Configuration, params: GetPortfolioCollateralRateV2Params) -> Result<Vec<models::GetPortfolioCollateralRateV2RespItem>, Error<GetPortfolioCollateralRateV2Error>> {
1354
1355 let uri_str = format!("{}/sapi/v2/portfolio/collateralRate", configuration.base_path);
1356 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1357
1358 let mut query_params: Vec<(String, String)> = Vec::new();
1360
1361 if let Some(ref param_value) = params.recv_window {
1362 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1363 }
1364 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1365
1366 let mut header_params = std::collections::HashMap::new();
1368
1369 if let Some(ref binance_auth) = configuration.binance_auth {
1371 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1373
1374 let body_string: Option<Vec<u8>> = None;
1376
1377 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1379 Ok(sig) => sig,
1380 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1381 };
1382
1383 query_params.push(("signature".to_string(), signature));
1385 }
1386
1387 if !query_params.is_empty() {
1389 req_builder = req_builder.query(&query_params);
1390 }
1391
1392
1393 if let Some(ref user_agent) = configuration.user_agent {
1395 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1396 }
1397
1398 for (header_name, header_value) in header_params {
1400 req_builder = req_builder.header(&header_name, &header_value);
1401 }
1402
1403
1404 let req = req_builder.build()?;
1405 let resp = configuration.client.execute(req).await?;
1406
1407 let status = resp.status();
1408 let content_type = resp
1409 .headers()
1410 .get("content-type")
1411 .and_then(|v| v.to_str().ok())
1412 .unwrap_or("application/octet-stream");
1413 let content_type = super::ContentType::from(content_type);
1414
1415 if !status.is_client_error() && !status.is_server_error() {
1416 let content = resp.text().await?;
1417 match content_type {
1418 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1419 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPortfolioCollateralRateV2RespItem>`"))),
1420 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::GetPortfolioCollateralRateV2RespItem>`")))),
1421 }
1422 } else {
1423 let content = resp.text().await?;
1424 let entity: Option<GetPortfolioCollateralRateV2Error> = serde_json::from_str(&content).ok();
1425 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1426 }
1427}
1428
1429pub async fn get_portfolio_interest_history_v1(configuration: &configuration::Configuration, params: GetPortfolioInterestHistoryV1Params) -> Result<Vec<models::GetPortfolioInterestHistoryV1RespItem>, Error<GetPortfolioInterestHistoryV1Error>> {
1431
1432 let uri_str = format!("{}/sapi/v1/portfolio/interest-history", configuration.base_path);
1433 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1434
1435 let mut query_params: Vec<(String, String)> = Vec::new();
1437
1438 if let Some(ref param_value) = params.asset {
1439 query_params.push(("asset".to_string(), param_value.to_string()));
1440 }
1441 if let Some(ref param_value) = params.start_time {
1442 query_params.push(("startTime".to_string(), param_value.to_string()));
1443 }
1444 if let Some(ref param_value) = params.end_time {
1445 query_params.push(("endTime".to_string(), param_value.to_string()));
1446 }
1447 if let Some(ref param_value) = params.size {
1448 query_params.push(("size".to_string(), param_value.to_string()));
1449 }
1450 if let Some(ref param_value) = params.recv_window {
1451 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1452 }
1453 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1454
1455 let mut header_params = std::collections::HashMap::new();
1457
1458 if let Some(ref binance_auth) = configuration.binance_auth {
1460 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1462
1463 let body_string: Option<Vec<u8>> = None;
1465
1466 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1468 Ok(sig) => sig,
1469 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1470 };
1471
1472 query_params.push(("signature".to_string(), signature));
1474 }
1475
1476 if !query_params.is_empty() {
1478 req_builder = req_builder.query(&query_params);
1479 }
1480
1481
1482 if let Some(ref user_agent) = configuration.user_agent {
1484 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1485 }
1486
1487 for (header_name, header_value) in header_params {
1489 req_builder = req_builder.header(&header_name, &header_value);
1490 }
1491
1492
1493 let req = req_builder.build()?;
1494 let resp = configuration.client.execute(req).await?;
1495
1496 let status = resp.status();
1497 let content_type = resp
1498 .headers()
1499 .get("content-type")
1500 .and_then(|v| v.to_str().ok())
1501 .unwrap_or("application/octet-stream");
1502 let content_type = super::ContentType::from(content_type);
1503
1504 if !status.is_client_error() && !status.is_server_error() {
1505 let content = resp.text().await?;
1506 match content_type {
1507 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1508 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPortfolioInterestHistoryV1RespItem>`"))),
1509 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::GetPortfolioInterestHistoryV1RespItem>`")))),
1510 }
1511 } else {
1512 let content = resp.text().await?;
1513 let entity: Option<GetPortfolioInterestHistoryV1Error> = serde_json::from_str(&content).ok();
1514 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1515 }
1516}
1517
1518pub async fn get_portfolio_margin_asset_leverage_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetPortfolioMarginAssetLeverageV1RespItem>, Error<GetPortfolioMarginAssetLeverageV1Error>> {
1520
1521 let uri_str = format!("{}/sapi/v1/portfolio/margin-asset-leverage", configuration.base_path);
1522 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1523
1524 let mut query_params: Vec<(String, String)> = Vec::new();
1526
1527
1528 let mut header_params = std::collections::HashMap::new();
1530
1531 if let Some(ref binance_auth) = configuration.binance_auth {
1533 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1535
1536 let body_string: Option<Vec<u8>> = None;
1538
1539 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1541 Ok(sig) => sig,
1542 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1543 };
1544
1545 query_params.push(("signature".to_string(), signature));
1547 }
1548
1549 if !query_params.is_empty() {
1551 req_builder = req_builder.query(&query_params);
1552 }
1553
1554
1555 if let Some(ref user_agent) = configuration.user_agent {
1557 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1558 }
1559
1560 for (header_name, header_value) in header_params {
1562 req_builder = req_builder.header(&header_name, &header_value);
1563 }
1564
1565
1566 let req = req_builder.build()?;
1567 let resp = configuration.client.execute(req).await?;
1568
1569 let status = resp.status();
1570 let content_type = resp
1571 .headers()
1572 .get("content-type")
1573 .and_then(|v| v.to_str().ok())
1574 .unwrap_or("application/octet-stream");
1575 let content_type = super::ContentType::from(content_type);
1576
1577 if !status.is_client_error() && !status.is_server_error() {
1578 let content = resp.text().await?;
1579 match content_type {
1580 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1581 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPortfolioMarginAssetLeverageV1RespItem>`"))),
1582 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::GetPortfolioMarginAssetLeverageV1RespItem>`")))),
1583 }
1584 } else {
1585 let content = resp.text().await?;
1586 let entity: Option<GetPortfolioMarginAssetLeverageV1Error> = serde_json::from_str(&content).ok();
1587 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1588 }
1589}
1590
1591pub async fn get_portfolio_pm_loan_history_v1(configuration: &configuration::Configuration, params: GetPortfolioPmLoanHistoryV1Params) -> Result<models::GetPortfolioPmLoanHistoryV1Resp, Error<GetPortfolioPmLoanHistoryV1Error>> {
1593
1594 let uri_str = format!("{}/sapi/v1/portfolio/pmLoan-history", configuration.base_path);
1595 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1596
1597 let mut query_params: Vec<(String, String)> = Vec::new();
1599
1600 if let Some(ref param_value) = params.start_time {
1601 query_params.push(("startTime".to_string(), param_value.to_string()));
1602 }
1603 if let Some(ref param_value) = params.end_time {
1604 query_params.push(("endTime".to_string(), param_value.to_string()));
1605 }
1606 if let Some(ref param_value) = params.current {
1607 query_params.push(("current".to_string(), param_value.to_string()));
1608 }
1609 if let Some(ref param_value) = params.size {
1610 query_params.push(("size".to_string(), param_value.to_string()));
1611 }
1612 if let Some(ref param_value) = params.recv_window {
1613 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1614 }
1615 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1616
1617 let mut header_params = std::collections::HashMap::new();
1619
1620 if let Some(ref binance_auth) = configuration.binance_auth {
1622 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1624
1625 let body_string: Option<Vec<u8>> = None;
1627
1628 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1630 Ok(sig) => sig,
1631 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1632 };
1633
1634 query_params.push(("signature".to_string(), signature));
1636 }
1637
1638 if !query_params.is_empty() {
1640 req_builder = req_builder.query(&query_params);
1641 }
1642
1643
1644 if let Some(ref user_agent) = configuration.user_agent {
1646 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1647 }
1648
1649 for (header_name, header_value) in header_params {
1651 req_builder = req_builder.header(&header_name, &header_value);
1652 }
1653
1654
1655 let req = req_builder.build()?;
1656 let resp = configuration.client.execute(req).await?;
1657
1658 let status = resp.status();
1659 let content_type = resp
1660 .headers()
1661 .get("content-type")
1662 .and_then(|v| v.to_str().ok())
1663 .unwrap_or("application/octet-stream");
1664 let content_type = super::ContentType::from(content_type);
1665
1666 if !status.is_client_error() && !status.is_server_error() {
1667 let content = resp.text().await?;
1668 match content_type {
1669 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1670 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPortfolioPmLoanHistoryV1Resp`"))),
1671 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::GetPortfolioPmLoanHistoryV1Resp`")))),
1672 }
1673 } else {
1674 let content = resp.text().await?;
1675 let entity: Option<GetPortfolioPmLoanHistoryV1Error> = serde_json::from_str(&content).ok();
1676 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1677 }
1678}
1679
1680pub async fn get_portfolio_pm_loan_v1(configuration: &configuration::Configuration, params: GetPortfolioPmLoanV1Params) -> Result<models::GetPortfolioPmLoanV1Resp, Error<GetPortfolioPmLoanV1Error>> {
1682
1683 let uri_str = format!("{}/sapi/v1/portfolio/pmLoan", configuration.base_path);
1684 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1685
1686 let mut query_params: Vec<(String, String)> = Vec::new();
1688
1689 if let Some(ref param_value) = params.recv_window {
1690 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1691 }
1692 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1693
1694 let mut header_params = std::collections::HashMap::new();
1696
1697 if let Some(ref binance_auth) = configuration.binance_auth {
1699 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1701
1702 let body_string: Option<Vec<u8>> = None;
1704
1705 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1707 Ok(sig) => sig,
1708 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1709 };
1710
1711 query_params.push(("signature".to_string(), signature));
1713 }
1714
1715 if !query_params.is_empty() {
1717 req_builder = req_builder.query(&query_params);
1718 }
1719
1720
1721 if let Some(ref user_agent) = configuration.user_agent {
1723 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1724 }
1725
1726 for (header_name, header_value) in header_params {
1728 req_builder = req_builder.header(&header_name, &header_value);
1729 }
1730
1731
1732 let req = req_builder.build()?;
1733 let resp = configuration.client.execute(req).await?;
1734
1735 let status = resp.status();
1736 let content_type = resp
1737 .headers()
1738 .get("content-type")
1739 .and_then(|v| v.to_str().ok())
1740 .unwrap_or("application/octet-stream");
1741 let content_type = super::ContentType::from(content_type);
1742
1743 if !status.is_client_error() && !status.is_server_error() {
1744 let content = resp.text().await?;
1745 match content_type {
1746 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1747 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPortfolioPmLoanV1Resp`"))),
1748 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::GetPortfolioPmLoanV1Resp`")))),
1749 }
1750 } else {
1751 let content = resp.text().await?;
1752 let entity: Option<GetPortfolioPmLoanV1Error> = serde_json::from_str(&content).ok();
1753 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1754 }
1755}
1756
1757pub async fn get_portfolio_repay_futures_switch_v1(configuration: &configuration::Configuration, params: GetPortfolioRepayFuturesSwitchV1Params) -> Result<models::GetPortfolioRepayFuturesSwitchV1Resp, Error<GetPortfolioRepayFuturesSwitchV1Error>> {
1759
1760 let uri_str = format!("{}/sapi/v1/portfolio/repay-futures-switch", configuration.base_path);
1761 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1762
1763 let mut query_params: Vec<(String, String)> = Vec::new();
1765
1766 if let Some(ref param_value) = params.recv_window {
1767 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1768 }
1769 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1770
1771 let mut header_params = std::collections::HashMap::new();
1773
1774 if let Some(ref binance_auth) = configuration.binance_auth {
1776 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1778
1779 let body_string: Option<Vec<u8>> = None;
1781
1782 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1784 Ok(sig) => sig,
1785 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1786 };
1787
1788 query_params.push(("signature".to_string(), signature));
1790 }
1791
1792 if !query_params.is_empty() {
1794 req_builder = req_builder.query(&query_params);
1795 }
1796
1797
1798 if let Some(ref user_agent) = configuration.user_agent {
1800 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1801 }
1802
1803 for (header_name, header_value) in header_params {
1805 req_builder = req_builder.header(&header_name, &header_value);
1806 }
1807
1808
1809 let req = req_builder.build()?;
1810 let resp = configuration.client.execute(req).await?;
1811
1812 let status = resp.status();
1813 let content_type = resp
1814 .headers()
1815 .get("content-type")
1816 .and_then(|v| v.to_str().ok())
1817 .unwrap_or("application/octet-stream");
1818 let content_type = super::ContentType::from(content_type);
1819
1820 if !status.is_client_error() && !status.is_server_error() {
1821 let content = resp.text().await?;
1822 match content_type {
1823 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1824 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPortfolioRepayFuturesSwitchV1Resp`"))),
1825 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::GetPortfolioRepayFuturesSwitchV1Resp`")))),
1826 }
1827 } else {
1828 let content = resp.text().await?;
1829 let entity: Option<GetPortfolioRepayFuturesSwitchV1Error> = serde_json::from_str(&content).ok();
1830 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1831 }
1832}
1833