Skip to main content

azisaba_graph/models/
player.rs

1/*
2 * Azisaba Graph API
3 *
4 * An API for connecting and sharing data across the Azisaba Network.
5 *
6 * The version of the OpenAPI document: 0.0.1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Player : Represents a player profile.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Player {
17    /// The unique identifier of the player.
18    #[serde(rename = "id")]
19    pub id: uuid::Uuid,
20    /// The Discord user ID linked to the player, or `null` if no Discord account is linked or the API key lacks the `players:read-details` scope.
21    #[serde(rename = "discordId", deserialize_with = "Option::deserialize")]
22    pub discord_id: Option<String>,
23    /// The username of the player.
24    #[serde(rename = "username")]
25    pub username: String,
26    /// The online status of the player.
27    #[serde(rename = "status")]
28    pub status: Status,
29    /// The server to which the player is currently connected, or `null` if the player is offline.
30    #[serde(rename = "currentServer", deserialize_with = "Option::deserialize")]
31    pub current_server: Option<String>,
32    /// The player's biography of up to 160 characters, or `null` if it is not set.
33    #[serde(rename = "bio", deserialize_with = "Option::deserialize")]
34    pub bio: Option<String>,
35}
36
37impl Player {
38    /// Represents a player profile.
39    pub fn new(id: uuid::Uuid, discord_id: Option<String>, username: String, status: Status, current_server: Option<String>, bio: Option<String>) -> Player {
40        Player {
41            id,
42            discord_id,
43            username,
44            status,
45            current_server,
46            bio,
47        }
48    }
49}
50/// The online status of the player.
51#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
52pub enum Status {
53    #[serde(rename = "online")]
54    Online,
55    #[serde(rename = "offline")]
56    Offline,
57}
58
59impl Default for Status {
60    fn default() -> Status {
61        Self::Online
62    }
63}
64