1use crate::{ BilibiliRequest, BpiClient, BpiError, BpiResponse };
6use serde::{ Deserialize, Serialize };
7
8#[derive(Debug, Serialize, Clone, Deserialize)]
12pub struct SeasonTask {
13 #[serde(default)]
15 pub id: String,
16 #[serde(default)]
17 pub title: String,
18 }
20
21#[derive(Debug, Serialize, Clone, Deserialize)]
23pub struct SeasonWelfare {
24 #[serde(default)]
26 pub id: String,
27 #[serde(default)]
28 pub title: String,
29 }
31
32#[derive(Debug, Serialize, Clone, Deserialize)]
34pub struct SeasonText {
35 #[serde(default)]
37 pub title: String,
38 }
40
41#[derive(Debug, Serialize, Clone, Deserialize)]
43pub struct SeasonRank {
44 }
47
48#[derive(Debug, Serialize, Clone, Deserialize)]
50pub struct SeasonInfoData {
51 pub current_time: String,
53 pub start_time: String,
55 pub end_time: String,
57 pub remain_amount: i32,
59 pub season_id: String,
61 pub tasks: Vec<SeasonTask>,
63 pub welfare: Vec<SeasonWelfare>,
65 pub cover: String,
67 pub today_tasks: Vec<SeasonTask>,
69 #[serde(default)]
71 pub text: Option<SeasonText>,
72 pub season_title: String,
74 #[serde(default)]
76 pub rank: Option<SeasonRank>,
77 }
79
80pub type SeasonInfoResponse = BpiResponse<SeasonInfoData>;
81
82impl BpiClient {
85 pub async fn manga_season_info(&self) -> Result<SeasonInfoResponse, BpiError> {
90 self
91 .post("https://manga.bilibili.com/twirp/user.v1.Season/GetSeasonInfo")
92 .send_bpi("获取漫画赛季信息").await
93 }
94}
95
96#[cfg(test)]
97mod tests {
98 use super::*;
99
100 #[tokio::test]
101 async fn test_get_manga_season_info() -> Result<(), Box<BpiError>> {
102 let bpi = BpiClient::new();
103
104 let result = bpi.manga_season_info().await?;
105
106 let data = result.into_data()?;
109
110 tracing::info!("{:#?}", data);
111
112 Ok(())
113 }
114}