rust_okx/api/finance/requests/
staking.rs1use std::borrow::Cow;
2
3use serde::Serialize;
4
5#[derive(Debug, Clone, Default, Serialize)]
7pub struct StakingDefiOffersRequest<'a> {
8 #[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
9 product_id: Option<Cow<'a, str>>,
10 #[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
11 protocol_type: Option<Cow<'a, str>>,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 ccy: Option<Cow<'a, str>>,
14}
15
16impl<'a> StakingDefiOffersRequest<'a> {
17 pub fn new() -> Self {
19 Self::default()
20 }
21
22 pub fn product_id(mut self, value: impl Into<Cow<'a, str>>) -> Self {
24 self.product_id = Some(value.into());
25 self
26 }
27
28 pub fn protocol_type(mut self, value: impl Into<Cow<'a, str>>) -> Self {
30 self.protocol_type = Some(value.into());
31 self
32 }
33
34 pub fn currency(mut self, value: impl Into<Cow<'a, str>>) -> Self {
36 self.ccy = Some(value.into());
37 self
38 }
39}
40
41#[derive(Debug, Clone, Serialize)]
43pub struct StakingDefiInvestment<'a> {
44 ccy: Cow<'a, str>,
45 amt: Cow<'a, str>,
46}
47
48impl<'a> StakingDefiInvestment<'a> {
49 pub fn new(ccy: impl Into<Cow<'a, str>>, amt: impl Into<Cow<'a, str>>) -> Self {
51 Self {
52 ccy: ccy.into(),
53 amt: amt.into(),
54 }
55 }
56}
57
58#[derive(Debug, Clone, Serialize)]
60pub struct StakingDefiPurchaseRequest<'a> {
61 #[serde(rename = "productId")]
62 product_id: Cow<'a, str>,
63 #[serde(rename = "investData")]
64 invest_data: Vec<StakingDefiInvestment<'a>>,
65 #[serde(skip_serializing_if = "Option::is_none")]
66 term: Option<Cow<'a, str>>,
67 #[serde(skip_serializing_if = "Option::is_none")]
68 tag: Option<Cow<'a, str>>,
69}
70
71impl<'a> StakingDefiPurchaseRequest<'a> {
72 pub fn new(
74 product_id: impl Into<Cow<'a, str>>,
75 invest_data: Vec<StakingDefiInvestment<'a>>,
76 ) -> Self {
77 Self {
78 product_id: product_id.into(),
79 invest_data,
80 term: None,
81 tag: None,
82 }
83 }
84
85 pub fn term(mut self, value: impl Into<Cow<'a, str>>) -> Self {
87 self.term = Some(value.into());
88 self
89 }
90
91 pub fn tag(mut self, value: impl Into<Cow<'a, str>>) -> Self {
93 self.tag = Some(value.into());
94 self
95 }
96}
97
98#[derive(Debug, Clone, Serialize)]
100pub struct StakingDefiRedeemRequest<'a> {
101 #[serde(rename = "ordId")]
102 ord_id: Cow<'a, str>,
103 #[serde(rename = "protocolType")]
104 protocol_type: Cow<'a, str>,
105 #[serde(rename = "allowEarlyRedeem", skip_serializing_if = "Option::is_none")]
106 allow_early_redeem: Option<bool>,
107}
108
109impl<'a> StakingDefiRedeemRequest<'a> {
110 pub fn new(ord_id: impl Into<Cow<'a, str>>, protocol_type: impl Into<Cow<'a, str>>) -> Self {
112 Self {
113 ord_id: ord_id.into(),
114 protocol_type: protocol_type.into(),
115 allow_early_redeem: None,
116 }
117 }
118
119 pub fn allow_early_redeem(mut self, value: bool) -> Self {
121 self.allow_early_redeem = Some(value);
122 self
123 }
124}
125
126#[derive(Debug, Clone, Serialize)]
128pub struct StakingDefiCancelRequest<'a> {
129 #[serde(rename = "ordId")]
130 ord_id: Cow<'a, str>,
131 #[serde(rename = "protocolType")]
132 protocol_type: Cow<'a, str>,
133}
134
135impl<'a> StakingDefiCancelRequest<'a> {
136 pub fn new(ord_id: impl Into<Cow<'a, str>>, protocol_type: impl Into<Cow<'a, str>>) -> Self {
138 Self {
139 ord_id: ord_id.into(),
140 protocol_type: protocol_type.into(),
141 }
142 }
143}
144
145#[derive(Debug, Clone, Default, Serialize)]
147pub struct StakingDefiActiveOrdersRequest<'a> {
148 #[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
149 product_id: Option<Cow<'a, str>>,
150 #[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
151 protocol_type: Option<Cow<'a, str>>,
152 #[serde(skip_serializing_if = "Option::is_none")]
153 ccy: Option<Cow<'a, str>>,
154 #[serde(skip_serializing_if = "Option::is_none")]
155 state: Option<Cow<'a, str>>,
156}
157
158impl<'a> StakingDefiActiveOrdersRequest<'a> {
159 pub fn new() -> Self {
161 Self::default()
162 }
163
164 pub fn product_id(mut self, value: impl Into<Cow<'a, str>>) -> Self {
166 self.product_id = Some(value.into());
167 self
168 }
169
170 pub fn protocol_type(mut self, value: impl Into<Cow<'a, str>>) -> Self {
172 self.protocol_type = Some(value.into());
173 self
174 }
175
176 pub fn currency(mut self, value: impl Into<Cow<'a, str>>) -> Self {
178 self.ccy = Some(value.into());
179 self
180 }
181
182 pub fn state(mut self, value: impl Into<Cow<'a, str>>) -> Self {
184 self.state = Some(value.into());
185 self
186 }
187}
188
189#[derive(Debug, Clone, Default, Serialize)]
191pub struct StakingDefiOrderHistoryRequest<'a> {
192 #[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
193 product_id: Option<Cow<'a, str>>,
194 #[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
195 protocol_type: Option<Cow<'a, str>>,
196 #[serde(skip_serializing_if = "Option::is_none")]
197 ccy: Option<Cow<'a, str>>,
198 #[serde(skip_serializing_if = "Option::is_none")]
199 after: Option<Cow<'a, str>>,
200 #[serde(skip_serializing_if = "Option::is_none")]
201 before: Option<Cow<'a, str>>,
202 #[serde(skip_serializing_if = "Option::is_none")]
203 limit: Option<u32>,
204}
205
206impl<'a> StakingDefiOrderHistoryRequest<'a> {
207 pub fn new() -> Self {
209 Self::default()
210 }
211
212 pub fn product_id(mut self, value: impl Into<Cow<'a, str>>) -> Self {
214 self.product_id = Some(value.into());
215 self
216 }
217
218 pub fn protocol_type(mut self, value: impl Into<Cow<'a, str>>) -> Self {
220 self.protocol_type = Some(value.into());
221 self
222 }
223
224 pub fn currency(mut self, value: impl Into<Cow<'a, str>>) -> Self {
226 self.ccy = Some(value.into());
227 self
228 }
229
230 pub fn after(mut self, value: impl Into<Cow<'a, str>>) -> Self {
232 self.after = Some(value.into());
233 self
234 }
235
236 pub fn before(mut self, value: impl Into<Cow<'a, str>>) -> Self {
238 self.before = Some(value.into());
239 self
240 }
241
242 pub fn limit(mut self, value: u32) -> Self {
244 self.limit = Some(value);
245 self
246 }
247}