Skip to main content

pickcat_api_collection/
notification.rs

1//! 通知章节(文档目前只记录了未读汇总接口)。
2//!
3//! 参见 <https://pickcat-docs.xiaole6324.fun/notification.html>。
4
5use crate::dto::notification::NotificationSummaryDTO;
6use crate::{Error, PickcatAccound};
7
8/// 通知接口,来自文档的「通知」章节
9/// (<https://pickcat-docs.xiaole6324.fun/notification.html>)。
10///
11/// 文档只记录了未读汇总接口;通知列表 / 已读接口尚未公开。
12pub trait NotificationBehavior {
13    /// `GET /api/v1/notification-summary` —— 需要会话,首页轮询用。
14    fn get_notification_summary(
15        &self,
16    ) -> impl std::future::Future<Output = Result<NotificationSummaryDTO, Error>> + Send;
17}
18
19impl NotificationBehavior for PickcatAccound {
20    async fn get_notification_summary(&self) -> Result<NotificationSummaryDTO, Error> {
21        Ok(self
22            .client
23            .get(format!("{}/api/v1/notification-summary", self.base_url))
24            .send()
25            .await?
26            .json::<NotificationSummaryDTO>()
27            .await?)
28    }
29}