Skip to main content

hypixel/models/skyblock/
profile.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6use crate::models::common::JsonObject;
7use crate::models::skyblock::member::{
8    Dungeons, MemberCurrencies, MemberLeveling, MiningCore, PetsData, PlayerData, SlayerData,
9};
10
11/// A SkyBlock profile, as returned by `skyblock/profile` and `skyblock/profiles`.
12#[derive(Debug, Clone, Deserialize, Serialize)]
13pub struct SkyBlockProfile {
14    pub profile_id: String,
15    #[serde(default)]
16    pub cute_name: Option<String>,
17    #[serde(default)]
18    pub selected: bool,
19    #[serde(default)]
20    pub game_mode: Option<String>,
21    #[serde(default)]
22    pub members: HashMap<String, SkyBlockMember>,
23    #[serde(default)]
24    pub banking: Option<Banking>,
25    #[serde(default)]
26    pub community_upgrades: Option<Value>,
27    #[serde(flatten)]
28    pub extra: JsonObject,
29}
30
31/// Co-op banking information for a [`SkyBlockProfile`].
32#[derive(Debug, Clone, Deserialize, Serialize)]
33pub struct Banking {
34    #[serde(default)]
35    pub balance: f64,
36    #[serde(default)]
37    pub transactions: Vec<Value>,
38    #[serde(flatten)]
39    pub extra: JsonObject,
40}
41
42/// A single member's data within a [`SkyBlockProfile`].
43///
44/// The member object is the deepest and most volatile part of the API. The
45/// well-known sections are typed, each with an `extra` catch-all so unknown
46/// fields survive round-trips. `profile`, `inventory`, and `jacobs_contest`
47/// stay raw JSON; the inventory payloads are base64+gzip NBT blobs handled by
48/// the [`util`](crate::util) helpers. Any further sections are preserved in
49/// [`extra`](Self::extra).
50#[derive(Debug, Clone, Default, Deserialize, Serialize)]
51pub struct SkyBlockMember {
52    #[serde(default)]
53    pub player_id: Option<String>,
54    #[serde(default)]
55    pub player_data: Option<PlayerData>,
56    #[serde(default)]
57    pub profile: Option<Value>,
58    #[serde(default)]
59    pub leveling: Option<MemberLeveling>,
60    #[serde(default)]
61    pub currencies: Option<MemberCurrencies>,
62    #[serde(default)]
63    pub inventory: Option<Value>,
64    #[serde(default)]
65    pub pets_data: Option<PetsData>,
66    #[serde(default)]
67    pub dungeons: Option<Dungeons>,
68    #[serde(default)]
69    pub slayer: Option<SlayerData>,
70    #[serde(default)]
71    pub mining_core: Option<MiningCore>,
72    #[serde(default)]
73    pub jacobs_contest: Option<Value>,
74    #[serde(flatten)]
75    pub extra: JsonObject,
76}
77
78#[derive(Debug, Clone, Deserialize)]
79pub(crate) struct ProfileResponse {
80    pub profile: Option<SkyBlockProfile>,
81}
82
83#[derive(Debug, Clone, Deserialize)]
84pub(crate) struct ProfilesResponse {
85    #[serde(default)]
86    pub profiles: Option<Vec<SkyBlockProfile>>,
87}