1pub mod min_api;
2pub mod data_api;
3
4
5use serde::Deserialize;
6
7
8#[derive(Deserialize, Debug)]
12pub struct CCCallsMade {
13 pub second: i32,
14 pub minute: i32,
15 pub hour: i32,
16 pub day: i32,
17 pub month: i32,
18 pub total_calls: i32,
19}
20
21#[derive(Deserialize, Debug)]
22pub struct CCMaxCalls {
23 pub second: i32,
24 pub minute: i32,
25 pub hour: i32,
26 pub day: i32,
27 pub month: i32,
28}
29
30#[derive(Deserialize, Debug)]
31pub struct CCRateLimit {
32 pub calls_made: Option<CCCallsMade>,
33 pub max_calls: Option<CCMaxCalls>,
34}
35
36#[derive(Deserialize, Debug)]
37pub struct CCMinWrapper<T> {
38 #[serde(rename = "Aggregated")]
39 pub aggregated: Option<bool>,
40 #[serde(rename = "TimeFrom")]
41 pub time_from: Option<i64>,
42 #[serde(rename = "TimeTo")]
43 pub time_to: Option<i64>,
44 #[serde(rename = "Data")]
45 pub data: Option<T>,
46}
47
48#[derive(Deserialize, Debug)]
49pub struct CCMinResponse<T> {
50 #[serde(rename = "Response")]
51 pub response: String,
52 #[serde(rename = "Message")]
53 pub message: String,
54 #[serde(rename = "HasWarning")]
55 pub has_warning: bool,
56 #[serde(rename = "Type")]
57 pub type_: i32,
58 #[serde(rename = "Data")]
59 pub data: Option<T>,
60 #[serde(rename = "RateLimit")]
61 pub rate_limit: Option<CCRateLimit>,
62}
63
64
65#[derive(Deserialize, Debug)]
69pub struct CCErrorOtherInfo {
70 pub param: Option<String>,
72 pub values: Option<Vec<String>>,
74 pub instrument_status: Option<String>,
76 pub first: Option<i64>,
78 pub last: Option<i64>,
80}
81
82#[derive(Deserialize, Debug)]
83pub struct CCError {
86 #[serde(rename = "type")]
87 pub type_: i32,
89 pub message: String,
91 pub other_info: Option<CCErrorOtherInfo>,
92}
93
94#[derive(Deserialize, Debug)]
95pub struct CCDataResponse<T> {
96 #[serde(rename = "Data")]
97 pub data: Option<T>,
98 #[serde(rename = "Err")]
99 pub error: Option<CCError>,
103}
104
105
106#[cfg(test)]
107mod tests {
108
109 #[test]
110 fn unit_test_nullable_field() -> () {
111 use serde_json;
112 use crate::schemas;
113 let d: String = String::from("{\"Data\":{}, \"Err\":{\"type\": 23, \"message\": \"hello\", \"other_info\":null}}");
114 let response: schemas::CCDataResponse<String> = serde_json::from_str(&d.to_string().replace("{}", "null")).unwrap();
115 assert_eq!(response.data, None);
116 }
117}