rust_okx/api/sub_account/
requests.rs1use serde::Serialize;
2
3#[derive(Debug, Clone, Copy, Serialize)]
5pub enum SubAccountType {
6 #[serde(rename = "6")]
8 Funding,
9 #[serde(rename = "18")]
11 Trading,
12}
13
14#[derive(Debug, Clone, Default, Serialize)]
16#[serde(rename_all = "camelCase")]
17pub struct SubAccountListRequest {
18 #[serde(skip_serializing_if = "Option::is_none")]
19 enable: Option<bool>,
20 #[serde(skip_serializing_if = "Option::is_none")]
21 sub_acct: Option<String>,
22 #[serde(skip_serializing_if = "Option::is_none")]
23 after: Option<String>,
24 #[serde(skip_serializing_if = "Option::is_none")]
25 before: Option<String>,
26 #[serde(skip_serializing_if = "Option::is_none")]
27 limit: Option<u32>,
28}
29
30impl SubAccountListRequest {
31 pub fn new() -> Self {
33 Self::default()
34 }
35
36 pub fn enable(mut self, enable: bool) -> Self {
38 self.enable = Some(enable);
39 self
40 }
41
42 pub fn sub_acct(mut self, sub_acct: impl Into<String>) -> Self {
44 self.sub_acct = Some(sub_acct.into());
45 self
46 }
47
48 pub fn after(mut self, after: impl Into<String>) -> Self {
50 self.after = Some(after.into());
51 self
52 }
53
54 pub fn before(mut self, before: impl Into<String>) -> Self {
56 self.before = Some(before.into());
57 self
58 }
59
60 pub fn limit(mut self, limit: u32) -> Self {
62 self.limit = Some(limit);
63 self
64 }
65}
66
67#[derive(Debug, Clone, Serialize)]
69#[serde(rename_all = "camelCase")]
70pub struct SubAccountApiKeysRequest {
71 sub_acct: String,
72 #[serde(skip_serializing_if = "Option::is_none")]
73 api_key: Option<String>,
74}
75
76impl SubAccountApiKeysRequest {
77 pub fn new(sub_acct: impl Into<String>) -> Self {
79 Self {
80 sub_acct: sub_acct.into(),
81 api_key: None,
82 }
83 }
84
85 pub fn api_key(mut self, api_key: impl Into<String>) -> Self {
87 self.api_key = Some(api_key.into());
88 self
89 }
90}
91
92#[derive(Debug, Clone, Serialize)]
94#[serde(rename_all = "camelCase")]
95pub struct SubAccountTradingBalancesRequest {
96 sub_acct: String,
97}
98
99impl SubAccountTradingBalancesRequest {
100 pub fn new(sub_acct: impl Into<String>) -> Self {
102 Self {
103 sub_acct: sub_acct.into(),
104 }
105 }
106}
107
108#[derive(Debug, Clone, Serialize)]
110#[serde(rename_all = "camelCase")]
111pub struct SubAccountFundingBalancesRequest {
112 sub_acct: String,
113 #[serde(skip_serializing_if = "Option::is_none")]
114 ccy: Option<String>,
115}
116
117impl SubAccountFundingBalancesRequest {
118 pub fn new(sub_acct: impl Into<String>) -> Self {
120 Self {
121 sub_acct: sub_acct.into(),
122 ccy: None,
123 }
124 }
125
126 pub fn ccy(mut self, ccy: impl Into<String>) -> Self {
128 self.ccy = Some(ccy.into());
129 self
130 }
131}
132
133#[derive(Debug, Clone, Serialize)]
135#[serde(rename_all = "camelCase")]
136pub struct SubAccountMaxWithdrawalRequest {
137 sub_acct: String,
138 #[serde(skip_serializing_if = "Option::is_none")]
139 ccy: Option<String>,
140}
141
142impl SubAccountMaxWithdrawalRequest {
143 pub fn new(sub_acct: impl Into<String>) -> Self {
145 Self {
146 sub_acct: sub_acct.into(),
147 ccy: None,
148 }
149 }
150
151 pub fn ccy(mut self, ccy: impl Into<String>) -> Self {
153 self.ccy = Some(ccy.into());
154 self
155 }
156}
157
158#[derive(Debug, Clone, Serialize)]
160#[serde(rename_all = "camelCase")]
161pub struct CreateSubAccountRequest {
162 sub_acct: String,
163 #[serde(skip_serializing_if = "Option::is_none")]
164 r#type: Option<String>,
165 #[serde(skip_serializing_if = "Option::is_none")]
166 label: Option<String>,
167 #[serde(skip_serializing_if = "Option::is_none")]
168 pwd: Option<String>,
169}
170
171impl CreateSubAccountRequest {
172 pub fn new(sub_acct: impl Into<String>) -> Self {
174 Self {
175 sub_acct: sub_acct.into(),
176 r#type: None,
177 label: None,
178 pwd: None,
179 }
180 }
181
182 pub fn sub_type(mut self, sub_type: impl Into<String>) -> Self {
184 self.r#type = Some(sub_type.into());
185 self
186 }
187
188 pub fn label(mut self, label: impl Into<String>) -> Self {
190 self.label = Some(label.into());
191 self
192 }
193
194 pub fn pwd(mut self, pwd: impl Into<String>) -> Self {
196 self.pwd = Some(pwd.into());
197 self
198 }
199}
200
201#[derive(Debug, Clone, Serialize)]
203#[serde(rename_all = "camelCase")]
204pub struct CreateSubAccountApiKeyRequest {
205 sub_acct: String,
206 label: String,
207 passphrase: String,
208 #[serde(skip_serializing_if = "Option::is_none")]
209 perm: Option<String>,
210 #[serde(skip_serializing_if = "Option::is_none")]
211 ip: Option<String>,
212}
213
214impl CreateSubAccountApiKeyRequest {
215 pub fn new(
217 sub_acct: impl Into<String>,
218 label: impl Into<String>,
219 passphrase: impl Into<String>,
220 ) -> Self {
221 Self {
222 sub_acct: sub_acct.into(),
223 label: label.into(),
224 passphrase: passphrase.into(),
225 perm: None,
226 ip: None,
227 }
228 }
229
230 pub fn perm(mut self, perm: impl Into<String>) -> Self {
232 self.perm = Some(perm.into());
233 self
234 }
235
236 pub fn ip(mut self, ip: impl Into<String>) -> Self {
238 self.ip = Some(ip.into());
239 self
240 }
241}
242
243#[derive(Debug, Clone, Serialize)]
245#[serde(rename_all = "camelCase")]
246pub struct ModifySubAccountApiKeyRequest {
247 sub_acct: String,
248 api_key: String,
249 #[serde(skip_serializing_if = "Option::is_none")]
250 label: Option<String>,
251 #[serde(skip_serializing_if = "Option::is_none")]
252 perm: Option<String>,
253 #[serde(skip_serializing_if = "Option::is_none")]
254 ip: Option<String>,
255}
256
257impl ModifySubAccountApiKeyRequest {
258 pub fn new(sub_acct: impl Into<String>, api_key: impl Into<String>) -> Self {
260 Self {
261 sub_acct: sub_acct.into(),
262 api_key: api_key.into(),
263 label: None,
264 perm: None,
265 ip: None,
266 }
267 }
268
269 pub fn label(mut self, label: impl Into<String>) -> Self {
271 self.label = Some(label.into());
272 self
273 }
274
275 pub fn perm(mut self, perm: impl Into<String>) -> Self {
277 self.perm = Some(perm.into());
278 self
279 }
280
281 pub fn ip(mut self, ip: impl Into<String>) -> Self {
283 self.ip = Some(ip.into());
284 self
285 }
286}
287
288#[derive(Debug, Clone, Serialize)]
290#[serde(rename_all = "camelCase")]
291pub struct DeleteSubAccountApiKeyRequest {
292 sub_acct: String,
293 api_key: String,
294}
295
296impl DeleteSubAccountApiKeyRequest {
297 pub fn new(sub_acct: impl Into<String>, api_key: impl Into<String>) -> Self {
299 Self {
300 sub_acct: sub_acct.into(),
301 api_key: api_key.into(),
302 }
303 }
304}
305
306#[derive(Debug, Clone, Serialize)]
308#[serde(rename_all = "camelCase")]
309pub struct SubAccountTransferRequest {
310 ccy: String,
311 amt: String,
312 from: SubAccountType,
313 to: SubAccountType,
314 from_sub_account: String,
315 to_sub_account: String,
316 #[serde(skip_serializing_if = "Option::is_none")]
317 loan_trans: Option<bool>,
318 #[serde(skip_serializing_if = "Option::is_none")]
319 omit_pos_risk: Option<String>,
320}
321
322impl SubAccountTransferRequest {
323 pub fn new(
328 ccy: impl Into<String>,
329 amt: impl Into<String>,
330 from: SubAccountType,
331 to: SubAccountType,
332 from_sub_account: impl Into<String>,
333 to_sub_account: impl Into<String>,
334 ) -> Self {
335 Self {
336 ccy: ccy.into(),
337 amt: amt.into(),
338 from,
339 to,
340 from_sub_account: from_sub_account.into(),
341 to_sub_account: to_sub_account.into(),
342 loan_trans: None,
343 omit_pos_risk: None,
344 }
345 }
346
347 pub fn loan_trans(mut self, loan_trans: bool) -> Self {
349 self.loan_trans = Some(loan_trans);
350 self
351 }
352
353 pub fn omit_pos_risk(mut self, omit_pos_risk: impl Into<String>) -> Self {
355 self.omit_pos_risk = Some(omit_pos_risk.into());
356 self
357 }
358}
359
360#[derive(Debug, Clone, Serialize)]
362#[serde(rename_all = "camelCase")]
363pub struct SetTransferOutRequest {
364 sub_acct: String,
365 can_trans_out: bool,
367}
368
369impl SetTransferOutRequest {
370 pub fn new(sub_acct: impl Into<String>) -> Self {
372 Self {
373 sub_acct: sub_acct.into(),
374 can_trans_out: true,
375 }
376 }
377
378 pub fn can_trans_out(mut self, can_trans_out: bool) -> Self {
380 self.can_trans_out = can_trans_out;
381 self
382 }
383}
384
385#[derive(Debug, Clone, Default, Serialize)]
387#[serde(rename_all = "camelCase")]
388pub struct SubAccountBillsRequest {
389 #[serde(skip_serializing_if = "Option::is_none")]
390 ccy: Option<String>,
391 #[serde(skip_serializing_if = "Option::is_none")]
392 r#type: Option<String>,
393 #[serde(skip_serializing_if = "Option::is_none")]
394 sub_acct: Option<String>,
395 #[serde(skip_serializing_if = "Option::is_none")]
396 after: Option<String>,
397 #[serde(skip_serializing_if = "Option::is_none")]
398 before: Option<String>,
399 #[serde(skip_serializing_if = "Option::is_none")]
400 limit: Option<u32>,
401}
402
403impl SubAccountBillsRequest {
404 pub fn new() -> Self {
406 Self::default()
407 }
408
409 pub fn ccy(mut self, ccy: impl Into<String>) -> Self {
411 self.ccy = Some(ccy.into());
412 self
413 }
414
415 pub fn bill_type(mut self, r#type: impl Into<String>) -> Self {
417 self.r#type = Some(r#type.into());
418 self
419 }
420
421 pub fn sub_acct(mut self, sub_acct: impl Into<String>) -> Self {
423 self.sub_acct = Some(sub_acct.into());
424 self
425 }
426
427 pub fn after(mut self, after: impl Into<String>) -> Self {
429 self.after = Some(after.into());
430 self
431 }
432
433 pub fn before(mut self, before: impl Into<String>) -> Self {
435 self.before = Some(before.into());
436 self
437 }
438
439 pub fn limit(mut self, limit: u32) -> Self {
441 self.limit = Some(limit);
442 self
443 }
444}
445
446#[derive(Debug, Clone, Default, Serialize)]
448#[serde(rename_all = "camelCase")]
449pub struct ManagedSubAccountBillsRequest {
450 #[serde(skip_serializing_if = "Option::is_none")]
451 ccy: Option<String>,
452 #[serde(skip_serializing_if = "Option::is_none")]
453 r#type: Option<String>,
454 #[serde(skip_serializing_if = "Option::is_none")]
455 sub_acct: Option<String>,
456 #[serde(skip_serializing_if = "Option::is_none")]
457 sub_uid: Option<String>,
458 #[serde(skip_serializing_if = "Option::is_none")]
459 after: Option<String>,
460 #[serde(skip_serializing_if = "Option::is_none")]
461 before: Option<String>,
462 #[serde(skip_serializing_if = "Option::is_none")]
463 limit: Option<u32>,
464}
465
466impl ManagedSubAccountBillsRequest {
467 pub fn new() -> Self {
469 Self::default()
470 }
471
472 pub fn ccy(mut self, ccy: impl Into<String>) -> Self {
474 self.ccy = Some(ccy.into());
475 self
476 }
477
478 pub fn bill_type(mut self, r#type: impl Into<String>) -> Self {
480 self.r#type = Some(r#type.into());
481 self
482 }
483
484 pub fn sub_acct(mut self, sub_acct: impl Into<String>) -> Self {
486 self.sub_acct = Some(sub_acct.into());
487 self
488 }
489
490 pub fn sub_uid(mut self, sub_uid: impl Into<String>) -> Self {
492 self.sub_uid = Some(sub_uid.into());
493 self
494 }
495
496 pub fn after(mut self, after: impl Into<String>) -> Self {
498 self.after = Some(after.into());
499 self
500 }
501
502 pub fn before(mut self, before: impl Into<String>) -> Self {
504 self.before = Some(before.into());
505 self
506 }
507
508 pub fn limit(mut self, limit: u32) -> Self {
510 self.limit = Some(limit);
511 self
512 }
513}
514
515#[derive(Debug, Clone, Default, Serialize)]
517#[serde(rename_all = "camelCase")]
518pub struct EntrustSubAccountListRequest {
519 #[serde(skip_serializing_if = "Option::is_none")]
520 sub_acct: Option<String>,
521}