gateio_rs/api/spot/
get_orders.rs1use crate::http::{Credentials, Method, request::Request};
2
3pub struct GetOrders {
5 pub currency_pair: Option<String>,
7 pub status: Option<String>,
9 pub page: Option<i32>,
11 pub limit: Option<i32>,
13 pub account: Option<String>,
15 pub from: Option<i64>,
17 pub to: Option<i64>,
19 pub side: Option<String>,
21 pub credentials: Option<Credentials>,
23}
24
25impl GetOrders {
26 pub fn new() -> Self {
28 Self {
29 currency_pair: None,
30 status: None,
31 page: None,
32 limit: None,
33 account: None,
34 from: None,
35 to: None,
36 side: None,
37 credentials: None,
38 }
39 }
40
41 pub fn currency_pair(mut self, currency_pair: &str) -> Self {
43 self.currency_pair = Some(currency_pair.into());
44 self
45 }
46
47 pub fn status(mut self, status: &str) -> Self {
49 self.status = Some(status.into());
50 self
51 }
52
53 pub fn page(mut self, page: i32) -> Self {
55 self.page = Some(page);
56 self
57 }
58
59 pub fn limit(mut self, limit: i32) -> Self {
61 self.limit = Some(limit);
62 self
63 }
64
65 pub fn account(mut self, account: &str) -> Self {
67 self.account = Some(account.into());
68 self
69 }
70
71 pub fn from(mut self, from: i64) -> Self {
73 self.from = Some(from);
74 self
75 }
76
77 pub fn to(mut self, to: i64) -> Self {
79 self.to = Some(to);
80 self
81 }
82
83 pub fn side(mut self, side: &str) -> Self {
85 self.side = Some(side.into());
86 self
87 }
88
89 pub fn credentials(mut self, creds: Credentials) -> Self {
91 self.credentials = Some(creds);
92 self
93 }
94}
95
96impl From<GetOrders> for Request {
97 fn from(request: GetOrders) -> Request {
98 let mut params = Vec::new();
99
100 if let Some(currency_pair) = request.currency_pair {
101 params.push(("currency_pair".into(), currency_pair));
102 }
103
104 if let Some(status) = request.status {
105 params.push(("status".into(), status));
106 }
107
108 if let Some(page) = request.page {
109 params.push(("page".into(), page.to_string()));
110 }
111
112 if let Some(limit) = request.limit {
113 params.push(("limit".into(), limit.to_string()));
114 }
115
116 if let Some(account) = request.account {
117 params.push(("account".into(), account));
118 }
119
120 if let Some(from) = request.from {
121 params.push(("from".into(), from.to_string()));
122 }
123
124 if let Some(to) = request.to {
125 params.push(("to".into(), to.to_string()));
126 }
127
128 if let Some(side) = request.side {
129 params.push(("side".into(), side));
130 }
131
132 Request {
133 method: Method::Get,
134 path: "/api/v4/spot/orders".into(),
135 params,
136 payload: "".to_string(),
137 x_gate_exp_time: None,
138 credentials: request.credentials,
139 sign: true,
140 }
141 }
142}