1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::derivatives::options::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct OptionsCreateBatchOrdersV1Params {
20 pub orders: Vec<models::OptionsCreateBatchOrdersV1ReqOrdersItem>,
21 pub timestamp: i64,
22 pub recv_window: Option<i64>
23}
24
25#[derive(Clone, Debug, Default)]
27pub struct OptionsCreateOrderV1Params {
28 pub quantity: String,
29 pub side: String,
30 pub symbol: String,
31 pub timestamp: i64,
32 pub r#type: String,
33 pub client_order_id: Option<String>,
34 pub is_mmp: Option<bool>,
35 pub new_order_resp_type: Option<String>,
36 pub post_only: Option<bool>,
37 pub price: Option<String>,
38 pub recv_window: Option<i64>,
39 pub reduce_only: Option<bool>,
40 pub time_in_force: Option<String>
41}
42
43#[derive(Clone, Debug, Default)]
45pub struct OptionsDeleteAllOpenOrdersByUnderlyingV1Params {
46 pub underlying: String,
48 pub timestamp: i64,
49 pub recv_window: Option<i64>
50}
51
52#[derive(Clone, Debug, Default)]
54pub struct OptionsDeleteAllOpenOrdersV1Params {
55 pub symbol: String,
57 pub timestamp: i64,
58 pub recv_window: Option<i64>
59}
60
61#[derive(Clone, Debug, Default)]
63pub struct OptionsDeleteBatchOrdersV1Params {
64 pub symbol: String,
66 pub timestamp: i64,
67 pub order_ids: Option<Vec<i64>>,
69 pub client_order_ids: Option<Vec<String>>,
71 pub recv_window: Option<i64>
72}
73
74#[derive(Clone, Debug, Default)]
76pub struct OptionsDeleteOrderV1Params {
77 pub symbol: String,
79 pub timestamp: i64,
80 pub order_id: Option<i64>,
82 pub client_order_id: Option<String>,
84 pub recv_window: Option<i64>
85}
86
87#[derive(Clone, Debug, Default)]
89pub struct OptionsGetExerciseRecordV1Params {
90 pub timestamp: i64,
91 pub symbol: Option<String>,
93 pub start_time: Option<i64>,
95 pub end_time: Option<i64>,
97 pub limit: Option<i32>,
99 pub recv_window: Option<i64>
100}
101
102#[derive(Clone, Debug, Default)]
104pub struct OptionsGetHistoryOrdersV1Params {
105 pub symbol: String,
107 pub timestamp: i64,
108 pub order_id: Option<i64>,
110 pub start_time: Option<i64>,
112 pub end_time: Option<i64>,
114 pub limit: Option<i32>,
116 pub recv_window: Option<i64>
117}
118
119#[derive(Clone, Debug, Default)]
121pub struct OptionsGetOpenOrdersV1Params {
122 pub timestamp: i64,
123 pub symbol: Option<String>,
125 pub order_id: Option<i64>,
127 pub start_time: Option<i64>,
129 pub end_time: Option<i64>,
131 pub limit: Option<i32>,
133 pub recv_window: Option<i64>
134}
135
136#[derive(Clone, Debug, Default)]
138pub struct OptionsGetOrderV1Params {
139 pub symbol: String,
141 pub timestamp: i64,
142 pub order_id: Option<i64>,
144 pub client_order_id: Option<String>,
146 pub recv_window: Option<i64>
147}
148
149#[derive(Clone, Debug, Default)]
151pub struct OptionsGetPositionV1Params {
152 pub timestamp: i64,
153 pub symbol: Option<String>,
155 pub recv_window: Option<i64>
156}
157
158#[derive(Clone, Debug, Default)]
160pub struct OptionsGetUserTradesV1Params {
161 pub timestamp: i64,
162 pub symbol: Option<String>,
164 pub from_id: Option<i64>,
166 pub start_time: Option<i64>,
168 pub end_time: Option<i64>,
170 pub limit: Option<i32>,
172 pub recv_window: Option<i64>
173}
174
175
176#[derive(Debug, Clone, Serialize, Deserialize)]
178#[serde(untagged)]
179pub enum OptionsCreateBatchOrdersV1Error {
180 Status4XX(models::ApiError),
181 Status5XX(models::ApiError),
182 UnknownValue(serde_json::Value),
183}
184
185#[derive(Debug, Clone, Serialize, Deserialize)]
187#[serde(untagged)]
188pub enum OptionsCreateOrderV1Error {
189 Status4XX(models::ApiError),
190 Status5XX(models::ApiError),
191 UnknownValue(serde_json::Value),
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum OptionsDeleteAllOpenOrdersByUnderlyingV1Error {
198 Status4XX(models::ApiError),
199 Status5XX(models::ApiError),
200 UnknownValue(serde_json::Value),
201}
202
203#[derive(Debug, Clone, Serialize, Deserialize)]
205#[serde(untagged)]
206pub enum OptionsDeleteAllOpenOrdersV1Error {
207 Status4XX(models::ApiError),
208 Status5XX(models::ApiError),
209 UnknownValue(serde_json::Value),
210}
211
212#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum OptionsDeleteBatchOrdersV1Error {
216 Status4XX(models::ApiError),
217 Status5XX(models::ApiError),
218 UnknownValue(serde_json::Value),
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize)]
223#[serde(untagged)]
224pub enum OptionsDeleteOrderV1Error {
225 Status4XX(models::ApiError),
226 Status5XX(models::ApiError),
227 UnknownValue(serde_json::Value),
228}
229
230#[derive(Debug, Clone, Serialize, Deserialize)]
232#[serde(untagged)]
233pub enum OptionsGetExerciseRecordV1Error {
234 Status4XX(models::ApiError),
235 Status5XX(models::ApiError),
236 UnknownValue(serde_json::Value),
237}
238
239#[derive(Debug, Clone, Serialize, Deserialize)]
241#[serde(untagged)]
242pub enum OptionsGetHistoryOrdersV1Error {
243 Status4XX(models::ApiError),
244 Status5XX(models::ApiError),
245 UnknownValue(serde_json::Value),
246}
247
248#[derive(Debug, Clone, Serialize, Deserialize)]
250#[serde(untagged)]
251pub enum OptionsGetOpenOrdersV1Error {
252 Status4XX(models::ApiError),
253 Status5XX(models::ApiError),
254 UnknownValue(serde_json::Value),
255}
256
257#[derive(Debug, Clone, Serialize, Deserialize)]
259#[serde(untagged)]
260pub enum OptionsGetOrderV1Error {
261 Status4XX(models::ApiError),
262 Status5XX(models::ApiError),
263 UnknownValue(serde_json::Value),
264}
265
266#[derive(Debug, Clone, Serialize, Deserialize)]
268#[serde(untagged)]
269pub enum OptionsGetPositionV1Error {
270 Status4XX(models::ApiError),
271 Status5XX(models::ApiError),
272 UnknownValue(serde_json::Value),
273}
274
275#[derive(Debug, Clone, Serialize, Deserialize)]
277#[serde(untagged)]
278pub enum OptionsGetUserTradesV1Error {
279 Status4XX(models::ApiError),
280 Status5XX(models::ApiError),
281 UnknownValue(serde_json::Value),
282}
283
284
285pub async fn options_create_batch_orders_v1(configuration: &configuration::Configuration, params: OptionsCreateBatchOrdersV1Params) -> Result<Vec<models::OptionsCreateBatchOrdersV1RespInner>, Error<OptionsCreateBatchOrdersV1Error>> {
287
288 let uri_str = format!("{}/eapi/v1/batchOrders", configuration.base_path);
289 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
290
291 let mut query_params: Vec<(String, String)> = Vec::new();
293
294
295 let mut header_params = std::collections::HashMap::new();
297
298 if let Some(ref binance_auth) = configuration.binance_auth {
300 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
302
303 let body_string: Option<Vec<u8>> = None;
305
306 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
308 Ok(sig) => sig,
309 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
310 };
311
312 query_params.push(("signature".to_string(), signature));
314 }
315
316 if !query_params.is_empty() {
318 req_builder = req_builder.query(&query_params);
319 }
320
321
322 if let Some(ref user_agent) = configuration.user_agent {
324 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
325 }
326
327 for (header_name, header_value) in header_params {
329 req_builder = req_builder.header(&header_name, &header_value);
330 }
331
332 let mut multipart_form_params = std::collections::HashMap::new();
333 multipart_form_params.insert("orders", params.orders.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
334 if let Some(param_value) = params.recv_window {
335 multipart_form_params.insert("recvWindow", param_value.to_string());
336 }
337 multipart_form_params.insert("timestamp", params.timestamp.to_string());
338 req_builder = req_builder.form(&multipart_form_params);
339
340 let req = req_builder.build()?;
341 let resp = configuration.client.execute(req).await?;
342
343 let status = resp.status();
344 let content_type = resp
345 .headers()
346 .get("content-type")
347 .and_then(|v| v.to_str().ok())
348 .unwrap_or("application/octet-stream");
349 let content_type = super::ContentType::from(content_type);
350
351 if !status.is_client_error() && !status.is_server_error() {
352 let content = resp.text().await?;
353 match content_type {
354 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
355 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsCreateBatchOrdersV1RespInner>`"))),
356 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::OptionsCreateBatchOrdersV1RespInner>`")))),
357 }
358 } else {
359 let content = resp.text().await?;
360 let entity: Option<OptionsCreateBatchOrdersV1Error> = serde_json::from_str(&content).ok();
361 Err(Error::ResponseError(ResponseContent { status, content, entity }))
362 }
363}
364
365pub async fn options_create_order_v1(configuration: &configuration::Configuration, params: OptionsCreateOrderV1Params) -> Result<models::OptionsCreateOrderV1Resp, Error<OptionsCreateOrderV1Error>> {
367
368 let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
369 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
370
371 let mut query_params: Vec<(String, String)> = Vec::new();
373
374
375 let mut header_params = std::collections::HashMap::new();
377
378 if let Some(ref binance_auth) = configuration.binance_auth {
380 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
382
383 let body_string: Option<Vec<u8>> = None;
385
386 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
388 Ok(sig) => sig,
389 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
390 };
391
392 query_params.push(("signature".to_string(), signature));
394 }
395
396 if !query_params.is_empty() {
398 req_builder = req_builder.query(&query_params);
399 }
400
401
402 if let Some(ref user_agent) = configuration.user_agent {
404 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
405 }
406
407 for (header_name, header_value) in header_params {
409 req_builder = req_builder.header(&header_name, &header_value);
410 }
411
412 let mut multipart_form_params = std::collections::HashMap::new();
413 if let Some(param_value) = params.client_order_id {
414 multipart_form_params.insert("clientOrderId", param_value.to_string());
415 }
416 if let Some(param_value) = params.is_mmp {
417 multipart_form_params.insert("isMmp", param_value.to_string());
418 }
419 if let Some(param_value) = params.new_order_resp_type {
420 multipart_form_params.insert("newOrderRespType", param_value.to_string());
421 }
422 if let Some(param_value) = params.post_only {
423 multipart_form_params.insert("postOnly", param_value.to_string());
424 }
425 if let Some(param_value) = params.price {
426 multipart_form_params.insert("price", param_value.to_string());
427 }
428 multipart_form_params.insert("quantity", params.quantity.to_string());
429 if let Some(param_value) = params.recv_window {
430 multipart_form_params.insert("recvWindow", param_value.to_string());
431 }
432 if let Some(param_value) = params.reduce_only {
433 multipart_form_params.insert("reduceOnly", param_value.to_string());
434 }
435 multipart_form_params.insert("side", params.side.to_string());
436 multipart_form_params.insert("symbol", params.symbol.to_string());
437 if let Some(param_value) = params.time_in_force {
438 multipart_form_params.insert("timeInForce", param_value.to_string());
439 }
440 multipart_form_params.insert("timestamp", params.timestamp.to_string());
441 multipart_form_params.insert("type", params.r#type.to_string());
442 req_builder = req_builder.form(&multipart_form_params);
443
444 let req = req_builder.build()?;
445 let resp = configuration.client.execute(req).await?;
446
447 let status = resp.status();
448 let content_type = resp
449 .headers()
450 .get("content-type")
451 .and_then(|v| v.to_str().ok())
452 .unwrap_or("application/octet-stream");
453 let content_type = super::ContentType::from(content_type);
454
455 if !status.is_client_error() && !status.is_server_error() {
456 let content = resp.text().await?;
457 match content_type {
458 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
459 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsCreateOrderV1Resp`"))),
460 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::OptionsCreateOrderV1Resp`")))),
461 }
462 } else {
463 let content = resp.text().await?;
464 let entity: Option<OptionsCreateOrderV1Error> = serde_json::from_str(&content).ok();
465 Err(Error::ResponseError(ResponseContent { status, content, entity }))
466 }
467}
468
469pub async fn options_delete_all_open_orders_by_underlying_v1(configuration: &configuration::Configuration, params: OptionsDeleteAllOpenOrdersByUnderlyingV1Params) -> Result<models::OptionsDeleteAllOpenOrdersByUnderlyingV1Resp, Error<OptionsDeleteAllOpenOrdersByUnderlyingV1Error>> {
471
472 let uri_str = format!("{}/eapi/v1/allOpenOrdersByUnderlying", configuration.base_path);
473 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
474
475 let mut query_params: Vec<(String, String)> = Vec::new();
477
478 query_params.push(("underlying".to_string(), params.underlying.to_string()));
479 if let Some(ref param_value) = params.recv_window {
480 query_params.push(("recvWindow".to_string(), param_value.to_string()));
481 }
482 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
483
484 let mut header_params = std::collections::HashMap::new();
486
487 if let Some(ref binance_auth) = configuration.binance_auth {
489 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
491
492 let body_string: Option<Vec<u8>> = None;
494
495 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
497 Ok(sig) => sig,
498 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
499 };
500
501 query_params.push(("signature".to_string(), signature));
503 }
504
505 if !query_params.is_empty() {
507 req_builder = req_builder.query(&query_params);
508 }
509
510
511 if let Some(ref user_agent) = configuration.user_agent {
513 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
514 }
515
516 for (header_name, header_value) in header_params {
518 req_builder = req_builder.header(&header_name, &header_value);
519 }
520
521
522 let req = req_builder.build()?;
523 let resp = configuration.client.execute(req).await?;
524
525 let status = resp.status();
526 let content_type = resp
527 .headers()
528 .get("content-type")
529 .and_then(|v| v.to_str().ok())
530 .unwrap_or("application/octet-stream");
531 let content_type = super::ContentType::from(content_type);
532
533 if !status.is_client_error() && !status.is_server_error() {
534 let content = resp.text().await?;
535 match content_type {
536 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
537 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsDeleteAllOpenOrdersByUnderlyingV1Resp`"))),
538 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::OptionsDeleteAllOpenOrdersByUnderlyingV1Resp`")))),
539 }
540 } else {
541 let content = resp.text().await?;
542 let entity: Option<OptionsDeleteAllOpenOrdersByUnderlyingV1Error> = serde_json::from_str(&content).ok();
543 Err(Error::ResponseError(ResponseContent { status, content, entity }))
544 }
545}
546
547pub async fn options_delete_all_open_orders_v1(configuration: &configuration::Configuration, params: OptionsDeleteAllOpenOrdersV1Params) -> Result<models::OptionsDeleteAllOpenOrdersV1Resp, Error<OptionsDeleteAllOpenOrdersV1Error>> {
549
550 let uri_str = format!("{}/eapi/v1/allOpenOrders", configuration.base_path);
551 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
552
553 let mut query_params: Vec<(String, String)> = Vec::new();
555
556 query_params.push(("symbol".to_string(), params.symbol.to_string()));
557 if let Some(ref param_value) = params.recv_window {
558 query_params.push(("recvWindow".to_string(), param_value.to_string()));
559 }
560 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
561
562 let mut header_params = std::collections::HashMap::new();
564
565 if let Some(ref binance_auth) = configuration.binance_auth {
567 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
569
570 let body_string: Option<Vec<u8>> = None;
572
573 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
575 Ok(sig) => sig,
576 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
577 };
578
579 query_params.push(("signature".to_string(), signature));
581 }
582
583 if !query_params.is_empty() {
585 req_builder = req_builder.query(&query_params);
586 }
587
588
589 if let Some(ref user_agent) = configuration.user_agent {
591 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
592 }
593
594 for (header_name, header_value) in header_params {
596 req_builder = req_builder.header(&header_name, &header_value);
597 }
598
599
600 let req = req_builder.build()?;
601 let resp = configuration.client.execute(req).await?;
602
603 let status = resp.status();
604 let content_type = resp
605 .headers()
606 .get("content-type")
607 .and_then(|v| v.to_str().ok())
608 .unwrap_or("application/octet-stream");
609 let content_type = super::ContentType::from(content_type);
610
611 if !status.is_client_error() && !status.is_server_error() {
612 let content = resp.text().await?;
613 match content_type {
614 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
615 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsDeleteAllOpenOrdersV1Resp`"))),
616 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::OptionsDeleteAllOpenOrdersV1Resp`")))),
617 }
618 } else {
619 let content = resp.text().await?;
620 let entity: Option<OptionsDeleteAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
621 Err(Error::ResponseError(ResponseContent { status, content, entity }))
622 }
623}
624
625pub async fn options_delete_batch_orders_v1(configuration: &configuration::Configuration, params: OptionsDeleteBatchOrdersV1Params) -> Result<Vec<models::OptionsDeleteBatchOrdersV1RespInner>, Error<OptionsDeleteBatchOrdersV1Error>> {
627
628 let uri_str = format!("{}/eapi/v1/batchOrders", configuration.base_path);
629 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
630
631 let mut query_params: Vec<(String, String)> = Vec::new();
633
634 query_params.push(("symbol".to_string(), params.symbol.to_string()));
635 if let Some(ref param_value) = params.order_ids {
636 match "multi" {
637 "multi" => {
638 for p in param_value {
639 query_params.push(("orderIds".to_string(), p.to_string()));
640 }
641 },
642 _ => {
643 let joined = param_value.iter()
644 .map(|p| p.to_string())
645 .collect::<Vec<String>>()
646 .join(",");
647 query_params.push(("orderIds".to_string(), joined));
648 }
649 };
650 }
651 if let Some(ref param_value) = params.client_order_ids {
652 match "multi" {
653 "multi" => {
654 for p in param_value {
655 query_params.push(("clientOrderIds".to_string(), p.to_string()));
656 }
657 },
658 _ => {
659 let joined = param_value.iter()
660 .map(|p| p.to_string())
661 .collect::<Vec<String>>()
662 .join(",");
663 query_params.push(("clientOrderIds".to_string(), joined));
664 }
665 };
666 }
667 if let Some(ref param_value) = params.recv_window {
668 query_params.push(("recvWindow".to_string(), param_value.to_string()));
669 }
670 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
671
672 let mut header_params = std::collections::HashMap::new();
674
675 if let Some(ref binance_auth) = configuration.binance_auth {
677 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
679
680 let body_string: Option<Vec<u8>> = None;
682
683 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
685 Ok(sig) => sig,
686 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
687 };
688
689 query_params.push(("signature".to_string(), signature));
691 }
692
693 if !query_params.is_empty() {
695 req_builder = req_builder.query(&query_params);
696 }
697
698
699 if let Some(ref user_agent) = configuration.user_agent {
701 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
702 }
703
704 for (header_name, header_value) in header_params {
706 req_builder = req_builder.header(&header_name, &header_value);
707 }
708
709
710 let req = req_builder.build()?;
711 let resp = configuration.client.execute(req).await?;
712
713 let status = resp.status();
714 let content_type = resp
715 .headers()
716 .get("content-type")
717 .and_then(|v| v.to_str().ok())
718 .unwrap_or("application/octet-stream");
719 let content_type = super::ContentType::from(content_type);
720
721 if !status.is_client_error() && !status.is_server_error() {
722 let content = resp.text().await?;
723 match content_type {
724 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
725 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsDeleteBatchOrdersV1RespInner>`"))),
726 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::OptionsDeleteBatchOrdersV1RespInner>`")))),
727 }
728 } else {
729 let content = resp.text().await?;
730 let entity: Option<OptionsDeleteBatchOrdersV1Error> = serde_json::from_str(&content).ok();
731 Err(Error::ResponseError(ResponseContent { status, content, entity }))
732 }
733}
734
735pub async fn options_delete_order_v1(configuration: &configuration::Configuration, params: OptionsDeleteOrderV1Params) -> Result<models::OptionsDeleteOrderV1Resp, Error<OptionsDeleteOrderV1Error>> {
737
738 let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
739 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
740
741 let mut query_params: Vec<(String, String)> = Vec::new();
743
744 query_params.push(("symbol".to_string(), params.symbol.to_string()));
745 if let Some(ref param_value) = params.order_id {
746 query_params.push(("orderId".to_string(), param_value.to_string()));
747 }
748 if let Some(ref param_value) = params.client_order_id {
749 query_params.push(("clientOrderId".to_string(), param_value.to_string()));
750 }
751 if let Some(ref param_value) = params.recv_window {
752 query_params.push(("recvWindow".to_string(), param_value.to_string()));
753 }
754 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
755
756 let mut header_params = std::collections::HashMap::new();
758
759 if let Some(ref binance_auth) = configuration.binance_auth {
761 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
763
764 let body_string: Option<Vec<u8>> = None;
766
767 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
769 Ok(sig) => sig,
770 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
771 };
772
773 query_params.push(("signature".to_string(), signature));
775 }
776
777 if !query_params.is_empty() {
779 req_builder = req_builder.query(&query_params);
780 }
781
782
783 if let Some(ref user_agent) = configuration.user_agent {
785 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
786 }
787
788 for (header_name, header_value) in header_params {
790 req_builder = req_builder.header(&header_name, &header_value);
791 }
792
793
794 let req = req_builder.build()?;
795 let resp = configuration.client.execute(req).await?;
796
797 let status = resp.status();
798 let content_type = resp
799 .headers()
800 .get("content-type")
801 .and_then(|v| v.to_str().ok())
802 .unwrap_or("application/octet-stream");
803 let content_type = super::ContentType::from(content_type);
804
805 if !status.is_client_error() && !status.is_server_error() {
806 let content = resp.text().await?;
807 match content_type {
808 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
809 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsDeleteOrderV1Resp`"))),
810 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::OptionsDeleteOrderV1Resp`")))),
811 }
812 } else {
813 let content = resp.text().await?;
814 let entity: Option<OptionsDeleteOrderV1Error> = serde_json::from_str(&content).ok();
815 Err(Error::ResponseError(ResponseContent { status, content, entity }))
816 }
817}
818
819pub async fn options_get_exercise_record_v1(configuration: &configuration::Configuration, params: OptionsGetExerciseRecordV1Params) -> Result<Vec<models::OptionsGetExerciseRecordV1RespItem>, Error<OptionsGetExerciseRecordV1Error>> {
821
822 let uri_str = format!("{}/eapi/v1/exerciseRecord", configuration.base_path);
823 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
824
825 let mut query_params: Vec<(String, String)> = Vec::new();
827
828 if let Some(ref param_value) = params.symbol {
829 query_params.push(("symbol".to_string(), param_value.to_string()));
830 }
831 if let Some(ref param_value) = params.start_time {
832 query_params.push(("startTime".to_string(), param_value.to_string()));
833 }
834 if let Some(ref param_value) = params.end_time {
835 query_params.push(("endTime".to_string(), param_value.to_string()));
836 }
837 if let Some(ref param_value) = params.limit {
838 query_params.push(("limit".to_string(), param_value.to_string()));
839 }
840 if let Some(ref param_value) = params.recv_window {
841 query_params.push(("recvWindow".to_string(), param_value.to_string()));
842 }
843 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
844
845 let mut header_params = std::collections::HashMap::new();
847
848 if let Some(ref binance_auth) = configuration.binance_auth {
850 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
852
853 let body_string: Option<Vec<u8>> = None;
855
856 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
858 Ok(sig) => sig,
859 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
860 };
861
862 query_params.push(("signature".to_string(), signature));
864 }
865
866 if !query_params.is_empty() {
868 req_builder = req_builder.query(&query_params);
869 }
870
871
872 if let Some(ref user_agent) = configuration.user_agent {
874 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
875 }
876
877 for (header_name, header_value) in header_params {
879 req_builder = req_builder.header(&header_name, &header_value);
880 }
881
882
883 let req = req_builder.build()?;
884 let resp = configuration.client.execute(req).await?;
885
886 let status = resp.status();
887 let content_type = resp
888 .headers()
889 .get("content-type")
890 .and_then(|v| v.to_str().ok())
891 .unwrap_or("application/octet-stream");
892 let content_type = super::ContentType::from(content_type);
893
894 if !status.is_client_error() && !status.is_server_error() {
895 let content = resp.text().await?;
896 match content_type {
897 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
898 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsGetExerciseRecordV1RespItem>`"))),
899 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::OptionsGetExerciseRecordV1RespItem>`")))),
900 }
901 } else {
902 let content = resp.text().await?;
903 let entity: Option<OptionsGetExerciseRecordV1Error> = serde_json::from_str(&content).ok();
904 Err(Error::ResponseError(ResponseContent { status, content, entity }))
905 }
906}
907
908pub async fn options_get_history_orders_v1(configuration: &configuration::Configuration, params: OptionsGetHistoryOrdersV1Params) -> Result<Vec<models::OptionsGetHistoryOrdersV1RespItem>, Error<OptionsGetHistoryOrdersV1Error>> {
910
911 let uri_str = format!("{}/eapi/v1/historyOrders", configuration.base_path);
912 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
913
914 let mut query_params: Vec<(String, String)> = Vec::new();
916
917 query_params.push(("symbol".to_string(), params.symbol.to_string()));
918 if let Some(ref param_value) = params.order_id {
919 query_params.push(("orderId".to_string(), param_value.to_string()));
920 }
921 if let Some(ref param_value) = params.start_time {
922 query_params.push(("startTime".to_string(), param_value.to_string()));
923 }
924 if let Some(ref param_value) = params.end_time {
925 query_params.push(("endTime".to_string(), param_value.to_string()));
926 }
927 if let Some(ref param_value) = params.limit {
928 query_params.push(("limit".to_string(), param_value.to_string()));
929 }
930 if let Some(ref param_value) = params.recv_window {
931 query_params.push(("recvWindow".to_string(), param_value.to_string()));
932 }
933 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
934
935 let mut header_params = std::collections::HashMap::new();
937
938 if let Some(ref binance_auth) = configuration.binance_auth {
940 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
942
943 let body_string: Option<Vec<u8>> = None;
945
946 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
948 Ok(sig) => sig,
949 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
950 };
951
952 query_params.push(("signature".to_string(), signature));
954 }
955
956 if !query_params.is_empty() {
958 req_builder = req_builder.query(&query_params);
959 }
960
961
962 if let Some(ref user_agent) = configuration.user_agent {
964 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
965 }
966
967 for (header_name, header_value) in header_params {
969 req_builder = req_builder.header(&header_name, &header_value);
970 }
971
972
973 let req = req_builder.build()?;
974 let resp = configuration.client.execute(req).await?;
975
976 let status = resp.status();
977 let content_type = resp
978 .headers()
979 .get("content-type")
980 .and_then(|v| v.to_str().ok())
981 .unwrap_or("application/octet-stream");
982 let content_type = super::ContentType::from(content_type);
983
984 if !status.is_client_error() && !status.is_server_error() {
985 let content = resp.text().await?;
986 match content_type {
987 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
988 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsGetHistoryOrdersV1RespItem>`"))),
989 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::OptionsGetHistoryOrdersV1RespItem>`")))),
990 }
991 } else {
992 let content = resp.text().await?;
993 let entity: Option<OptionsGetHistoryOrdersV1Error> = serde_json::from_str(&content).ok();
994 Err(Error::ResponseError(ResponseContent { status, content, entity }))
995 }
996}
997
998pub async fn options_get_open_orders_v1(configuration: &configuration::Configuration, params: OptionsGetOpenOrdersV1Params) -> Result<Vec<models::OptionsGetOpenOrdersV1RespItem>, Error<OptionsGetOpenOrdersV1Error>> {
1000
1001 let uri_str = format!("{}/eapi/v1/openOrders", configuration.base_path);
1002 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1003
1004 let mut query_params: Vec<(String, String)> = Vec::new();
1006
1007 if let Some(ref param_value) = params.symbol {
1008 query_params.push(("symbol".to_string(), param_value.to_string()));
1009 }
1010 if let Some(ref param_value) = params.order_id {
1011 query_params.push(("orderId".to_string(), param_value.to_string()));
1012 }
1013 if let Some(ref param_value) = params.start_time {
1014 query_params.push(("startTime".to_string(), param_value.to_string()));
1015 }
1016 if let Some(ref param_value) = params.end_time {
1017 query_params.push(("endTime".to_string(), param_value.to_string()));
1018 }
1019 if let Some(ref param_value) = params.limit {
1020 query_params.push(("limit".to_string(), param_value.to_string()));
1021 }
1022 if let Some(ref param_value) = params.recv_window {
1023 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1024 }
1025 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1026
1027 let mut header_params = std::collections::HashMap::new();
1029
1030 if let Some(ref binance_auth) = configuration.binance_auth {
1032 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1034
1035 let body_string: Option<Vec<u8>> = None;
1037
1038 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1040 Ok(sig) => sig,
1041 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1042 };
1043
1044 query_params.push(("signature".to_string(), signature));
1046 }
1047
1048 if !query_params.is_empty() {
1050 req_builder = req_builder.query(&query_params);
1051 }
1052
1053
1054 if let Some(ref user_agent) = configuration.user_agent {
1056 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1057 }
1058
1059 for (header_name, header_value) in header_params {
1061 req_builder = req_builder.header(&header_name, &header_value);
1062 }
1063
1064
1065 let req = req_builder.build()?;
1066 let resp = configuration.client.execute(req).await?;
1067
1068 let status = resp.status();
1069 let content_type = resp
1070 .headers()
1071 .get("content-type")
1072 .and_then(|v| v.to_str().ok())
1073 .unwrap_or("application/octet-stream");
1074 let content_type = super::ContentType::from(content_type);
1075
1076 if !status.is_client_error() && !status.is_server_error() {
1077 let content = resp.text().await?;
1078 match content_type {
1079 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1080 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsGetOpenOrdersV1RespItem>`"))),
1081 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::OptionsGetOpenOrdersV1RespItem>`")))),
1082 }
1083 } else {
1084 let content = resp.text().await?;
1085 let entity: Option<OptionsGetOpenOrdersV1Error> = serde_json::from_str(&content).ok();
1086 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1087 }
1088}
1089
1090pub async fn options_get_order_v1(configuration: &configuration::Configuration, params: OptionsGetOrderV1Params) -> Result<models::OptionsGetOrderV1Resp, Error<OptionsGetOrderV1Error>> {
1092
1093 let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
1094 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1095
1096 let mut query_params: Vec<(String, String)> = Vec::new();
1098
1099 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1100 if let Some(ref param_value) = params.order_id {
1101 query_params.push(("orderId".to_string(), param_value.to_string()));
1102 }
1103 if let Some(ref param_value) = params.client_order_id {
1104 query_params.push(("clientOrderId".to_string(), param_value.to_string()));
1105 }
1106 if let Some(ref param_value) = params.recv_window {
1107 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1108 }
1109 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1110
1111 let mut header_params = std::collections::HashMap::new();
1113
1114 if let Some(ref binance_auth) = configuration.binance_auth {
1116 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1118
1119 let body_string: Option<Vec<u8>> = None;
1121
1122 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1124 Ok(sig) => sig,
1125 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1126 };
1127
1128 query_params.push(("signature".to_string(), signature));
1130 }
1131
1132 if !query_params.is_empty() {
1134 req_builder = req_builder.query(&query_params);
1135 }
1136
1137
1138 if let Some(ref user_agent) = configuration.user_agent {
1140 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1141 }
1142
1143 for (header_name, header_value) in header_params {
1145 req_builder = req_builder.header(&header_name, &header_value);
1146 }
1147
1148
1149 let req = req_builder.build()?;
1150 let resp = configuration.client.execute(req).await?;
1151
1152 let status = resp.status();
1153 let content_type = resp
1154 .headers()
1155 .get("content-type")
1156 .and_then(|v| v.to_str().ok())
1157 .unwrap_or("application/octet-stream");
1158 let content_type = super::ContentType::from(content_type);
1159
1160 if !status.is_client_error() && !status.is_server_error() {
1161 let content = resp.text().await?;
1162 match content_type {
1163 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1164 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsGetOrderV1Resp`"))),
1165 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::OptionsGetOrderV1Resp`")))),
1166 }
1167 } else {
1168 let content = resp.text().await?;
1169 let entity: Option<OptionsGetOrderV1Error> = serde_json::from_str(&content).ok();
1170 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1171 }
1172}
1173
1174pub async fn options_get_position_v1(configuration: &configuration::Configuration, params: OptionsGetPositionV1Params) -> Result<Vec<models::OptionsGetPositionV1RespItem>, Error<OptionsGetPositionV1Error>> {
1176
1177 let uri_str = format!("{}/eapi/v1/position", configuration.base_path);
1178 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1179
1180 let mut query_params: Vec<(String, String)> = Vec::new();
1182
1183 if let Some(ref param_value) = params.symbol {
1184 query_params.push(("symbol".to_string(), param_value.to_string()));
1185 }
1186 if let Some(ref param_value) = params.recv_window {
1187 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1188 }
1189 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1190
1191 let mut header_params = std::collections::HashMap::new();
1193
1194 if let Some(ref binance_auth) = configuration.binance_auth {
1196 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1198
1199 let body_string: Option<Vec<u8>> = None;
1201
1202 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1204 Ok(sig) => sig,
1205 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1206 };
1207
1208 query_params.push(("signature".to_string(), signature));
1210 }
1211
1212 if !query_params.is_empty() {
1214 req_builder = req_builder.query(&query_params);
1215 }
1216
1217
1218 if let Some(ref user_agent) = configuration.user_agent {
1220 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1221 }
1222
1223 for (header_name, header_value) in header_params {
1225 req_builder = req_builder.header(&header_name, &header_value);
1226 }
1227
1228
1229 let req = req_builder.build()?;
1230 let resp = configuration.client.execute(req).await?;
1231
1232 let status = resp.status();
1233 let content_type = resp
1234 .headers()
1235 .get("content-type")
1236 .and_then(|v| v.to_str().ok())
1237 .unwrap_or("application/octet-stream");
1238 let content_type = super::ContentType::from(content_type);
1239
1240 if !status.is_client_error() && !status.is_server_error() {
1241 let content = resp.text().await?;
1242 match content_type {
1243 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1244 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsGetPositionV1RespItem>`"))),
1245 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::OptionsGetPositionV1RespItem>`")))),
1246 }
1247 } else {
1248 let content = resp.text().await?;
1249 let entity: Option<OptionsGetPositionV1Error> = serde_json::from_str(&content).ok();
1250 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1251 }
1252}
1253
1254pub async fn options_get_user_trades_v1(configuration: &configuration::Configuration, params: OptionsGetUserTradesV1Params) -> Result<Vec<models::OptionsGetUserTradesV1RespItem>, Error<OptionsGetUserTradesV1Error>> {
1256
1257 let uri_str = format!("{}/eapi/v1/userTrades", configuration.base_path);
1258 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1259
1260 let mut query_params: Vec<(String, String)> = Vec::new();
1262
1263 if let Some(ref param_value) = params.symbol {
1264 query_params.push(("symbol".to_string(), param_value.to_string()));
1265 }
1266 if let Some(ref param_value) = params.from_id {
1267 query_params.push(("fromId".to_string(), param_value.to_string()));
1268 }
1269 if let Some(ref param_value) = params.start_time {
1270 query_params.push(("startTime".to_string(), param_value.to_string()));
1271 }
1272 if let Some(ref param_value) = params.end_time {
1273 query_params.push(("endTime".to_string(), param_value.to_string()));
1274 }
1275 if let Some(ref param_value) = params.limit {
1276 query_params.push(("limit".to_string(), param_value.to_string()));
1277 }
1278 if let Some(ref param_value) = params.recv_window {
1279 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1280 }
1281 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1282
1283 let mut header_params = std::collections::HashMap::new();
1285
1286 if let Some(ref binance_auth) = configuration.binance_auth {
1288 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1290
1291 let body_string: Option<Vec<u8>> = None;
1293
1294 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1296 Ok(sig) => sig,
1297 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1298 };
1299
1300 query_params.push(("signature".to_string(), signature));
1302 }
1303
1304 if !query_params.is_empty() {
1306 req_builder = req_builder.query(&query_params);
1307 }
1308
1309
1310 if let Some(ref user_agent) = configuration.user_agent {
1312 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1313 }
1314
1315 for (header_name, header_value) in header_params {
1317 req_builder = req_builder.header(&header_name, &header_value);
1318 }
1319
1320
1321 let req = req_builder.build()?;
1322 let resp = configuration.client.execute(req).await?;
1323
1324 let status = resp.status();
1325 let content_type = resp
1326 .headers()
1327 .get("content-type")
1328 .and_then(|v| v.to_str().ok())
1329 .unwrap_or("application/octet-stream");
1330 let content_type = super::ContentType::from(content_type);
1331
1332 if !status.is_client_error() && !status.is_server_error() {
1333 let content = resp.text().await?;
1334 match content_type {
1335 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1336 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsGetUserTradesV1RespItem>`"))),
1337 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::OptionsGetUserTradesV1RespItem>`")))),
1338 }
1339 } else {
1340 let content = resp.text().await?;
1341 let entity: Option<OptionsGetUserTradesV1Error> = serde_json::from_str(&content).ok();
1342 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1343 }
1344}
1345