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 CreateLoanVipRenewV1Params {
20 pub loan_term: i32,
21 pub order_id: i64,
22 pub timestamp: i64,
23 pub recv_window: Option<i64>
24}
25
26#[derive(Clone, Debug, Default)]
28pub struct CreateLoanVipRepayV1Params {
29 pub amount: String,
30 pub order_id: i64,
31 pub timestamp: i64,
32 pub recv_window: Option<i64>
33}
34
35#[derive(Clone, Debug, Default)]
37pub struct GetLoanVipAccruedInterestV1Params {
38 pub recv_window: i64,
39 pub timestamp: i64,
40 pub order_id: Option<i64>,
41 pub loan_coin: Option<String>,
42 pub start_time: Option<i64>,
43 pub end_time: Option<i64>,
44 pub current: Option<i64>,
46 pub limit: Option<i64>
48}
49
50#[derive(Clone, Debug, Default)]
52pub struct GetLoanVipCollateralAccountV1Params {
53 pub timestamp: i64,
54 pub order_id: Option<i64>,
55 pub collateral_account_id: Option<i64>,
56 pub recv_window: Option<i64>
57}
58
59#[derive(Clone, Debug, Default)]
61pub struct GetLoanVipCollateralDataV1Params {
62 pub timestamp: i64,
63 pub collateral_coin: Option<String>,
64 pub recv_window: Option<i64>
65}
66
67#[derive(Clone, Debug, Default)]
69pub struct GetLoanVipInterestRateHistoryV1Params {
70 pub coin: String,
71 pub recv_window: i64,
72 pub timestamp: i64,
73 pub start_time: Option<i64>,
74 pub end_time: Option<i64>,
75 pub current: Option<i64>,
77 pub limit: Option<i64>
79}
80
81#[derive(Clone, Debug, Default)]
83pub struct GetLoanVipLoanableDataV1Params {
84 pub timestamp: i64,
85 pub loan_coin: Option<String>,
86 pub vip_level: Option<i32>,
88 pub recv_window: Option<i64>
89}
90
91#[derive(Clone, Debug, Default)]
93pub struct GetLoanVipOngoingOrdersV1Params {
94 pub timestamp: i64,
95 pub order_id: Option<i64>,
96 pub collateral_account_id: Option<i64>,
97 pub loan_coin: Option<String>,
98 pub collateral_coin: Option<String>,
99 pub current: Option<i64>,
101 pub limit: Option<i64>,
103 pub recv_window: Option<i64>
104}
105
106#[derive(Clone, Debug, Default)]
108pub struct GetLoanVipRepayHistoryV1Params {
109 pub timestamp: i64,
110 pub order_id: Option<i64>,
111 pub loan_coin: Option<String>,
112 pub start_time: Option<i64>,
113 pub end_time: Option<i64>,
114 pub current: Option<i64>,
116 pub limit: Option<i64>,
118 pub recv_window: Option<i64>
119}
120
121#[derive(Clone, Debug, Default)]
123pub struct GetLoanVipRequestDataV1Params {
124 pub timestamp: i64,
125 pub current: Option<i64>,
127 pub limit: Option<i64>,
129 pub recv_window: Option<i64>
130}
131
132#[derive(Clone, Debug, Default)]
134pub struct GetLoanVipRequestInterestRateV1Params {
135 pub loan_coin: String,
137 pub timestamp: i64,
138 pub recv_window: Option<i64>
139}
140
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(untagged)]
145pub enum CreateLoanVipBorrowV1Error {
146 Status4XX(models::ApiError),
147 Status5XX(models::ApiError),
148 UnknownValue(serde_json::Value),
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum CreateLoanVipRenewV1Error {
155 Status4XX(models::ApiError),
156 Status5XX(models::ApiError),
157 UnknownValue(serde_json::Value),
158}
159
160#[derive(Debug, Clone, Serialize, Deserialize)]
162#[serde(untagged)]
163pub enum CreateLoanVipRepayV1Error {
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 GetLoanVipAccruedInterestV1Error {
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 GetLoanVipCollateralAccountV1Error {
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 GetLoanVipCollateralDataV1Error {
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 GetLoanVipInterestRateHistoryV1Error {
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 GetLoanVipLoanableDataV1Error {
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 GetLoanVipOngoingOrdersV1Error {
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 GetLoanVipRepayHistoryV1Error {
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 GetLoanVipRequestDataV1Error {
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 GetLoanVipRequestInterestRateV1Error {
245 Status4XX(models::ApiError),
246 Status5XX(models::ApiError),
247 UnknownValue(serde_json::Value),
248}
249
250
251pub async fn create_loan_vip_borrow_v1(configuration: &configuration::Configuration) -> Result<models::CreateLoanVipBorrowV1Resp, Error<CreateLoanVipBorrowV1Error>> {
253
254 let uri_str = format!("{}/sapi/v1/loan/vip/borrow", configuration.base_path);
255 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
256
257 let mut query_params: Vec<(String, String)> = Vec::new();
259
260
261 let mut header_params = std::collections::HashMap::new();
263
264 if let Some(ref binance_auth) = configuration.binance_auth {
266 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
268
269 let body_string: Option<Vec<u8>> = None;
271
272 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
274 Ok(sig) => sig,
275 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
276 };
277
278 query_params.push(("signature".to_string(), signature));
280 }
281
282 if !query_params.is_empty() {
284 req_builder = req_builder.query(&query_params);
285 }
286
287
288 if let Some(ref user_agent) = configuration.user_agent {
290 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
291 }
292
293 for (header_name, header_value) in header_params {
295 req_builder = req_builder.header(&header_name, &header_value);
296 }
297
298
299 let req = req_builder.build()?;
300 let resp = configuration.client.execute(req).await?;
301
302 let status = resp.status();
303 let content_type = resp
304 .headers()
305 .get("content-type")
306 .and_then(|v| v.to_str().ok())
307 .unwrap_or("application/octet-stream");
308 let content_type = super::ContentType::from(content_type);
309
310 if !status.is_client_error() && !status.is_server_error() {
311 let content = resp.text().await?;
312 match content_type {
313 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
314 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateLoanVipBorrowV1Resp`"))),
315 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::CreateLoanVipBorrowV1Resp`")))),
316 }
317 } else {
318 let content = resp.text().await?;
319 let entity: Option<CreateLoanVipBorrowV1Error> = serde_json::from_str(&content).ok();
320 Err(Error::ResponseError(ResponseContent { status, content, entity }))
321 }
322}
323
324pub async fn create_loan_vip_renew_v1(configuration: &configuration::Configuration, params: CreateLoanVipRenewV1Params) -> Result<models::CreateLoanVipRenewV1Resp, Error<CreateLoanVipRenewV1Error>> {
326
327 let uri_str = format!("{}/sapi/v1/loan/vip/renew", configuration.base_path);
328 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
329
330 let mut query_params: Vec<(String, String)> = Vec::new();
332
333
334 let mut header_params = std::collections::HashMap::new();
336
337 if let Some(ref binance_auth) = configuration.binance_auth {
339 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
341
342 let body_string: Option<Vec<u8>> = None;
344
345 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
347 Ok(sig) => sig,
348 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
349 };
350
351 query_params.push(("signature".to_string(), signature));
353 }
354
355 if !query_params.is_empty() {
357 req_builder = req_builder.query(&query_params);
358 }
359
360
361 if let Some(ref user_agent) = configuration.user_agent {
363 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
364 }
365
366 for (header_name, header_value) in header_params {
368 req_builder = req_builder.header(&header_name, &header_value);
369 }
370
371 let mut multipart_form_params = std::collections::HashMap::new();
372 multipart_form_params.insert("loanTerm", params.loan_term.to_string());
373 multipart_form_params.insert("orderId", params.order_id.to_string());
374 if let Some(param_value) = params.recv_window {
375 multipart_form_params.insert("recvWindow", param_value.to_string());
376 }
377 multipart_form_params.insert("timestamp", params.timestamp.to_string());
378 req_builder = req_builder.form(&multipart_form_params);
379
380 let req = req_builder.build()?;
381 let resp = configuration.client.execute(req).await?;
382
383 let status = resp.status();
384 let content_type = resp
385 .headers()
386 .get("content-type")
387 .and_then(|v| v.to_str().ok())
388 .unwrap_or("application/octet-stream");
389 let content_type = super::ContentType::from(content_type);
390
391 if !status.is_client_error() && !status.is_server_error() {
392 let content = resp.text().await?;
393 match content_type {
394 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
395 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateLoanVipRenewV1Resp`"))),
396 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::CreateLoanVipRenewV1Resp`")))),
397 }
398 } else {
399 let content = resp.text().await?;
400 let entity: Option<CreateLoanVipRenewV1Error> = serde_json::from_str(&content).ok();
401 Err(Error::ResponseError(ResponseContent { status, content, entity }))
402 }
403}
404
405pub async fn create_loan_vip_repay_v1(configuration: &configuration::Configuration, params: CreateLoanVipRepayV1Params) -> Result<models::CreateLoanVipRepayV1Resp, Error<CreateLoanVipRepayV1Error>> {
407
408 let uri_str = format!("{}/sapi/v1/loan/vip/repay", configuration.base_path);
409 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
410
411 let mut query_params: Vec<(String, String)> = Vec::new();
413
414
415 let mut header_params = std::collections::HashMap::new();
417
418 if let Some(ref binance_auth) = configuration.binance_auth {
420 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
422
423 let body_string: Option<Vec<u8>> = None;
425
426 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
428 Ok(sig) => sig,
429 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
430 };
431
432 query_params.push(("signature".to_string(), signature));
434 }
435
436 if !query_params.is_empty() {
438 req_builder = req_builder.query(&query_params);
439 }
440
441
442 if let Some(ref user_agent) = configuration.user_agent {
444 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
445 }
446
447 for (header_name, header_value) in header_params {
449 req_builder = req_builder.header(&header_name, &header_value);
450 }
451
452 let mut multipart_form_params = std::collections::HashMap::new();
453 multipart_form_params.insert("amount", params.amount.to_string());
454 multipart_form_params.insert("orderId", params.order_id.to_string());
455 if let Some(param_value) = params.recv_window {
456 multipart_form_params.insert("recvWindow", param_value.to_string());
457 }
458 multipart_form_params.insert("timestamp", params.timestamp.to_string());
459 req_builder = req_builder.form(&multipart_form_params);
460
461 let req = req_builder.build()?;
462 let resp = configuration.client.execute(req).await?;
463
464 let status = resp.status();
465 let content_type = resp
466 .headers()
467 .get("content-type")
468 .and_then(|v| v.to_str().ok())
469 .unwrap_or("application/octet-stream");
470 let content_type = super::ContentType::from(content_type);
471
472 if !status.is_client_error() && !status.is_server_error() {
473 let content = resp.text().await?;
474 match content_type {
475 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
476 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateLoanVipRepayV1Resp`"))),
477 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::CreateLoanVipRepayV1Resp`")))),
478 }
479 } else {
480 let content = resp.text().await?;
481 let entity: Option<CreateLoanVipRepayV1Error> = serde_json::from_str(&content).ok();
482 Err(Error::ResponseError(ResponseContent { status, content, entity }))
483 }
484}
485
486pub async fn get_loan_vip_accrued_interest_v1(configuration: &configuration::Configuration, params: GetLoanVipAccruedInterestV1Params) -> Result<models::GetLoanVipAccruedInterestV1Resp, Error<GetLoanVipAccruedInterestV1Error>> {
488
489 let uri_str = format!("{}/sapi/v1/loan/vip/accruedInterest", configuration.base_path);
490 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
491
492 let mut query_params: Vec<(String, String)> = Vec::new();
494
495 if let Some(ref param_value) = params.order_id {
496 query_params.push(("orderId".to_string(), param_value.to_string()));
497 }
498 if let Some(ref param_value) = params.loan_coin {
499 query_params.push(("loanCoin".to_string(), param_value.to_string()));
500 }
501 if let Some(ref param_value) = params.start_time {
502 query_params.push(("startTime".to_string(), param_value.to_string()));
503 }
504 if let Some(ref param_value) = params.end_time {
505 query_params.push(("endTime".to_string(), param_value.to_string()));
506 }
507 if let Some(ref param_value) = params.current {
508 query_params.push(("current".to_string(), param_value.to_string()));
509 }
510 if let Some(ref param_value) = params.limit {
511 query_params.push(("limit".to_string(), param_value.to_string()));
512 }
513 query_params.push(("recvWindow".to_string(), params.recv_window.to_string()));
514 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
515
516 let mut header_params = std::collections::HashMap::new();
518
519 if let Some(ref binance_auth) = configuration.binance_auth {
521 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
523
524 let body_string: Option<Vec<u8>> = None;
526
527 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
529 Ok(sig) => sig,
530 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
531 };
532
533 query_params.push(("signature".to_string(), signature));
535 }
536
537 if !query_params.is_empty() {
539 req_builder = req_builder.query(&query_params);
540 }
541
542
543 if let Some(ref user_agent) = configuration.user_agent {
545 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
546 }
547
548 for (header_name, header_value) in header_params {
550 req_builder = req_builder.header(&header_name, &header_value);
551 }
552
553
554 let req = req_builder.build()?;
555 let resp = configuration.client.execute(req).await?;
556
557 let status = resp.status();
558 let content_type = resp
559 .headers()
560 .get("content-type")
561 .and_then(|v| v.to_str().ok())
562 .unwrap_or("application/octet-stream");
563 let content_type = super::ContentType::from(content_type);
564
565 if !status.is_client_error() && !status.is_server_error() {
566 let content = resp.text().await?;
567 match content_type {
568 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
569 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLoanVipAccruedInterestV1Resp`"))),
570 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::GetLoanVipAccruedInterestV1Resp`")))),
571 }
572 } else {
573 let content = resp.text().await?;
574 let entity: Option<GetLoanVipAccruedInterestV1Error> = serde_json::from_str(&content).ok();
575 Err(Error::ResponseError(ResponseContent { status, content, entity }))
576 }
577}
578
579pub async fn get_loan_vip_collateral_account_v1(configuration: &configuration::Configuration, params: GetLoanVipCollateralAccountV1Params) -> Result<models::GetLoanVipCollateralAccountV1Resp, Error<GetLoanVipCollateralAccountV1Error>> {
581
582 let uri_str = format!("{}/sapi/v1/loan/vip/collateral/account", configuration.base_path);
583 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
584
585 let mut query_params: Vec<(String, String)> = Vec::new();
587
588 if let Some(ref param_value) = params.order_id {
589 query_params.push(("orderId".to_string(), param_value.to_string()));
590 }
591 if let Some(ref param_value) = params.collateral_account_id {
592 query_params.push(("collateralAccountId".to_string(), param_value.to_string()));
593 }
594 if let Some(ref param_value) = params.recv_window {
595 query_params.push(("recvWindow".to_string(), param_value.to_string()));
596 }
597 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
598
599 let mut header_params = std::collections::HashMap::new();
601
602 if let Some(ref binance_auth) = configuration.binance_auth {
604 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
606
607 let body_string: Option<Vec<u8>> = None;
609
610 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
612 Ok(sig) => sig,
613 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
614 };
615
616 query_params.push(("signature".to_string(), signature));
618 }
619
620 if !query_params.is_empty() {
622 req_builder = req_builder.query(&query_params);
623 }
624
625
626 if let Some(ref user_agent) = configuration.user_agent {
628 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
629 }
630
631 for (header_name, header_value) in header_params {
633 req_builder = req_builder.header(&header_name, &header_value);
634 }
635
636
637 let req = req_builder.build()?;
638 let resp = configuration.client.execute(req).await?;
639
640 let status = resp.status();
641 let content_type = resp
642 .headers()
643 .get("content-type")
644 .and_then(|v| v.to_str().ok())
645 .unwrap_or("application/octet-stream");
646 let content_type = super::ContentType::from(content_type);
647
648 if !status.is_client_error() && !status.is_server_error() {
649 let content = resp.text().await?;
650 match content_type {
651 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
652 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLoanVipCollateralAccountV1Resp`"))),
653 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::GetLoanVipCollateralAccountV1Resp`")))),
654 }
655 } else {
656 let content = resp.text().await?;
657 let entity: Option<GetLoanVipCollateralAccountV1Error> = serde_json::from_str(&content).ok();
658 Err(Error::ResponseError(ResponseContent { status, content, entity }))
659 }
660}
661
662pub async fn get_loan_vip_collateral_data_v1(configuration: &configuration::Configuration, params: GetLoanVipCollateralDataV1Params) -> Result<models::GetLoanVipCollateralDataV1Resp, Error<GetLoanVipCollateralDataV1Error>> {
664
665 let uri_str = format!("{}/sapi/v1/loan/vip/collateral/data", configuration.base_path);
666 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
667
668 let mut query_params: Vec<(String, String)> = Vec::new();
670
671 if let Some(ref param_value) = params.collateral_coin {
672 query_params.push(("collateralCoin".to_string(), param_value.to_string()));
673 }
674 if let Some(ref param_value) = params.recv_window {
675 query_params.push(("recvWindow".to_string(), param_value.to_string()));
676 }
677 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
678
679 let mut header_params = std::collections::HashMap::new();
681
682 if let Some(ref binance_auth) = configuration.binance_auth {
684 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
686
687 let body_string: Option<Vec<u8>> = None;
689
690 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
692 Ok(sig) => sig,
693 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
694 };
695
696 query_params.push(("signature".to_string(), signature));
698 }
699
700 if !query_params.is_empty() {
702 req_builder = req_builder.query(&query_params);
703 }
704
705
706 if let Some(ref user_agent) = configuration.user_agent {
708 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
709 }
710
711 for (header_name, header_value) in header_params {
713 req_builder = req_builder.header(&header_name, &header_value);
714 }
715
716
717 let req = req_builder.build()?;
718 let resp = configuration.client.execute(req).await?;
719
720 let status = resp.status();
721 let content_type = resp
722 .headers()
723 .get("content-type")
724 .and_then(|v| v.to_str().ok())
725 .unwrap_or("application/octet-stream");
726 let content_type = super::ContentType::from(content_type);
727
728 if !status.is_client_error() && !status.is_server_error() {
729 let content = resp.text().await?;
730 match content_type {
731 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
732 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLoanVipCollateralDataV1Resp`"))),
733 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::GetLoanVipCollateralDataV1Resp`")))),
734 }
735 } else {
736 let content = resp.text().await?;
737 let entity: Option<GetLoanVipCollateralDataV1Error> = serde_json::from_str(&content).ok();
738 Err(Error::ResponseError(ResponseContent { status, content, entity }))
739 }
740}
741
742pub async fn get_loan_vip_interest_rate_history_v1(configuration: &configuration::Configuration, params: GetLoanVipInterestRateHistoryV1Params) -> Result<models::GetLoanVipInterestRateHistoryV1Resp, Error<GetLoanVipInterestRateHistoryV1Error>> {
744
745 let uri_str = format!("{}/sapi/v1/loan/vip/interestRateHistory", configuration.base_path);
746 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
747
748 let mut query_params: Vec<(String, String)> = Vec::new();
750
751 query_params.push(("coin".to_string(), params.coin.to_string()));
752 if let Some(ref param_value) = params.start_time {
753 query_params.push(("startTime".to_string(), param_value.to_string()));
754 }
755 if let Some(ref param_value) = params.end_time {
756 query_params.push(("endTime".to_string(), param_value.to_string()));
757 }
758 if let Some(ref param_value) = params.current {
759 query_params.push(("current".to_string(), param_value.to_string()));
760 }
761 if let Some(ref param_value) = params.limit {
762 query_params.push(("limit".to_string(), param_value.to_string()));
763 }
764 query_params.push(("recvWindow".to_string(), params.recv_window.to_string()));
765 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
766
767 let mut header_params = std::collections::HashMap::new();
769
770 if let Some(ref binance_auth) = configuration.binance_auth {
772 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
774
775 let body_string: Option<Vec<u8>> = None;
777
778 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
780 Ok(sig) => sig,
781 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
782 };
783
784 query_params.push(("signature".to_string(), signature));
786 }
787
788 if !query_params.is_empty() {
790 req_builder = req_builder.query(&query_params);
791 }
792
793
794 if let Some(ref user_agent) = configuration.user_agent {
796 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
797 }
798
799 for (header_name, header_value) in header_params {
801 req_builder = req_builder.header(&header_name, &header_value);
802 }
803
804
805 let req = req_builder.build()?;
806 let resp = configuration.client.execute(req).await?;
807
808 let status = resp.status();
809 let content_type = resp
810 .headers()
811 .get("content-type")
812 .and_then(|v| v.to_str().ok())
813 .unwrap_or("application/octet-stream");
814 let content_type = super::ContentType::from(content_type);
815
816 if !status.is_client_error() && !status.is_server_error() {
817 let content = resp.text().await?;
818 match content_type {
819 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
820 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLoanVipInterestRateHistoryV1Resp`"))),
821 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::GetLoanVipInterestRateHistoryV1Resp`")))),
822 }
823 } else {
824 let content = resp.text().await?;
825 let entity: Option<GetLoanVipInterestRateHistoryV1Error> = serde_json::from_str(&content).ok();
826 Err(Error::ResponseError(ResponseContent { status, content, entity }))
827 }
828}
829
830pub async fn get_loan_vip_loanable_data_v1(configuration: &configuration::Configuration, params: GetLoanVipLoanableDataV1Params) -> Result<models::GetLoanVipLoanableDataV1Resp, Error<GetLoanVipLoanableDataV1Error>> {
832
833 let uri_str = format!("{}/sapi/v1/loan/vip/loanable/data", configuration.base_path);
834 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
835
836 let mut query_params: Vec<(String, String)> = Vec::new();
838
839 if let Some(ref param_value) = params.loan_coin {
840 query_params.push(("loanCoin".to_string(), param_value.to_string()));
841 }
842 if let Some(ref param_value) = params.vip_level {
843 query_params.push(("vipLevel".to_string(), param_value.to_string()));
844 }
845 if let Some(ref param_value) = params.recv_window {
846 query_params.push(("recvWindow".to_string(), param_value.to_string()));
847 }
848 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
849
850 let mut header_params = std::collections::HashMap::new();
852
853 if let Some(ref binance_auth) = configuration.binance_auth {
855 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
857
858 let body_string: Option<Vec<u8>> = None;
860
861 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
863 Ok(sig) => sig,
864 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
865 };
866
867 query_params.push(("signature".to_string(), signature));
869 }
870
871 if !query_params.is_empty() {
873 req_builder = req_builder.query(&query_params);
874 }
875
876
877 if let Some(ref user_agent) = configuration.user_agent {
879 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
880 }
881
882 for (header_name, header_value) in header_params {
884 req_builder = req_builder.header(&header_name, &header_value);
885 }
886
887
888 let req = req_builder.build()?;
889 let resp = configuration.client.execute(req).await?;
890
891 let status = resp.status();
892 let content_type = resp
893 .headers()
894 .get("content-type")
895 .and_then(|v| v.to_str().ok())
896 .unwrap_or("application/octet-stream");
897 let content_type = super::ContentType::from(content_type);
898
899 if !status.is_client_error() && !status.is_server_error() {
900 let content = resp.text().await?;
901 match content_type {
902 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
903 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLoanVipLoanableDataV1Resp`"))),
904 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::GetLoanVipLoanableDataV1Resp`")))),
905 }
906 } else {
907 let content = resp.text().await?;
908 let entity: Option<GetLoanVipLoanableDataV1Error> = serde_json::from_str(&content).ok();
909 Err(Error::ResponseError(ResponseContent { status, content, entity }))
910 }
911}
912
913pub async fn get_loan_vip_ongoing_orders_v1(configuration: &configuration::Configuration, params: GetLoanVipOngoingOrdersV1Params) -> Result<models::GetLoanVipOngoingOrdersV1Resp, Error<GetLoanVipOngoingOrdersV1Error>> {
915
916 let uri_str = format!("{}/sapi/v1/loan/vip/ongoing/orders", configuration.base_path);
917 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
918
919 let mut query_params: Vec<(String, String)> = Vec::new();
921
922 if let Some(ref param_value) = params.order_id {
923 query_params.push(("orderId".to_string(), param_value.to_string()));
924 }
925 if let Some(ref param_value) = params.collateral_account_id {
926 query_params.push(("collateralAccountId".to_string(), param_value.to_string()));
927 }
928 if let Some(ref param_value) = params.loan_coin {
929 query_params.push(("loanCoin".to_string(), param_value.to_string()));
930 }
931 if let Some(ref param_value) = params.collateral_coin {
932 query_params.push(("collateralCoin".to_string(), param_value.to_string()));
933 }
934 if let Some(ref param_value) = params.current {
935 query_params.push(("current".to_string(), param_value.to_string()));
936 }
937 if let Some(ref param_value) = params.limit {
938 query_params.push(("limit".to_string(), param_value.to_string()));
939 }
940 if let Some(ref param_value) = params.recv_window {
941 query_params.push(("recvWindow".to_string(), param_value.to_string()));
942 }
943 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
944
945 let mut header_params = std::collections::HashMap::new();
947
948 if let Some(ref binance_auth) = configuration.binance_auth {
950 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
952
953 let body_string: Option<Vec<u8>> = None;
955
956 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
958 Ok(sig) => sig,
959 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
960 };
961
962 query_params.push(("signature".to_string(), signature));
964 }
965
966 if !query_params.is_empty() {
968 req_builder = req_builder.query(&query_params);
969 }
970
971
972 if let Some(ref user_agent) = configuration.user_agent {
974 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
975 }
976
977 for (header_name, header_value) in header_params {
979 req_builder = req_builder.header(&header_name, &header_value);
980 }
981
982
983 let req = req_builder.build()?;
984 let resp = configuration.client.execute(req).await?;
985
986 let status = resp.status();
987 let content_type = resp
988 .headers()
989 .get("content-type")
990 .and_then(|v| v.to_str().ok())
991 .unwrap_or("application/octet-stream");
992 let content_type = super::ContentType::from(content_type);
993
994 if !status.is_client_error() && !status.is_server_error() {
995 let content = resp.text().await?;
996 match content_type {
997 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
998 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLoanVipOngoingOrdersV1Resp`"))),
999 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::GetLoanVipOngoingOrdersV1Resp`")))),
1000 }
1001 } else {
1002 let content = resp.text().await?;
1003 let entity: Option<GetLoanVipOngoingOrdersV1Error> = serde_json::from_str(&content).ok();
1004 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1005 }
1006}
1007
1008pub async fn get_loan_vip_repay_history_v1(configuration: &configuration::Configuration, params: GetLoanVipRepayHistoryV1Params) -> Result<models::GetLoanVipRepayHistoryV1Resp, Error<GetLoanVipRepayHistoryV1Error>> {
1010
1011 let uri_str = format!("{}/sapi/v1/loan/vip/repay/history", configuration.base_path);
1012 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1013
1014 let mut query_params: Vec<(String, String)> = Vec::new();
1016
1017 if let Some(ref param_value) = params.order_id {
1018 query_params.push(("orderId".to_string(), param_value.to_string()));
1019 }
1020 if let Some(ref param_value) = params.loan_coin {
1021 query_params.push(("loanCoin".to_string(), param_value.to_string()));
1022 }
1023 if let Some(ref param_value) = params.start_time {
1024 query_params.push(("startTime".to_string(), param_value.to_string()));
1025 }
1026 if let Some(ref param_value) = params.end_time {
1027 query_params.push(("endTime".to_string(), param_value.to_string()));
1028 }
1029 if let Some(ref param_value) = params.current {
1030 query_params.push(("current".to_string(), param_value.to_string()));
1031 }
1032 if let Some(ref param_value) = params.limit {
1033 query_params.push(("limit".to_string(), param_value.to_string()));
1034 }
1035 if let Some(ref param_value) = params.recv_window {
1036 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1037 }
1038 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1039
1040 let mut header_params = std::collections::HashMap::new();
1042
1043 if let Some(ref binance_auth) = configuration.binance_auth {
1045 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1047
1048 let body_string: Option<Vec<u8>> = None;
1050
1051 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1053 Ok(sig) => sig,
1054 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1055 };
1056
1057 query_params.push(("signature".to_string(), signature));
1059 }
1060
1061 if !query_params.is_empty() {
1063 req_builder = req_builder.query(&query_params);
1064 }
1065
1066
1067 if let Some(ref user_agent) = configuration.user_agent {
1069 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1070 }
1071
1072 for (header_name, header_value) in header_params {
1074 req_builder = req_builder.header(&header_name, &header_value);
1075 }
1076
1077
1078 let req = req_builder.build()?;
1079 let resp = configuration.client.execute(req).await?;
1080
1081 let status = resp.status();
1082 let content_type = resp
1083 .headers()
1084 .get("content-type")
1085 .and_then(|v| v.to_str().ok())
1086 .unwrap_or("application/octet-stream");
1087 let content_type = super::ContentType::from(content_type);
1088
1089 if !status.is_client_error() && !status.is_server_error() {
1090 let content = resp.text().await?;
1091 match content_type {
1092 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1093 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLoanVipRepayHistoryV1Resp`"))),
1094 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::GetLoanVipRepayHistoryV1Resp`")))),
1095 }
1096 } else {
1097 let content = resp.text().await?;
1098 let entity: Option<GetLoanVipRepayHistoryV1Error> = serde_json::from_str(&content).ok();
1099 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1100 }
1101}
1102
1103pub async fn get_loan_vip_request_data_v1(configuration: &configuration::Configuration, params: GetLoanVipRequestDataV1Params) -> Result<models::GetLoanVipRequestDataV1Resp, Error<GetLoanVipRequestDataV1Error>> {
1105
1106 let uri_str = format!("{}/sapi/v1/loan/vip/request/data", configuration.base_path);
1107 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1108
1109 let mut query_params: Vec<(String, String)> = Vec::new();
1111
1112 if let Some(ref param_value) = params.current {
1113 query_params.push(("current".to_string(), param_value.to_string()));
1114 }
1115 if let Some(ref param_value) = params.limit {
1116 query_params.push(("limit".to_string(), param_value.to_string()));
1117 }
1118 if let Some(ref param_value) = params.recv_window {
1119 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1120 }
1121 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1122
1123 let mut header_params = std::collections::HashMap::new();
1125
1126 if let Some(ref binance_auth) = configuration.binance_auth {
1128 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1130
1131 let body_string: Option<Vec<u8>> = None;
1133
1134 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1136 Ok(sig) => sig,
1137 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1138 };
1139
1140 query_params.push(("signature".to_string(), signature));
1142 }
1143
1144 if !query_params.is_empty() {
1146 req_builder = req_builder.query(&query_params);
1147 }
1148
1149
1150 if let Some(ref user_agent) = configuration.user_agent {
1152 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1153 }
1154
1155 for (header_name, header_value) in header_params {
1157 req_builder = req_builder.header(&header_name, &header_value);
1158 }
1159
1160
1161 let req = req_builder.build()?;
1162 let resp = configuration.client.execute(req).await?;
1163
1164 let status = resp.status();
1165 let content_type = resp
1166 .headers()
1167 .get("content-type")
1168 .and_then(|v| v.to_str().ok())
1169 .unwrap_or("application/octet-stream");
1170 let content_type = super::ContentType::from(content_type);
1171
1172 if !status.is_client_error() && !status.is_server_error() {
1173 let content = resp.text().await?;
1174 match content_type {
1175 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1176 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLoanVipRequestDataV1Resp`"))),
1177 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::GetLoanVipRequestDataV1Resp`")))),
1178 }
1179 } else {
1180 let content = resp.text().await?;
1181 let entity: Option<GetLoanVipRequestDataV1Error> = serde_json::from_str(&content).ok();
1182 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1183 }
1184}
1185
1186pub async fn get_loan_vip_request_interest_rate_v1(configuration: &configuration::Configuration, params: GetLoanVipRequestInterestRateV1Params) -> Result<Vec<models::GetLoanVipRequestInterestRateV1RespItem>, Error<GetLoanVipRequestInterestRateV1Error>> {
1188
1189 let uri_str = format!("{}/sapi/v1/loan/vip/request/interestRate", configuration.base_path);
1190 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1191
1192 let mut query_params: Vec<(String, String)> = Vec::new();
1194
1195 query_params.push(("loanCoin".to_string(), params.loan_coin.to_string()));
1196 if let Some(ref param_value) = params.recv_window {
1197 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1198 }
1199 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1200
1201 let mut header_params = std::collections::HashMap::new();
1203
1204 if let Some(ref binance_auth) = configuration.binance_auth {
1206 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1208
1209 let body_string: Option<Vec<u8>> = None;
1211
1212 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1214 Ok(sig) => sig,
1215 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1216 };
1217
1218 query_params.push(("signature".to_string(), signature));
1220 }
1221
1222 if !query_params.is_empty() {
1224 req_builder = req_builder.query(&query_params);
1225 }
1226
1227
1228 if let Some(ref user_agent) = configuration.user_agent {
1230 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1231 }
1232
1233 for (header_name, header_value) in header_params {
1235 req_builder = req_builder.header(&header_name, &header_value);
1236 }
1237
1238
1239 let req = req_builder.build()?;
1240 let resp = configuration.client.execute(req).await?;
1241
1242 let status = resp.status();
1243 let content_type = resp
1244 .headers()
1245 .get("content-type")
1246 .and_then(|v| v.to_str().ok())
1247 .unwrap_or("application/octet-stream");
1248 let content_type = super::ContentType::from(content_type);
1249
1250 if !status.is_client_error() && !status.is_server_error() {
1251 let content = resp.text().await?;
1252 match content_type {
1253 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1254 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetLoanVipRequestInterestRateV1RespItem>`"))),
1255 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::GetLoanVipRequestInterestRateV1RespItem>`")))),
1256 }
1257 } else {
1258 let content = resp.text().await?;
1259 let entity: Option<GetLoanVipRequestInterestRateV1Error> = serde_json::from_str(&content).ok();
1260 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1261 }
1262}
1263