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
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
 * Chess
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0
 * 
 * Generated by: https://openapi-generator.tech
 */




#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct DailyGame {
    /// URL of the white player's profile
    #[serde(rename = "white")]
    pub white: String,
    /// URL of the black player's profile
    #[serde(rename = "black")]
    pub black: String,
    /// URL of this game
    #[serde(rename = "url")]
    pub url: String,
    /// current FEN
    #[serde(rename = "fen")]
    pub fen: String,
    /// current PGN
    #[serde(rename = "pgn")]
    pub pgn: String,
    #[serde(rename = "turn")]
    pub turn: crate::models::Player,
    /// timestamp of when the next move must be made
    #[serde(rename = "move_by", skip_serializing_if = "Option::is_none")]
    #[serde(with = "chrono::serde::ts_seconds_option")]
	pub move_by: Option<chrono::DateTime<chrono::Utc>>,
    #[serde(rename = "draw_offer", skip_serializing_if = "Option::is_none")]
    pub draw_offer: Option<crate::models::Player>,
    /// timestamp of the last activity on the game
    #[serde(rename = "last_activity")]
    #[serde(with = "chrono::serde::ts_seconds")]
	pub last_activity: chrono::DateTime<chrono::Utc>,
    /// timestamp of the game start (Daily Chess only)
    #[serde(rename = "start_time", skip_serializing_if = "Option::is_none")]
    #[serde(with = "chrono::serde::ts_seconds_option")]
	pub start_time: Option<chrono::DateTime<chrono::Utc>>,
    /// PGN-compliant time control
    #[serde(rename = "time_control")]
    pub time_control: String,
    /// time-per-move grouping, used for ratings
    #[serde(rename = "time_class")]
    pub time_class: TimeClass,
    /// game variant information (e.g., \"chess960\")
    #[serde(rename = "rules")]
    pub rules: Rules,
    /// URL pointing to tournament (if available)
    #[serde(rename = "tournament", skip_serializing_if = "Option::is_none")]
    pub tournament: Option<String>,
    /// URL pointing to team match (if available)
    #[serde(rename = "match", skip_serializing_if = "Option::is_none")]
    pub _match: Option<String>,
}

impl DailyGame {
    pub fn new(white: String, black: String, url: String, fen: String, pgn: String, turn: crate::models::Player, last_activity: chrono::DateTime<chrono::Utc>, time_control: String, time_class: TimeClass, rules: Rules) -> DailyGame {
        DailyGame {
            white,
            black,
            url,
            fen,
            pgn,
            turn,
            move_by: None,
            draw_offer: None,
            last_activity,
            start_time: None,
            time_control,
            time_class,
            rules,
            tournament: None,
            _match: None,
        }
    }
}

/// time-per-move grouping, used for ratings
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum TimeClass {
    #[serde(rename = "daily")]
    Daily,
    #[serde(rename = "rapid")]
    Rapid,
    #[serde(rename = "blitz")]
    Blitz,
    #[serde(rename = "bullet")]
    Bullet,
}

impl std::fmt::Display for TimeClass {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            TimeClass::Daily => write!(f, "daily"),
            TimeClass::Rapid => write!(f, "rapid"),
            TimeClass::Blitz => write!(f, "blitz"),
            TimeClass::Bullet => write!(f, "bullet"),

        }
    }
}

/// game variant information (e.g., \"chess960\")
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Rules {
    #[serde(rename = "chess")]
    Chess,
    #[serde(rename = "chess960")]
    Chess960,
    #[serde(rename = "bughouse")]
    Bughouse,
    #[serde(rename = "kingofthehill")]
    Kingofthehill,
    #[serde(rename = "threecheck")]
    Threecheck,
    #[serde(rename = "crazyhouse")]
    Crazyhouse,
}

impl std::fmt::Display for Rules {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Rules::Chess => write!(f, "chess"),
            Rules::Chess960 => write!(f, "chess960"),
            Rules::Bughouse => write!(f, "bughouse"),
            Rules::Kingofthehill => write!(f, "kingofthehill"),
            Rules::Threecheck => write!(f, "threecheck"),
            Rules::Crazyhouse => write!(f, "crazyhouse"),

        }
    }
}