1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use rust_decimal::Decimal;
use std::collections::HashMap;
pub type SimplePrice = HashMap<String, Decimal>;
pub type SimplePrices = HashMap<String, SimplePrice>;
#[derive(Default, Setters)]
pub struct SimplePriceReq {
#[setters(skip)]
pub ids: String,
#[setters(skip)]
pub vs_currencies: String,
#[setters(bool)]
pub include_market_cap: bool,
#[setters(bool)]
pub include_24hr_vol: bool,
#[setters(bool)]
pub include_24hr_change: bool,
#[setters(bool)]
pub include_last_updated_at: bool,
}
impl SimplePriceReq {
pub fn new(ids: String, vs_currencies: String) -> Self {
Self {
ids,
vs_currencies,
..Default::default()
}
}
pub fn query(&self) -> String {
fomat!(
"ids=" (self.ids)
"&vs_currencies=" (self.vs_currencies)
if (self.include_market_cap) {
"&include_market_cap=true"
}
if (self.include_24hr_vol) {
"&include_24hr_vol=true"
}
if (self.include_24hr_change) {
"&include_24hr_change=true"
}
if (self.include_last_updated_at) {
"&include_last_updated_at=true"
}
)
}
}