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 CompletedGame {
    #[serde(rename = "white")]
    pub white: crate::models::PlayerResult,
    #[serde(rename = "black")]
    pub black: crate::models::PlayerResult,
    /// 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,
    /// 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>>,
    /// Timestamp of the game end
    #[serde(rename = "end_time")]
    pub end_time: i32,
    /// Indicates if the game was rated
    #[serde(rename = "rated")]
    pub rated: bool,
    /// 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 ECO opening (if available)
    #[serde(rename = "eco", skip_serializing_if = "Option::is_none")]
    pub eco: Option<String>,
    /// 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 CompletedGame {
    pub fn new(white: crate::models::PlayerResult, black: crate::models::PlayerResult, url: String, fen: String, pgn: String, end_time: i32, rated: bool, time_control: String, time_class: TimeClass, rules: Rules) -> CompletedGame {
        CompletedGame {
            white,
            black,
            url,
            fen,
            pgn,
            start_time: None,
            end_time,
            rated,
            time_control,
            time_class,
            rules,
            eco: None,
            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"),

        }
    }
}