earthmc 2.0.5

Async client for interacting with the EarthMC API
Documentation
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::{
    endpoints::{nations::NationRankKind, towns::TownRankKind},
    model::{
        named_uuid::{NamedUuid, NamedUuidOpt},
        permission::TownyPermissions,
        timestamp::Timestamp,
    },
};

#[derive(Clone, Deserialize, Serialize, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Player {
    pub name: String,
    pub uuid: Uuid,
    /// Set through `/n set title` in-game.
    pub title: Option<String>,
    /// Set through `/n set surname` in-game.
    pub surname: Option<String>,
    /// Formatted name combining, in this order, title, username and surname.
    pub formatted_name: String,
    /// About section of `/res` set with `/res set about` in-game.
    pub about: Option<String>,
    pub town: NamedUuidOpt,
    pub nation: NamedUuidOpt,
    pub timestamps: PlayerTimestamps,
    pub status: PlayerStatus,
    pub stats: PlayerStats,
    pub perms: TownyPermissions,
    pub ranks: PlayerRanks,
    pub friends: Vec<NamedUuid>,
}

#[derive(Clone, Deserialize, Serialize, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
pub struct PlayerTimestamps {
    /// Server join time.
    #[cfg_attr(
        feature = "chrono",
        serde(with = "crate::model::timestamp::seconds")
    )]
    pub registered: Timestamp,
    /// Town join time.
    #[cfg_attr(
        feature = "chrono",
        serde(with = "crate::model::timestamp::optional_seconds")
    )]
    pub joined_town_at: Option<Timestamp>,
    /// Last online time.
    /// Can be [`None`] if the player is an NPC.
    #[cfg_attr(
        feature = "chrono",
        serde(with = "crate::model::timestamp::optional_seconds")
    )]
    pub last_online: Option<Timestamp>,
}

#[derive(Clone, Deserialize, Serialize, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
pub struct PlayerStatus {
    pub is_online: bool,
    /// Towny NPC flag.
    #[serde(rename = "isNPC")]
    pub is_npc: bool,
    pub is_mayor: bool,
    pub is_king: bool,
    pub has_town: bool,
    pub has_nation: bool,
}

#[derive(Clone, Deserialize, Serialize, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
pub struct PlayerStats {
    /// Shown on `/res` in-game.
    pub balance: f64,
    pub num_friends: i32,
}

#[derive(Clone, Deserialize, Serialize, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
pub struct PlayerRanks {
    pub town_ranks: Vec<TownRankKind>,
    pub nation_ranks: Vec<NationRankKind>,
}