#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Notifications {
pub trades: u32,
pub game_turns: u32,
pub moderator_messages: u32,
pub comments: u32,
pub items: u32,
pub invites: u32,
pub gifts: u32,
pub chat: u32,
pub help_request_replies: u32,
pub account_alerts: u32,
}
#[derive(Debug, Clone, Default, serde::Deserialize)]
#[serde(default)]
pub struct RawNotificationCounts {
#[serde(rename = "1")]
pub trades: u64,
#[serde(rename = "2")]
pub game_turns: u64,
#[serde(rename = "3")]
pub moderator_messages: u64,
#[serde(rename = "4")]
pub comments: u64,
#[serde(rename = "5")]
pub items: u64,
#[serde(rename = "6")]
pub invites: u64,
#[serde(rename = "8")]
pub gifts: u64,
#[serde(rename = "9")]
pub chat: u64,
#[serde(rename = "10")]
pub help_request_replies: u64,
#[serde(rename = "11")]
pub account_alerts: u64,
}
impl From<RawNotificationCounts> for Notifications {
fn from(raw: RawNotificationCounts) -> Self {
let narrow = |v: u64| u32::try_from(v).unwrap_or(u32::MAX);
Self {
trades: narrow(raw.trades),
game_turns: narrow(raw.game_turns),
moderator_messages: narrow(raw.moderator_messages),
comments: narrow(raw.comments),
items: narrow(raw.items),
invites: narrow(raw.invites),
gifts: narrow(raw.gifts),
chat: narrow(raw.chat),
help_request_replies: narrow(raw.help_request_replies),
account_alerts: narrow(raw.account_alerts),
}
}
}
#[derive(Debug, Clone, Default, serde::Deserialize)]
#[serde(default)]
pub struct NotificationCountsEnvelope {
pub notifications: RawNotificationCounts,
}