gateio_rs/api/spot/
get_orderbook.rs1use crate::http::{Credentials, Method, request::Request};
2
3pub struct GetOrderbook {
5 pub currency_pair: String,
7 pub interval: Option<String>,
9 pub limit: Option<i64>,
11 pub with_id: Option<bool>,
13 pub credentials: Option<Credentials>,
15}
16
17impl GetOrderbook {
18 pub fn new(currency_pair: &str) -> Self {
20 Self {
21 currency_pair: currency_pair.to_owned(),
22 interval: None,
23 limit: None,
24 with_id: None,
25 credentials: None,
26 }
27 }
28
29 pub fn interval(mut self, interval: &str) -> Self {
31 self.interval = Some(interval.into());
32 self
33 }
34
35 pub fn limit(mut self, limit: i64) -> Self {
37 self.limit = Some(limit.into());
38 self
39 }
40
41 pub fn with_id(mut self, with_id: bool) -> Self {
43 self.with_id = Some(with_id);
44 self
45 }
46
47 pub fn credentials(mut self, creds: Credentials) -> Self {
49 self.credentials = Some(creds);
50 self
51 }
52}
53
54impl From<GetOrderbook> for Request {
55 fn from(request: GetOrderbook) -> Request {
56 let mut params = vec![("currency_pair".to_owned(), request.currency_pair)];
57
58 if let Some(interval) = request.interval {
59 params.push(("interval".into(), interval.to_string()));
60 }
61
62 if let Some(limit) = request.limit {
63 params.push(("limit".into(), limit.to_string()));
64 }
65
66 if let Some(with_id) = request.with_id {
67 params.push(("with_id".into(), with_id.to_string()));
68 }
69
70 Request {
71 method: Method::Get,
72 path: "/api/v4/spot/order_book".into(),
73 params,
74 payload: "".to_string(),
75 x_gate_exp_time: None,
76 credentials: request.credentials,
77 sign: false,
78 }
79 }
80}