chesscom-openapi 0.1.1

OpenAPI-generated API client bindings for Chess.com
Documentation
/*
 * 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"),

        }
    }
}