hypixel-sdk 0.1.0

Async client for the Hypixel Public API with typed models and SkyBlock helpers
Documentation
use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use serde_json::Value;

use crate::models::common::JsonObject;

/// A SkyBlock profile, as returned by `skyblock/profile` and `skyblock/profiles`.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct SkyBlockProfile {
    pub profile_id: String,
    #[serde(default)]
    pub cute_name: Option<String>,
    #[serde(default)]
    pub selected: bool,
    #[serde(default)]
    pub game_mode: Option<String>,
    #[serde(default)]
    pub members: HashMap<String, SkyBlockMember>,
    #[serde(default)]
    pub banking: Option<Banking>,
    #[serde(default)]
    pub community_upgrades: Option<Value>,
    #[serde(flatten)]
    pub extra: JsonObject,
}

/// Co-op banking information for a [`SkyBlockProfile`].
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Banking {
    #[serde(default)]
    pub balance: f64,
    #[serde(default)]
    pub transactions: Vec<Value>,
    #[serde(flatten)]
    pub extra: JsonObject,
}

/// A single member's data within a [`SkyBlockProfile`].
///
/// The member object is the deepest and most volatile part of the API. The
/// well-known top-level sections are exposed as raw JSON values (so callers can
/// navigate them without the SDK breaking on Hypixel's frequent additions), and
/// any further sections are preserved in [`extra`](Self::extra). Helpers in the
/// [`util`](crate::util) module operate on these sections, e.g. decoding the
/// base64+gzip NBT inventory blobs.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct SkyBlockMember {
    #[serde(default)]
    pub player_id: Option<String>,
    #[serde(default)]
    pub player_data: Option<Value>,
    #[serde(default)]
    pub profile: Option<Value>,
    #[serde(default)]
    pub leveling: Option<Value>,
    #[serde(default)]
    pub currencies: Option<Value>,
    #[serde(default)]
    pub inventory: Option<Value>,
    #[serde(default)]
    pub pets_data: Option<Value>,
    #[serde(default)]
    pub dungeons: Option<Value>,
    #[serde(default)]
    pub slayer: Option<Value>,
    #[serde(default)]
    pub mining_core: Option<Value>,
    #[serde(default)]
    pub jacobs_contest: Option<Value>,
    #[serde(flatten)]
    pub extra: JsonObject,
}

#[derive(Debug, Clone, Deserialize)]
pub(crate) struct ProfileResponse {
    pub profile: Option<SkyBlockProfile>,
}

#[derive(Debug, Clone, Deserialize)]
pub(crate) struct ProfilesResponse {
    #[serde(default)]
    pub profiles: Option<Vec<SkyBlockProfile>>,
}