1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::options::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct CreateBatchOrdersV1Params {
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 CreateBlockOrderExecuteV1Params {
28 pub block_order_matching_key: String,
29 pub timestamp: i64,
30 pub recv_window: Option<i64>
31}
32
33#[derive(Clone, Debug, Default)]
35pub struct CreateCountdownCancelAllHeartBeatV1Params {
36 pub timestamp: i64,
37 pub underlyings: String,
38 pub recv_window: Option<i64>
39}
40
41#[derive(Clone, Debug, Default)]
43pub struct CreateCountdownCancelAllV1Params {
44 pub countdown_time: i64,
45 pub timestamp: i64,
46 pub underlying: String,
47 pub recv_window: Option<i64>
48}
49
50#[derive(Clone, Debug, Default)]
52pub struct CreateMmpResetV1Params {
53 pub timestamp: i64,
54 pub recv_window: Option<i64>,
55 pub underlying: Option<String>
56}
57
58#[derive(Clone, Debug, Default)]
60pub struct CreateMmpSetV1Params {
61 pub timestamp: i64,
62 pub delta_limit: Option<String>,
63 pub frozen_time_in_milliseconds: Option<i64>,
64 pub qty_limit: Option<String>,
65 pub recv_window: Option<i64>,
66 pub underlying: Option<String>,
67 pub window_time_in_milliseconds: Option<i64>
68}
69
70#[derive(Clone, Debug, Default)]
72pub struct CreateOrderV1Params {
73 pub quantity: String,
74 pub side: String,
75 pub symbol: String,
76 pub timestamp: i64,
77 pub r#type: String,
78 pub client_order_id: Option<String>,
79 pub is_mmp: Option<bool>,
80 pub new_order_resp_type: Option<String>,
81 pub post_only: Option<bool>,
82 pub price: Option<String>,
83 pub recv_window: Option<i64>,
84 pub reduce_only: Option<bool>,
85 pub time_in_force: Option<String>
86}
87
88#[derive(Clone, Debug, Default)]
90pub struct DeleteAllOpenOrdersByUnderlyingV1Params {
91 pub underlying: String,
93 pub timestamp: i64,
94 pub recv_window: Option<i64>
95}
96
97#[derive(Clone, Debug, Default)]
99pub struct DeleteAllOpenOrdersV1Params {
100 pub symbol: String,
102 pub timestamp: i64,
103 pub recv_window: Option<i64>
104}
105
106#[derive(Clone, Debug, Default)]
108pub struct DeleteBatchOrdersV1Params {
109 pub symbol: String,
111 pub timestamp: i64,
112 pub order_ids: Option<Vec<i64>>,
114 pub client_order_ids: Option<Vec<String>>,
116 pub recv_window: Option<i64>
117}
118
119#[derive(Clone, Debug, Default)]
121pub struct DeleteOrderV1Params {
122 pub symbol: String,
124 pub timestamp: i64,
125 pub order_id: Option<i64>,
127 pub client_order_id: Option<String>,
129 pub recv_window: Option<i64>
130}
131
132#[derive(Clone, Debug, Default)]
134pub struct GetAccountV1Params {
135 pub timestamp: i64,
136 pub recv_window: Option<i64>
137}
138
139#[derive(Clone, Debug, Default)]
141pub struct GetBillV1Params {
142 pub currency: String,
144 pub timestamp: i64,
145 pub record_id: Option<i64>,
147 pub start_time: Option<i64>,
149 pub end_time: Option<i64>,
151 pub limit: Option<i32>,
153 pub recv_window: Option<i64>
154}
155
156#[derive(Clone, Debug, Default)]
158pub struct GetBlockOrderExecuteV1Params {
159 pub block_order_matching_key: String,
160 pub timestamp: i64,
161 pub recv_window: Option<i64>
163}
164
165#[derive(Clone, Debug, Default)]
167pub struct GetBlockOrderOrdersV1Params {
168 pub timestamp: i64,
169 pub block_order_matching_key: Option<String>,
171 pub end_time: Option<i64>,
172 pub start_time: Option<i64>,
173 pub underlying: Option<String>,
174 pub recv_window: Option<i64>
176}
177
178#[derive(Clone, Debug, Default)]
180pub struct GetBlockTradesV1Params {
181 pub symbol: Option<String>,
183 pub limit: Option<i32>
185}
186
187#[derive(Clone, Debug, Default)]
189pub struct GetBlockUserTradesV1Params {
190 pub timestamp: i64,
191 pub end_time: Option<i64>,
192 pub start_time: Option<i64>,
193 pub underlying: Option<String>,
194 pub recv_window: Option<i64>
196}
197
198#[derive(Clone, Debug, Default)]
200pub struct GetCountdownCancelAllV1Params {
201 pub timestamp: i64,
202 pub underlying: Option<String>,
204 pub recv_window: Option<i64>
205}
206
207#[derive(Clone, Debug, Default)]
209pub struct GetDepthV1Params {
210 pub symbol: String,
212 pub limit: Option<i32>
214}
215
216#[derive(Clone, Debug, Default)]
218pub struct GetExerciseHistoryV1Params {
219 pub underlying: Option<String>,
221 pub start_time: Option<i64>,
223 pub end_time: Option<i64>,
225 pub limit: Option<i32>
227}
228
229#[derive(Clone, Debug, Default)]
231pub struct GetExerciseRecordV1Params {
232 pub timestamp: i64,
233 pub symbol: Option<String>,
235 pub start_time: Option<i64>,
237 pub end_time: Option<i64>,
239 pub limit: Option<i32>,
241 pub recv_window: Option<i64>
242}
243
244#[derive(Clone, Debug, Default)]
246pub struct GetHistoricalTradesV1Params {
247 pub symbol: String,
249 pub from_id: Option<i64>,
251 pub limit: Option<i32>
253}
254
255#[derive(Clone, Debug, Default)]
257pub struct GetHistoryOrdersV1Params {
258 pub symbol: String,
260 pub timestamp: i64,
261 pub order_id: Option<i64>,
263 pub start_time: Option<i64>,
265 pub end_time: Option<i64>,
267 pub limit: Option<i32>,
269 pub recv_window: Option<i64>
270}
271
272#[derive(Clone, Debug, Default)]
274pub struct GetIncomeAsynIdV1Params {
275 pub download_id: String,
277 pub timestamp: i64,
278 pub recv_window: Option<i64>
279}
280
281#[derive(Clone, Debug, Default)]
283pub struct GetIndexV1Params {
284 pub underlying: String
286}
287
288#[derive(Clone, Debug, Default)]
290pub struct GetKlinesV1Params {
291 pub symbol: String,
293 pub interval: String,
295 pub start_time: Option<i64>,
297 pub end_time: Option<i64>,
299 pub limit: Option<i32>
301}
302
303#[derive(Clone, Debug, Default)]
305pub struct GetMarginAccountV1Params {
306 pub timestamp: i64,
307 pub recv_window: Option<i64>
308}
309
310#[derive(Clone, Debug, Default)]
312pub struct GetMarkV1Params {
313 pub symbol: Option<String>
315}
316
317#[derive(Clone, Debug, Default)]
319pub struct GetMmpV1Params {
320 pub timestamp: i64,
321 pub underlying: Option<String>,
323 pub recv_window: Option<i64>
324}
325
326#[derive(Clone, Debug, Default)]
328pub struct GetOpenInterestV1Params {
329 pub underlying_asset: String,
331 pub expiration: String
333}
334
335#[derive(Clone, Debug, Default)]
337pub struct GetOpenOrdersV1Params {
338 pub timestamp: i64,
339 pub symbol: Option<String>,
341 pub order_id: Option<i64>,
343 pub start_time: Option<i64>,
345 pub end_time: Option<i64>,
347 pub limit: Option<i32>,
349 pub recv_window: Option<i64>
350}
351
352#[derive(Clone, Debug, Default)]
354pub struct GetOrderV1Params {
355 pub symbol: String,
357 pub timestamp: i64,
358 pub order_id: Option<i64>,
360 pub client_order_id: Option<String>,
362 pub recv_window: Option<i64>
363}
364
365#[derive(Clone, Debug, Default)]
367pub struct GetPositionV1Params {
368 pub timestamp: i64,
369 pub symbol: Option<String>,
371 pub recv_window: Option<i64>
372}
373
374#[derive(Clone, Debug, Default)]
376pub struct GetTickerV1Params {
377 pub symbol: Option<String>
379}
380
381#[derive(Clone, Debug, Default)]
383pub struct GetTradesV1Params {
384 pub symbol: String,
386 pub limit: Option<i32>
388}
389
390#[derive(Clone, Debug, Default)]
392pub struct GetUserTradesV1Params {
393 pub timestamp: i64,
394 pub symbol: Option<String>,
396 pub from_id: Option<i64>,
398 pub start_time: Option<i64>,
400 pub end_time: Option<i64>,
402 pub limit: Option<i32>,
404 pub recv_window: Option<i64>
405}
406
407#[derive(Clone, Debug, Default)]
409pub struct UpdateBlockOrderCreateV1Params {
410 pub block_order_matching_key: String,
411 pub timestamp: i32,
412 pub recv_window: Option<i32>
413}
414
415
416#[derive(Debug, Clone, Serialize, Deserialize)]
418#[serde(untagged)]
419pub enum CreateBatchOrdersV1Error {
420 Status4XX(models::ApiError),
421 Status5XX(models::ApiError),
422 UnknownValue(serde_json::Value),
423}
424
425#[derive(Debug, Clone, Serialize, Deserialize)]
427#[serde(untagged)]
428pub enum CreateBlockOrderExecuteV1Error {
429 Status4XX(models::ApiError),
430 Status5XX(models::ApiError),
431 UnknownValue(serde_json::Value),
432}
433
434#[derive(Debug, Clone, Serialize, Deserialize)]
436#[serde(untagged)]
437pub enum CreateCountdownCancelAllHeartBeatV1Error {
438 Status4XX(models::ApiError),
439 Status5XX(models::ApiError),
440 UnknownValue(serde_json::Value),
441}
442
443#[derive(Debug, Clone, Serialize, Deserialize)]
445#[serde(untagged)]
446pub enum CreateCountdownCancelAllV1Error {
447 Status4XX(models::ApiError),
448 Status5XX(models::ApiError),
449 UnknownValue(serde_json::Value),
450}
451
452#[derive(Debug, Clone, Serialize, Deserialize)]
454#[serde(untagged)]
455pub enum CreateListenKeyV1Error {
456 Status4XX(models::ApiError),
457 Status5XX(models::ApiError),
458 UnknownValue(serde_json::Value),
459}
460
461#[derive(Debug, Clone, Serialize, Deserialize)]
463#[serde(untagged)]
464pub enum CreateMmpResetV1Error {
465 Status4XX(models::ApiError),
466 Status5XX(models::ApiError),
467 UnknownValue(serde_json::Value),
468}
469
470#[derive(Debug, Clone, Serialize, Deserialize)]
472#[serde(untagged)]
473pub enum CreateMmpSetV1Error {
474 Status4XX(models::ApiError),
475 Status5XX(models::ApiError),
476 UnknownValue(serde_json::Value),
477}
478
479#[derive(Debug, Clone, Serialize, Deserialize)]
481#[serde(untagged)]
482pub enum CreateOrderV1Error {
483 Status4XX(models::ApiError),
484 Status5XX(models::ApiError),
485 UnknownValue(serde_json::Value),
486}
487
488#[derive(Debug, Clone, Serialize, Deserialize)]
490#[serde(untagged)]
491pub enum DeleteAllOpenOrdersByUnderlyingV1Error {
492 Status4XX(models::ApiError),
493 Status5XX(models::ApiError),
494 UnknownValue(serde_json::Value),
495}
496
497#[derive(Debug, Clone, Serialize, Deserialize)]
499#[serde(untagged)]
500pub enum DeleteAllOpenOrdersV1Error {
501 Status4XX(models::ApiError),
502 Status5XX(models::ApiError),
503 UnknownValue(serde_json::Value),
504}
505
506#[derive(Debug, Clone, Serialize, Deserialize)]
508#[serde(untagged)]
509pub enum DeleteBatchOrdersV1Error {
510 Status4XX(models::ApiError),
511 Status5XX(models::ApiError),
512 UnknownValue(serde_json::Value),
513}
514
515#[derive(Debug, Clone, Serialize, Deserialize)]
517#[serde(untagged)]
518pub enum DeleteListenKeyV1Error {
519 Status4XX(models::ApiError),
520 Status5XX(models::ApiError),
521 UnknownValue(serde_json::Value),
522}
523
524#[derive(Debug, Clone, Serialize, Deserialize)]
526#[serde(untagged)]
527pub enum DeleteOrderV1Error {
528 Status4XX(models::ApiError),
529 Status5XX(models::ApiError),
530 UnknownValue(serde_json::Value),
531}
532
533#[derive(Debug, Clone, Serialize, Deserialize)]
535#[serde(untagged)]
536pub enum GetAccountV1Error {
537 Status4XX(models::ApiError),
538 Status5XX(models::ApiError),
539 UnknownValue(serde_json::Value),
540}
541
542#[derive(Debug, Clone, Serialize, Deserialize)]
544#[serde(untagged)]
545pub enum GetBillV1Error {
546 Status4XX(models::ApiError),
547 Status5XX(models::ApiError),
548 UnknownValue(serde_json::Value),
549}
550
551#[derive(Debug, Clone, Serialize, Deserialize)]
553#[serde(untagged)]
554pub enum GetBlockOrderExecuteV1Error {
555 Status4XX(models::ApiError),
556 Status5XX(models::ApiError),
557 UnknownValue(serde_json::Value),
558}
559
560#[derive(Debug, Clone, Serialize, Deserialize)]
562#[serde(untagged)]
563pub enum GetBlockOrderOrdersV1Error {
564 Status4XX(models::ApiError),
565 Status5XX(models::ApiError),
566 UnknownValue(serde_json::Value),
567}
568
569#[derive(Debug, Clone, Serialize, Deserialize)]
571#[serde(untagged)]
572pub enum GetBlockTradesV1Error {
573 Status4XX(models::ApiError),
574 Status5XX(models::ApiError),
575 UnknownValue(serde_json::Value),
576}
577
578#[derive(Debug, Clone, Serialize, Deserialize)]
580#[serde(untagged)]
581pub enum GetBlockUserTradesV1Error {
582 Status4XX(models::ApiError),
583 Status5XX(models::ApiError),
584 UnknownValue(serde_json::Value),
585}
586
587#[derive(Debug, Clone, Serialize, Deserialize)]
589#[serde(untagged)]
590pub enum GetCountdownCancelAllV1Error {
591 Status4XX(models::ApiError),
592 Status5XX(models::ApiError),
593 UnknownValue(serde_json::Value),
594}
595
596#[derive(Debug, Clone, Serialize, Deserialize)]
598#[serde(untagged)]
599pub enum GetDepthV1Error {
600 Status4XX(models::ApiError),
601 Status5XX(models::ApiError),
602 UnknownValue(serde_json::Value),
603}
604
605#[derive(Debug, Clone, Serialize, Deserialize)]
607#[serde(untagged)]
608pub enum GetExchangeInfoV1Error {
609 Status4XX(models::ApiError),
610 Status5XX(models::ApiError),
611 UnknownValue(serde_json::Value),
612}
613
614#[derive(Debug, Clone, Serialize, Deserialize)]
616#[serde(untagged)]
617pub enum GetExerciseHistoryV1Error {
618 Status4XX(models::ApiError),
619 Status5XX(models::ApiError),
620 UnknownValue(serde_json::Value),
621}
622
623#[derive(Debug, Clone, Serialize, Deserialize)]
625#[serde(untagged)]
626pub enum GetExerciseRecordV1Error {
627 Status4XX(models::ApiError),
628 Status5XX(models::ApiError),
629 UnknownValue(serde_json::Value),
630}
631
632#[derive(Debug, Clone, Serialize, Deserialize)]
634#[serde(untagged)]
635pub enum GetHistoricalTradesV1Error {
636 Status4XX(models::ApiError),
637 Status5XX(models::ApiError),
638 UnknownValue(serde_json::Value),
639}
640
641#[derive(Debug, Clone, Serialize, Deserialize)]
643#[serde(untagged)]
644pub enum GetHistoryOrdersV1Error {
645 Status4XX(models::ApiError),
646 Status5XX(models::ApiError),
647 UnknownValue(serde_json::Value),
648}
649
650#[derive(Debug, Clone, Serialize, Deserialize)]
652#[serde(untagged)]
653pub enum GetIncomeAsynIdV1Error {
654 Status4XX(models::ApiError),
655 Status5XX(models::ApiError),
656 UnknownValue(serde_json::Value),
657}
658
659#[derive(Debug, Clone, Serialize, Deserialize)]
661#[serde(untagged)]
662pub enum GetIncomeAsynV1Error {
663 Status4XX(models::ApiError),
664 Status5XX(models::ApiError),
665 UnknownValue(serde_json::Value),
666}
667
668#[derive(Debug, Clone, Serialize, Deserialize)]
670#[serde(untagged)]
671pub enum GetIndexV1Error {
672 Status4XX(models::ApiError),
673 Status5XX(models::ApiError),
674 UnknownValue(serde_json::Value),
675}
676
677#[derive(Debug, Clone, Serialize, Deserialize)]
679#[serde(untagged)]
680pub enum GetKlinesV1Error {
681 Status4XX(models::ApiError),
682 Status5XX(models::ApiError),
683 UnknownValue(serde_json::Value),
684}
685
686#[derive(Debug, Clone, Serialize, Deserialize)]
688#[serde(untagged)]
689pub enum GetMarginAccountV1Error {
690 Status4XX(models::ApiError),
691 Status5XX(models::ApiError),
692 UnknownValue(serde_json::Value),
693}
694
695#[derive(Debug, Clone, Serialize, Deserialize)]
697#[serde(untagged)]
698pub enum GetMarkV1Error {
699 Status4XX(models::ApiError),
700 Status5XX(models::ApiError),
701 UnknownValue(serde_json::Value),
702}
703
704#[derive(Debug, Clone, Serialize, Deserialize)]
706#[serde(untagged)]
707pub enum GetMmpV1Error {
708 Status4XX(models::ApiError),
709 Status5XX(models::ApiError),
710 UnknownValue(serde_json::Value),
711}
712
713#[derive(Debug, Clone, Serialize, Deserialize)]
715#[serde(untagged)]
716pub enum GetOpenInterestV1Error {
717 Status4XX(models::ApiError),
718 Status5XX(models::ApiError),
719 UnknownValue(serde_json::Value),
720}
721
722#[derive(Debug, Clone, Serialize, Deserialize)]
724#[serde(untagged)]
725pub enum GetOpenOrdersV1Error {
726 Status4XX(models::ApiError),
727 Status5XX(models::ApiError),
728 UnknownValue(serde_json::Value),
729}
730
731#[derive(Debug, Clone, Serialize, Deserialize)]
733#[serde(untagged)]
734pub enum GetOrderV1Error {
735 Status4XX(models::ApiError),
736 Status5XX(models::ApiError),
737 UnknownValue(serde_json::Value),
738}
739
740#[derive(Debug, Clone, Serialize, Deserialize)]
742#[serde(untagged)]
743pub enum GetPingV1Error {
744 Status4XX(models::ApiError),
745 Status5XX(models::ApiError),
746 UnknownValue(serde_json::Value),
747}
748
749#[derive(Debug, Clone, Serialize, Deserialize)]
751#[serde(untagged)]
752pub enum GetPositionV1Error {
753 Status4XX(models::ApiError),
754 Status5XX(models::ApiError),
755 UnknownValue(serde_json::Value),
756}
757
758#[derive(Debug, Clone, Serialize, Deserialize)]
760#[serde(untagged)]
761pub enum GetTickerV1Error {
762 Status4XX(models::ApiError),
763 Status5XX(models::ApiError),
764 UnknownValue(serde_json::Value),
765}
766
767#[derive(Debug, Clone, Serialize, Deserialize)]
769#[serde(untagged)]
770pub enum GetTimeV1Error {
771 Status4XX(models::ApiError),
772 Status5XX(models::ApiError),
773 UnknownValue(serde_json::Value),
774}
775
776#[derive(Debug, Clone, Serialize, Deserialize)]
778#[serde(untagged)]
779pub enum GetTradesV1Error {
780 Status4XX(models::ApiError),
781 Status5XX(models::ApiError),
782 UnknownValue(serde_json::Value),
783}
784
785#[derive(Debug, Clone, Serialize, Deserialize)]
787#[serde(untagged)]
788pub enum GetUserTradesV1Error {
789 Status4XX(models::ApiError),
790 Status5XX(models::ApiError),
791 UnknownValue(serde_json::Value),
792}
793
794#[derive(Debug, Clone, Serialize, Deserialize)]
796#[serde(untagged)]
797pub enum UpdateBlockOrderCreateV1Error {
798 Status4XX(models::ApiError),
799 Status5XX(models::ApiError),
800 UnknownValue(serde_json::Value),
801}
802
803#[derive(Debug, Clone, Serialize, Deserialize)]
805#[serde(untagged)]
806pub enum UpdateListenKeyV1Error {
807 Status4XX(models::ApiError),
808 Status5XX(models::ApiError),
809 UnknownValue(serde_json::Value),
810}
811
812
813pub async fn create_batch_orders_v1(configuration: &configuration::Configuration, params: CreateBatchOrdersV1Params) -> Result<Vec<models::OptionsCreateBatchOrdersV1RespInner>, Error<CreateBatchOrdersV1Error>> {
815
816 let uri_str = format!("{}/eapi/v1/batchOrders", configuration.base_path);
817 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
818
819 let mut query_params: Vec<(String, String)> = Vec::new();
821
822
823 let mut header_params = std::collections::HashMap::new();
825
826 if let Some(ref binance_auth) = configuration.binance_auth {
828 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
830
831 let body_string: Option<Vec<u8>> = None;
833
834 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
836 Ok(sig) => sig,
837 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
838 };
839
840 query_params.push(("signature".to_string(), signature));
842 }
843
844 if !query_params.is_empty() {
846 req_builder = req_builder.query(&query_params);
847 }
848
849
850 if let Some(ref user_agent) = configuration.user_agent {
852 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
853 }
854
855 for (header_name, header_value) in header_params {
857 req_builder = req_builder.header(&header_name, &header_value);
858 }
859
860 let mut multipart_form_params = std::collections::HashMap::new();
861 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());
862 if let Some(param_value) = params.recv_window {
863 multipart_form_params.insert("recvWindow", param_value.to_string());
864 }
865 multipart_form_params.insert("timestamp", params.timestamp.to_string());
866 req_builder = req_builder.form(&multipart_form_params);
867
868 let req = req_builder.build()?;
869 let resp = configuration.client.execute(req).await?;
870
871 let status = resp.status();
872 let content_type = resp
873 .headers()
874 .get("content-type")
875 .and_then(|v| v.to_str().ok())
876 .unwrap_or("application/octet-stream");
877 let content_type = super::ContentType::from(content_type);
878
879 if !status.is_client_error() && !status.is_server_error() {
880 let content = resp.text().await?;
881 match content_type {
882 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
883 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsCreateBatchOrdersV1RespInner>`"))),
884 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>`")))),
885 }
886 } else {
887 let content = resp.text().await?;
888 let entity: Option<CreateBatchOrdersV1Error> = serde_json::from_str(&content).ok();
889 Err(Error::ResponseError(ResponseContent { status, content, entity }))
890 }
891}
892
893pub async fn create_block_order_execute_v1(configuration: &configuration::Configuration, params: CreateBlockOrderExecuteV1Params) -> Result<models::CreateBlockOrderExecuteV1Resp, Error<CreateBlockOrderExecuteV1Error>> {
895
896 let uri_str = format!("{}/eapi/v1/block/order/execute", configuration.base_path);
897 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
898
899 let mut query_params: Vec<(String, String)> = Vec::new();
901
902
903 let mut header_params = std::collections::HashMap::new();
905
906 if let Some(ref binance_auth) = configuration.binance_auth {
908 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
910
911 let body_string: Option<Vec<u8>> = None;
913
914 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
916 Ok(sig) => sig,
917 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
918 };
919
920 query_params.push(("signature".to_string(), signature));
922 }
923
924 if !query_params.is_empty() {
926 req_builder = req_builder.query(&query_params);
927 }
928
929
930 if let Some(ref user_agent) = configuration.user_agent {
932 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
933 }
934
935 for (header_name, header_value) in header_params {
937 req_builder = req_builder.header(&header_name, &header_value);
938 }
939
940 let mut multipart_form_params = std::collections::HashMap::new();
941 multipart_form_params.insert("blockOrderMatchingKey", params.block_order_matching_key.to_string());
942 if let Some(param_value) = params.recv_window {
943 multipart_form_params.insert("recvWindow", param_value.to_string());
944 }
945 multipart_form_params.insert("timestamp", params.timestamp.to_string());
946 req_builder = req_builder.form(&multipart_form_params);
947
948 let req = req_builder.build()?;
949 let resp = configuration.client.execute(req).await?;
950
951 let status = resp.status();
952 let content_type = resp
953 .headers()
954 .get("content-type")
955 .and_then(|v| v.to_str().ok())
956 .unwrap_or("application/octet-stream");
957 let content_type = super::ContentType::from(content_type);
958
959 if !status.is_client_error() && !status.is_server_error() {
960 let content = resp.text().await?;
961 match content_type {
962 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
963 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateBlockOrderExecuteV1Resp`"))),
964 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::CreateBlockOrderExecuteV1Resp`")))),
965 }
966 } else {
967 let content = resp.text().await?;
968 let entity: Option<CreateBlockOrderExecuteV1Error> = serde_json::from_str(&content).ok();
969 Err(Error::ResponseError(ResponseContent { status, content, entity }))
970 }
971}
972
973pub async fn create_countdown_cancel_all_heart_beat_v1(configuration: &configuration::Configuration, params: CreateCountdownCancelAllHeartBeatV1Params) -> Result<models::CreateCountdownCancelAllHeartBeatV1Resp, Error<CreateCountdownCancelAllHeartBeatV1Error>> {
975
976 let uri_str = format!("{}/eapi/v1/countdownCancelAllHeartBeat", configuration.base_path);
977 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
978
979 let mut query_params: Vec<(String, String)> = Vec::new();
981
982
983 let mut header_params = std::collections::HashMap::new();
985
986 if let Some(ref binance_auth) = configuration.binance_auth {
988 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
990
991 let body_string: Option<Vec<u8>> = None;
993
994 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
996 Ok(sig) => sig,
997 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
998 };
999
1000 query_params.push(("signature".to_string(), signature));
1002 }
1003
1004 if !query_params.is_empty() {
1006 req_builder = req_builder.query(&query_params);
1007 }
1008
1009
1010 if let Some(ref user_agent) = configuration.user_agent {
1012 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1013 }
1014
1015 for (header_name, header_value) in header_params {
1017 req_builder = req_builder.header(&header_name, &header_value);
1018 }
1019
1020 let mut multipart_form_params = std::collections::HashMap::new();
1021 if let Some(param_value) = params.recv_window {
1022 multipart_form_params.insert("recvWindow", param_value.to_string());
1023 }
1024 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1025 multipart_form_params.insert("underlyings", params.underlyings.to_string());
1026 req_builder = req_builder.form(&multipart_form_params);
1027
1028 let req = req_builder.build()?;
1029 let resp = configuration.client.execute(req).await?;
1030
1031 let status = resp.status();
1032 let content_type = resp
1033 .headers()
1034 .get("content-type")
1035 .and_then(|v| v.to_str().ok())
1036 .unwrap_or("application/octet-stream");
1037 let content_type = super::ContentType::from(content_type);
1038
1039 if !status.is_client_error() && !status.is_server_error() {
1040 let content = resp.text().await?;
1041 match content_type {
1042 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1043 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCountdownCancelAllHeartBeatV1Resp`"))),
1044 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::CreateCountdownCancelAllHeartBeatV1Resp`")))),
1045 }
1046 } else {
1047 let content = resp.text().await?;
1048 let entity: Option<CreateCountdownCancelAllHeartBeatV1Error> = serde_json::from_str(&content).ok();
1049 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1050 }
1051}
1052
1053pub async fn create_countdown_cancel_all_v1(configuration: &configuration::Configuration, params: CreateCountdownCancelAllV1Params) -> Result<models::CreateCountdownCancelAllV1Resp, Error<CreateCountdownCancelAllV1Error>> {
1055
1056 let uri_str = format!("{}/eapi/v1/countdownCancelAll", configuration.base_path);
1057 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1058
1059 let mut query_params: Vec<(String, String)> = Vec::new();
1061
1062
1063 let mut header_params = std::collections::HashMap::new();
1065
1066 if let Some(ref binance_auth) = configuration.binance_auth {
1068 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1070
1071 let body_string: Option<Vec<u8>> = None;
1073
1074 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1076 Ok(sig) => sig,
1077 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1078 };
1079
1080 query_params.push(("signature".to_string(), signature));
1082 }
1083
1084 if !query_params.is_empty() {
1086 req_builder = req_builder.query(&query_params);
1087 }
1088
1089
1090 if let Some(ref user_agent) = configuration.user_agent {
1092 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1093 }
1094
1095 for (header_name, header_value) in header_params {
1097 req_builder = req_builder.header(&header_name, &header_value);
1098 }
1099
1100 let mut multipart_form_params = std::collections::HashMap::new();
1101 multipart_form_params.insert("countdownTime", params.countdown_time.to_string());
1102 if let Some(param_value) = params.recv_window {
1103 multipart_form_params.insert("recvWindow", param_value.to_string());
1104 }
1105 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1106 multipart_form_params.insert("underlying", params.underlying.to_string());
1107 req_builder = req_builder.form(&multipart_form_params);
1108
1109 let req = req_builder.build()?;
1110 let resp = configuration.client.execute(req).await?;
1111
1112 let status = resp.status();
1113 let content_type = resp
1114 .headers()
1115 .get("content-type")
1116 .and_then(|v| v.to_str().ok())
1117 .unwrap_or("application/octet-stream");
1118 let content_type = super::ContentType::from(content_type);
1119
1120 if !status.is_client_error() && !status.is_server_error() {
1121 let content = resp.text().await?;
1122 match content_type {
1123 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1124 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCountdownCancelAllV1Resp`"))),
1125 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::CreateCountdownCancelAllV1Resp`")))),
1126 }
1127 } else {
1128 let content = resp.text().await?;
1129 let entity: Option<CreateCountdownCancelAllV1Error> = serde_json::from_str(&content).ok();
1130 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1131 }
1132}
1133
1134pub async fn create_listen_key_v1(configuration: &configuration::Configuration) -> Result<models::CreateListenKeyV1Resp, Error<CreateListenKeyV1Error>> {
1136
1137 let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
1138 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1139
1140 let mut query_params: Vec<(String, String)> = Vec::new();
1142
1143
1144 let mut header_params = std::collections::HashMap::new();
1146
1147 if let Some(ref binance_auth) = configuration.binance_auth {
1149 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1151
1152 let body_string: Option<Vec<u8>> = None;
1154
1155 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1157 Ok(sig) => sig,
1158 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1159 };
1160
1161 query_params.push(("signature".to_string(), signature));
1163 }
1164
1165 if !query_params.is_empty() {
1167 req_builder = req_builder.query(&query_params);
1168 }
1169
1170
1171 if let Some(ref user_agent) = configuration.user_agent {
1173 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1174 }
1175
1176 for (header_name, header_value) in header_params {
1178 req_builder = req_builder.header(&header_name, &header_value);
1179 }
1180
1181
1182 let req = req_builder.build()?;
1183 let resp = configuration.client.execute(req).await?;
1184
1185 let status = resp.status();
1186 let content_type = resp
1187 .headers()
1188 .get("content-type")
1189 .and_then(|v| v.to_str().ok())
1190 .unwrap_or("application/octet-stream");
1191 let content_type = super::ContentType::from(content_type);
1192
1193 if !status.is_client_error() && !status.is_server_error() {
1194 let content = resp.text().await?;
1195 match content_type {
1196 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1197 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateListenKeyV1Resp`"))),
1198 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::CreateListenKeyV1Resp`")))),
1199 }
1200 } else {
1201 let content = resp.text().await?;
1202 let entity: Option<CreateListenKeyV1Error> = serde_json::from_str(&content).ok();
1203 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1204 }
1205}
1206
1207pub async fn create_mmp_reset_v1(configuration: &configuration::Configuration, params: CreateMmpResetV1Params) -> Result<models::CreateMmpResetV1Resp, Error<CreateMmpResetV1Error>> {
1209
1210 let uri_str = format!("{}/eapi/v1/mmpReset", configuration.base_path);
1211 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1212
1213 let mut query_params: Vec<(String, String)> = Vec::new();
1215
1216
1217 let mut header_params = std::collections::HashMap::new();
1219
1220 if let Some(ref binance_auth) = configuration.binance_auth {
1222 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1224
1225 let body_string: Option<Vec<u8>> = None;
1227
1228 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1230 Ok(sig) => sig,
1231 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1232 };
1233
1234 query_params.push(("signature".to_string(), signature));
1236 }
1237
1238 if !query_params.is_empty() {
1240 req_builder = req_builder.query(&query_params);
1241 }
1242
1243
1244 if let Some(ref user_agent) = configuration.user_agent {
1246 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1247 }
1248
1249 for (header_name, header_value) in header_params {
1251 req_builder = req_builder.header(&header_name, &header_value);
1252 }
1253
1254 let mut multipart_form_params = std::collections::HashMap::new();
1255 if let Some(param_value) = params.recv_window {
1256 multipart_form_params.insert("recvWindow", param_value.to_string());
1257 }
1258 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1259 if let Some(param_value) = params.underlying {
1260 multipart_form_params.insert("underlying", param_value.to_string());
1261 }
1262 req_builder = req_builder.form(&multipart_form_params);
1263
1264 let req = req_builder.build()?;
1265 let resp = configuration.client.execute(req).await?;
1266
1267 let status = resp.status();
1268 let content_type = resp
1269 .headers()
1270 .get("content-type")
1271 .and_then(|v| v.to_str().ok())
1272 .unwrap_or("application/octet-stream");
1273 let content_type = super::ContentType::from(content_type);
1274
1275 if !status.is_client_error() && !status.is_server_error() {
1276 let content = resp.text().await?;
1277 match content_type {
1278 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1279 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMmpResetV1Resp`"))),
1280 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::CreateMmpResetV1Resp`")))),
1281 }
1282 } else {
1283 let content = resp.text().await?;
1284 let entity: Option<CreateMmpResetV1Error> = serde_json::from_str(&content).ok();
1285 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1286 }
1287}
1288
1289pub async fn create_mmp_set_v1(configuration: &configuration::Configuration, params: CreateMmpSetV1Params) -> Result<models::CreateMmpSetV1Resp, Error<CreateMmpSetV1Error>> {
1291
1292 let uri_str = format!("{}/eapi/v1/mmpSet", configuration.base_path);
1293 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1294
1295 let mut query_params: Vec<(String, String)> = Vec::new();
1297
1298
1299 let mut header_params = std::collections::HashMap::new();
1301
1302 if let Some(ref binance_auth) = configuration.binance_auth {
1304 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1306
1307 let body_string: Option<Vec<u8>> = None;
1309
1310 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1312 Ok(sig) => sig,
1313 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1314 };
1315
1316 query_params.push(("signature".to_string(), signature));
1318 }
1319
1320 if !query_params.is_empty() {
1322 req_builder = req_builder.query(&query_params);
1323 }
1324
1325
1326 if let Some(ref user_agent) = configuration.user_agent {
1328 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1329 }
1330
1331 for (header_name, header_value) in header_params {
1333 req_builder = req_builder.header(&header_name, &header_value);
1334 }
1335
1336 let mut multipart_form_params = std::collections::HashMap::new();
1337 if let Some(param_value) = params.delta_limit {
1338 multipart_form_params.insert("deltaLimit", param_value.to_string());
1339 }
1340 if let Some(param_value) = params.frozen_time_in_milliseconds {
1341 multipart_form_params.insert("frozenTimeInMilliseconds", param_value.to_string());
1342 }
1343 if let Some(param_value) = params.qty_limit {
1344 multipart_form_params.insert("qtyLimit", param_value.to_string());
1345 }
1346 if let Some(param_value) = params.recv_window {
1347 multipart_form_params.insert("recvWindow", param_value.to_string());
1348 }
1349 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1350 if let Some(param_value) = params.underlying {
1351 multipart_form_params.insert("underlying", param_value.to_string());
1352 }
1353 if let Some(param_value) = params.window_time_in_milliseconds {
1354 multipart_form_params.insert("windowTimeInMilliseconds", param_value.to_string());
1355 }
1356 req_builder = req_builder.form(&multipart_form_params);
1357
1358 let req = req_builder.build()?;
1359 let resp = configuration.client.execute(req).await?;
1360
1361 let status = resp.status();
1362 let content_type = resp
1363 .headers()
1364 .get("content-type")
1365 .and_then(|v| v.to_str().ok())
1366 .unwrap_or("application/octet-stream");
1367 let content_type = super::ContentType::from(content_type);
1368
1369 if !status.is_client_error() && !status.is_server_error() {
1370 let content = resp.text().await?;
1371 match content_type {
1372 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1373 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMmpSetV1Resp`"))),
1374 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::CreateMmpSetV1Resp`")))),
1375 }
1376 } else {
1377 let content = resp.text().await?;
1378 let entity: Option<CreateMmpSetV1Error> = serde_json::from_str(&content).ok();
1379 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1380 }
1381}
1382
1383pub async fn create_order_v1(configuration: &configuration::Configuration, params: CreateOrderV1Params) -> Result<models::OptionsCreateOrderV1Resp, Error<CreateOrderV1Error>> {
1385
1386 let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
1387 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1388
1389 let mut query_params: Vec<(String, String)> = Vec::new();
1391
1392
1393 let mut header_params = std::collections::HashMap::new();
1395
1396 if let Some(ref binance_auth) = configuration.binance_auth {
1398 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1400
1401 let body_string: Option<Vec<u8>> = None;
1403
1404 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1406 Ok(sig) => sig,
1407 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1408 };
1409
1410 query_params.push(("signature".to_string(), signature));
1412 }
1413
1414 if !query_params.is_empty() {
1416 req_builder = req_builder.query(&query_params);
1417 }
1418
1419
1420 if let Some(ref user_agent) = configuration.user_agent {
1422 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1423 }
1424
1425 for (header_name, header_value) in header_params {
1427 req_builder = req_builder.header(&header_name, &header_value);
1428 }
1429
1430 let mut multipart_form_params = std::collections::HashMap::new();
1431 if let Some(param_value) = params.client_order_id {
1432 multipart_form_params.insert("clientOrderId", param_value.to_string());
1433 }
1434 if let Some(param_value) = params.is_mmp {
1435 multipart_form_params.insert("isMmp", param_value.to_string());
1436 }
1437 if let Some(param_value) = params.new_order_resp_type {
1438 multipart_form_params.insert("newOrderRespType", param_value.to_string());
1439 }
1440 if let Some(param_value) = params.post_only {
1441 multipart_form_params.insert("postOnly", param_value.to_string());
1442 }
1443 if let Some(param_value) = params.price {
1444 multipart_form_params.insert("price", param_value.to_string());
1445 }
1446 multipart_form_params.insert("quantity", params.quantity.to_string());
1447 if let Some(param_value) = params.recv_window {
1448 multipart_form_params.insert("recvWindow", param_value.to_string());
1449 }
1450 if let Some(param_value) = params.reduce_only {
1451 multipart_form_params.insert("reduceOnly", param_value.to_string());
1452 }
1453 multipart_form_params.insert("side", params.side.to_string());
1454 multipart_form_params.insert("symbol", params.symbol.to_string());
1455 if let Some(param_value) = params.time_in_force {
1456 multipart_form_params.insert("timeInForce", param_value.to_string());
1457 }
1458 multipart_form_params.insert("timestamp", params.timestamp.to_string());
1459 multipart_form_params.insert("type", params.r#type.to_string());
1460 req_builder = req_builder.form(&multipart_form_params);
1461
1462 let req = req_builder.build()?;
1463 let resp = configuration.client.execute(req).await?;
1464
1465 let status = resp.status();
1466 let content_type = resp
1467 .headers()
1468 .get("content-type")
1469 .and_then(|v| v.to_str().ok())
1470 .unwrap_or("application/octet-stream");
1471 let content_type = super::ContentType::from(content_type);
1472
1473 if !status.is_client_error() && !status.is_server_error() {
1474 let content = resp.text().await?;
1475 match content_type {
1476 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1477 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsCreateOrderV1Resp`"))),
1478 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`")))),
1479 }
1480 } else {
1481 let content = resp.text().await?;
1482 let entity: Option<CreateOrderV1Error> = serde_json::from_str(&content).ok();
1483 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1484 }
1485}
1486
1487pub async fn delete_all_open_orders_by_underlying_v1(configuration: &configuration::Configuration, params: DeleteAllOpenOrdersByUnderlyingV1Params) -> Result<models::DeleteAllOpenOrdersByUnderlyingV1Resp, Error<DeleteAllOpenOrdersByUnderlyingV1Error>> {
1489
1490 let uri_str = format!("{}/eapi/v1/allOpenOrdersByUnderlying", configuration.base_path);
1491 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1492
1493 let mut query_params: Vec<(String, String)> = Vec::new();
1495
1496 query_params.push(("underlying".to_string(), params.underlying.to_string()));
1497 if let Some(ref param_value) = params.recv_window {
1498 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1499 }
1500 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1501
1502 let mut header_params = std::collections::HashMap::new();
1504
1505 if let Some(ref binance_auth) = configuration.binance_auth {
1507 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1509
1510 let body_string: Option<Vec<u8>> = None;
1512
1513 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1515 Ok(sig) => sig,
1516 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1517 };
1518
1519 query_params.push(("signature".to_string(), signature));
1521 }
1522
1523 if !query_params.is_empty() {
1525 req_builder = req_builder.query(&query_params);
1526 }
1527
1528
1529 if let Some(ref user_agent) = configuration.user_agent {
1531 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1532 }
1533
1534 for (header_name, header_value) in header_params {
1536 req_builder = req_builder.header(&header_name, &header_value);
1537 }
1538
1539
1540 let req = req_builder.build()?;
1541 let resp = configuration.client.execute(req).await?;
1542
1543 let status = resp.status();
1544 let content_type = resp
1545 .headers()
1546 .get("content-type")
1547 .and_then(|v| v.to_str().ok())
1548 .unwrap_or("application/octet-stream");
1549 let content_type = super::ContentType::from(content_type);
1550
1551 if !status.is_client_error() && !status.is_server_error() {
1552 let content = resp.text().await?;
1553 match content_type {
1554 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1555 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAllOpenOrdersByUnderlyingV1Resp`"))),
1556 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::DeleteAllOpenOrdersByUnderlyingV1Resp`")))),
1557 }
1558 } else {
1559 let content = resp.text().await?;
1560 let entity: Option<DeleteAllOpenOrdersByUnderlyingV1Error> = serde_json::from_str(&content).ok();
1561 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1562 }
1563}
1564
1565pub async fn delete_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteAllOpenOrdersV1Params) -> Result<models::DeleteAllOpenOrdersV1Resp, Error<DeleteAllOpenOrdersV1Error>> {
1567
1568 let uri_str = format!("{}/eapi/v1/allOpenOrders", configuration.base_path);
1569 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1570
1571 let mut query_params: Vec<(String, String)> = Vec::new();
1573
1574 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1575 if let Some(ref param_value) = params.recv_window {
1576 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1577 }
1578 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1579
1580 let mut header_params = std::collections::HashMap::new();
1582
1583 if let Some(ref binance_auth) = configuration.binance_auth {
1585 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1587
1588 let body_string: Option<Vec<u8>> = None;
1590
1591 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1593 Ok(sig) => sig,
1594 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1595 };
1596
1597 query_params.push(("signature".to_string(), signature));
1599 }
1600
1601 if !query_params.is_empty() {
1603 req_builder = req_builder.query(&query_params);
1604 }
1605
1606
1607 if let Some(ref user_agent) = configuration.user_agent {
1609 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1610 }
1611
1612 for (header_name, header_value) in header_params {
1614 req_builder = req_builder.header(&header_name, &header_value);
1615 }
1616
1617
1618 let req = req_builder.build()?;
1619 let resp = configuration.client.execute(req).await?;
1620
1621 let status = resp.status();
1622 let content_type = resp
1623 .headers()
1624 .get("content-type")
1625 .and_then(|v| v.to_str().ok())
1626 .unwrap_or("application/octet-stream");
1627 let content_type = super::ContentType::from(content_type);
1628
1629 if !status.is_client_error() && !status.is_server_error() {
1630 let content = resp.text().await?;
1631 match content_type {
1632 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1633 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAllOpenOrdersV1Resp`"))),
1634 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::DeleteAllOpenOrdersV1Resp`")))),
1635 }
1636 } else {
1637 let content = resp.text().await?;
1638 let entity: Option<DeleteAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
1639 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1640 }
1641}
1642
1643pub async fn delete_batch_orders_v1(configuration: &configuration::Configuration, params: DeleteBatchOrdersV1Params) -> Result<Vec<models::OptionsDeleteBatchOrdersV1RespInner>, Error<DeleteBatchOrdersV1Error>> {
1645
1646 let uri_str = format!("{}/eapi/v1/batchOrders", configuration.base_path);
1647 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1648
1649 let mut query_params: Vec<(String, String)> = Vec::new();
1651
1652 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1653 if let Some(ref param_value) = params.order_ids {
1654 match "multi" {
1655 "multi" => {
1656 for p in param_value {
1657 query_params.push(("orderIds".to_string(), p.to_string()));
1658 }
1659 },
1660 _ => {
1661 let joined = param_value.iter()
1662 .map(|p| p.to_string())
1663 .collect::<Vec<String>>()
1664 .join(",");
1665 query_params.push(("orderIds".to_string(), joined));
1666 }
1667 };
1668 }
1669 if let Some(ref param_value) = params.client_order_ids {
1670 match "multi" {
1671 "multi" => {
1672 for p in param_value {
1673 query_params.push(("clientOrderIds".to_string(), p.to_string()));
1674 }
1675 },
1676 _ => {
1677 let joined = param_value.iter()
1678 .map(|p| p.to_string())
1679 .collect::<Vec<String>>()
1680 .join(",");
1681 query_params.push(("clientOrderIds".to_string(), joined));
1682 }
1683 };
1684 }
1685 if let Some(ref param_value) = params.recv_window {
1686 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1687 }
1688 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1689
1690 let mut header_params = std::collections::HashMap::new();
1692
1693 if let Some(ref binance_auth) = configuration.binance_auth {
1695 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1697
1698 let body_string: Option<Vec<u8>> = None;
1700
1701 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1703 Ok(sig) => sig,
1704 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1705 };
1706
1707 query_params.push(("signature".to_string(), signature));
1709 }
1710
1711 if !query_params.is_empty() {
1713 req_builder = req_builder.query(&query_params);
1714 }
1715
1716
1717 if let Some(ref user_agent) = configuration.user_agent {
1719 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1720 }
1721
1722 for (header_name, header_value) in header_params {
1724 req_builder = req_builder.header(&header_name, &header_value);
1725 }
1726
1727
1728 let req = req_builder.build()?;
1729 let resp = configuration.client.execute(req).await?;
1730
1731 let status = resp.status();
1732 let content_type = resp
1733 .headers()
1734 .get("content-type")
1735 .and_then(|v| v.to_str().ok())
1736 .unwrap_or("application/octet-stream");
1737 let content_type = super::ContentType::from(content_type);
1738
1739 if !status.is_client_error() && !status.is_server_error() {
1740 let content = resp.text().await?;
1741 match content_type {
1742 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1743 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsDeleteBatchOrdersV1RespInner>`"))),
1744 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>`")))),
1745 }
1746 } else {
1747 let content = resp.text().await?;
1748 let entity: Option<DeleteBatchOrdersV1Error> = serde_json::from_str(&content).ok();
1749 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1750 }
1751}
1752
1753pub async fn delete_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<DeleteListenKeyV1Error>> {
1755
1756 let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
1757 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1758
1759 let mut query_params: Vec<(String, String)> = Vec::new();
1761
1762
1763 let mut header_params = std::collections::HashMap::new();
1765
1766 if let Some(ref binance_auth) = configuration.binance_auth {
1768 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1770
1771 let body_string: Option<Vec<u8>> = None;
1773
1774 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1776 Ok(sig) => sig,
1777 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1778 };
1779
1780 query_params.push(("signature".to_string(), signature));
1782 }
1783
1784 if !query_params.is_empty() {
1786 req_builder = req_builder.query(&query_params);
1787 }
1788
1789
1790 if let Some(ref user_agent) = configuration.user_agent {
1792 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1793 }
1794
1795 for (header_name, header_value) in header_params {
1797 req_builder = req_builder.header(&header_name, &header_value);
1798 }
1799
1800
1801 let req = req_builder.build()?;
1802 let resp = configuration.client.execute(req).await?;
1803
1804 let status = resp.status();
1805 let content_type = resp
1806 .headers()
1807 .get("content-type")
1808 .and_then(|v| v.to_str().ok())
1809 .unwrap_or("application/octet-stream");
1810 let content_type = super::ContentType::from(content_type);
1811
1812 if !status.is_client_error() && !status.is_server_error() {
1813 let content = resp.text().await?;
1814 match content_type {
1815 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1816 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
1817 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
1818 }
1819 } else {
1820 let content = resp.text().await?;
1821 let entity: Option<DeleteListenKeyV1Error> = serde_json::from_str(&content).ok();
1822 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1823 }
1824}
1825
1826pub async fn delete_order_v1(configuration: &configuration::Configuration, params: DeleteOrderV1Params) -> Result<models::DeleteOrderV1Resp, Error<DeleteOrderV1Error>> {
1828
1829 let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
1830 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1831
1832 let mut query_params: Vec<(String, String)> = Vec::new();
1834
1835 query_params.push(("symbol".to_string(), params.symbol.to_string()));
1836 if let Some(ref param_value) = params.order_id {
1837 query_params.push(("orderId".to_string(), param_value.to_string()));
1838 }
1839 if let Some(ref param_value) = params.client_order_id {
1840 query_params.push(("clientOrderId".to_string(), param_value.to_string()));
1841 }
1842 if let Some(ref param_value) = params.recv_window {
1843 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1844 }
1845 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1846
1847 let mut header_params = std::collections::HashMap::new();
1849
1850 if let Some(ref binance_auth) = configuration.binance_auth {
1852 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1854
1855 let body_string: Option<Vec<u8>> = None;
1857
1858 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1860 Ok(sig) => sig,
1861 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1862 };
1863
1864 query_params.push(("signature".to_string(), signature));
1866 }
1867
1868 if !query_params.is_empty() {
1870 req_builder = req_builder.query(&query_params);
1871 }
1872
1873
1874 if let Some(ref user_agent) = configuration.user_agent {
1876 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1877 }
1878
1879 for (header_name, header_value) in header_params {
1881 req_builder = req_builder.header(&header_name, &header_value);
1882 }
1883
1884
1885 let req = req_builder.build()?;
1886 let resp = configuration.client.execute(req).await?;
1887
1888 let status = resp.status();
1889 let content_type = resp
1890 .headers()
1891 .get("content-type")
1892 .and_then(|v| v.to_str().ok())
1893 .unwrap_or("application/octet-stream");
1894 let content_type = super::ContentType::from(content_type);
1895
1896 if !status.is_client_error() && !status.is_server_error() {
1897 let content = resp.text().await?;
1898 match content_type {
1899 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1900 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteOrderV1Resp`"))),
1901 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::DeleteOrderV1Resp`")))),
1902 }
1903 } else {
1904 let content = resp.text().await?;
1905 let entity: Option<DeleteOrderV1Error> = serde_json::from_str(&content).ok();
1906 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1907 }
1908}
1909
1910pub async fn get_account_v1(configuration: &configuration::Configuration, params: GetAccountV1Params) -> Result<models::GetAccountV1Resp, Error<GetAccountV1Error>> {
1912
1913 let uri_str = format!("{}/eapi/v1/account", configuration.base_path);
1914 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1915
1916 let mut query_params: Vec<(String, String)> = Vec::new();
1918
1919 if let Some(ref param_value) = params.recv_window {
1920 query_params.push(("recvWindow".to_string(), param_value.to_string()));
1921 }
1922 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1923
1924 let mut header_params = std::collections::HashMap::new();
1926
1927 if let Some(ref binance_auth) = configuration.binance_auth {
1929 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1931
1932 let body_string: Option<Vec<u8>> = None;
1934
1935 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1937 Ok(sig) => sig,
1938 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1939 };
1940
1941 query_params.push(("signature".to_string(), signature));
1943 }
1944
1945 if !query_params.is_empty() {
1947 req_builder = req_builder.query(&query_params);
1948 }
1949
1950
1951 if let Some(ref user_agent) = configuration.user_agent {
1953 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1954 }
1955
1956 for (header_name, header_value) in header_params {
1958 req_builder = req_builder.header(&header_name, &header_value);
1959 }
1960
1961
1962 let req = req_builder.build()?;
1963 let resp = configuration.client.execute(req).await?;
1964
1965 let status = resp.status();
1966 let content_type = resp
1967 .headers()
1968 .get("content-type")
1969 .and_then(|v| v.to_str().ok())
1970 .unwrap_or("application/octet-stream");
1971 let content_type = super::ContentType::from(content_type);
1972
1973 if !status.is_client_error() && !status.is_server_error() {
1974 let content = resp.text().await?;
1975 match content_type {
1976 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1977 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountV1Resp`"))),
1978 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::GetAccountV1Resp`")))),
1979 }
1980 } else {
1981 let content = resp.text().await?;
1982 let entity: Option<GetAccountV1Error> = serde_json::from_str(&content).ok();
1983 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1984 }
1985}
1986
1987pub async fn get_bill_v1(configuration: &configuration::Configuration, params: GetBillV1Params) -> Result<Vec<models::GetBillV1RespItem>, Error<GetBillV1Error>> {
1989
1990 let uri_str = format!("{}/eapi/v1/bill", configuration.base_path);
1991 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1992
1993 let mut query_params: Vec<(String, String)> = Vec::new();
1995
1996 query_params.push(("currency".to_string(), params.currency.to_string()));
1997 if let Some(ref param_value) = params.record_id {
1998 query_params.push(("recordId".to_string(), param_value.to_string()));
1999 }
2000 if let Some(ref param_value) = params.start_time {
2001 query_params.push(("startTime".to_string(), param_value.to_string()));
2002 }
2003 if let Some(ref param_value) = params.end_time {
2004 query_params.push(("endTime".to_string(), param_value.to_string()));
2005 }
2006 if let Some(ref param_value) = params.limit {
2007 query_params.push(("limit".to_string(), param_value.to_string()));
2008 }
2009 if let Some(ref param_value) = params.recv_window {
2010 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2011 }
2012 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2013
2014 let mut header_params = std::collections::HashMap::new();
2016
2017 if let Some(ref binance_auth) = configuration.binance_auth {
2019 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2021
2022 let body_string: Option<Vec<u8>> = None;
2024
2025 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2027 Ok(sig) => sig,
2028 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2029 };
2030
2031 query_params.push(("signature".to_string(), signature));
2033 }
2034
2035 if !query_params.is_empty() {
2037 req_builder = req_builder.query(&query_params);
2038 }
2039
2040
2041 if let Some(ref user_agent) = configuration.user_agent {
2043 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2044 }
2045
2046 for (header_name, header_value) in header_params {
2048 req_builder = req_builder.header(&header_name, &header_value);
2049 }
2050
2051
2052 let req = req_builder.build()?;
2053 let resp = configuration.client.execute(req).await?;
2054
2055 let status = resp.status();
2056 let content_type = resp
2057 .headers()
2058 .get("content-type")
2059 .and_then(|v| v.to_str().ok())
2060 .unwrap_or("application/octet-stream");
2061 let content_type = super::ContentType::from(content_type);
2062
2063 if !status.is_client_error() && !status.is_server_error() {
2064 let content = resp.text().await?;
2065 match content_type {
2066 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2067 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBillV1RespItem>`"))),
2068 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::GetBillV1RespItem>`")))),
2069 }
2070 } else {
2071 let content = resp.text().await?;
2072 let entity: Option<GetBillV1Error> = serde_json::from_str(&content).ok();
2073 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2074 }
2075}
2076
2077pub async fn get_block_order_execute_v1(configuration: &configuration::Configuration, params: GetBlockOrderExecuteV1Params) -> Result<models::GetBlockOrderExecuteV1Resp, Error<GetBlockOrderExecuteV1Error>> {
2079
2080 let uri_str = format!("{}/eapi/v1/block/order/execute", configuration.base_path);
2081 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2082
2083 let mut query_params: Vec<(String, String)> = Vec::new();
2085
2086 query_params.push(("blockOrderMatchingKey".to_string(), params.block_order_matching_key.to_string()));
2087 if let Some(ref param_value) = params.recv_window {
2088 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2089 }
2090 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2091
2092 let mut header_params = std::collections::HashMap::new();
2094
2095 if let Some(ref binance_auth) = configuration.binance_auth {
2097 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2099
2100 let body_string: Option<Vec<u8>> = None;
2102
2103 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2105 Ok(sig) => sig,
2106 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2107 };
2108
2109 query_params.push(("signature".to_string(), signature));
2111 }
2112
2113 if !query_params.is_empty() {
2115 req_builder = req_builder.query(&query_params);
2116 }
2117
2118
2119 if let Some(ref user_agent) = configuration.user_agent {
2121 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2122 }
2123
2124 for (header_name, header_value) in header_params {
2126 req_builder = req_builder.header(&header_name, &header_value);
2127 }
2128
2129
2130 let req = req_builder.build()?;
2131 let resp = configuration.client.execute(req).await?;
2132
2133 let status = resp.status();
2134 let content_type = resp
2135 .headers()
2136 .get("content-type")
2137 .and_then(|v| v.to_str().ok())
2138 .unwrap_or("application/octet-stream");
2139 let content_type = super::ContentType::from(content_type);
2140
2141 if !status.is_client_error() && !status.is_server_error() {
2142 let content = resp.text().await?;
2143 match content_type {
2144 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2145 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetBlockOrderExecuteV1Resp`"))),
2146 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::GetBlockOrderExecuteV1Resp`")))),
2147 }
2148 } else {
2149 let content = resp.text().await?;
2150 let entity: Option<GetBlockOrderExecuteV1Error> = serde_json::from_str(&content).ok();
2151 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2152 }
2153}
2154
2155pub async fn get_block_order_orders_v1(configuration: &configuration::Configuration, params: GetBlockOrderOrdersV1Params) -> Result<Vec<models::GetBlockOrderOrdersV1RespItem>, Error<GetBlockOrderOrdersV1Error>> {
2157
2158 let uri_str = format!("{}/eapi/v1/block/order/orders", configuration.base_path);
2159 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2160
2161 let mut query_params: Vec<(String, String)> = Vec::new();
2163
2164 if let Some(ref param_value) = params.block_order_matching_key {
2165 query_params.push(("blockOrderMatchingKey".to_string(), param_value.to_string()));
2166 }
2167 if let Some(ref param_value) = params.end_time {
2168 query_params.push(("endTime".to_string(), param_value.to_string()));
2169 }
2170 if let Some(ref param_value) = params.start_time {
2171 query_params.push(("startTime".to_string(), param_value.to_string()));
2172 }
2173 if let Some(ref param_value) = params.underlying {
2174 query_params.push(("underlying".to_string(), param_value.to_string()));
2175 }
2176 if let Some(ref param_value) = params.recv_window {
2177 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2178 }
2179 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2180
2181 let mut header_params = std::collections::HashMap::new();
2183
2184 if let Some(ref binance_auth) = configuration.binance_auth {
2186 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2188
2189 let body_string: Option<Vec<u8>> = None;
2191
2192 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2194 Ok(sig) => sig,
2195 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2196 };
2197
2198 query_params.push(("signature".to_string(), signature));
2200 }
2201
2202 if !query_params.is_empty() {
2204 req_builder = req_builder.query(&query_params);
2205 }
2206
2207
2208 if let Some(ref user_agent) = configuration.user_agent {
2210 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2211 }
2212
2213 for (header_name, header_value) in header_params {
2215 req_builder = req_builder.header(&header_name, &header_value);
2216 }
2217
2218
2219 let req = req_builder.build()?;
2220 let resp = configuration.client.execute(req).await?;
2221
2222 let status = resp.status();
2223 let content_type = resp
2224 .headers()
2225 .get("content-type")
2226 .and_then(|v| v.to_str().ok())
2227 .unwrap_or("application/octet-stream");
2228 let content_type = super::ContentType::from(content_type);
2229
2230 if !status.is_client_error() && !status.is_server_error() {
2231 let content = resp.text().await?;
2232 match content_type {
2233 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2234 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBlockOrderOrdersV1RespItem>`"))),
2235 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::GetBlockOrderOrdersV1RespItem>`")))),
2236 }
2237 } else {
2238 let content = resp.text().await?;
2239 let entity: Option<GetBlockOrderOrdersV1Error> = serde_json::from_str(&content).ok();
2240 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2241 }
2242}
2243
2244pub async fn get_block_trades_v1(configuration: &configuration::Configuration, params: GetBlockTradesV1Params) -> Result<Vec<models::GetBlockTradesV1RespItem>, Error<GetBlockTradesV1Error>> {
2246
2247 let uri_str = format!("{}/eapi/v1/blockTrades", configuration.base_path);
2248 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2249
2250 let mut query_params: Vec<(String, String)> = Vec::new();
2252
2253 if let Some(ref param_value) = params.symbol {
2254 query_params.push(("symbol".to_string(), param_value.to_string()));
2255 }
2256 if let Some(ref param_value) = params.limit {
2257 query_params.push(("limit".to_string(), param_value.to_string()));
2258 }
2259
2260 let mut header_params = std::collections::HashMap::new();
2262
2263 if let Some(ref binance_auth) = configuration.binance_auth {
2265 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2267
2268 let body_string: Option<Vec<u8>> = None;
2270
2271 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2273 Ok(sig) => sig,
2274 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2275 };
2276
2277 query_params.push(("signature".to_string(), signature));
2279 }
2280
2281 if !query_params.is_empty() {
2283 req_builder = req_builder.query(&query_params);
2284 }
2285
2286
2287 if let Some(ref user_agent) = configuration.user_agent {
2289 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2290 }
2291
2292 for (header_name, header_value) in header_params {
2294 req_builder = req_builder.header(&header_name, &header_value);
2295 }
2296
2297
2298 let req = req_builder.build()?;
2299 let resp = configuration.client.execute(req).await?;
2300
2301 let status = resp.status();
2302 let content_type = resp
2303 .headers()
2304 .get("content-type")
2305 .and_then(|v| v.to_str().ok())
2306 .unwrap_or("application/octet-stream");
2307 let content_type = super::ContentType::from(content_type);
2308
2309 if !status.is_client_error() && !status.is_server_error() {
2310 let content = resp.text().await?;
2311 match content_type {
2312 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2313 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBlockTradesV1RespItem>`"))),
2314 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::GetBlockTradesV1RespItem>`")))),
2315 }
2316 } else {
2317 let content = resp.text().await?;
2318 let entity: Option<GetBlockTradesV1Error> = serde_json::from_str(&content).ok();
2319 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2320 }
2321}
2322
2323pub async fn get_block_user_trades_v1(configuration: &configuration::Configuration, params: GetBlockUserTradesV1Params) -> Result<Vec<models::GetBlockUserTradesV1RespItem>, Error<GetBlockUserTradesV1Error>> {
2325
2326 let uri_str = format!("{}/eapi/v1/block/user-trades", configuration.base_path);
2327 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2328
2329 let mut query_params: Vec<(String, String)> = Vec::new();
2331
2332 if let Some(ref param_value) = params.end_time {
2333 query_params.push(("endTime".to_string(), param_value.to_string()));
2334 }
2335 if let Some(ref param_value) = params.start_time {
2336 query_params.push(("startTime".to_string(), param_value.to_string()));
2337 }
2338 if let Some(ref param_value) = params.underlying {
2339 query_params.push(("underlying".to_string(), param_value.to_string()));
2340 }
2341 if let Some(ref param_value) = params.recv_window {
2342 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2343 }
2344 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2345
2346 let mut header_params = std::collections::HashMap::new();
2348
2349 if let Some(ref binance_auth) = configuration.binance_auth {
2351 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2353
2354 let body_string: Option<Vec<u8>> = None;
2356
2357 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2359 Ok(sig) => sig,
2360 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2361 };
2362
2363 query_params.push(("signature".to_string(), signature));
2365 }
2366
2367 if !query_params.is_empty() {
2369 req_builder = req_builder.query(&query_params);
2370 }
2371
2372
2373 if let Some(ref user_agent) = configuration.user_agent {
2375 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2376 }
2377
2378 for (header_name, header_value) in header_params {
2380 req_builder = req_builder.header(&header_name, &header_value);
2381 }
2382
2383
2384 let req = req_builder.build()?;
2385 let resp = configuration.client.execute(req).await?;
2386
2387 let status = resp.status();
2388 let content_type = resp
2389 .headers()
2390 .get("content-type")
2391 .and_then(|v| v.to_str().ok())
2392 .unwrap_or("application/octet-stream");
2393 let content_type = super::ContentType::from(content_type);
2394
2395 if !status.is_client_error() && !status.is_server_error() {
2396 let content = resp.text().await?;
2397 match content_type {
2398 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2399 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBlockUserTradesV1RespItem>`"))),
2400 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::GetBlockUserTradesV1RespItem>`")))),
2401 }
2402 } else {
2403 let content = resp.text().await?;
2404 let entity: Option<GetBlockUserTradesV1Error> = serde_json::from_str(&content).ok();
2405 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2406 }
2407}
2408
2409pub async fn get_countdown_cancel_all_v1(configuration: &configuration::Configuration, params: GetCountdownCancelAllV1Params) -> Result<models::GetCountdownCancelAllV1Resp, Error<GetCountdownCancelAllV1Error>> {
2411
2412 let uri_str = format!("{}/eapi/v1/countdownCancelAll", configuration.base_path);
2413 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2414
2415 let mut query_params: Vec<(String, String)> = Vec::new();
2417
2418 if let Some(ref param_value) = params.underlying {
2419 query_params.push(("underlying".to_string(), param_value.to_string()));
2420 }
2421 if let Some(ref param_value) = params.recv_window {
2422 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2423 }
2424 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2425
2426 let mut header_params = std::collections::HashMap::new();
2428
2429 if let Some(ref binance_auth) = configuration.binance_auth {
2431 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2433
2434 let body_string: Option<Vec<u8>> = None;
2436
2437 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2439 Ok(sig) => sig,
2440 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2441 };
2442
2443 query_params.push(("signature".to_string(), signature));
2445 }
2446
2447 if !query_params.is_empty() {
2449 req_builder = req_builder.query(&query_params);
2450 }
2451
2452
2453 if let Some(ref user_agent) = configuration.user_agent {
2455 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2456 }
2457
2458 for (header_name, header_value) in header_params {
2460 req_builder = req_builder.header(&header_name, &header_value);
2461 }
2462
2463
2464 let req = req_builder.build()?;
2465 let resp = configuration.client.execute(req).await?;
2466
2467 let status = resp.status();
2468 let content_type = resp
2469 .headers()
2470 .get("content-type")
2471 .and_then(|v| v.to_str().ok())
2472 .unwrap_or("application/octet-stream");
2473 let content_type = super::ContentType::from(content_type);
2474
2475 if !status.is_client_error() && !status.is_server_error() {
2476 let content = resp.text().await?;
2477 match content_type {
2478 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2479 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCountdownCancelAllV1Resp`"))),
2480 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::GetCountdownCancelAllV1Resp`")))),
2481 }
2482 } else {
2483 let content = resp.text().await?;
2484 let entity: Option<GetCountdownCancelAllV1Error> = serde_json::from_str(&content).ok();
2485 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2486 }
2487}
2488
2489pub async fn get_depth_v1(configuration: &configuration::Configuration, params: GetDepthV1Params) -> Result<models::GetDepthV1Resp, Error<GetDepthV1Error>> {
2491
2492 let uri_str = format!("{}/eapi/v1/depth", configuration.base_path);
2493 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2494
2495 let mut query_params: Vec<(String, String)> = Vec::new();
2497
2498 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2499 if let Some(ref param_value) = params.limit {
2500 query_params.push(("limit".to_string(), param_value.to_string()));
2501 }
2502
2503 let mut header_params = std::collections::HashMap::new();
2505
2506 if let Some(ref binance_auth) = configuration.binance_auth {
2508 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2510
2511 let body_string: Option<Vec<u8>> = None;
2513
2514 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2516 Ok(sig) => sig,
2517 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2518 };
2519
2520 query_params.push(("signature".to_string(), signature));
2522 }
2523
2524 if !query_params.is_empty() {
2526 req_builder = req_builder.query(&query_params);
2527 }
2528
2529
2530 if let Some(ref user_agent) = configuration.user_agent {
2532 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2533 }
2534
2535 for (header_name, header_value) in header_params {
2537 req_builder = req_builder.header(&header_name, &header_value);
2538 }
2539
2540
2541 let req = req_builder.build()?;
2542 let resp = configuration.client.execute(req).await?;
2543
2544 let status = resp.status();
2545 let content_type = resp
2546 .headers()
2547 .get("content-type")
2548 .and_then(|v| v.to_str().ok())
2549 .unwrap_or("application/octet-stream");
2550 let content_type = super::ContentType::from(content_type);
2551
2552 if !status.is_client_error() && !status.is_server_error() {
2553 let content = resp.text().await?;
2554 match content_type {
2555 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2556 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetDepthV1Resp`"))),
2557 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::GetDepthV1Resp`")))),
2558 }
2559 } else {
2560 let content = resp.text().await?;
2561 let entity: Option<GetDepthV1Error> = serde_json::from_str(&content).ok();
2562 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2563 }
2564}
2565
2566pub async fn get_exchange_info_v1(configuration: &configuration::Configuration) -> Result<models::OptionsGetExchangeInfoV1Resp, Error<GetExchangeInfoV1Error>> {
2568
2569 let uri_str = format!("{}/eapi/v1/exchangeInfo", configuration.base_path);
2570 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2571
2572 let mut query_params: Vec<(String, String)> = Vec::new();
2574
2575
2576 let mut header_params = std::collections::HashMap::new();
2578
2579 if let Some(ref binance_auth) = configuration.binance_auth {
2581 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2583
2584 let body_string: Option<Vec<u8>> = None;
2586
2587 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2589 Ok(sig) => sig,
2590 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2591 };
2592
2593 query_params.push(("signature".to_string(), signature));
2595 }
2596
2597 if !query_params.is_empty() {
2599 req_builder = req_builder.query(&query_params);
2600 }
2601
2602
2603 if let Some(ref user_agent) = configuration.user_agent {
2605 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2606 }
2607
2608 for (header_name, header_value) in header_params {
2610 req_builder = req_builder.header(&header_name, &header_value);
2611 }
2612
2613
2614 let req = req_builder.build()?;
2615 let resp = configuration.client.execute(req).await?;
2616
2617 let status = resp.status();
2618 let content_type = resp
2619 .headers()
2620 .get("content-type")
2621 .and_then(|v| v.to_str().ok())
2622 .unwrap_or("application/octet-stream");
2623 let content_type = super::ContentType::from(content_type);
2624
2625 if !status.is_client_error() && !status.is_server_error() {
2626 let content = resp.text().await?;
2627 match content_type {
2628 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2629 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsGetExchangeInfoV1Resp`"))),
2630 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::OptionsGetExchangeInfoV1Resp`")))),
2631 }
2632 } else {
2633 let content = resp.text().await?;
2634 let entity: Option<GetExchangeInfoV1Error> = serde_json::from_str(&content).ok();
2635 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2636 }
2637}
2638
2639pub async fn get_exercise_history_v1(configuration: &configuration::Configuration, params: GetExerciseHistoryV1Params) -> Result<Vec<models::GetExerciseHistoryV1RespItem>, Error<GetExerciseHistoryV1Error>> {
2641
2642 let uri_str = format!("{}/eapi/v1/exerciseHistory", configuration.base_path);
2643 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2644
2645 let mut query_params: Vec<(String, String)> = Vec::new();
2647
2648 if let Some(ref param_value) = params.underlying {
2649 query_params.push(("underlying".to_string(), param_value.to_string()));
2650 }
2651 if let Some(ref param_value) = params.start_time {
2652 query_params.push(("startTime".to_string(), param_value.to_string()));
2653 }
2654 if let Some(ref param_value) = params.end_time {
2655 query_params.push(("endTime".to_string(), param_value.to_string()));
2656 }
2657 if let Some(ref param_value) = params.limit {
2658 query_params.push(("limit".to_string(), param_value.to_string()));
2659 }
2660
2661 let mut header_params = std::collections::HashMap::new();
2663
2664 if let Some(ref binance_auth) = configuration.binance_auth {
2666 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2668
2669 let body_string: Option<Vec<u8>> = None;
2671
2672 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2674 Ok(sig) => sig,
2675 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2676 };
2677
2678 query_params.push(("signature".to_string(), signature));
2680 }
2681
2682 if !query_params.is_empty() {
2684 req_builder = req_builder.query(&query_params);
2685 }
2686
2687
2688 if let Some(ref user_agent) = configuration.user_agent {
2690 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2691 }
2692
2693 for (header_name, header_value) in header_params {
2695 req_builder = req_builder.header(&header_name, &header_value);
2696 }
2697
2698
2699 let req = req_builder.build()?;
2700 let resp = configuration.client.execute(req).await?;
2701
2702 let status = resp.status();
2703 let content_type = resp
2704 .headers()
2705 .get("content-type")
2706 .and_then(|v| v.to_str().ok())
2707 .unwrap_or("application/octet-stream");
2708 let content_type = super::ContentType::from(content_type);
2709
2710 if !status.is_client_error() && !status.is_server_error() {
2711 let content = resp.text().await?;
2712 match content_type {
2713 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2714 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetExerciseHistoryV1RespItem>`"))),
2715 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::GetExerciseHistoryV1RespItem>`")))),
2716 }
2717 } else {
2718 let content = resp.text().await?;
2719 let entity: Option<GetExerciseHistoryV1Error> = serde_json::from_str(&content).ok();
2720 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2721 }
2722}
2723
2724pub async fn get_exercise_record_v1(configuration: &configuration::Configuration, params: GetExerciseRecordV1Params) -> Result<Vec<models::GetExerciseRecordV1RespItem>, Error<GetExerciseRecordV1Error>> {
2726
2727 let uri_str = format!("{}/eapi/v1/exerciseRecord", configuration.base_path);
2728 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2729
2730 let mut query_params: Vec<(String, String)> = Vec::new();
2732
2733 if let Some(ref param_value) = params.symbol {
2734 query_params.push(("symbol".to_string(), param_value.to_string()));
2735 }
2736 if let Some(ref param_value) = params.start_time {
2737 query_params.push(("startTime".to_string(), param_value.to_string()));
2738 }
2739 if let Some(ref param_value) = params.end_time {
2740 query_params.push(("endTime".to_string(), param_value.to_string()));
2741 }
2742 if let Some(ref param_value) = params.limit {
2743 query_params.push(("limit".to_string(), param_value.to_string()));
2744 }
2745 if let Some(ref param_value) = params.recv_window {
2746 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2747 }
2748 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2749
2750 let mut header_params = std::collections::HashMap::new();
2752
2753 if let Some(ref binance_auth) = configuration.binance_auth {
2755 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2757
2758 let body_string: Option<Vec<u8>> = None;
2760
2761 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2763 Ok(sig) => sig,
2764 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2765 };
2766
2767 query_params.push(("signature".to_string(), signature));
2769 }
2770
2771 if !query_params.is_empty() {
2773 req_builder = req_builder.query(&query_params);
2774 }
2775
2776
2777 if let Some(ref user_agent) = configuration.user_agent {
2779 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2780 }
2781
2782 for (header_name, header_value) in header_params {
2784 req_builder = req_builder.header(&header_name, &header_value);
2785 }
2786
2787
2788 let req = req_builder.build()?;
2789 let resp = configuration.client.execute(req).await?;
2790
2791 let status = resp.status();
2792 let content_type = resp
2793 .headers()
2794 .get("content-type")
2795 .and_then(|v| v.to_str().ok())
2796 .unwrap_or("application/octet-stream");
2797 let content_type = super::ContentType::from(content_type);
2798
2799 if !status.is_client_error() && !status.is_server_error() {
2800 let content = resp.text().await?;
2801 match content_type {
2802 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2803 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetExerciseRecordV1RespItem>`"))),
2804 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::GetExerciseRecordV1RespItem>`")))),
2805 }
2806 } else {
2807 let content = resp.text().await?;
2808 let entity: Option<GetExerciseRecordV1Error> = serde_json::from_str(&content).ok();
2809 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2810 }
2811}
2812
2813pub async fn get_historical_trades_v1(configuration: &configuration::Configuration, params: GetHistoricalTradesV1Params) -> Result<Vec<models::GetHistoricalTradesV1RespItem>, Error<GetHistoricalTradesV1Error>> {
2815
2816 let uri_str = format!("{}/eapi/v1/historicalTrades", configuration.base_path);
2817 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2818
2819 let mut query_params: Vec<(String, String)> = Vec::new();
2821
2822 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2823 if let Some(ref param_value) = params.from_id {
2824 query_params.push(("fromId".to_string(), param_value.to_string()));
2825 }
2826 if let Some(ref param_value) = params.limit {
2827 query_params.push(("limit".to_string(), param_value.to_string()));
2828 }
2829
2830 let mut header_params = std::collections::HashMap::new();
2832
2833 if let Some(ref binance_auth) = configuration.binance_auth {
2835 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2837
2838 let body_string: Option<Vec<u8>> = None;
2840
2841 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2843 Ok(sig) => sig,
2844 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2845 };
2846
2847 query_params.push(("signature".to_string(), signature));
2849 }
2850
2851 if !query_params.is_empty() {
2853 req_builder = req_builder.query(&query_params);
2854 }
2855
2856
2857 if let Some(ref user_agent) = configuration.user_agent {
2859 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2860 }
2861
2862 for (header_name, header_value) in header_params {
2864 req_builder = req_builder.header(&header_name, &header_value);
2865 }
2866
2867
2868 let req = req_builder.build()?;
2869 let resp = configuration.client.execute(req).await?;
2870
2871 let status = resp.status();
2872 let content_type = resp
2873 .headers()
2874 .get("content-type")
2875 .and_then(|v| v.to_str().ok())
2876 .unwrap_or("application/octet-stream");
2877 let content_type = super::ContentType::from(content_type);
2878
2879 if !status.is_client_error() && !status.is_server_error() {
2880 let content = resp.text().await?;
2881 match content_type {
2882 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2883 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetHistoricalTradesV1RespItem>`"))),
2884 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::GetHistoricalTradesV1RespItem>`")))),
2885 }
2886 } else {
2887 let content = resp.text().await?;
2888 let entity: Option<GetHistoricalTradesV1Error> = serde_json::from_str(&content).ok();
2889 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2890 }
2891}
2892
2893pub async fn get_history_orders_v1(configuration: &configuration::Configuration, params: GetHistoryOrdersV1Params) -> Result<Vec<models::GetHistoryOrdersV1RespItem>, Error<GetHistoryOrdersV1Error>> {
2895
2896 let uri_str = format!("{}/eapi/v1/historyOrders", configuration.base_path);
2897 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2898
2899 let mut query_params: Vec<(String, String)> = Vec::new();
2901
2902 query_params.push(("symbol".to_string(), params.symbol.to_string()));
2903 if let Some(ref param_value) = params.order_id {
2904 query_params.push(("orderId".to_string(), param_value.to_string()));
2905 }
2906 if let Some(ref param_value) = params.start_time {
2907 query_params.push(("startTime".to_string(), param_value.to_string()));
2908 }
2909 if let Some(ref param_value) = params.end_time {
2910 query_params.push(("endTime".to_string(), param_value.to_string()));
2911 }
2912 if let Some(ref param_value) = params.limit {
2913 query_params.push(("limit".to_string(), param_value.to_string()));
2914 }
2915 if let Some(ref param_value) = params.recv_window {
2916 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2917 }
2918 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2919
2920 let mut header_params = std::collections::HashMap::new();
2922
2923 if let Some(ref binance_auth) = configuration.binance_auth {
2925 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2927
2928 let body_string: Option<Vec<u8>> = None;
2930
2931 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2933 Ok(sig) => sig,
2934 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2935 };
2936
2937 query_params.push(("signature".to_string(), signature));
2939 }
2940
2941 if !query_params.is_empty() {
2943 req_builder = req_builder.query(&query_params);
2944 }
2945
2946
2947 if let Some(ref user_agent) = configuration.user_agent {
2949 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2950 }
2951
2952 for (header_name, header_value) in header_params {
2954 req_builder = req_builder.header(&header_name, &header_value);
2955 }
2956
2957
2958 let req = req_builder.build()?;
2959 let resp = configuration.client.execute(req).await?;
2960
2961 let status = resp.status();
2962 let content_type = resp
2963 .headers()
2964 .get("content-type")
2965 .and_then(|v| v.to_str().ok())
2966 .unwrap_or("application/octet-stream");
2967 let content_type = super::ContentType::from(content_type);
2968
2969 if !status.is_client_error() && !status.is_server_error() {
2970 let content = resp.text().await?;
2971 match content_type {
2972 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2973 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetHistoryOrdersV1RespItem>`"))),
2974 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::GetHistoryOrdersV1RespItem>`")))),
2975 }
2976 } else {
2977 let content = resp.text().await?;
2978 let entity: Option<GetHistoryOrdersV1Error> = serde_json::from_str(&content).ok();
2979 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2980 }
2981}
2982
2983pub async fn get_income_asyn_id_v1(configuration: &configuration::Configuration, params: GetIncomeAsynIdV1Params) -> Result<models::GetIncomeAsynIdV1Resp, Error<GetIncomeAsynIdV1Error>> {
2985
2986 let uri_str = format!("{}/eapi/v1/income/asyn/id", configuration.base_path);
2987 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2988
2989 let mut query_params: Vec<(String, String)> = Vec::new();
2991
2992 query_params.push(("downloadId".to_string(), params.download_id.to_string()));
2993 if let Some(ref param_value) = params.recv_window {
2994 query_params.push(("recvWindow".to_string(), param_value.to_string()));
2995 }
2996 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2997
2998 let mut header_params = std::collections::HashMap::new();
3000
3001 if let Some(ref binance_auth) = configuration.binance_auth {
3003 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3005
3006 let body_string: Option<Vec<u8>> = None;
3008
3009 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3011 Ok(sig) => sig,
3012 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3013 };
3014
3015 query_params.push(("signature".to_string(), signature));
3017 }
3018
3019 if !query_params.is_empty() {
3021 req_builder = req_builder.query(&query_params);
3022 }
3023
3024
3025 if let Some(ref user_agent) = configuration.user_agent {
3027 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3028 }
3029
3030 for (header_name, header_value) in header_params {
3032 req_builder = req_builder.header(&header_name, &header_value);
3033 }
3034
3035
3036 let req = req_builder.build()?;
3037 let resp = configuration.client.execute(req).await?;
3038
3039 let status = resp.status();
3040 let content_type = resp
3041 .headers()
3042 .get("content-type")
3043 .and_then(|v| v.to_str().ok())
3044 .unwrap_or("application/octet-stream");
3045 let content_type = super::ContentType::from(content_type);
3046
3047 if !status.is_client_error() && !status.is_server_error() {
3048 let content = resp.text().await?;
3049 match content_type {
3050 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3051 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIncomeAsynIdV1Resp`"))),
3052 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::GetIncomeAsynIdV1Resp`")))),
3053 }
3054 } else {
3055 let content = resp.text().await?;
3056 let entity: Option<GetIncomeAsynIdV1Error> = serde_json::from_str(&content).ok();
3057 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3058 }
3059}
3060
3061pub async fn get_income_asyn_v1(configuration: &configuration::Configuration) -> Result<models::GetIncomeAsynV1Resp, Error<GetIncomeAsynV1Error>> {
3063
3064 let uri_str = format!("{}/eapi/v1/income/asyn", configuration.base_path);
3065 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3066
3067 let mut query_params: Vec<(String, String)> = Vec::new();
3069
3070
3071 let mut header_params = std::collections::HashMap::new();
3073
3074 if let Some(ref binance_auth) = configuration.binance_auth {
3076 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3078
3079 let body_string: Option<Vec<u8>> = None;
3081
3082 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3084 Ok(sig) => sig,
3085 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3086 };
3087
3088 query_params.push(("signature".to_string(), signature));
3090 }
3091
3092 if !query_params.is_empty() {
3094 req_builder = req_builder.query(&query_params);
3095 }
3096
3097
3098 if let Some(ref user_agent) = configuration.user_agent {
3100 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3101 }
3102
3103 for (header_name, header_value) in header_params {
3105 req_builder = req_builder.header(&header_name, &header_value);
3106 }
3107
3108
3109 let req = req_builder.build()?;
3110 let resp = configuration.client.execute(req).await?;
3111
3112 let status = resp.status();
3113 let content_type = resp
3114 .headers()
3115 .get("content-type")
3116 .and_then(|v| v.to_str().ok())
3117 .unwrap_or("application/octet-stream");
3118 let content_type = super::ContentType::from(content_type);
3119
3120 if !status.is_client_error() && !status.is_server_error() {
3121 let content = resp.text().await?;
3122 match content_type {
3123 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3124 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIncomeAsynV1Resp`"))),
3125 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::GetIncomeAsynV1Resp`")))),
3126 }
3127 } else {
3128 let content = resp.text().await?;
3129 let entity: Option<GetIncomeAsynV1Error> = serde_json::from_str(&content).ok();
3130 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3131 }
3132}
3133
3134pub async fn get_index_v1(configuration: &configuration::Configuration, params: GetIndexV1Params) -> Result<models::GetIndexV1Resp, Error<GetIndexV1Error>> {
3136
3137 let uri_str = format!("{}/eapi/v1/index", configuration.base_path);
3138 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3139
3140 let mut query_params: Vec<(String, String)> = Vec::new();
3142
3143 query_params.push(("underlying".to_string(), params.underlying.to_string()));
3144
3145 let mut header_params = std::collections::HashMap::new();
3147
3148 if let Some(ref binance_auth) = configuration.binance_auth {
3150 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3152
3153 let body_string: Option<Vec<u8>> = None;
3155
3156 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3158 Ok(sig) => sig,
3159 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3160 };
3161
3162 query_params.push(("signature".to_string(), signature));
3164 }
3165
3166 if !query_params.is_empty() {
3168 req_builder = req_builder.query(&query_params);
3169 }
3170
3171
3172 if let Some(ref user_agent) = configuration.user_agent {
3174 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3175 }
3176
3177 for (header_name, header_value) in header_params {
3179 req_builder = req_builder.header(&header_name, &header_value);
3180 }
3181
3182
3183 let req = req_builder.build()?;
3184 let resp = configuration.client.execute(req).await?;
3185
3186 let status = resp.status();
3187 let content_type = resp
3188 .headers()
3189 .get("content-type")
3190 .and_then(|v| v.to_str().ok())
3191 .unwrap_or("application/octet-stream");
3192 let content_type = super::ContentType::from(content_type);
3193
3194 if !status.is_client_error() && !status.is_server_error() {
3195 let content = resp.text().await?;
3196 match content_type {
3197 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3198 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIndexV1Resp`"))),
3199 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::GetIndexV1Resp`")))),
3200 }
3201 } else {
3202 let content = resp.text().await?;
3203 let entity: Option<GetIndexV1Error> = serde_json::from_str(&content).ok();
3204 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3205 }
3206}
3207
3208pub async fn get_klines_v1(configuration: &configuration::Configuration, params: GetKlinesV1Params) -> Result<Vec<models::GetKlinesV1RespItem>, Error<GetKlinesV1Error>> {
3210
3211 let uri_str = format!("{}/eapi/v1/klines", configuration.base_path);
3212 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3213
3214 let mut query_params: Vec<(String, String)> = Vec::new();
3216
3217 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3218 query_params.push(("interval".to_string(), params.interval.to_string()));
3219 if let Some(ref param_value) = params.start_time {
3220 query_params.push(("startTime".to_string(), param_value.to_string()));
3221 }
3222 if let Some(ref param_value) = params.end_time {
3223 query_params.push(("endTime".to_string(), param_value.to_string()));
3224 }
3225 if let Some(ref param_value) = params.limit {
3226 query_params.push(("limit".to_string(), param_value.to_string()));
3227 }
3228
3229 let mut header_params = std::collections::HashMap::new();
3231
3232 if let Some(ref binance_auth) = configuration.binance_auth {
3234 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3236
3237 let body_string: Option<Vec<u8>> = None;
3239
3240 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3242 Ok(sig) => sig,
3243 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3244 };
3245
3246 query_params.push(("signature".to_string(), signature));
3248 }
3249
3250 if !query_params.is_empty() {
3252 req_builder = req_builder.query(&query_params);
3253 }
3254
3255
3256 if let Some(ref user_agent) = configuration.user_agent {
3258 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3259 }
3260
3261 for (header_name, header_value) in header_params {
3263 req_builder = req_builder.header(&header_name, &header_value);
3264 }
3265
3266
3267 let req = req_builder.build()?;
3268 let resp = configuration.client.execute(req).await?;
3269
3270 let status = resp.status();
3271 let content_type = resp
3272 .headers()
3273 .get("content-type")
3274 .and_then(|v| v.to_str().ok())
3275 .unwrap_or("application/octet-stream");
3276 let content_type = super::ContentType::from(content_type);
3277
3278 if !status.is_client_error() && !status.is_server_error() {
3279 let content = resp.text().await?;
3280 match content_type {
3281 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3282 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetKlinesV1RespItem>`"))),
3283 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::GetKlinesV1RespItem>`")))),
3284 }
3285 } else {
3286 let content = resp.text().await?;
3287 let entity: Option<GetKlinesV1Error> = serde_json::from_str(&content).ok();
3288 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3289 }
3290}
3291
3292pub async fn get_margin_account_v1(configuration: &configuration::Configuration, params: GetMarginAccountV1Params) -> Result<models::GetMarginAccountV1Resp, Error<GetMarginAccountV1Error>> {
3294
3295 let uri_str = format!("{}/eapi/v1/marginAccount", configuration.base_path);
3296 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3297
3298 let mut query_params: Vec<(String, String)> = Vec::new();
3300
3301 if let Some(ref param_value) = params.recv_window {
3302 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3303 }
3304 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3305
3306 let mut header_params = std::collections::HashMap::new();
3308
3309 if let Some(ref binance_auth) = configuration.binance_auth {
3311 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3313
3314 let body_string: Option<Vec<u8>> = None;
3316
3317 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3319 Ok(sig) => sig,
3320 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3321 };
3322
3323 query_params.push(("signature".to_string(), signature));
3325 }
3326
3327 if !query_params.is_empty() {
3329 req_builder = req_builder.query(&query_params);
3330 }
3331
3332
3333 if let Some(ref user_agent) = configuration.user_agent {
3335 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3336 }
3337
3338 for (header_name, header_value) in header_params {
3340 req_builder = req_builder.header(&header_name, &header_value);
3341 }
3342
3343
3344 let req = req_builder.build()?;
3345 let resp = configuration.client.execute(req).await?;
3346
3347 let status = resp.status();
3348 let content_type = resp
3349 .headers()
3350 .get("content-type")
3351 .and_then(|v| v.to_str().ok())
3352 .unwrap_or("application/octet-stream");
3353 let content_type = super::ContentType::from(content_type);
3354
3355 if !status.is_client_error() && !status.is_server_error() {
3356 let content = resp.text().await?;
3357 match content_type {
3358 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3359 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginAccountV1Resp`"))),
3360 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::GetMarginAccountV1Resp`")))),
3361 }
3362 } else {
3363 let content = resp.text().await?;
3364 let entity: Option<GetMarginAccountV1Error> = serde_json::from_str(&content).ok();
3365 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3366 }
3367}
3368
3369pub async fn get_mark_v1(configuration: &configuration::Configuration, params: GetMarkV1Params) -> Result<Vec<models::GetMarkV1RespItem>, Error<GetMarkV1Error>> {
3371
3372 let uri_str = format!("{}/eapi/v1/mark", configuration.base_path);
3373 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3374
3375 let mut query_params: Vec<(String, String)> = Vec::new();
3377
3378 if let Some(ref param_value) = params.symbol {
3379 query_params.push(("symbol".to_string(), param_value.to_string()));
3380 }
3381
3382 let mut header_params = std::collections::HashMap::new();
3384
3385 if let Some(ref binance_auth) = configuration.binance_auth {
3387 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3389
3390 let body_string: Option<Vec<u8>> = None;
3392
3393 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3395 Ok(sig) => sig,
3396 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3397 };
3398
3399 query_params.push(("signature".to_string(), signature));
3401 }
3402
3403 if !query_params.is_empty() {
3405 req_builder = req_builder.query(&query_params);
3406 }
3407
3408
3409 if let Some(ref user_agent) = configuration.user_agent {
3411 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3412 }
3413
3414 for (header_name, header_value) in header_params {
3416 req_builder = req_builder.header(&header_name, &header_value);
3417 }
3418
3419
3420 let req = req_builder.build()?;
3421 let resp = configuration.client.execute(req).await?;
3422
3423 let status = resp.status();
3424 let content_type = resp
3425 .headers()
3426 .get("content-type")
3427 .and_then(|v| v.to_str().ok())
3428 .unwrap_or("application/octet-stream");
3429 let content_type = super::ContentType::from(content_type);
3430
3431 if !status.is_client_error() && !status.is_server_error() {
3432 let content = resp.text().await?;
3433 match content_type {
3434 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3435 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarkV1RespItem>`"))),
3436 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::GetMarkV1RespItem>`")))),
3437 }
3438 } else {
3439 let content = resp.text().await?;
3440 let entity: Option<GetMarkV1Error> = serde_json::from_str(&content).ok();
3441 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3442 }
3443}
3444
3445pub async fn get_mmp_v1(configuration: &configuration::Configuration, params: GetMmpV1Params) -> Result<models::GetMmpV1Resp, Error<GetMmpV1Error>> {
3447
3448 let uri_str = format!("{}/eapi/v1/mmp", configuration.base_path);
3449 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3450
3451 let mut query_params: Vec<(String, String)> = Vec::new();
3453
3454 if let Some(ref param_value) = params.underlying {
3455 query_params.push(("underlying".to_string(), param_value.to_string()));
3456 }
3457 if let Some(ref param_value) = params.recv_window {
3458 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3459 }
3460 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3461
3462 let mut header_params = std::collections::HashMap::new();
3464
3465 if let Some(ref binance_auth) = configuration.binance_auth {
3467 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3469
3470 let body_string: Option<Vec<u8>> = None;
3472
3473 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3475 Ok(sig) => sig,
3476 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3477 };
3478
3479 query_params.push(("signature".to_string(), signature));
3481 }
3482
3483 if !query_params.is_empty() {
3485 req_builder = req_builder.query(&query_params);
3486 }
3487
3488
3489 if let Some(ref user_agent) = configuration.user_agent {
3491 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3492 }
3493
3494 for (header_name, header_value) in header_params {
3496 req_builder = req_builder.header(&header_name, &header_value);
3497 }
3498
3499
3500 let req = req_builder.build()?;
3501 let resp = configuration.client.execute(req).await?;
3502
3503 let status = resp.status();
3504 let content_type = resp
3505 .headers()
3506 .get("content-type")
3507 .and_then(|v| v.to_str().ok())
3508 .unwrap_or("application/octet-stream");
3509 let content_type = super::ContentType::from(content_type);
3510
3511 if !status.is_client_error() && !status.is_server_error() {
3512 let content = resp.text().await?;
3513 match content_type {
3514 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3515 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMmpV1Resp`"))),
3516 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::GetMmpV1Resp`")))),
3517 }
3518 } else {
3519 let content = resp.text().await?;
3520 let entity: Option<GetMmpV1Error> = serde_json::from_str(&content).ok();
3521 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3522 }
3523}
3524
3525pub async fn get_open_interest_v1(configuration: &configuration::Configuration, params: GetOpenInterestV1Params) -> Result<Vec<models::GetOpenInterestV1RespItem>, Error<GetOpenInterestV1Error>> {
3527
3528 let uri_str = format!("{}/eapi/v1/openInterest", configuration.base_path);
3529 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3530
3531 let mut query_params: Vec<(String, String)> = Vec::new();
3533
3534 query_params.push(("underlyingAsset".to_string(), params.underlying_asset.to_string()));
3535 query_params.push(("expiration".to_string(), params.expiration.to_string()));
3536
3537 let mut header_params = std::collections::HashMap::new();
3539
3540 if let Some(ref binance_auth) = configuration.binance_auth {
3542 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3544
3545 let body_string: Option<Vec<u8>> = None;
3547
3548 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3550 Ok(sig) => sig,
3551 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3552 };
3553
3554 query_params.push(("signature".to_string(), signature));
3556 }
3557
3558 if !query_params.is_empty() {
3560 req_builder = req_builder.query(&query_params);
3561 }
3562
3563
3564 if let Some(ref user_agent) = configuration.user_agent {
3566 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3567 }
3568
3569 for (header_name, header_value) in header_params {
3571 req_builder = req_builder.header(&header_name, &header_value);
3572 }
3573
3574
3575 let req = req_builder.build()?;
3576 let resp = configuration.client.execute(req).await?;
3577
3578 let status = resp.status();
3579 let content_type = resp
3580 .headers()
3581 .get("content-type")
3582 .and_then(|v| v.to_str().ok())
3583 .unwrap_or("application/octet-stream");
3584 let content_type = super::ContentType::from(content_type);
3585
3586 if !status.is_client_error() && !status.is_server_error() {
3587 let content = resp.text().await?;
3588 match content_type {
3589 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3590 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetOpenInterestV1RespItem>`"))),
3591 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::GetOpenInterestV1RespItem>`")))),
3592 }
3593 } else {
3594 let content = resp.text().await?;
3595 let entity: Option<GetOpenInterestV1Error> = serde_json::from_str(&content).ok();
3596 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3597 }
3598}
3599
3600pub async fn get_open_orders_v1(configuration: &configuration::Configuration, params: GetOpenOrdersV1Params) -> Result<Vec<models::GetOpenOrdersV1RespItem>, Error<GetOpenOrdersV1Error>> {
3602
3603 let uri_str = format!("{}/eapi/v1/openOrders", configuration.base_path);
3604 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3605
3606 let mut query_params: Vec<(String, String)> = Vec::new();
3608
3609 if let Some(ref param_value) = params.symbol {
3610 query_params.push(("symbol".to_string(), param_value.to_string()));
3611 }
3612 if let Some(ref param_value) = params.order_id {
3613 query_params.push(("orderId".to_string(), param_value.to_string()));
3614 }
3615 if let Some(ref param_value) = params.start_time {
3616 query_params.push(("startTime".to_string(), param_value.to_string()));
3617 }
3618 if let Some(ref param_value) = params.end_time {
3619 query_params.push(("endTime".to_string(), param_value.to_string()));
3620 }
3621 if let Some(ref param_value) = params.limit {
3622 query_params.push(("limit".to_string(), param_value.to_string()));
3623 }
3624 if let Some(ref param_value) = params.recv_window {
3625 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3626 }
3627 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3628
3629 let mut header_params = std::collections::HashMap::new();
3631
3632 if let Some(ref binance_auth) = configuration.binance_auth {
3634 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3636
3637 let body_string: Option<Vec<u8>> = None;
3639
3640 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3642 Ok(sig) => sig,
3643 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3644 };
3645
3646 query_params.push(("signature".to_string(), signature));
3648 }
3649
3650 if !query_params.is_empty() {
3652 req_builder = req_builder.query(&query_params);
3653 }
3654
3655
3656 if let Some(ref user_agent) = configuration.user_agent {
3658 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3659 }
3660
3661 for (header_name, header_value) in header_params {
3663 req_builder = req_builder.header(&header_name, &header_value);
3664 }
3665
3666
3667 let req = req_builder.build()?;
3668 let resp = configuration.client.execute(req).await?;
3669
3670 let status = resp.status();
3671 let content_type = resp
3672 .headers()
3673 .get("content-type")
3674 .and_then(|v| v.to_str().ok())
3675 .unwrap_or("application/octet-stream");
3676 let content_type = super::ContentType::from(content_type);
3677
3678 if !status.is_client_error() && !status.is_server_error() {
3679 let content = resp.text().await?;
3680 match content_type {
3681 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3682 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetOpenOrdersV1RespItem>`"))),
3683 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::GetOpenOrdersV1RespItem>`")))),
3684 }
3685 } else {
3686 let content = resp.text().await?;
3687 let entity: Option<GetOpenOrdersV1Error> = serde_json::from_str(&content).ok();
3688 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3689 }
3690}
3691
3692pub async fn get_order_v1(configuration: &configuration::Configuration, params: GetOrderV1Params) -> Result<models::GetOrderV1Resp, Error<GetOrderV1Error>> {
3694
3695 let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
3696 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3697
3698 let mut query_params: Vec<(String, String)> = Vec::new();
3700
3701 query_params.push(("symbol".to_string(), params.symbol.to_string()));
3702 if let Some(ref param_value) = params.order_id {
3703 query_params.push(("orderId".to_string(), param_value.to_string()));
3704 }
3705 if let Some(ref param_value) = params.client_order_id {
3706 query_params.push(("clientOrderId".to_string(), param_value.to_string()));
3707 }
3708 if let Some(ref param_value) = params.recv_window {
3709 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3710 }
3711 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3712
3713 let mut header_params = std::collections::HashMap::new();
3715
3716 if let Some(ref binance_auth) = configuration.binance_auth {
3718 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3720
3721 let body_string: Option<Vec<u8>> = None;
3723
3724 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3726 Ok(sig) => sig,
3727 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3728 };
3729
3730 query_params.push(("signature".to_string(), signature));
3732 }
3733
3734 if !query_params.is_empty() {
3736 req_builder = req_builder.query(&query_params);
3737 }
3738
3739
3740 if let Some(ref user_agent) = configuration.user_agent {
3742 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3743 }
3744
3745 for (header_name, header_value) in header_params {
3747 req_builder = req_builder.header(&header_name, &header_value);
3748 }
3749
3750
3751 let req = req_builder.build()?;
3752 let resp = configuration.client.execute(req).await?;
3753
3754 let status = resp.status();
3755 let content_type = resp
3756 .headers()
3757 .get("content-type")
3758 .and_then(|v| v.to_str().ok())
3759 .unwrap_or("application/octet-stream");
3760 let content_type = super::ContentType::from(content_type);
3761
3762 if !status.is_client_error() && !status.is_server_error() {
3763 let content = resp.text().await?;
3764 match content_type {
3765 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3766 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrderV1Resp`"))),
3767 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::GetOrderV1Resp`")))),
3768 }
3769 } else {
3770 let content = resp.text().await?;
3771 let entity: Option<GetOrderV1Error> = serde_json::from_str(&content).ok();
3772 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3773 }
3774}
3775
3776pub async fn get_ping_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<GetPingV1Error>> {
3778
3779 let uri_str = format!("{}/eapi/v1/ping", configuration.base_path);
3780 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3781
3782 let mut query_params: Vec<(String, String)> = Vec::new();
3784
3785
3786 let mut header_params = std::collections::HashMap::new();
3788
3789 if let Some(ref binance_auth) = configuration.binance_auth {
3791 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3793
3794 let body_string: Option<Vec<u8>> = None;
3796
3797 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3799 Ok(sig) => sig,
3800 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3801 };
3802
3803 query_params.push(("signature".to_string(), signature));
3805 }
3806
3807 if !query_params.is_empty() {
3809 req_builder = req_builder.query(&query_params);
3810 }
3811
3812
3813 if let Some(ref user_agent) = configuration.user_agent {
3815 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3816 }
3817
3818 for (header_name, header_value) in header_params {
3820 req_builder = req_builder.header(&header_name, &header_value);
3821 }
3822
3823
3824 let req = req_builder.build()?;
3825 let resp = configuration.client.execute(req).await?;
3826
3827 let status = resp.status();
3828 let content_type = resp
3829 .headers()
3830 .get("content-type")
3831 .and_then(|v| v.to_str().ok())
3832 .unwrap_or("application/octet-stream");
3833 let content_type = super::ContentType::from(content_type);
3834
3835 if !status.is_client_error() && !status.is_server_error() {
3836 let content = resp.text().await?;
3837 match content_type {
3838 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3839 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
3840 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
3841 }
3842 } else {
3843 let content = resp.text().await?;
3844 let entity: Option<GetPingV1Error> = serde_json::from_str(&content).ok();
3845 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3846 }
3847}
3848
3849pub async fn get_position_v1(configuration: &configuration::Configuration, params: GetPositionV1Params) -> Result<Vec<models::GetPositionV1RespItem>, Error<GetPositionV1Error>> {
3851
3852 let uri_str = format!("{}/eapi/v1/position", configuration.base_path);
3853 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3854
3855 let mut query_params: Vec<(String, String)> = Vec::new();
3857
3858 if let Some(ref param_value) = params.symbol {
3859 query_params.push(("symbol".to_string(), param_value.to_string()));
3860 }
3861 if let Some(ref param_value) = params.recv_window {
3862 query_params.push(("recvWindow".to_string(), param_value.to_string()));
3863 }
3864 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
3865
3866 let mut header_params = std::collections::HashMap::new();
3868
3869 if let Some(ref binance_auth) = configuration.binance_auth {
3871 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3873
3874 let body_string: Option<Vec<u8>> = None;
3876
3877 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3879 Ok(sig) => sig,
3880 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3881 };
3882
3883 query_params.push(("signature".to_string(), signature));
3885 }
3886
3887 if !query_params.is_empty() {
3889 req_builder = req_builder.query(&query_params);
3890 }
3891
3892
3893 if let Some(ref user_agent) = configuration.user_agent {
3895 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3896 }
3897
3898 for (header_name, header_value) in header_params {
3900 req_builder = req_builder.header(&header_name, &header_value);
3901 }
3902
3903
3904 let req = req_builder.build()?;
3905 let resp = configuration.client.execute(req).await?;
3906
3907 let status = resp.status();
3908 let content_type = resp
3909 .headers()
3910 .get("content-type")
3911 .and_then(|v| v.to_str().ok())
3912 .unwrap_or("application/octet-stream");
3913 let content_type = super::ContentType::from(content_type);
3914
3915 if !status.is_client_error() && !status.is_server_error() {
3916 let content = resp.text().await?;
3917 match content_type {
3918 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3919 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPositionV1RespItem>`"))),
3920 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::GetPositionV1RespItem>`")))),
3921 }
3922 } else {
3923 let content = resp.text().await?;
3924 let entity: Option<GetPositionV1Error> = serde_json::from_str(&content).ok();
3925 Err(Error::ResponseError(ResponseContent { status, content, entity }))
3926 }
3927}
3928
3929pub async fn get_ticker_v1(configuration: &configuration::Configuration, params: GetTickerV1Params) -> Result<Vec<models::GetTickerV1RespItem>, Error<GetTickerV1Error>> {
3931
3932 let uri_str = format!("{}/eapi/v1/ticker", configuration.base_path);
3933 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
3934
3935 let mut query_params: Vec<(String, String)> = Vec::new();
3937
3938 if let Some(ref param_value) = params.symbol {
3939 query_params.push(("symbol".to_string(), param_value.to_string()));
3940 }
3941
3942 let mut header_params = std::collections::HashMap::new();
3944
3945 if let Some(ref binance_auth) = configuration.binance_auth {
3947 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
3949
3950 let body_string: Option<Vec<u8>> = None;
3952
3953 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
3955 Ok(sig) => sig,
3956 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
3957 };
3958
3959 query_params.push(("signature".to_string(), signature));
3961 }
3962
3963 if !query_params.is_empty() {
3965 req_builder = req_builder.query(&query_params);
3966 }
3967
3968
3969 if let Some(ref user_agent) = configuration.user_agent {
3971 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
3972 }
3973
3974 for (header_name, header_value) in header_params {
3976 req_builder = req_builder.header(&header_name, &header_value);
3977 }
3978
3979
3980 let req = req_builder.build()?;
3981 let resp = configuration.client.execute(req).await?;
3982
3983 let status = resp.status();
3984 let content_type = resp
3985 .headers()
3986 .get("content-type")
3987 .and_then(|v| v.to_str().ok())
3988 .unwrap_or("application/octet-stream");
3989 let content_type = super::ContentType::from(content_type);
3990
3991 if !status.is_client_error() && !status.is_server_error() {
3992 let content = resp.text().await?;
3993 match content_type {
3994 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
3995 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetTickerV1RespItem>`"))),
3996 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::GetTickerV1RespItem>`")))),
3997 }
3998 } else {
3999 let content = resp.text().await?;
4000 let entity: Option<GetTickerV1Error> = serde_json::from_str(&content).ok();
4001 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4002 }
4003}
4004
4005pub async fn get_time_v1(configuration: &configuration::Configuration) -> Result<models::GetTimeV1Resp, Error<GetTimeV1Error>> {
4007
4008 let uri_str = format!("{}/eapi/v1/time", configuration.base_path);
4009 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4010
4011 let mut query_params: Vec<(String, String)> = Vec::new();
4013
4014
4015 let mut header_params = std::collections::HashMap::new();
4017
4018 if let Some(ref binance_auth) = configuration.binance_auth {
4020 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4022
4023 let body_string: Option<Vec<u8>> = None;
4025
4026 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4028 Ok(sig) => sig,
4029 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4030 };
4031
4032 query_params.push(("signature".to_string(), signature));
4034 }
4035
4036 if !query_params.is_empty() {
4038 req_builder = req_builder.query(&query_params);
4039 }
4040
4041
4042 if let Some(ref user_agent) = configuration.user_agent {
4044 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4045 }
4046
4047 for (header_name, header_value) in header_params {
4049 req_builder = req_builder.header(&header_name, &header_value);
4050 }
4051
4052
4053 let req = req_builder.build()?;
4054 let resp = configuration.client.execute(req).await?;
4055
4056 let status = resp.status();
4057 let content_type = resp
4058 .headers()
4059 .get("content-type")
4060 .and_then(|v| v.to_str().ok())
4061 .unwrap_or("application/octet-stream");
4062 let content_type = super::ContentType::from(content_type);
4063
4064 if !status.is_client_error() && !status.is_server_error() {
4065 let content = resp.text().await?;
4066 match content_type {
4067 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4068 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTimeV1Resp`"))),
4069 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::GetTimeV1Resp`")))),
4070 }
4071 } else {
4072 let content = resp.text().await?;
4073 let entity: Option<GetTimeV1Error> = serde_json::from_str(&content).ok();
4074 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4075 }
4076}
4077
4078pub async fn get_trades_v1(configuration: &configuration::Configuration, params: GetTradesV1Params) -> Result<Vec<models::GetTradesV1RespItem>, Error<GetTradesV1Error>> {
4080
4081 let uri_str = format!("{}/eapi/v1/trades", configuration.base_path);
4082 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4083
4084 let mut query_params: Vec<(String, String)> = Vec::new();
4086
4087 query_params.push(("symbol".to_string(), params.symbol.to_string()));
4088 if let Some(ref param_value) = params.limit {
4089 query_params.push(("limit".to_string(), param_value.to_string()));
4090 }
4091
4092 let mut header_params = std::collections::HashMap::new();
4094
4095 if let Some(ref binance_auth) = configuration.binance_auth {
4097 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4099
4100 let body_string: Option<Vec<u8>> = None;
4102
4103 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4105 Ok(sig) => sig,
4106 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4107 };
4108
4109 query_params.push(("signature".to_string(), signature));
4111 }
4112
4113 if !query_params.is_empty() {
4115 req_builder = req_builder.query(&query_params);
4116 }
4117
4118
4119 if let Some(ref user_agent) = configuration.user_agent {
4121 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4122 }
4123
4124 for (header_name, header_value) in header_params {
4126 req_builder = req_builder.header(&header_name, &header_value);
4127 }
4128
4129
4130 let req = req_builder.build()?;
4131 let resp = configuration.client.execute(req).await?;
4132
4133 let status = resp.status();
4134 let content_type = resp
4135 .headers()
4136 .get("content-type")
4137 .and_then(|v| v.to_str().ok())
4138 .unwrap_or("application/octet-stream");
4139 let content_type = super::ContentType::from(content_type);
4140
4141 if !status.is_client_error() && !status.is_server_error() {
4142 let content = resp.text().await?;
4143 match content_type {
4144 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4145 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetTradesV1RespItem>`"))),
4146 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::GetTradesV1RespItem>`")))),
4147 }
4148 } else {
4149 let content = resp.text().await?;
4150 let entity: Option<GetTradesV1Error> = serde_json::from_str(&content).ok();
4151 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4152 }
4153}
4154
4155pub async fn get_user_trades_v1(configuration: &configuration::Configuration, params: GetUserTradesV1Params) -> Result<Vec<models::GetUserTradesV1RespItem>, Error<GetUserTradesV1Error>> {
4157
4158 let uri_str = format!("{}/eapi/v1/userTrades", configuration.base_path);
4159 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
4160
4161 let mut query_params: Vec<(String, String)> = Vec::new();
4163
4164 if let Some(ref param_value) = params.symbol {
4165 query_params.push(("symbol".to_string(), param_value.to_string()));
4166 }
4167 if let Some(ref param_value) = params.from_id {
4168 query_params.push(("fromId".to_string(), param_value.to_string()));
4169 }
4170 if let Some(ref param_value) = params.start_time {
4171 query_params.push(("startTime".to_string(), param_value.to_string()));
4172 }
4173 if let Some(ref param_value) = params.end_time {
4174 query_params.push(("endTime".to_string(), param_value.to_string()));
4175 }
4176 if let Some(ref param_value) = params.limit {
4177 query_params.push(("limit".to_string(), param_value.to_string()));
4178 }
4179 if let Some(ref param_value) = params.recv_window {
4180 query_params.push(("recvWindow".to_string(), param_value.to_string()));
4181 }
4182 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
4183
4184 let mut header_params = std::collections::HashMap::new();
4186
4187 if let Some(ref binance_auth) = configuration.binance_auth {
4189 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4191
4192 let body_string: Option<Vec<u8>> = None;
4194
4195 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4197 Ok(sig) => sig,
4198 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4199 };
4200
4201 query_params.push(("signature".to_string(), signature));
4203 }
4204
4205 if !query_params.is_empty() {
4207 req_builder = req_builder.query(&query_params);
4208 }
4209
4210
4211 if let Some(ref user_agent) = configuration.user_agent {
4213 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4214 }
4215
4216 for (header_name, header_value) in header_params {
4218 req_builder = req_builder.header(&header_name, &header_value);
4219 }
4220
4221
4222 let req = req_builder.build()?;
4223 let resp = configuration.client.execute(req).await?;
4224
4225 let status = resp.status();
4226 let content_type = resp
4227 .headers()
4228 .get("content-type")
4229 .and_then(|v| v.to_str().ok())
4230 .unwrap_or("application/octet-stream");
4231 let content_type = super::ContentType::from(content_type);
4232
4233 if !status.is_client_error() && !status.is_server_error() {
4234 let content = resp.text().await?;
4235 match content_type {
4236 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4237 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetUserTradesV1RespItem>`"))),
4238 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::GetUserTradesV1RespItem>`")))),
4239 }
4240 } else {
4241 let content = resp.text().await?;
4242 let entity: Option<GetUserTradesV1Error> = serde_json::from_str(&content).ok();
4243 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4244 }
4245}
4246
4247pub async fn update_block_order_create_v1(configuration: &configuration::Configuration, params: UpdateBlockOrderCreateV1Params) -> Result<models::UpdateBlockOrderCreateV1Resp, Error<UpdateBlockOrderCreateV1Error>> {
4249
4250 let uri_str = format!("{}/eapi/v1/block/order/create", configuration.base_path);
4251 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
4252
4253 let mut query_params: Vec<(String, String)> = Vec::new();
4255
4256
4257 let mut header_params = std::collections::HashMap::new();
4259
4260 if let Some(ref binance_auth) = configuration.binance_auth {
4262 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4264
4265 let body_string: Option<Vec<u8>> = None;
4267
4268 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4270 Ok(sig) => sig,
4271 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4272 };
4273
4274 query_params.push(("signature".to_string(), signature));
4276 }
4277
4278 if !query_params.is_empty() {
4280 req_builder = req_builder.query(&query_params);
4281 }
4282
4283
4284 if let Some(ref user_agent) = configuration.user_agent {
4286 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4287 }
4288
4289 for (header_name, header_value) in header_params {
4291 req_builder = req_builder.header(&header_name, &header_value);
4292 }
4293
4294 let mut multipart_form_params = std::collections::HashMap::new();
4295 multipart_form_params.insert("blockOrderMatchingKey", params.block_order_matching_key.to_string());
4296 if let Some(param_value) = params.recv_window {
4297 multipart_form_params.insert("recvWindow", param_value.to_string());
4298 }
4299 multipart_form_params.insert("timestamp", params.timestamp.to_string());
4300 req_builder = req_builder.form(&multipart_form_params);
4301
4302 let req = req_builder.build()?;
4303 let resp = configuration.client.execute(req).await?;
4304
4305 let status = resp.status();
4306 let content_type = resp
4307 .headers()
4308 .get("content-type")
4309 .and_then(|v| v.to_str().ok())
4310 .unwrap_or("application/octet-stream");
4311 let content_type = super::ContentType::from(content_type);
4312
4313 if !status.is_client_error() && !status.is_server_error() {
4314 let content = resp.text().await?;
4315 match content_type {
4316 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4317 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateBlockOrderCreateV1Resp`"))),
4318 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::UpdateBlockOrderCreateV1Resp`")))),
4319 }
4320 } else {
4321 let content = resp.text().await?;
4322 let entity: Option<UpdateBlockOrderCreateV1Error> = serde_json::from_str(&content).ok();
4323 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4324 }
4325}
4326
4327pub async fn update_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<UpdateListenKeyV1Error>> {
4329
4330 let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
4331 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
4332
4333 let mut query_params: Vec<(String, String)> = Vec::new();
4335
4336
4337 let mut header_params = std::collections::HashMap::new();
4339
4340 if let Some(ref binance_auth) = configuration.binance_auth {
4342 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
4344
4345 let body_string: Option<Vec<u8>> = None;
4347
4348 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
4350 Ok(sig) => sig,
4351 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
4352 };
4353
4354 query_params.push(("signature".to_string(), signature));
4356 }
4357
4358 if !query_params.is_empty() {
4360 req_builder = req_builder.query(&query_params);
4361 }
4362
4363
4364 if let Some(ref user_agent) = configuration.user_agent {
4366 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4367 }
4368
4369 for (header_name, header_value) in header_params {
4371 req_builder = req_builder.header(&header_name, &header_value);
4372 }
4373
4374
4375 let req = req_builder.build()?;
4376 let resp = configuration.client.execute(req).await?;
4377
4378 let status = resp.status();
4379 let content_type = resp
4380 .headers()
4381 .get("content-type")
4382 .and_then(|v| v.to_str().ok())
4383 .unwrap_or("application/octet-stream");
4384 let content_type = super::ContentType::from(content_type);
4385
4386 if !status.is_client_error() && !status.is_server_error() {
4387 let content = resp.text().await?;
4388 match content_type {
4389 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
4390 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
4391 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
4392 }
4393 } else {
4394 let content = resp.text().await?;
4395 let entity: Option<UpdateListenKeyV1Error> = serde_json::from_str(&content).ok();
4396 Err(Error::ResponseError(ResponseContent { status, content, entity }))
4397 }
4398}
4399