gateio_rs/api/spot/
get_insurance_history.rs1use crate::http::{Credentials, Method, request::Request};
2
3pub struct GetInsuranceHistory {
5 pub business: String,
7 pub currency: String,
9 pub from: i64,
11 pub to: i64,
13 pub limit: Option<u32>,
15 pub page: Option<u32>,
17 pub credentials: Option<Credentials>,
19}
20
21impl GetInsuranceHistory {
22 pub fn new(business: &str, currency: &str, from: i64, to: i64) -> Self {
24 Self {
25 business: business.to_owned(),
26 currency: currency.to_owned(),
27 from,
28 to,
29 limit: None,
30 page: None,
31 credentials: None,
32 }
33 }
34
35 pub fn limit(mut self, limit: u32) -> Self {
37 self.limit = Some(limit);
38 self
39 }
40
41 pub fn page(mut self, page: u32) -> Self {
43 self.page = Some(page);
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<GetInsuranceHistory> for Request {
55 fn from(req: GetInsuranceHistory) -> Request {
56 let mut params = Vec::new();
57
58 params.push(("business".to_owned(), req.business));
59 params.push(("currency".to_owned(), req.currency));
60 params.push(("from".to_owned(), req.from.to_string()));
61 params.push(("to".to_owned(), req.to.to_string()));
62 if let Some(limit) = req.limit {
63 params.push(("limit".to_owned(), limit.to_string()));
64 }
65 if let Some(page) = req.page {
66 params.push(("page".to_owned(), page.to_string()));
67 }
68
69 Request {
70 method: Method::Get,
71 path: "/api/v4/spot/insurance_history".into(),
72 params,
73 payload: String::new(),
74 x_gate_exp_time: None,
75 credentials: req.credentials,
76 sign: true,
77 }
78 }
79}