hypixel 0.1.0

Rust wrapper for the Hypixel public API.
Documentation
use serde::Deserialize;

/// This struct represents the response from Hypixel games endpoint.
#[derive(Deserialize)]
pub struct GameInfoResponse {
    /// Actual data.
    pub games: Games
}

/// List of games and their associated game information.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub struct Games {
    pub quakecraft: GameData,
    pub skyclash: GameData,
    pub build_battle: GameData,
    pub uhc: GameData,
    pub legacy: GameData,
    pub skyblock: GameData,
    pub housing: GameData,
    pub mcgo: GameData,
    pub wool_games: GameData,
    pub survival_games: GameData,
    pub battleground: GameData,
    pub murder_mystery: GameData,
    pub arcade: GameData,
    pub arena: GameData,
    pub tntgames: GameData,
    pub walls: GameData,
    pub skywars: GameData,
    pub vampirez: GameData,
    pub prototype: GameData,
    pub walls3: GameData,
    pub bedwars: GameData,
    pub paintball: GameData,
    pub super_smash: GameData,
    pub smp: GameData,
    pub replay: GameData,
    pub true_combat: GameData,
    pub pit: GameData,
    pub speed_uhc: GameData,
    pub duels: GameData,
    pub gingerbread: GameData
}

/// Data for the game object from Hypixel games endpoint.
#[derive(Debug, Deserialize)]
pub struct GameData {
    /// Game ID.
    pub id: usize,
    /// Name of the game mode.
    pub name: String,
    /// Database name of game.
    #[serde(rename = "databaseName")]
    pub database_name: String,
    /// Wether it is a legacy gamemode.
    pub legacy: Option<bool>,
    /// Wether it is no longer playable.
    pub retired: Option<bool>
}

/// Represents response from the Hypixel challenges endpoint.
#[derive(Deserialize)]
pub struct ChallengesResponse {
    /// Actual data.
    pub challenges: Challenges
}

/// All game modes and their associated list of challenges.
#[derive(Debug, Deserialize)]
pub struct Challenges {
    pub arcade: Vec<ChallengeData>,
    pub arena: Vec<ChallengeData>,
    pub bedwars: Vec<ChallengeData>,
    pub hungergames: Vec<ChallengeData>,
    pub buildbattle: Vec<ChallengeData>,
    pub truecombat: Vec<ChallengeData>,
    pub duels: Vec<ChallengeData>,
    pub mcgo: Vec<ChallengeData>,
    pub murdermystery: Vec<ChallengeData>,
    pub paintball: Vec<ChallengeData>,
    pub quake: Vec<ChallengeData>,
    pub skyclash: Vec<ChallengeData>,
    pub skywars: Vec<ChallengeData>,
    pub supersmash: Vec<ChallengeData>,
    pub speeduhc: Vec<ChallengeData>,
    pub gingerbread: Vec<ChallengeData>,
    pub tntgames: Vec<ChallengeData>,
    pub uhc: Vec<ChallengeData>,
    pub vampirez: Vec<ChallengeData>,
    pub walls3: Vec<ChallengeData>,
    pub walls: Vec<ChallengeData>,
    pub battleground: Vec<ChallengeData>, 
    pub woolgames: Vec<ChallengeData>
}

/// Data for the challenge object shared by game modes.
#[derive(Debug, Deserialize)]
pub struct ChallengeData {
    /// ID of the challenge.
    pub id: String,
    /// Name of the challenge.
    pub name: String,
    /// Rewards received after completion.
    pub rewards: Vec<ChallengeReward>
}

/// Reward data for the challenge data object.
#[derive(Debug, Deserialize)]
pub struct ChallengeReward {
    /// Type of the reward.
    #[serde(rename = "type")]
    pub reward_type: String,
    /// Amount given after completion.
    pub amount: usize
}

/// Represents response from the Hypixel quests endpoint.
#[derive(Deserialize)] 
pub struct QuestsResponse {
    /// Actual data.
    pub quests: Quests
}

