chesscom_openapi/models/
profile.rs

1/*
2 * Chess
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12
13
14#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
15pub struct Profile {
16    #[serde(rename = "@id")]
17    pub id: String,
18    #[serde(rename = "url")]
19    pub url: String,
20    #[serde(rename = "username")]
21    pub username: String,
22    #[serde(rename = "player_id")]
23    pub player_id: i32,
24    #[serde(rename = "title", skip_serializing_if = "Option::is_none")]
25    pub title: Option<crate::models::Title>,
26    #[serde(rename = "status")]
27    pub status: Status,
28    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
29    pub name: Option<String>,
30    #[serde(rename = "avatar", skip_serializing_if = "Option::is_none")]
31    pub avatar: Option<String>,
32    #[serde(rename = "location", skip_serializing_if = "Option::is_none")]
33    pub location: Option<String>,
34    #[serde(rename = "country")]
35    pub country: String,
36    #[serde(rename = "joined")]
37    #[serde(with = "chrono::serde::ts_seconds")]
38	pub joined: chrono::DateTime<chrono::Utc>,
39    #[serde(rename = "last_online")]
40    #[serde(with = "chrono::serde::ts_seconds")]
41	pub last_online: chrono::DateTime<chrono::Utc>,
42    #[serde(rename = "followers")]
43    pub followers: i32,
44    #[serde(rename = "is_streamer")]
45    pub is_streamer: bool,
46    #[serde(rename = "twitch_url", skip_serializing_if = "Option::is_none")]
47    pub twitch_url: Option<String>,
48    #[serde(rename = "fide", skip_serializing_if = "Option::is_none")]
49    pub fide: Option<i32>,
50}
51
52impl Profile {
53    pub fn new(id: String, url: String, username: String, player_id: i32, status: Status, country: String, joined: chrono::DateTime<chrono::Utc>, last_online: chrono::DateTime<chrono::Utc>, followers: i32, is_streamer: bool) -> Profile {
54        Profile {
55            id,
56            url,
57            username,
58            player_id,
59            title: None,
60            status,
61            name: None,
62            avatar: None,
63            location: None,
64            country,
65            joined,
66            last_online,
67            followers,
68            is_streamer,
69            twitch_url: None,
70            fide: None,
71        }
72    }
73}
74
75/// 
76#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
77pub enum Status {
78    #[serde(rename = "closed")]
79    Closed,
80    #[serde(rename = "closed:fair_play_violations")]
81    ClosedfairPlayViolations,
82    #[serde(rename = "basic")]
83    Basic,
84    #[serde(rename = "premium")]
85    Premium,
86    #[serde(rename = "mod")]
87    _Mod,
88    #[serde(rename = "staff")]
89    Staff,
90}
91
92impl std::fmt::Display for Status {
93    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
94        match self {
95            Status::Closed => write!(f, "closed"),
96            Status::ClosedfairPlayViolations => write!(f, "closed:fair_play_violations"),
97            Status::Basic => write!(f, "basic"),
98            Status::Premium => write!(f, "premium"),
99            Status::_Mod => write!(f, "mod"),
100            Status::Staff => write!(f, "staff"),
101
102        }
103    }
104}
105
106