1use std::borrow::Cow;
2
3use serde::Serialize;
4
5#[derive(Debug, Clone, Copy, Serialize)]
7pub enum SubAccountType {
8 #[serde(rename = "6")]
10 Funding,
11 #[serde(rename = "18")]
13 Trading,
14}
15
16#[derive(Debug, Clone, Default, Serialize)]
18#[serde(rename_all = "camelCase")]
19pub struct SubAccountListRequest<'a> {
20 #[serde(skip_serializing_if = "Option::is_none")]
21 enable: Option<bool>,
22 #[serde(skip_serializing_if = "Option::is_none")]
23 sub_acct: Option<Cow<'a, str>>,
24 #[serde(skip_serializing_if = "Option::is_none")]
25 after: Option<Cow<'a, str>>,
26 #[serde(skip_serializing_if = "Option::is_none")]
27 before: Option<Cow<'a, str>>,
28 #[serde(skip_serializing_if = "Option::is_none")]
29 limit: Option<u32>,
30}
31
32impl<'a> SubAccountListRequest<'a> {
33 pub fn new() -> Self {
35 Self::default()
36 }
37
38 pub fn enable(mut self, enable: bool) -> Self {
40 self.enable = Some(enable);
41 self
42 }
43
44 pub fn sub_acct(mut self, sub_acct: impl Into<Cow<'a, str>>) -> Self {
46 self.sub_acct = Some(sub_acct.into());
47 self
48 }
49
50 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
52 self.after = Some(after.into());
53 self
54 }
55
56 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> Self {
58 self.before = Some(before.into());
59 self
60 }
61
62 pub fn limit(mut self, limit: u32) -> Self {
64 self.limit = Some(limit);
65 self
66 }
67}
68
69#[derive(Debug, Clone, Serialize)]
71#[serde(rename_all = "camelCase")]
72pub struct SubAccountApiKeysRequest<'a> {
73 sub_acct: Cow<'a, str>,
74 #[serde(skip_serializing_if = "Option::is_none")]
75 api_key: Option<Cow<'a, str>>,
76}
77
78impl<'a> SubAccountApiKeysRequest<'a> {
79 pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
81 Self {
82 sub_acct: sub_acct.into(),
83 api_key: None,
84 }
85 }
86
87 pub fn api_key(mut self, api_key: impl Into<Cow<'a, str>>) -> Self {
89 self.api_key = Some(api_key.into());
90 self
91 }
92}
93
94#[derive(Debug, Clone, Serialize)]
96#[serde(rename_all = "camelCase")]
97pub struct SubAccountTradingBalancesRequest<'a> {
98 sub_acct: Cow<'a, str>,
99}
100
101impl<'a> SubAccountTradingBalancesRequest<'a> {
102 pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
104 Self {
105 sub_acct: sub_acct.into(),
106 }
107 }
108}
109
110#[derive(Debug, Clone, Serialize)]
112#[serde(rename_all = "camelCase")]
113pub struct SubAccountFundingBalancesRequest<'a> {
114 sub_acct: Cow<'a, str>,
115 #[serde(skip_serializing_if = "Option::is_none")]
116 ccy: Option<Cow<'a, str>>,
117}
118
119impl<'a> SubAccountFundingBalancesRequest<'a> {
120 pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
122 Self {
123 sub_acct: sub_acct.into(),
124 ccy: None,
125 }
126 }
127
128 pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
130 self.ccy = Some(ccy.into());
131 self
132 }
133}
134
135#[derive(Debug, Clone, Serialize)]
137#[serde(rename_all = "camelCase")]
138pub struct SubAccountMaxWithdrawalRequest<'a> {
139 sub_acct: Cow<'a, str>,
140 #[serde(skip_serializing_if = "Option::is_none")]
141 ccy: Option<Cow<'a, str>>,
142}
143
144impl<'a> SubAccountMaxWithdrawalRequest<'a> {
145 pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
147 Self {
148 sub_acct: sub_acct.into(),
149 ccy: None,
150 }
151 }
152
153 pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
155 self.ccy = Some(ccy.into());
156 self
157 }
158}
159
160#[derive(Debug, Clone, Serialize)]
162#[serde(rename_all = "camelCase")]
163pub struct CreateSubAccountRequest<'a> {
164 sub_acct: Cow<'a, str>,
165 #[serde(skip_serializing_if = "Option::is_none")]
166 r#type: Option<Cow<'a, str>>,
167 #[serde(skip_serializing_if = "Option::is_none")]
168 label: Option<Cow<'a, str>>,
169 #[serde(skip_serializing_if = "Option::is_none")]
171 pwd: Option<String>,
172}
173
174impl<'a> CreateSubAccountRequest<'a> {
175 pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
177 Self {
178 sub_acct: sub_acct.into(),
179 r#type: None,
180 label: None,
181 pwd: None,
182 }
183 }
184
185 pub fn sub_type(mut self, sub_type: impl Into<Cow<'a, str>>) -> Self {
187 self.r#type = Some(sub_type.into());
188 self
189 }
190
191 pub fn label(mut self, label: impl Into<Cow<'a, str>>) -> Self {
193 self.label = Some(label.into());
194 self
195 }
196
197 pub fn pwd(mut self, pwd: impl Into<String>) -> Self {
199 self.pwd = Some(pwd.into());
200 self
201 }
202}
203
204#[derive(Debug, Clone, Serialize)]
206#[serde(rename_all = "camelCase")]
207pub struct CreateSubAccountApiKeyRequest<'a> {
208 sub_acct: Cow<'a, str>,
209 label: Cow<'a, str>,
210 passphrase: String,
212 #[serde(skip_serializing_if = "Option::is_none")]
213 perm: Option<Cow<'a, str>>,
214 #[serde(skip_serializing_if = "Option::is_none")]
215 ip: Option<Cow<'a, str>>,
216}
217
218impl<'a> CreateSubAccountApiKeyRequest<'a> {
219 pub fn new(
221 sub_acct: impl Into<Cow<'a, str>>,
222 label: impl Into<Cow<'a, str>>,
223 passphrase: impl Into<String>,
224 ) -> Self {
225 Self {
226 sub_acct: sub_acct.into(),
227 label: label.into(),
228 passphrase: passphrase.into(),
229 perm: None,
230 ip: None,
231 }
232 }
233
234 pub fn perm(mut self, perm: impl Into<Cow<'a, str>>) -> Self {
236 self.perm = Some(perm.into());
237 self
238 }
239
240 pub fn ip(mut self, ip: impl Into<Cow<'a, str>>) -> Self {
242 self.ip = Some(ip.into());
243 self
244 }
245}
246
247#[derive(Debug, Clone, Serialize)]
249#[serde(rename_all = "camelCase")]
250pub struct ModifySubAccountApiKeyRequest<'a> {
251 sub_acct: Cow<'a, str>,
252 api_key: Cow<'a, str>,
253 #[serde(skip_serializing_if = "Option::is_none")]
254 label: Option<Cow<'a, str>>,
255 #[serde(skip_serializing_if = "Option::is_none")]
256 perm: Option<Cow<'a, str>>,
257 #[serde(skip_serializing_if = "Option::is_none")]
258 ip: Option<Cow<'a, str>>,
259}
260
261impl<'a> ModifySubAccountApiKeyRequest<'a> {
262 pub fn new(sub_acct: impl Into<Cow<'a, str>>, api_key: impl Into<Cow<'a, str>>) -> Self {
264 Self {
265 sub_acct: sub_acct.into(),
266 api_key: api_key.into(),
267 label: None,
268 perm: None,
269 ip: None,
270 }
271 }
272
273 pub fn label(mut self, label: impl Into<Cow<'a, str>>) -> Self {
275 self.label = Some(label.into());
276 self
277 }
278
279 pub fn perm(mut self, perm: impl Into<Cow<'a, str>>) -> Self {
281 self.perm = Some(perm.into());
282 self
283 }
284
285 pub fn ip(mut self, ip: impl Into<Cow<'a, str>>) -> Self {
287 self.ip = Some(ip.into());
288 self
289 }
290}
291
292#[derive(Debug, Clone, Serialize)]
294#[serde(rename_all = "camelCase")]
295pub struct DeleteSubAccountApiKeyRequest<'a> {
296 sub_acct: Cow<'a, str>,
297 api_key: Cow<'a, str>,
298}
299
300impl<'a> DeleteSubAccountApiKeyRequest<'a> {
301 pub fn new(sub_acct: impl Into<Cow<'a, str>>, api_key: impl Into<Cow<'a, str>>) -> Self {
303 Self {
304 sub_acct: sub_acct.into(),
305 api_key: api_key.into(),
306 }
307 }
308}
309
310#[derive(Debug, Clone, Serialize)]
312#[serde(rename_all = "camelCase")]
313pub struct SubAccountTransferRequest<'a> {
314 ccy: Cow<'a, str>,
315 amt: Cow<'a, str>,
316 from: SubAccountType,
317 to: SubAccountType,
318 from_sub_account: Cow<'a, str>,
319 to_sub_account: Cow<'a, str>,
320 #[serde(skip_serializing_if = "Option::is_none")]
321 loan_trans: Option<bool>,
322 #[serde(skip_serializing_if = "Option::is_none")]
323 omit_pos_risk: Option<bool>,
324}
325
326impl<'a> SubAccountTransferRequest<'a> {
327 pub fn new(
332 ccy: impl Into<Cow<'a, str>>,
333 amt: impl Into<Cow<'a, str>>,
334 from: SubAccountType,
335 to: SubAccountType,
336 from_sub_account: impl Into<Cow<'a, str>>,
337 to_sub_account: impl Into<Cow<'a, str>>,
338 ) -> Self {
339 Self {
340 ccy: ccy.into(),
341 amt: amt.into(),
342 from,
343 to,
344 from_sub_account: from_sub_account.into(),
345 to_sub_account: to_sub_account.into(),
346 loan_trans: None,
347 omit_pos_risk: None,
348 }
349 }
350
351 pub fn loan_trans(mut self, loan_trans: bool) -> Self {
353 self.loan_trans = Some(loan_trans);
354 self
355 }
356
357 pub fn omit_pos_risk(mut self, omit_pos_risk: bool) -> Self {
359 self.omit_pos_risk = Some(omit_pos_risk);
360 self
361 }
362}
363
364#[derive(Debug, Clone, Serialize)]
366#[serde(rename_all = "camelCase")]
367pub struct SetTransferOutRequest<'a> {
368 sub_acct: Cow<'a, str>,
369 can_trans_out: bool,
371}
372
373impl<'a> SetTransferOutRequest<'a> {
374 pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
376 Self {
377 sub_acct: sub_acct.into(),
378 can_trans_out: true,
379 }
380 }
381
382 pub fn can_trans_out(mut self, can_trans_out: bool) -> Self {
384 self.can_trans_out = can_trans_out;
385 self
386 }
387}
388
389#[derive(Debug, Clone, Default, Serialize)]
391#[serde(rename_all = "camelCase")]
392pub struct SubAccountBillsRequest<'a> {
393 #[serde(skip_serializing_if = "Option::is_none")]
394 ccy: Option<Cow<'a, str>>,
395 #[serde(skip_serializing_if = "Option::is_none")]
396 r#type: Option<Cow<'a, str>>,
397 #[serde(skip_serializing_if = "Option::is_none")]
398 sub_acct: Option<Cow<'a, str>>,
399 #[serde(skip_serializing_if = "Option::is_none")]
400 after: Option<Cow<'a, str>>,
401 #[serde(skip_serializing_if = "Option::is_none")]
402 before: Option<Cow<'a, str>>,
403 #[serde(skip_serializing_if = "Option::is_none")]
404 limit: Option<u32>,
405}
406
407impl<'a> SubAccountBillsRequest<'a> {
408 pub fn new() -> Self {
410 Self::default()
411 }
412
413 pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
415 self.ccy = Some(ccy.into());
416 self
417 }
418
419 pub fn bill_type(mut self, r#type: impl Into<Cow<'a, str>>) -> Self {
421 self.r#type = Some(r#type.into());
422 self
423 }
424
425 pub fn sub_acct(mut self, sub_acct: impl Into<Cow<'a, str>>) -> Self {
427 self.sub_acct = Some(sub_acct.into());
428 self
429 }
430
431 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
433 self.after = Some(after.into());
434 self
435 }
436
437 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> Self {
439 self.before = Some(before.into());
440 self
441 }
442
443 pub fn limit(mut self, limit: u32) -> Self {
445 self.limit = Some(limit);
446 self
447 }
448}
449
450#[derive(Debug, Clone, Default, Serialize)]
452#[serde(rename_all = "camelCase")]
453pub struct ManagedSubAccountBillsRequest<'a> {
454 #[serde(skip_serializing_if = "Option::is_none")]
455 ccy: Option<Cow<'a, str>>,
456 #[serde(skip_serializing_if = "Option::is_none")]
457 r#type: Option<Cow<'a, str>>,
458 #[serde(skip_serializing_if = "Option::is_none")]
459 sub_acct: Option<Cow<'a, str>>,
460 #[serde(skip_serializing_if = "Option::is_none")]
461 sub_uid: Option<Cow<'a, str>>,
462 #[serde(skip_serializing_if = "Option::is_none")]
463 after: Option<Cow<'a, str>>,
464 #[serde(skip_serializing_if = "Option::is_none")]
465 before: Option<Cow<'a, str>>,
466 #[serde(skip_serializing_if = "Option::is_none")]
467 limit: Option<u32>,
468}
469
470impl<'a> ManagedSubAccountBillsRequest<'a> {
471 pub fn new() -> Self {
473 Self::default()
474 }
475
476 pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
478 self.ccy = Some(ccy.into());
479 self
480 }
481
482 pub fn bill_type(mut self, r#type: impl Into<Cow<'a, str>>) -> Self {
484 self.r#type = Some(r#type.into());
485 self
486 }
487
488 pub fn sub_acct(mut self, sub_acct: impl Into<Cow<'a, str>>) -> Self {
490 self.sub_acct = Some(sub_acct.into());
491 self
492 }
493
494 pub fn sub_uid(mut self, sub_uid: impl Into<Cow<'a, str>>) -> Self {
496 self.sub_uid = Some(sub_uid.into());
497 self
498 }
499
500 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
502 self.after = Some(after.into());
503 self
504 }
505
506 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> Self {
508 self.before = Some(before.into());
509 self
510 }
511
512 pub fn limit(mut self, limit: u32) -> Self {
514 self.limit = Some(limit);
515 self
516 }
517}
518
519#[derive(Debug, Clone, Default, Serialize)]
521#[serde(rename_all = "camelCase")]
522pub struct EntrustSubAccountListRequest<'a> {
523 #[serde(skip_serializing_if = "Option::is_none")]
524 sub_acct: Option<Cow<'a, str>>,
525}