/// List of game modes and their list of quests.
#[derive(Debug, Deserialize)]
pub struct Quests {
    pub quake: Vec<Quest>,
    pub walls: Vec<Quest>,
    pub paintball: Vec<Quest>,
    pub hungergames: Vec<Quest>,
    pub tntgames: Vec<Quest>,
    pub vampirez: Vec<Quest>,
    pub walls3: Vec<Quest>,
    pub arcade: Vec<Quest>,
    pub arena: Vec<Quest>,
    pub uhc: Vec<Quest>,
    pub mcgo: Vec<Quest>,
    pub battleground: Vec<Quest>,
    pub supersmash: Vec<Quest>,
    pub gingerbread: Vec<Quest>,
    pub skywars: Vec<Quest>,
    pub truecombat: Vec<Quest>,
    pub skyclash: Vec<Quest>,
    pub prototype: Vec<Quest>,
    pub bedwars: Vec<Quest>,
    pub murdermystery: Vec<Quest>,
    pub buildbattle: Vec<Quest>,
    pub duels:  Vec<Quest>,
    pub woolgames: Vec<Quest>
}

/// Quest data for game fields.
#[derive(Debug, Deserialize)] 
pub struct Quest {
    /// ID of the quest.
    pub id: String,
    /// Name of the quest.
    pub name: String,
    /// Rewards received after completion.
    pub rewards: Vec<QuestReward>,
    /// Objectives.
    pub objectives: Vec<QuestObjective>,
    /// Requirements.
    pub requirements: Vec<QuestRequirement>,
    /// Description of the quest.
    pub description: String
}

/// Data for quest rewards.
#[derive(Debug, Deserialize)] 
pub struct QuestReward {
    /// Type of the reward.
    #[serde(rename = "type")]
    pub quest_type: String,
    /// Amount given after completion.
    pub amount: usize
}

/// Objective data for quests object.
#[derive(Debug, Deserialize)]
pub struct QuestObjective {
    /// ID of the objective.
    pub id: String,
    /// Type of the objective.
    #[serde(rename = "type")]
    pub obj_type: String,
    /// Amount needed if any.
    pub integer: Option<usize>
}

/// Requirement data for quests object.
#[derive(Debug, Deserialize)] 
pub struct QuestRequirement {
    /// Type of the requirement.
    #[serde(rename = "type")]
    pub req_type: String
}

/// Represents response from the Hypixel guild achievements endpoint.
#[derive(Deserialize)]
pub struct GuildAchievementsResponse {
    /// Tiered achievements.
    pub tiered: GuildAchievements
}

/// Contains all guild achievements (tiered) from the Hypixel API.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub struct GuildAchievements {
    pub prestige: GuildAchievement,
    pub experience_kings: GuildAchievement,
    pub winners: GuildAchievement,
    pub online_players: GuildAchievement
}

/// Achievements data for the guild object.
#[derive(Debug, Deserialize)]
pub struct GuildAchievement {
    /// Name of the achievement.
    pub name: String,
    /// Description of the achievement.
    pub description: String,
    /// Tiers of the achievement.
    pub tiers: Vec<GuildAchievementTier>
}

/// Tier data for the guild achievement data object.
#[derive(Debug, Deserialize)]
pub struct GuildAchievementTier {
    /// Tier level.
    pub tier: usize,
    /// Amount required to reach tier.
    pub amount: usize
}

/// Represents response from vanity pets Hypixel endpoint.
#[derive(Deserialize)]
pub struct VanityPetsResponse {
    /// Actual data.
    pub types: Vec<VanityPet>
}

/// Vanity pet object from the Hypixel vanity pets endpoint.
#[derive(Debug, Deserialize)]
pub struct VanityPet {
    /// Key of the pet.
    pub key: String,
    /// Name of the pet.
    pub name: String,
    /// Rarity of the pet.
    pub rarity: Option<String>,
    /// A sort of ID.
    pub package: String
}

/// Represents response from vanity companions Hypixel endpoint.
#[derive(Deserialize)]
pub struct CompanionsResponse {
    /// Actual data.
    pub types: Vec<Companion>
} 

/// Companion object from the vanity companions Hypixel endpoint.
#[derive(Debug, Deserialize)]
pub struct Companion {
    /// Key of the companion.
    pub key: String,
    /// Name of the companion.
    pub name: String,
    /// Rarity of the companion. 
    /// For some reason most of them have a null value.
    pub rarity: Option<String>,
    /// Package of the companion.
    pub package: String
}