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;
7
8/// A SkyBlock profile, as returned by `skyblock/profile` and `skyblock/profiles`.
9#[derive(Debug, Clone, Deserialize, Serialize)]
10pub struct SkyBlockProfile {
11    pub profile_id: String,
12    #[serde(default)]
13    pub cute_name: Option<String>,
14    #[serde(default)]
15    pub selected: bool,
16    #[serde(default)]
17    pub game_mode: Option<String>,
18    #[serde(default)]
19    pub members: HashMap<String, SkyBlockMember>,
20    #[serde(default)]
21    pub banking: Option<Banking>,
22    #[serde(default)]
23    pub community_upgrades: Option<Value>,
24    #[serde(flatten)]
25    pub extra: JsonObject,
26}
27
28/// Co-op banking information for a [`SkyBlockProfile`].
29#[derive(Debug, Clone, Deserialize, Serialize)]
30pub struct Banking {
31    #[serde(default)]
32    pub balance: f64,
33    #[serde(default)]
34    pub transactions: Vec<Value>,
35    #[serde(flatten)]
36    pub extra: JsonObject,
37}
38
39/// A single member's data within a [`SkyBlockProfile`].
40///
41/// The member object is the deepest and most volatile part of the API. The
42/// well-known top-level sections are exposed as raw JSON values (so callers can
43/// navigate them without the SDK breaking on Hypixel's frequent additions), and
44/// any further sections are preserved in [`extra`](Self::extra). Helpers in the
45/// [`util`](crate::util) module operate on these sections, e.g. decoding the
46/// base64+gzip NBT inventory blobs.
47#[derive(Debug, Clone, Default, Deserialize, Serialize)]
48pub struct SkyBlockMember {
49    #[serde(default)]
50    pub player_id: Option<String>,
51    #[serde(default)]
52    pub player_data: Option<Value>,
53    #[serde(default)]
54    pub profile: Option<Value>,
55    #[serde(default)]
56    pub leveling: Option<Value>,
57    #[serde(default)]
58    pub currencies: Option<Value>,
59    #[serde(default)]
60    pub inventory: Option<Value>,
61    #[serde(default)]
62    pub pets_data: Option<Value>,
63    #[serde(default)]
64    pub dungeons: Option<Value>,
65    #[serde(default)]
66    pub slayer: Option<Value>,
67    #[serde(default)]
68    pub mining_core: Option<Value>,
69    #[serde(default)]
70    pub jacobs_contest: Option<Value>,
71    #[serde(flatten)]
72    pub extra: JsonObject,
73}
74
75#[derive(Debug, Clone, Deserialize)]
76pub(crate) struct ProfileResponse {
77    pub profile: Option<SkyBlockProfile>,
78}
79
80#[derive(Debug, Clone, Deserialize)]
81pub(crate) struct ProfilesResponse {
82    #[serde(default)]
83    pub profiles: Option<Vec<SkyBlockProfile>>,
84}