rust_okx/api/trade/requests/
advanced.rs1use serde::Serialize;
2
3#[derive(Debug, Clone, Serialize)]
5pub struct EasyConvertRequest {
6 #[serde(rename = "fromCcy")]
7 from_ccy: Vec<String>,
8 #[serde(rename = "toCcy")]
9 to_ccy: String,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 source: Option<String>,
12}
13
14impl EasyConvertRequest {
15 pub fn new<I, S>(from_ccy: I, to_ccy: impl Into<String>) -> Self
17 where
18 I: IntoIterator<Item = S>,
19 S: Into<String>,
20 {
21 Self {
22 from_ccy: from_ccy.into_iter().map(Into::into).collect(),
23 to_ccy: to_ccy.into(),
24 source: None,
25 }
26 }
27
28 pub fn source(mut self, value: impl Into<String>) -> Self {
30 self.source = Some(value.into());
31 self
32 }
33}
34
35#[derive(Debug, Clone, Default, Serialize)]
37pub struct EasyConvertHistoryRequest {
38 #[serde(skip_serializing_if = "Option::is_none")]
39 after: Option<String>,
40 #[serde(skip_serializing_if = "Option::is_none")]
41 before: Option<String>,
42 #[serde(skip_serializing_if = "Option::is_none")]
43 limit: Option<u32>,
44}
45
46impl EasyConvertHistoryRequest {
47 pub fn new() -> Self {
49 Self::default()
50 }
51
52 pub fn after(mut self, value: impl Into<String>) -> Self {
54 self.after = Some(value.into());
55 self
56 }
57
58 pub fn before(mut self, value: impl Into<String>) -> Self {
60 self.before = Some(value.into());
61 self
62 }
63
64 pub fn limit(mut self, value: u32) -> Self {
66 self.limit = Some(value);
67 self
68 }
69}
70
71#[derive(Debug, Clone, Default, Serialize)]
73pub struct OneClickRepayCurrencyListRequest {
74 #[serde(rename = "debtType", skip_serializing_if = "Option::is_none")]
75 debt_type: Option<String>,
76}
77
78impl OneClickRepayCurrencyListRequest {
79 pub fn new() -> Self {
81 Self::default()
82 }
83
84 pub fn debt_type(mut self, value: impl Into<String>) -> Self {
86 self.debt_type = Some(value.into());
87 self
88 }
89}
90
91#[derive(Debug, Clone, Serialize)]
93#[serde(untagged)]
94enum DebtCurrencySelection {
95 One(String),
96 Many(Vec<String>),
97}
98
99#[derive(Debug, Clone, Serialize)]
101pub struct OneClickRepayRequest {
102 #[serde(rename = "debtCcy")]
103 debt_ccy: DebtCurrencySelection,
104 #[serde(rename = "repayCcy", skip_serializing_if = "Option::is_none")]
105 repay_ccy: Option<String>,
106 #[serde(rename = "repayCcyList", skip_serializing_if = "Option::is_none")]
107 repay_ccy_list: Option<Vec<String>>,
108}
109
110impl OneClickRepayRequest {
111 pub fn new<I, S>(debt_ccy: I, repay_ccy: impl Into<String>) -> Self
113 where
114 I: IntoIterator<Item = S>,
115 S: Into<String>,
116 {
117 Self {
118 debt_ccy: DebtCurrencySelection::Many(debt_ccy.into_iter().map(Into::into).collect()),
119 repay_ccy: Some(repay_ccy.into()),
120 repay_ccy_list: None,
121 }
122 }
123
124 pub fn v2<I, S>(debt_ccy: impl Into<String>, repay_ccy_list: I) -> Self
126 where
127 I: IntoIterator<Item = S>,
128 S: Into<String>,
129 {
130 Self {
131 debt_ccy: DebtCurrencySelection::One(debt_ccy.into()),
132 repay_ccy: None,
133 repay_ccy_list: Some(repay_ccy_list.into_iter().map(Into::into).collect()),
134 }
135 }
136}
137
138#[derive(Debug, Clone, Default, Serialize)]
140pub struct OneClickRepayHistoryRequest {
141 #[serde(skip_serializing_if = "Option::is_none")]
142 after: Option<String>,
143 #[serde(skip_serializing_if = "Option::is_none")]
144 before: Option<String>,
145 #[serde(skip_serializing_if = "Option::is_none")]
146 limit: Option<u32>,
147}
148
149impl OneClickRepayHistoryRequest {
150 pub fn new() -> Self {
152 Self::default()
153 }
154
155 pub fn after(mut self, value: impl Into<String>) -> Self {
157 self.after = Some(value.into());
158 self
159 }
160
161 pub fn before(mut self, value: impl Into<String>) -> Self {
163 self.before = Some(value.into());
164 self
165 }
166
167 pub fn limit(mut self, value: u32) -> Self {
169 self.limit = Some(value);
170 self
171 }
172}