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 r#type: Cow<'a, str>,
166 #[serde(skip_serializing_if = "Option::is_none")]
167 label: Option<Cow<'a, str>>,
168 #[serde(skip_serializing_if = "Option::is_none")]
170 pwd: Option<String>,
171}
172
173impl<'a> CreateSubAccountRequest<'a> {
174 pub fn new(sub_acct: impl Into<Cow<'a, str>>, sub_type: impl Into<Cow<'a, str>>) -> Self {
179 Self {
180 sub_acct: sub_acct.into(),
181 r#type: sub_type.into(),
182 label: None,
183 pwd: None,
184 }
185 }
186
187 pub fn label(mut self, label: impl Into<Cow<'a, str>>) -> Self {
189 self.label = Some(label.into());
190 self
191 }
192
193 pub fn pwd(mut self, pwd: impl Into<String>) -> Self {
195 self.pwd = Some(pwd.into());
196 self
197 }
198}
199
200#[derive(Debug, Clone, Serialize)]
202#[serde(rename_all = "camelCase")]
203pub struct CreateSubAccountApiKeyRequest<'a> {
204 sub_acct: Cow<'a, str>,
205 label: Cow<'a, str>,
206 passphrase: String,
208 #[serde(skip_serializing_if = "Option::is_none")]
209 perm: Option<Cow<'a, str>>,
210 #[serde(skip_serializing_if = "Option::is_none")]
211 ip: Option<Cow<'a, str>>,
212}
213
214impl<'a> CreateSubAccountApiKeyRequest<'a> {
215 pub fn new(
217 sub_acct: impl Into<Cow<'a, str>>,
218 label: impl Into<Cow<'a, str>>,
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<Cow<'a, str>>) -> Self {
232 self.perm = Some(perm.into());
233 self
234 }
235
236 pub fn ip(mut self, ip: impl Into<Cow<'a, str>>) -> 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<'a> {
247 sub_acct: Cow<'a, str>,
248 api_key: Cow<'a, str>,
249 #[serde(skip_serializing_if = "Option::is_none")]
250 label: Option<Cow<'a, str>>,
251 #[serde(skip_serializing_if = "Option::is_none")]
252 perm: Option<Cow<'a, str>>,
253 #[serde(skip_serializing_if = "Option::is_none")]
254 ip: Option<Cow<'a, str>>,
255}
256
257impl<'a> ModifySubAccountApiKeyRequest<'a> {
258 pub fn new(sub_acct: impl Into<Cow<'a, str>>, api_key: impl Into<Cow<'a, str>>) -> 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<Cow<'a, str>>) -> Self {
271 self.label = Some(label.into());
272 self
273 }
274
275 pub fn perm(mut self, perm: impl Into<Cow<'a, str>>) -> Self {
277 self.perm = Some(perm.into());
278 self
279 }
280
281 pub fn ip(mut self, ip: impl Into<Cow<'a, str>>) -> 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<'a> {
292 sub_acct: Cow<'a, str>,
293 api_key: Cow<'a, str>,
294}
295
296impl<'a> DeleteSubAccountApiKeyRequest<'a> {
297 pub fn new(sub_acct: impl Into<Cow<'a, str>>, api_key: impl Into<Cow<'a, str>>) -> 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<'a> {
310 ccy: Cow<'a, str>,
311 amt: Cow<'a, str>,
312 from: SubAccountType,
313 to: SubAccountType,
314 from_sub_account: Cow<'a, str>,
315 to_sub_account: Cow<'a, str>,
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<bool>,
320}
321
322impl<'a> SubAccountTransferRequest<'a> {
323 pub fn new(
328 ccy: impl Into<Cow<'a, str>>,
329 amt: impl Into<Cow<'a, str>>,
330 from: SubAccountType,
331 to: SubAccountType,
332 from_sub_account: impl Into<Cow<'a, str>>,
333 to_sub_account: impl Into<Cow<'a, str>>,
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: bool) -> Self {
355 self.omit_pos_risk = Some(omit_pos_risk);
356 self
357 }
358}
359
360#[derive(Debug, Clone, Serialize)]
362#[serde(rename_all = "camelCase")]
363pub struct SetTransferOutRequest<'a> {
364 sub_acct: Cow<'a, str>,
365 can_trans_out: bool,
367}
368
369impl<'a> SetTransferOutRequest<'a> {
370 pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> 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<'a> {
389 #[serde(skip_serializing_if = "Option::is_none")]
390 ccy: Option<Cow<'a, str>>,
391 #[serde(skip_serializing_if = "Option::is_none")]
392 r#type: Option<Cow<'a, str>>,
393 #[serde(skip_serializing_if = "Option::is_none")]
394 sub_acct: Option<Cow<'a, str>>,
395 #[serde(skip_serializing_if = "Option::is_none")]
396 after: Option<Cow<'a, str>>,
397 #[serde(skip_serializing_if = "Option::is_none")]
398 before: Option<Cow<'a, str>>,
399 #[serde(skip_serializing_if = "Option::is_none")]
400 limit: Option<u32>,
401}
402
403impl<'a> SubAccountBillsRequest<'a> {
404 pub fn new() -> Self {
406 Self::default()
407 }
408
409 pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
411 self.ccy = Some(ccy.into());
412 self
413 }
414
415 pub fn bill_type(mut self, r#type: impl Into<Cow<'a, str>>) -> Self {
417 self.r#type = Some(r#type.into());
418 self
419 }
420
421 pub fn sub_acct(mut self, sub_acct: impl Into<Cow<'a, str>>) -> Self {
423 self.sub_acct = Some(sub_acct.into());
424 self
425 }
426
427 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
429 self.after = Some(after.into());
430 self
431 }
432
433 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> 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<'a> {
450 #[serde(skip_serializing_if = "Option::is_none")]
451 ccy: Option<Cow<'a, str>>,
452 #[serde(skip_serializing_if = "Option::is_none")]
453 r#type: Option<Cow<'a, str>>,
454 #[serde(skip_serializing_if = "Option::is_none")]
455 sub_acct: Option<Cow<'a, str>>,
456 #[serde(skip_serializing_if = "Option::is_none")]
457 sub_uid: Option<Cow<'a, str>>,
458 #[serde(skip_serializing_if = "Option::is_none")]
459 after: Option<Cow<'a, str>>,
460 #[serde(skip_serializing_if = "Option::is_none")]
461 before: Option<Cow<'a, str>>,
462 #[serde(skip_serializing_if = "Option::is_none")]
463 limit: Option<u32>,
464}
465
466impl<'a> ManagedSubAccountBillsRequest<'a> {
467 pub fn new() -> Self {
469 Self::default()
470 }
471
472 pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
474 self.ccy = Some(ccy.into());
475 self
476 }
477
478 pub fn bill_type(mut self, r#type: impl Into<Cow<'a, str>>) -> Self {
480 self.r#type = Some(r#type.into());
481 self
482 }
483
484 pub fn sub_acct(mut self, sub_acct: impl Into<Cow<'a, str>>) -> Self {
486 self.sub_acct = Some(sub_acct.into());
487 self
488 }
489
490 pub fn sub_uid(mut self, sub_uid: impl Into<Cow<'a, str>>) -> Self {
492 self.sub_uid = Some(sub_uid.into());
493 self
494 }
495
496 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
498 self.after = Some(after.into());
499 self
500 }
501
502 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> 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<'a> {
519 #[serde(skip_serializing_if = "Option::is_none")]
520 sub_acct: Option<Cow<'a, str>>,
521}