1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::margin::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct MarginCreateMarginIsolatedAccountV1Params {
20 pub symbol: String,
21 pub timestamp: i64,
22 pub recv_window: Option<i64>
23}
24
25#[derive(Clone, Debug, Default)]
27pub struct MarginCreateMarginMaxLeverageV1Params {
28 pub max_leverage: i32
29}
30
31#[derive(Clone, Debug, Default)]
33pub struct MarginDeleteMarginIsolatedAccountV1Params {
34 pub symbol: String,
35 pub timestamp: i64,
36 pub recv_window: Option<i64>
38}
39
40#[derive(Clone, Debug, Default)]
42pub struct MarginGetBnbBurnV1Params {
43 pub timestamp: i64,
44 pub recv_window: Option<i64>
46}
47
48#[derive(Clone, Debug, Default)]
50pub struct MarginGetMarginAccountV1Params {
51 pub timestamp: i64,
52 pub recv_window: Option<i64>
54}
55
56#[derive(Clone, Debug, Default)]
58pub struct MarginGetMarginCapitalFlowV1Params {
59 pub timestamp: i64,
60 pub asset: Option<String>,
61 pub symbol: Option<String>,
63 pub r#type: Option<String>,
64 pub start_time: Option<i64>,
66 pub end_time: Option<i64>,
67 pub from_id: Option<i64>,
69 pub limit: Option<i64>,
71 pub recv_window: Option<i64>
73}
74
75#[derive(Clone, Debug, Default)]
77pub struct MarginGetMarginCrossMarginDataV1Params {
78 pub timestamp: i64,
79 pub vip_level: Option<i32>,
81 pub coin: Option<String>,
82 pub recv_window: Option<i64>
84}
85
86#[derive(Clone, Debug, Default)]
88pub struct MarginGetMarginIsolatedAccountLimitV1Params {
89 pub timestamp: i64,
90 pub recv_window: Option<i64>
92}
93
94#[derive(Clone, Debug, Default)]
96pub struct MarginGetMarginIsolatedAccountV1Params {
97 pub timestamp: i64,
98 pub symbols: Option<String>,
100 pub recv_window: Option<i64>
102}
103
104#[derive(Clone, Debug, Default)]
106pub struct MarginGetMarginIsolatedMarginDataV1Params {
107 pub timestamp: i64,
108 pub vip_level: Option<i32>,
110 pub symbol: Option<String>,
111 pub recv_window: Option<i64>
113}
114
115#[derive(Clone, Debug, Default)]
117pub struct MarginGetMarginTradeCoeffV1Params {
118 pub timestamp: i64,
119 pub recv_window: Option<i64>
120}
121
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum MarginCreateMarginIsolatedAccountV1Error {
127 Status4XX(models::ApiError),
128 Status5XX(models::ApiError),
129 UnknownValue(serde_json::Value),
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize)]
134#[serde(untagged)]
135pub enum MarginCreateMarginMaxLeverageV1Error {
136 Status4XX(models::ApiError),
137 Status5XX(models::ApiError),
138 UnknownValue(serde_json::Value),
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize)]
143#[serde(untagged)]
144pub enum MarginDeleteMarginIsolatedAccountV1Error {
145 Status4XX(models::ApiError),
146 Status5XX(models::ApiError),
147 UnknownValue(serde_json::Value),
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize)]
152#[serde(untagged)]
153pub enum MarginGetBnbBurnV1Error {
154 Status4XX(models::ApiError),
155 Status5XX(models::ApiError),
156 UnknownValue(serde_json::Value),
157}
158
159#[derive(Debug, Clone, Serialize, Deserialize)]
161#[serde(untagged)]
162pub enum MarginGetMarginAccountV1Error {
163 Status4XX(models::ApiError),
164 Status5XX(models::ApiError),
165 UnknownValue(serde_json::Value),
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum MarginGetMarginCapitalFlowV1Error {
172 Status4XX(models::ApiError),
173 Status5XX(models::ApiError),
174 UnknownValue(serde_json::Value),
175}
176
177#[derive(Debug, Clone, Serialize, Deserialize)]
179#[serde(untagged)]
180pub enum MarginGetMarginCrossMarginDataV1Error {
181 Status4XX(models::ApiError),
182 Status5XX(models::ApiError),
183 UnknownValue(serde_json::Value),
184}
185
186#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum MarginGetMarginIsolatedAccountLimitV1Error {
190 Status4XX(models::ApiError),
191 Status5XX(models::ApiError),
192 UnknownValue(serde_json::Value),
193}
194
195#[derive(Debug, Clone, Serialize, Deserialize)]
197#[serde(untagged)]
198pub enum MarginGetMarginIsolatedAccountV1Error {
199 Status4XX(models::ApiError),
200 Status5XX(models::ApiError),
201 UnknownValue(serde_json::Value),
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206#[serde(untagged)]
207pub enum MarginGetMarginIsolatedMarginDataV1Error {
208 Status4XX(models::ApiError),
209 Status5XX(models::ApiError),
210 UnknownValue(serde_json::Value),
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize)]
215#[serde(untagged)]
216pub enum MarginGetMarginTradeCoeffV1Error {
217 Status4XX(models::ApiError),
218 Status5XX(models::ApiError),
219 UnknownValue(serde_json::Value),
220}
221
222
223pub async fn margin_create_margin_isolated_account_v1(configuration: &configuration::Configuration, params: MarginCreateMarginIsolatedAccountV1Params) -> Result<models::MarginCreateMarginIsolatedAccountV1Resp, Error<MarginCreateMarginIsolatedAccountV1Error>> {
225
226 let uri_str = format!("{}/sapi/v1/margin/isolated/account", configuration.base_path);
227 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
228
229 let mut query_params: Vec<(String, String)> = Vec::new();
231
232
233 let mut header_params = std::collections::HashMap::new();
235
236 if let Some(ref binance_auth) = configuration.binance_auth {
238 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
240
241 let body_string: Option<Vec<u8>> = None;
243
244 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
246 Ok(sig) => sig,
247 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
248 };
249
250 query_params.push(("signature".to_string(), signature));
252 }
253
254 if !query_params.is_empty() {
256 req_builder = req_builder.query(&query_params);
257 }
258
259
260 if let Some(ref user_agent) = configuration.user_agent {
262 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
263 }
264
265 for (header_name, header_value) in header_params {
267 req_builder = req_builder.header(&header_name, &header_value);
268 }
269
270 let mut multipart_form_params = std::collections::HashMap::new();
271 if let Some(param_value) = params.recv_window {
272 multipart_form_params.insert("recvWindow", param_value.to_string());
273 }
274 multipart_form_params.insert("symbol", params.symbol.to_string());
275 multipart_form_params.insert("timestamp", params.timestamp.to_string());
276 req_builder = req_builder.form(&multipart_form_params);
277
278 let req = req_builder.build()?;
279 let resp = configuration.client.execute(req).await?;
280
281 let status = resp.status();
282 let content_type = resp
283 .headers()
284 .get("content-type")
285 .and_then(|v| v.to_str().ok())
286 .unwrap_or("application/octet-stream");
287 let content_type = super::ContentType::from(content_type);
288
289 if !status.is_client_error() && !status.is_server_error() {
290 let content = resp.text().await?;
291 match content_type {
292 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
293 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginIsolatedAccountV1Resp`"))),
294 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::MarginCreateMarginIsolatedAccountV1Resp`")))),
295 }
296 } else {
297 let content = resp.text().await?;
298 let entity: Option<MarginCreateMarginIsolatedAccountV1Error> = serde_json::from_str(&content).ok();
299 Err(Error::ResponseError(ResponseContent { status, content, entity }))
300 }
301}
302
303pub async fn margin_create_margin_max_leverage_v1(configuration: &configuration::Configuration, params: MarginCreateMarginMaxLeverageV1Params) -> Result<models::MarginCreateMarginMaxLeverageV1Resp, Error<MarginCreateMarginMaxLeverageV1Error>> {
305
306 let uri_str = format!("{}/sapi/v1/margin/max-leverage", configuration.base_path);
307 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
308
309 let mut query_params: Vec<(String, String)> = Vec::new();
311
312
313 let mut header_params = std::collections::HashMap::new();
315
316 if let Some(ref binance_auth) = configuration.binance_auth {
318 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
320
321 let body_string: Option<Vec<u8>> = None;
323
324 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
326 Ok(sig) => sig,
327 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
328 };
329
330 query_params.push(("signature".to_string(), signature));
332 }
333
334 if !query_params.is_empty() {
336 req_builder = req_builder.query(&query_params);
337 }
338
339
340 if let Some(ref user_agent) = configuration.user_agent {
342 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
343 }
344
345 for (header_name, header_value) in header_params {
347 req_builder = req_builder.header(&header_name, &header_value);
348 }
349
350 let mut multipart_form_params = std::collections::HashMap::new();
351 multipart_form_params.insert("maxLeverage", params.max_leverage.to_string());
352 req_builder = req_builder.form(&multipart_form_params);
353
354 let req = req_builder.build()?;
355 let resp = configuration.client.execute(req).await?;
356
357 let status = resp.status();
358 let content_type = resp
359 .headers()
360 .get("content-type")
361 .and_then(|v| v.to_str().ok())
362 .unwrap_or("application/octet-stream");
363 let content_type = super::ContentType::from(content_type);
364
365 if !status.is_client_error() && !status.is_server_error() {
366 let content = resp.text().await?;
367 match content_type {
368 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
369 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginCreateMarginMaxLeverageV1Resp`"))),
370 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::MarginCreateMarginMaxLeverageV1Resp`")))),
371 }
372 } else {
373 let content = resp.text().await?;
374 let entity: Option<MarginCreateMarginMaxLeverageV1Error> = serde_json::from_str(&content).ok();
375 Err(Error::ResponseError(ResponseContent { status, content, entity }))
376 }
377}
378
379pub async fn margin_delete_margin_isolated_account_v1(configuration: &configuration::Configuration, params: MarginDeleteMarginIsolatedAccountV1Params) -> Result<models::MarginDeleteMarginIsolatedAccountV1Resp, Error<MarginDeleteMarginIsolatedAccountV1Error>> {
381
382 let uri_str = format!("{}/sapi/v1/margin/isolated/account", configuration.base_path);
383 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
384
385 let mut query_params: Vec<(String, String)> = Vec::new();
387
388 query_params.push(("symbol".to_string(), params.symbol.to_string()));
389 if let Some(ref param_value) = params.recv_window {
390 query_params.push(("recvWindow".to_string(), param_value.to_string()));
391 }
392 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
393
394 let mut header_params = std::collections::HashMap::new();
396
397 if let Some(ref binance_auth) = configuration.binance_auth {
399 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
401
402 let body_string: Option<Vec<u8>> = None;
404
405 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
407 Ok(sig) => sig,
408 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
409 };
410
411 query_params.push(("signature".to_string(), signature));
413 }
414
415 if !query_params.is_empty() {
417 req_builder = req_builder.query(&query_params);
418 }
419
420
421 if let Some(ref user_agent) = configuration.user_agent {
423 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
424 }
425
426 for (header_name, header_value) in header_params {
428 req_builder = req_builder.header(&header_name, &header_value);
429 }
430
431
432 let req = req_builder.build()?;
433 let resp = configuration.client.execute(req).await?;
434
435 let status = resp.status();
436 let content_type = resp
437 .headers()
438 .get("content-type")
439 .and_then(|v| v.to_str().ok())
440 .unwrap_or("application/octet-stream");
441 let content_type = super::ContentType::from(content_type);
442
443 if !status.is_client_error() && !status.is_server_error() {
444 let content = resp.text().await?;
445 match content_type {
446 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
447 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginDeleteMarginIsolatedAccountV1Resp`"))),
448 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::MarginDeleteMarginIsolatedAccountV1Resp`")))),
449 }
450 } else {
451 let content = resp.text().await?;
452 let entity: Option<MarginDeleteMarginIsolatedAccountV1Error> = serde_json::from_str(&content).ok();
453 Err(Error::ResponseError(ResponseContent { status, content, entity }))
454 }
455}
456
457pub async fn margin_get_bnb_burn_v1(configuration: &configuration::Configuration, params: MarginGetBnbBurnV1Params) -> Result<models::MarginGetBnbBurnV1Resp, Error<MarginGetBnbBurnV1Error>> {
459
460 let uri_str = format!("{}/sapi/v1/bnbBurn", configuration.base_path);
461 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
462
463 let mut query_params: Vec<(String, String)> = Vec::new();
465
466 if let Some(ref param_value) = params.recv_window {
467 query_params.push(("recvWindow".to_string(), param_value.to_string()));
468 }
469 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
470
471 let mut header_params = std::collections::HashMap::new();
473
474 if let Some(ref binance_auth) = configuration.binance_auth {
476 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
478
479 let body_string: Option<Vec<u8>> = None;
481
482 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
484 Ok(sig) => sig,
485 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
486 };
487
488 query_params.push(("signature".to_string(), signature));
490 }
491
492 if !query_params.is_empty() {
494 req_builder = req_builder.query(&query_params);
495 }
496
497
498 if let Some(ref user_agent) = configuration.user_agent {
500 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
501 }
502
503 for (header_name, header_value) in header_params {
505 req_builder = req_builder.header(&header_name, &header_value);
506 }
507
508
509 let req = req_builder.build()?;
510 let resp = configuration.client.execute(req).await?;
511
512 let status = resp.status();
513 let content_type = resp
514 .headers()
515 .get("content-type")
516 .and_then(|v| v.to_str().ok())
517 .unwrap_or("application/octet-stream");
518 let content_type = super::ContentType::from(content_type);
519
520 if !status.is_client_error() && !status.is_server_error() {
521 let content = resp.text().await?;
522 match content_type {
523 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
524 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetBnbBurnV1Resp`"))),
525 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::MarginGetBnbBurnV1Resp`")))),
526 }
527 } else {
528 let content = resp.text().await?;
529 let entity: Option<MarginGetBnbBurnV1Error> = serde_json::from_str(&content).ok();
530 Err(Error::ResponseError(ResponseContent { status, content, entity }))
531 }
532}
533
534pub async fn margin_get_margin_account_v1(configuration: &configuration::Configuration, params: MarginGetMarginAccountV1Params) -> Result<models::MarginGetMarginAccountV1Resp, Error<MarginGetMarginAccountV1Error>> {
536
537 let uri_str = format!("{}/sapi/v1/margin/account", configuration.base_path);
538 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
539
540 let mut query_params: Vec<(String, String)> = Vec::new();
542
543 if let Some(ref param_value) = params.recv_window {
544 query_params.push(("recvWindow".to_string(), param_value.to_string()));
545 }
546 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
547
548 let mut header_params = std::collections::HashMap::new();
550
551 if let Some(ref binance_auth) = configuration.binance_auth {
553 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
555
556 let body_string: Option<Vec<u8>> = None;
558
559 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
561 Ok(sig) => sig,
562 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
563 };
564
565 query_params.push(("signature".to_string(), signature));
567 }
568
569 if !query_params.is_empty() {
571 req_builder = req_builder.query(&query_params);
572 }
573
574
575 if let Some(ref user_agent) = configuration.user_agent {
577 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
578 }
579
580 for (header_name, header_value) in header_params {
582 req_builder = req_builder.header(&header_name, &header_value);
583 }
584
585
586 let req = req_builder.build()?;
587 let resp = configuration.client.execute(req).await?;
588
589 let status = resp.status();
590 let content_type = resp
591 .headers()
592 .get("content-type")
593 .and_then(|v| v.to_str().ok())
594 .unwrap_or("application/octet-stream");
595 let content_type = super::ContentType::from(content_type);
596
597 if !status.is_client_error() && !status.is_server_error() {
598 let content = resp.text().await?;
599 match content_type {
600 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
601 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginAccountV1Resp`"))),
602 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::MarginGetMarginAccountV1Resp`")))),
603 }
604 } else {
605 let content = resp.text().await?;
606 let entity: Option<MarginGetMarginAccountV1Error> = serde_json::from_str(&content).ok();
607 Err(Error::ResponseError(ResponseContent { status, content, entity }))
608 }
609}
610
611pub async fn margin_get_margin_capital_flow_v1(configuration: &configuration::Configuration, params: MarginGetMarginCapitalFlowV1Params) -> Result<Vec<models::MarginGetMarginCapitalFlowV1RespItem>, Error<MarginGetMarginCapitalFlowV1Error>> {
613
614 let uri_str = format!("{}/sapi/v1/margin/capital-flow", configuration.base_path);
615 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
616
617 let mut query_params: Vec<(String, String)> = Vec::new();
619
620 if let Some(ref param_value) = params.asset {
621 query_params.push(("asset".to_string(), param_value.to_string()));
622 }
623 if let Some(ref param_value) = params.symbol {
624 query_params.push(("symbol".to_string(), param_value.to_string()));
625 }
626 if let Some(ref param_value) = params.r#type {
627 query_params.push(("type".to_string(), param_value.to_string()));
628 }
629 if let Some(ref param_value) = params.start_time {
630 query_params.push(("startTime".to_string(), param_value.to_string()));
631 }
632 if let Some(ref param_value) = params.end_time {
633 query_params.push(("endTime".to_string(), param_value.to_string()));
634 }
635 if let Some(ref param_value) = params.from_id {
636 query_params.push(("fromId".to_string(), param_value.to_string()));
637 }
638 if let Some(ref param_value) = params.limit {
639 query_params.push(("limit".to_string(), param_value.to_string()));
640 }
641 if let Some(ref param_value) = params.recv_window {
642 query_params.push(("recvWindow".to_string(), param_value.to_string()));
643 }
644 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
645
646 let mut header_params = std::collections::HashMap::new();
648
649 if let Some(ref binance_auth) = configuration.binance_auth {
651 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
653
654 let body_string: Option<Vec<u8>> = None;
656
657 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
659 Ok(sig) => sig,
660 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
661 };
662
663 query_params.push(("signature".to_string(), signature));
665 }
666
667 if !query_params.is_empty() {
669 req_builder = req_builder.query(&query_params);
670 }
671
672
673 if let Some(ref user_agent) = configuration.user_agent {
675 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
676 }
677
678 for (header_name, header_value) in header_params {
680 req_builder = req_builder.header(&header_name, &header_value);
681 }
682
683
684 let req = req_builder.build()?;
685 let resp = configuration.client.execute(req).await?;
686
687 let status = resp.status();
688 let content_type = resp
689 .headers()
690 .get("content-type")
691 .and_then(|v| v.to_str().ok())
692 .unwrap_or("application/octet-stream");
693 let content_type = super::ContentType::from(content_type);
694
695 if !status.is_client_error() && !status.is_server_error() {
696 let content = resp.text().await?;
697 match content_type {
698 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
699 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::MarginGetMarginCapitalFlowV1RespItem>`"))),
700 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::MarginGetMarginCapitalFlowV1RespItem>`")))),
701 }
702 } else {
703 let content = resp.text().await?;
704 let entity: Option<MarginGetMarginCapitalFlowV1Error> = serde_json::from_str(&content).ok();
705 Err(Error::ResponseError(ResponseContent { status, content, entity }))
706 }
707}
708
709pub async fn margin_get_margin_cross_margin_data_v1(configuration: &configuration::Configuration, params: MarginGetMarginCrossMarginDataV1Params) -> Result<Vec<models::MarginGetMarginCrossMarginDataV1RespItem>, Error<MarginGetMarginCrossMarginDataV1Error>> {
711
712 let uri_str = format!("{}/sapi/v1/margin/crossMarginData", configuration.base_path);
713 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
714
715 let mut query_params: Vec<(String, String)> = Vec::new();
717
718 if let Some(ref param_value) = params.vip_level {
719 query_params.push(("vipLevel".to_string(), param_value.to_string()));
720 }
721 if let Some(ref param_value) = params.coin {
722 query_params.push(("coin".to_string(), param_value.to_string()));
723 }
724 if let Some(ref param_value) = params.recv_window {
725 query_params.push(("recvWindow".to_string(), param_value.to_string()));
726 }
727 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
728
729 let mut header_params = std::collections::HashMap::new();
731
732 if let Some(ref binance_auth) = configuration.binance_auth {
734 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
736
737 let body_string: Option<Vec<u8>> = None;
739
740 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
742 Ok(sig) => sig,
743 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
744 };
745
746 query_params.push(("signature".to_string(), signature));
748 }
749
750 if !query_params.is_empty() {
752 req_builder = req_builder.query(&query_params);
753 }
754
755
756 if let Some(ref user_agent) = configuration.user_agent {
758 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
759 }
760
761 for (header_name, header_value) in header_params {
763 req_builder = req_builder.header(&header_name, &header_value);
764 }
765
766
767 let req = req_builder.build()?;
768 let resp = configuration.client.execute(req).await?;
769
770 let status = resp.status();
771 let content_type = resp
772 .headers()
773 .get("content-type")
774 .and_then(|v| v.to_str().ok())
775 .unwrap_or("application/octet-stream");
776 let content_type = super::ContentType::from(content_type);
777
778 if !status.is_client_error() && !status.is_server_error() {
779 let content = resp.text().await?;
780 match content_type {
781 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
782 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::MarginGetMarginCrossMarginDataV1RespItem>`"))),
783 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::MarginGetMarginCrossMarginDataV1RespItem>`")))),
784 }
785 } else {
786 let content = resp.text().await?;
787 let entity: Option<MarginGetMarginCrossMarginDataV1Error> = serde_json::from_str(&content).ok();
788 Err(Error::ResponseError(ResponseContent { status, content, entity }))
789 }
790}
791
792pub async fn margin_get_margin_isolated_account_limit_v1(configuration: &configuration::Configuration, params: MarginGetMarginIsolatedAccountLimitV1Params) -> Result<models::MarginGetMarginIsolatedAccountLimitV1Resp, Error<MarginGetMarginIsolatedAccountLimitV1Error>> {
794
795 let uri_str = format!("{}/sapi/v1/margin/isolated/accountLimit", configuration.base_path);
796 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
797
798 let mut query_params: Vec<(String, String)> = Vec::new();
800
801 if let Some(ref param_value) = params.recv_window {
802 query_params.push(("recvWindow".to_string(), param_value.to_string()));
803 }
804 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
805
806 let mut header_params = std::collections::HashMap::new();
808
809 if let Some(ref binance_auth) = configuration.binance_auth {
811 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
813
814 let body_string: Option<Vec<u8>> = None;
816
817 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
819 Ok(sig) => sig,
820 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
821 };
822
823 query_params.push(("signature".to_string(), signature));
825 }
826
827 if !query_params.is_empty() {
829 req_builder = req_builder.query(&query_params);
830 }
831
832
833 if let Some(ref user_agent) = configuration.user_agent {
835 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
836 }
837
838 for (header_name, header_value) in header_params {
840 req_builder = req_builder.header(&header_name, &header_value);
841 }
842
843
844 let req = req_builder.build()?;
845 let resp = configuration.client.execute(req).await?;
846
847 let status = resp.status();
848 let content_type = resp
849 .headers()
850 .get("content-type")
851 .and_then(|v| v.to_str().ok())
852 .unwrap_or("application/octet-stream");
853 let content_type = super::ContentType::from(content_type);
854
855 if !status.is_client_error() && !status.is_server_error() {
856 let content = resp.text().await?;
857 match content_type {
858 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
859 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginIsolatedAccountLimitV1Resp`"))),
860 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::MarginGetMarginIsolatedAccountLimitV1Resp`")))),
861 }
862 } else {
863 let content = resp.text().await?;
864 let entity: Option<MarginGetMarginIsolatedAccountLimitV1Error> = serde_json::from_str(&content).ok();
865 Err(Error::ResponseError(ResponseContent { status, content, entity }))
866 }
867}
868
869pub async fn margin_get_margin_isolated_account_v1(configuration: &configuration::Configuration, params: MarginGetMarginIsolatedAccountV1Params) -> Result<models::MarginGetMarginIsolatedAccountV1Resp, Error<MarginGetMarginIsolatedAccountV1Error>> {
871
872 let uri_str = format!("{}/sapi/v1/margin/isolated/account", configuration.base_path);
873 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
874
875 let mut query_params: Vec<(String, String)> = Vec::new();
877
878 if let Some(ref param_value) = params.symbols {
879 query_params.push(("symbols".to_string(), param_value.to_string()));
880 }
881 if let Some(ref param_value) = params.recv_window {
882 query_params.push(("recvWindow".to_string(), param_value.to_string()));
883 }
884 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
885
886 let mut header_params = std::collections::HashMap::new();
888
889 if let Some(ref binance_auth) = configuration.binance_auth {
891 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
893
894 let body_string: Option<Vec<u8>> = None;
896
897 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
899 Ok(sig) => sig,
900 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
901 };
902
903 query_params.push(("signature".to_string(), signature));
905 }
906
907 if !query_params.is_empty() {
909 req_builder = req_builder.query(&query_params);
910 }
911
912
913 if let Some(ref user_agent) = configuration.user_agent {
915 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
916 }
917
918 for (header_name, header_value) in header_params {
920 req_builder = req_builder.header(&header_name, &header_value);
921 }
922
923
924 let req = req_builder.build()?;
925 let resp = configuration.client.execute(req).await?;
926
927 let status = resp.status();
928 let content_type = resp
929 .headers()
930 .get("content-type")
931 .and_then(|v| v.to_str().ok())
932 .unwrap_or("application/octet-stream");
933 let content_type = super::ContentType::from(content_type);
934
935 if !status.is_client_error() && !status.is_server_error() {
936 let content = resp.text().await?;
937 match content_type {
938 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
939 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginIsolatedAccountV1Resp`"))),
940 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::MarginGetMarginIsolatedAccountV1Resp`")))),
941 }
942 } else {
943 let content = resp.text().await?;
944 let entity: Option<MarginGetMarginIsolatedAccountV1Error> = serde_json::from_str(&content).ok();
945 Err(Error::ResponseError(ResponseContent { status, content, entity }))
946 }
947}
948
949pub async fn margin_get_margin_isolated_margin_data_v1(configuration: &configuration::Configuration, params: MarginGetMarginIsolatedMarginDataV1Params) -> Result<Vec<models::MarginGetMarginIsolatedMarginDataV1RespItem>, Error<MarginGetMarginIsolatedMarginDataV1Error>> {
951
952 let uri_str = format!("{}/sapi/v1/margin/isolatedMarginData", configuration.base_path);
953 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
954
955 let mut query_params: Vec<(String, String)> = Vec::new();
957
958 if let Some(ref param_value) = params.vip_level {
959 query_params.push(("vipLevel".to_string(), param_value.to_string()));
960 }
961 if let Some(ref param_value) = params.symbol {
962 query_params.push(("symbol".to_string(), param_value.to_string()));
963 }
964 if let Some(ref param_value) = params.recv_window {
965 query_params.push(("recvWindow".to_string(), param_value.to_string()));
966 }
967 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
968
969 let mut header_params = std::collections::HashMap::new();
971
972 if let Some(ref binance_auth) = configuration.binance_auth {
974 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
976
977 let body_string: Option<Vec<u8>> = None;
979
980 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
982 Ok(sig) => sig,
983 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
984 };
985
986 query_params.push(("signature".to_string(), signature));
988 }
989
990 if !query_params.is_empty() {
992 req_builder = req_builder.query(&query_params);
993 }
994
995
996 if let Some(ref user_agent) = configuration.user_agent {
998 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
999 }
1000
1001 for (header_name, header_value) in header_params {
1003 req_builder = req_builder.header(&header_name, &header_value);
1004 }
1005
1006
1007 let req = req_builder.build()?;
1008 let resp = configuration.client.execute(req).await?;
1009
1010 let status = resp.status();
1011 let content_type = resp
1012 .headers()
1013 .get("content-type")
1014 .and_then(|v| v.to_str().ok())
1015 .unwrap_or("application/octet-stream");
1016 let content_type = super::ContentType::from(content_type);
1017
1018 if !status.is_client_error() && !status.is_server_error() {
1019 let content = resp.text().await?;
1020 match content_type {
1021 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1022 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::MarginGetMarginIsolatedMarginDataV1RespItem>`"))),
1023 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::MarginGetMarginIsolatedMarginDataV1RespItem>`")))),
1024 }
1025 } else {
1026 let content = resp.text().await?;
1027 let entity: Option<MarginGetMarginIsolatedMarginDataV1Error> = serde_json::from_str(&content).ok();
1028 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1029 }
1030}
1031
1032pub async fn margin_get_margin_trade_coeff_v1(configuration: &configuration::Configuration, params: MarginGetMarginTradeCoeffV1Params) -> Result<models::MarginGetMarginTradeCoeffV1Resp, Error<MarginGetMarginTradeCoeffV1Error>> {
1034
1035 let uri_str = format!("{}/sapi/v1/margin/tradeCoeff", configuration.base_path);
1036 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1037
1038 let mut query_params: Vec<(String, String)> = Vec::new();
1040
1041 if let Some(ref param_value) = params.recv_window {
1042 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1043 }
1044 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1045
1046 let mut header_params = std::collections::HashMap::new();
1048
1049 if let Some(ref binance_auth) = configuration.binance_auth {
1051 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1053
1054 let body_string: Option<Vec<u8>> = None;
1056
1057 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1059 Ok(sig) => sig,
1060 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1061 };
1062
1063 query_params.push(("signature".to_string(), signature));
1065 }
1066
1067 if !query_params.is_empty() {
1069 req_builder = req_builder.query(&query_params);
1070 }
1071
1072
1073 if let Some(ref user_agent) = configuration.user_agent {
1075 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1076 }
1077
1078 for (header_name, header_value) in header_params {
1080 req_builder = req_builder.header(&header_name, &header_value);
1081 }
1082
1083
1084 let req = req_builder.build()?;
1085 let resp = configuration.client.execute(req).await?;
1086
1087 let status = resp.status();
1088 let content_type = resp
1089 .headers()
1090 .get("content-type")
1091 .and_then(|v| v.to_str().ok())
1092 .unwrap_or("application/octet-stream");
1093 let content_type = super::ContentType::from(content_type);
1094
1095 if !status.is_client_error() && !status.is_server_error() {
1096 let content = resp.text().await?;
1097 match content_type {
1098 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1099 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MarginGetMarginTradeCoeffV1Resp`"))),
1100 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::MarginGetMarginTradeCoeffV1Resp`")))),
1101 }
1102 } else {
1103 let content = resp.text().await?;
1104 let entity: Option<MarginGetMarginTradeCoeffV1Error> = serde_json::from_str(&content).ok();
1105 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1106 }
1107}
1108