rust_okx/api/account/requests/
settings.rs1use std::borrow::Cow;
2
3use serde::Serialize;
4
5#[derive(Debug, Clone, Serialize)]
7pub struct SetPositionModeRequest<'a> {
8 #[serde(rename = "posMode")]
9 pos_mode: Cow<'a, str>,
10}
11
12impl<'a> SetPositionModeRequest<'a> {
13 pub fn new(pos_mode: impl Into<Cow<'a, str>>) -> Self {
15 Self {
16 pos_mode: pos_mode.into(),
17 }
18 }
19}
20
21#[derive(Debug, Clone, Serialize)]
23pub struct SetCollateralAssetsRequest<'a> {
24 #[serde(rename = "type")]
25 collateral_type: Cow<'a, str>,
26 #[serde(rename = "collateralEnabled")]
27 collateral_enabled: bool,
28 #[serde(rename = "ccyList", skip_serializing_if = "Vec::is_empty")]
29 ccy_list: Vec<Cow<'a, str>>,
30}
31
32impl<'a> SetCollateralAssetsRequest<'a> {
33 pub fn all(collateral_enabled: bool) -> Self {
35 Self {
36 collateral_type: Cow::Borrowed("all"),
37 collateral_enabled,
38 ccy_list: Vec::new(),
39 }
40 }
41
42 pub fn custom<I, C>(ccy_list: I, collateral_enabled: bool) -> Self
44 where
45 I: IntoIterator<Item = C>,
46 C: Into<Cow<'a, str>>,
47 {
48 Self {
49 collateral_type: Cow::Borrowed("custom"),
50 collateral_enabled,
51 ccy_list: ccy_list.into_iter().map(Into::into).collect(),
52 }
53 }
54
55 pub fn new(collateral_type: impl Into<Cow<'a, str>>, collateral_enabled: bool) -> Self {
57 Self {
58 collateral_type: collateral_type.into(),
59 collateral_enabled,
60 ccy_list: Vec::new(),
61 }
62 }
63
64 pub fn currencies<I, C>(mut self, ccy_list: I) -> Self
66 where
67 I: IntoIterator<Item = C>,
68 C: Into<Cow<'a, str>>,
69 {
70 self.ccy_list = ccy_list.into_iter().map(Into::into).collect();
71 self
72 }
73}
74
75#[derive(Debug, Clone, Serialize)]
77pub struct SetGreeksRequest<'a> {
78 #[serde(rename = "greeksType")]
79 greeks_type: Cow<'a, str>,
80}
81
82impl<'a> SetGreeksRequest<'a> {
83 pub fn new(greeks_type: impl Into<Cow<'a, str>>) -> Self {
85 Self {
86 greeks_type: greeks_type.into(),
87 }
88 }
89}
90
91#[derive(Debug, Clone, Serialize)]
93pub struct SetIsolatedModeRequest<'a> {
94 #[serde(rename = "isoMode")]
95 iso_mode: Cow<'a, str>,
96 #[serde(rename = "type")]
97 mode_type: Cow<'a, str>,
98}
99
100impl<'a> SetIsolatedModeRequest<'a> {
101 pub fn new(iso_mode: impl Into<Cow<'a, str>>, mode_type: impl Into<Cow<'a, str>>) -> Self {
103 Self {
104 iso_mode: iso_mode.into(),
105 mode_type: mode_type.into(),
106 }
107 }
108}
109
110#[derive(Debug, Clone, Serialize)]
112pub struct SetAutoLoanRequest {
113 #[serde(rename = "autoLoan")]
114 auto_loan: bool,
115}
116
117impl SetAutoLoanRequest {
118 pub fn new(auto_loan: bool) -> Self {
120 Self { auto_loan }
121 }
122}
123
124#[derive(Debug, Clone, Serialize)]
126pub struct SetAccountLevelRequest<'a> {
127 #[serde(rename = "acctLv")]
128 acct_lv: Cow<'a, str>,
129}
130
131impl<'a> SetAccountLevelRequest<'a> {
132 pub fn new(acct_lv: impl Into<Cow<'a, str>>) -> Self {
134 Self {
135 acct_lv: acct_lv.into(),
136 }
137 }
138}