tetrio_api/http/parameters/
personal_user_records.rs

1use serde::{Deserialize, Serialize};
2
3use super::value_bound_query::Prisecter;
4
5
6#[derive(Debug, Serialize, Deserialize, Clone)]
7#[serde(rename_all = "lowercase")]
8pub enum GameMode {
9    #[serde(rename = "40l")]
10    Sprint,
11    Blitz,
12    Zenith,
13    ZenithEX,
14    League,
15}
16
17impl ToString for GameMode {
18    fn to_string(&self) -> String {
19        match self {
20            Self::Sprint => { return "40l".to_string(); },
21            Self::Blitz => { return "blitz".to_string(); },
22            Self::Zenith => { return "zenith".to_string(); },
23            Self::ZenithEX => { return "zenithex".to_string(); },
24            Self::League => { return "league ".to_string(); },
25        };
26    }
27}
28
29pub enum PersonalLeaderboard {
30    Top,
31    Recent,
32    Progression
33}
34
35impl ToString for PersonalLeaderboard {
36    fn to_string(&self) -> String {
37        match self {
38            Self::Top => { return "top".to_string(); },
39            Self::Recent => { return "recent".to_string(); },
40            Self::Progression => { return "progression".to_string(); },
41        };
42    }
43}
44
45pub enum PersonalRecordsQuery {
46    After {
47        after: Prisecter,
48        limit: Option<i64>,
49    },
50    Before {
51        before: Prisecter,
52        limit: Option<i64>,
53    },
54    NotBound {
55        limit: Option<i64>,
56    },
57    None,
58}
59
60impl PersonalRecordsQuery {
61    pub fn as_query_params(self) -> Vec<[String; 2]> {
62        let mut result = vec![];
63        match self {
64            PersonalRecordsQuery::After {
65                after,
66                limit,
67                ..
68            } => {
69                result.push(["after".to_string(), after.to_string()]);
70                if let Some(limit) = limit {
71                    result.push(["limit".to_string(), limit.to_string()]);
72                };
73
74
75            }
76            PersonalRecordsQuery::Before {
77                before,
78                limit,
79                ..
80            } => {
81                result.push(["before".to_string(), before.to_string()]);
82                if let Some(limit) = limit {
83                    result.push(["limit".to_string(), limit.to_string()]);
84                };
85
86            }
87            PersonalRecordsQuery::NotBound { limit,  } => {
88                if let Some(limit) = limit {
89                    result.push(["limit".to_string(), limit.to_string()]);
90                };
91
92
93            }
94            PersonalRecordsQuery::None => {},
95        };
96
97        return result;
98    }
99}