//! Notification services.
use crate::{
client::SteamUser,
endpoint::steam_endpoint,
error::SteamUserError,
types::{Notifications, notifications::NotificationCountsEnvelope},
};
impl SteamUser {
/// Retrieves the current counts for various Steam notifications.
///
/// This includes unread messages, trade offers, new items, and more.
///
/// # Returns
///
/// Returns a [`Notifications`] struct containing the counts for each type
/// of notification.
#[steam_endpoint(GET, host = Community, path = "/actions/GetNotificationCounts", kind = Read)]
pub async fn get_notifications(&self) -> Result<Notifications, SteamUserError> {
// Steam returns `{ "notifications": { "1": n, "2": n, ... } }`.
// Deserialize directly into a typed envelope; missing keys default to 0.
let envelope: NotificationCountsEnvelope = self.get_path("/actions/GetNotificationCounts").send().await?.json().await?;
Ok(envelope.notifications.into())
}
}