1use rust_decimal::Decimal;
2use serde::{Deserialize, Serialize};
3
4use crate::{
5 Timestamp,
6 wallet::{DepositStatus, WithdrawStatus},
7};
8
9#[derive(Debug, PartialEq)]
10pub struct Response<T> {
11 pub result: T,
12 pub headers: Headers,
13}
14
15#[derive(Debug, PartialEq)]
16pub struct Headers {
17 pub retry_after: Option<Timestamp>,
18}
19
20#[derive(Debug, Serialize, PartialEq, Default)]
23#[serde(rename_all = "camelCase")]
24pub struct GetAllCoinsParams {
25 recv_window: Option<u64>,
26}
27
28impl GetAllCoinsParams {
29 pub fn new() -> Self {
30 Self::default()
31 }
32
33 pub fn recv_window(mut self, value: u64) -> Self {
34 self.recv_window = Some(value);
35 self
36 }
37}
38
39#[derive(Debug, Deserialize, PartialEq)]
42#[serde(rename_all = "camelCase")]
43pub struct CoinInfo {
44 pub coin: String,
45 pub name: String,
46 pub free: Decimal,
47 pub locked: Decimal,
48 pub freeze: Decimal,
49 pub withdrawing: Decimal,
50 pub ipoing: Decimal,
51 pub ipoable: Decimal,
52 pub storage: Decimal,
53 pub deposit_all_enable: bool,
54 pub withdraw_all_enable: bool,
55 pub trading: bool,
56 pub is_legal_money: bool,
57 pub network_list: Vec<CoinNetwork>,
58}
59
60#[derive(Debug, Deserialize, PartialEq)]
61#[serde(rename_all = "camelCase")]
62pub struct CoinNetwork {
63 pub network: String,
64 pub coin: String,
65 pub name: String,
66 pub deposit_enable: bool,
67 pub withdraw_enable: bool,
68 pub is_default: bool,
69 pub min_confirm: u32,
70 pub un_lock_confirm: u32,
71 pub withdraw_fee: Decimal,
72 pub withdraw_min: Decimal,
73 pub withdraw_max: Decimal,
74 pub deposit_dust: Option<Decimal>,
75 pub special_tips: Option<String>,
76 pub same_address: bool,
77}
78
79#[derive(Debug, Serialize, PartialEq)]
82#[serde(rename_all = "camelCase")]
83pub struct GetDepositAddressParams {
84 coin: String,
85 network: Option<String>,
86 amount: Option<Decimal>,
88 recv_window: Option<u64>,
89}
90
91impl GetDepositAddressParams {
92 pub fn new(coin: impl Into<String>) -> Self {
93 Self {
94 coin: coin.into(),
95 network: None,
96 amount: None,
97 recv_window: None,
98 }
99 }
100
101 pub fn network(mut self, value: impl Into<String>) -> Self {
102 self.network = Some(value.into());
103 self
104 }
105
106 pub fn amount(mut self, value: Decimal) -> Self {
107 self.amount = Some(value);
108 self
109 }
110
111 pub fn recv_window(mut self, value: u64) -> Self {
112 self.recv_window = Some(value);
113 self
114 }
115}
116
117#[derive(Debug, Deserialize, PartialEq)]
118#[serde(rename_all = "camelCase")]
119pub struct DepositAddress {
120 pub address: String,
121 pub coin: String,
122 pub tag: String,
124 pub url: String,
125}
126
127#[derive(Debug, Serialize, PartialEq, Default)]
130#[serde(rename_all = "camelCase")]
131pub struct GetDepositHistoryParams {
132 coin: Option<String>,
133 status: Option<DepositStatus>,
134 start_time: Option<Timestamp>,
135 end_time: Option<Timestamp>,
136 limit: Option<u32>,
138 offset: Option<u32>,
139 recv_window: Option<u64>,
140}
141
142impl GetDepositHistoryParams {
143 pub fn new() -> Self {
144 Self::default()
145 }
146
147 pub fn coin(mut self, value: impl Into<String>) -> Self {
148 self.coin = Some(value.into());
149 self
150 }
151 pub fn status(mut self, value: DepositStatus) -> Self {
152 self.status = Some(value);
153 self
154 }
155 pub fn start_time(mut self, value: Timestamp) -> Self {
156 self.start_time = Some(value);
157 self
158 }
159 pub fn end_time(mut self, value: Timestamp) -> Self {
160 self.end_time = Some(value);
161 self
162 }
163 pub fn limit(mut self, value: u32) -> Self {
164 self.limit = Some(value);
165 self
166 }
167 pub fn offset(mut self, value: u32) -> Self {
168 self.offset = Some(value);
169 self
170 }
171 pub fn recv_window(mut self, value: u64) -> Self {
172 self.recv_window = Some(value);
173 self
174 }
175}
176
177#[derive(Debug, Deserialize, PartialEq)]
178#[serde(rename_all = "camelCase")]
179pub struct Deposit {
180 pub id: String,
182 pub amount: Decimal,
183 pub coin: String,
184 pub network: String,
185 pub status: DepositStatus,
186 pub address: String,
187 pub address_tag: String,
188 pub tx_id: String,
189 pub insert_time: Timestamp,
190 pub transfer_type: u8,
191 pub confirm_times: String,
192 pub unlock_confirm: u32,
193 pub wallet_type: u8,
194}
195
196#[derive(Debug, Serialize, PartialEq, Default)]
199#[serde(rename_all = "camelCase")]
200pub struct GetWithdrawHistoryParams {
201 coin: Option<String>,
202 status: Option<WithdrawStatus>,
204 withdraw_order_id: Option<String>,
206 start_time: Option<Timestamp>,
207 end_time: Option<Timestamp>,
208 limit: Option<u32>,
210 offset: Option<u32>,
211 recv_window: Option<u64>,
212}
213
214impl GetWithdrawHistoryParams {
215 pub fn new() -> Self {
216 Self::default()
217 }
218
219 pub fn coin(mut self, value: impl Into<String>) -> Self {
220 self.coin = Some(value.into());
221 self
222 }
223 pub fn status(mut self, value: WithdrawStatus) -> Self {
224 self.status = Some(value);
225 self
226 }
227 pub fn withdraw_order_id(mut self, value: impl Into<String>) -> Self {
228 self.withdraw_order_id = Some(value.into());
229 self
230 }
231 pub fn start_time(mut self, value: Timestamp) -> Self {
232 self.start_time = Some(value);
233 self
234 }
235 pub fn end_time(mut self, value: Timestamp) -> Self {
236 self.end_time = Some(value);
237 self
238 }
239 pub fn limit(mut self, value: u32) -> Self {
240 self.limit = Some(value);
241 self
242 }
243 pub fn offset(mut self, value: u32) -> Self {
244 self.offset = Some(value);
245 self
246 }
247 pub fn recv_window(mut self, value: u64) -> Self {
248 self.recv_window = Some(value);
249 self
250 }
251}
252
253#[derive(Debug, Deserialize, PartialEq)]
254#[serde(rename_all = "camelCase")]
255pub struct Withdraw {
256 pub id: String,
257 pub amount: Decimal,
258 pub transaction_fee: Decimal,
259 pub coin: String,
260 pub status: WithdrawStatus,
261 pub address: String,
262 pub tx_id: String,
263 pub apply_time: String,
264 pub network: String,
265 pub transfer_type: u8,
266 pub withdraw_order_id: Option<String>,
267 pub info: Option<String>,
268 pub confirm_no: Option<u32>,
269 pub wallet_type: u8,
270 pub tx_key: Option<String>,
271 pub complete_time: Option<String>,
272}
273
274#[derive(Debug, Serialize, PartialEq, Default)]
277#[serde(rename_all = "camelCase")]
278pub struct GetAccountStatusParams {
279 recv_window: Option<u64>,
280}
281
282impl GetAccountStatusParams {
283 pub fn new() -> Self {
284 Self::default()
285 }
286
287 pub fn recv_window(mut self, value: u64) -> Self {
288 self.recv_window = Some(value);
289 self
290 }
291}
292
293#[derive(Debug, Deserialize, PartialEq)]
294pub struct AccountStatus {
295 pub data: String,
297}
298
299#[derive(Debug, Serialize, PartialEq, Default)]
302#[serde(rename_all = "camelCase")]
303pub struct GetTradeFeeParams {
304 symbol: Option<String>,
305 recv_window: Option<u64>,
306}
307
308impl GetTradeFeeParams {
309 pub fn new() -> Self {
310 Self::default()
311 }
312
313 pub fn symbol(mut self, value: impl Into<String>) -> Self {
314 self.symbol = Some(value.into());
315 self
316 }
317
318 pub fn recv_window(mut self, value: u64) -> Self {
319 self.recv_window = Some(value);
320 self
321 }
322}
323
324#[derive(Debug, Deserialize, PartialEq)]
325#[serde(rename_all = "camelCase")]
326pub struct TradeFee {
327 pub symbol: String,
328 pub maker_commission: Decimal,
329 pub taker_commission: Decimal,
330}