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<i64>,
26}
27
28impl GetAllCoinsParams {
29 pub fn new() -> Self {
30 Self::default()
31 }
32
33 pub fn recv_window(mut self, value: i64) -> 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<i64>,
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: i64) -> 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<i64>,
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: i64) -> 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 amount: Decimal,
181 pub coin: String,
182 pub network: String,
183 pub status: DepositStatus,
184 pub address: String,
185 pub address_tag: String,
186 pub tx_id: String,
187 pub insert_time: Timestamp,
188 pub transfer_type: u8,
189 pub confirm_times: String,
190 pub unlock_confirm: u32,
191 pub wallet_type: u8,
192}
193
194#[derive(Debug, Serialize, PartialEq, Default)]
197#[serde(rename_all = "camelCase")]
198pub struct GetWithdrawHistoryParams {
199 coin: Option<String>,
200 status: Option<WithdrawStatus>,
202 withdraw_order_id: Option<String>,
204 start_time: Option<Timestamp>,
205 end_time: Option<Timestamp>,
206 limit: Option<u32>,
208 offset: Option<u32>,
209 recv_window: Option<i64>,
210}
211
212impl GetWithdrawHistoryParams {
213 pub fn new() -> Self {
214 Self::default()
215 }
216
217 pub fn coin(mut self, value: impl Into<String>) -> Self {
218 self.coin = Some(value.into());
219 self
220 }
221 pub fn status(mut self, value: WithdrawStatus) -> Self {
222 self.status = Some(value);
223 self
224 }
225 pub fn withdraw_order_id(mut self, value: impl Into<String>) -> Self {
226 self.withdraw_order_id = Some(value.into());
227 self
228 }
229 pub fn start_time(mut self, value: Timestamp) -> Self {
230 self.start_time = Some(value);
231 self
232 }
233 pub fn end_time(mut self, value: Timestamp) -> Self {
234 self.end_time = Some(value);
235 self
236 }
237 pub fn limit(mut self, value: u32) -> Self {
238 self.limit = Some(value);
239 self
240 }
241 pub fn offset(mut self, value: u32) -> Self {
242 self.offset = Some(value);
243 self
244 }
245 pub fn recv_window(mut self, value: i64) -> Self {
246 self.recv_window = Some(value);
247 self
248 }
249}
250
251#[derive(Debug, Deserialize, PartialEq)]
252#[serde(rename_all = "camelCase")]
253pub struct Withdraw {
254 pub id: String,
255 pub amount: Decimal,
256 pub transaction_fee: Decimal,
257 pub coin: String,
258 pub status: WithdrawStatus,
259 pub address: String,
260 pub tx_id: String,
261 pub apply_time: String,
262 pub network: String,
263 pub transfer_type: u8,
264 pub withdraw_order_id: Option<String>,
265 pub info: Option<String>,
266 pub confirm_no: Option<u32>,
267 pub wallet_type: u8,
268 pub tx_key: Option<String>,
269 pub complete_time: Option<String>,
270}
271
272#[derive(Debug, Serialize, PartialEq, Default)]
275#[serde(rename_all = "camelCase")]
276pub struct GetAccountStatusParams {
277 recv_window: Option<i64>,
278}
279
280impl GetAccountStatusParams {
281 pub fn new() -> Self {
282 Self::default()
283 }
284
285 pub fn recv_window(mut self, value: i64) -> Self {
286 self.recv_window = Some(value);
287 self
288 }
289}
290
291#[derive(Debug, Deserialize, PartialEq)]
292pub struct AccountStatus {
293 pub data: String,
295}
296
297#[derive(Debug, Serialize, PartialEq, Default)]
300#[serde(rename_all = "camelCase")]
301pub struct GetTradeFeeParams {
302 symbol: Option<String>,
303 recv_window: Option<i64>,
304}
305
306impl GetTradeFeeParams {
307 pub fn new() -> Self {
308 Self::default()
309 }
310
311 pub fn symbol(mut self, value: impl Into<String>) -> Self {
312 self.symbol = Some(value.into());
313 self
314 }
315
316 pub fn recv_window(mut self, value: i64) -> Self {
317 self.recv_window = Some(value);
318 self
319 }
320}
321
322#[derive(Debug, Deserialize, PartialEq)]
323#[serde(rename_all = "camelCase")]
324pub struct TradeFee {
325 pub symbol: String,
326 pub maker_commission: Decimal,
327 pub taker_commission: Decimal,
328}