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
use serde::{Deserialize, Serialize};

#[derive(Default, Clone, Debug, Serialize)]
pub struct GetQuery {
    pub days: u32,
}

pub type GetRequest = crate::model::Request<GetQuery>;

impl GetRequest {
    pub fn new(username: &str, days: Option<u32>) -> Self {
        let path = format!("/api/storm/dashboard/{}", username);
        Self {
            path,
            query: days.map(|x| GetQuery { days: x }),
            ..Default::default()
        }
    }
}

pub type Dashboard = StormDashboardJson;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct StormDashboardJson {
    high: High,
    days: Vec<Day>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct High {
    #[serde(rename = "allTime")]
    all_time: i64,
    day: i64,
    month: i64,
    week: i64,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Day {
    #[serde(rename = "_id")]
    id: String,
    combo: i64,
    errors: i64,
    highest: i64,
    moves: i64,
    runs: i64,
    score: i64,
    time: i64,
}