gateio_rs/api/spot/
get_account_book.rs1use crate::http::{Credentials, Method, request::Request};
2
3pub struct GetAccountBook {
5 pub currency: Option<String>,
7 pub from: Option<i64>,
9 pub to: Option<i64>,
11 pub page: Option<i32>,
13 pub limit: Option<i64>,
15 pub book_type: Option<String>,
17 pub code: Option<String>,
19 pub credentials: Option<Credentials>,
21}
22
23impl GetAccountBook {
24 pub fn new() -> Self {
26 Self {
27 currency: None,
28 from: None,
29 to: None,
30 page: None,
31 limit: None,
32 book_type: None,
33 code: None,
34 credentials: None,
35 }
36 }
37
38 pub fn currency(mut self, currency: &str) -> Self {
40 self.currency = Some(currency.into());
41 self
42 }
43
44 pub fn from(mut self, from: i64) -> Self {
46 self.from = Some(from.into());
47 self
48 }
49
50 pub fn to(mut self, to: i64) -> Self {
52 self.to = Some(to.into());
53 self
54 }
55
56 pub fn page(mut self, page: i32) -> Self {
58 self.page = Some(page.into());
59 self
60 }
61
62 pub fn limit(mut self, limit: i64) -> Self {
64 self.limit = Some(limit.into());
65 self
66 }
67
68 pub fn book_type(mut self, book_type: &str) -> Self {
70 self.book_type = Some(book_type.into());
71 self
72 }
73
74 pub fn code(mut self, code: &str) -> Self {
76 self.code = Some(code.into());
77 self
78 }
79
80 pub fn credentials(mut self, creds: Credentials) -> Self {
82 self.credentials = Some(creds);
83 self
84 }
85}
86
87impl From<GetAccountBook> for Request {
88 fn from(request: GetAccountBook) -> Request {
89 let mut params = Vec::new();
90
91 if let Some(currency) = request.currency {
92 params.push(("currency".into(), currency.to_string()));
93 }
94
95 if let Some(from) = request.from {
96 params.push(("from".into(), from.to_string()));
97 }
98
99 if let Some(to) = request.to {
100 params.push(("to".into(), to.to_string()));
101 }
102
103 if let Some(page) = request.page {
104 params.push(("page".into(), page.to_string()));
105 }
106
107 if let Some(limit) = request.limit {
108 params.push(("limit".into(), limit.to_string()));
109 }
110
111 if let Some(book_type) = request.book_type {
112 params.push(("type".into(), book_type.to_string()));
113 }
114
115 if let Some(code) = request.code {
116 params.push(("code".into(), code.to_string()));
117 }
118
119 Request {
120 method: Method::Get,
121 path: "/api/v4/spot/account_book".into(),
122 params,
123 payload: "".to_string(),
124 x_gate_exp_time: None,
125 credentials: request.credentials,
126 sign: true,
127 }
128 }
129}