gateio_rs/api/spot/
get_my_trades.rs1use crate::http::{Credentials, Method, request::Request};
2
3pub struct GetMyTrades {
5 pub currency_pair: Option<String>,
7 pub page: Option<i32>,
9 pub limit: Option<i32>,
11 pub from: Option<i64>,
13 pub to: Option<i64>,
15 pub order_id: Option<String>,
17 pub credentials: Option<Credentials>,
19}
20
21impl GetMyTrades {
22 pub fn new() -> Self {
24 Self {
25 currency_pair: None,
26 page: None,
27 limit: None,
28 from: None,
29 to: None,
30 order_id: None,
31 credentials: None,
32 }
33 }
34
35 pub fn currency_pair(mut self, currency_pair: &str) -> Self {
37 self.currency_pair = Some(currency_pair.into());
38 self
39 }
40
41 pub fn page(mut self, page: i32) -> Self {
43 self.page = Some(page);
44 self
45 }
46
47 pub fn limit(mut self, limit: i32) -> Self {
49 self.limit = Some(limit);
50 self
51 }
52
53 pub fn from(mut self, from: i64) -> Self {
55 self.from = Some(from);
56 self
57 }
58
59 pub fn to(mut self, to: i64) -> Self {
61 self.to = Some(to);
62 self
63 }
64
65 pub fn order_id(mut self, order_id: &str) -> Self {
67 self.order_id = Some(order_id.into());
68 self
69 }
70
71 pub fn credentials(mut self, creds: Credentials) -> Self {
73 self.credentials = Some(creds);
74 self
75 }
76}
77
78impl From<GetMyTrades> for Request {
79 fn from(request: GetMyTrades) -> Request {
80 let mut params = Vec::new();
81
82 if let Some(currency_pair) = request.currency_pair {
83 params.push(("currency_pair".into(), currency_pair));
84 }
85
86 if let Some(page) = request.page {
87 params.push(("page".into(), page.to_string()));
88 }
89
90 if let Some(limit) = request.limit {
91 params.push(("limit".into(), limit.to_string()));
92 }
93
94 if let Some(from) = request.from {
95 params.push(("from".into(), from.to_string()));
96 }
97
98 if let Some(to) = request.to {
99 params.push(("to".into(), to.to_string()));
100 }
101
102 if let Some(order_id) = request.order_id {
103 params.push(("order_id".into(), order_id));
104 }
105
106 Request {
107 method: Method::Get,
108 path: "/api/v4/spot/my_trades".into(),
109 params,
110 payload: "".to_string(),
111 x_gate_exp_time: None,
112 credentials: request.credentials,
113 sign: true,
114 }
115 }
116}