Skip to main content

bpi_rs/login/member_center/
exp.rs

1//! 查询每日投币获得经验数
2//!
3//! [文档](https://socialsisteryi.github.io/bilibili-API-collect/docs/login/member_center.html#查询每日投币获得经验数)
4
5use crate::{ BilibiliRequest, BpiClient, BpiError, BpiResponse };
6
7impl BpiClient {
8    /// 查询每日投币获得经验数
9    ///
10    /// # 文档
11    /// [查看API文档](https://github.com/SocialSisterYi/bilibili-API-collect/tree/master/docs/login)
12    pub async fn member_center_today_coin_exp(&self) -> Result<BpiResponse<u32>, BpiError> {
13        self
14            .get("https://api.bilibili.com/x/web-interface/coin/today/exp")
15            .send_bpi("每日投币经验").await
16    }
17}
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22
23    #[tokio::test]
24    async fn test_get_today_coin_exp() {
25        let bpi = BpiClient::new();
26
27        match bpi.member_center_today_coin_exp().await {
28            Ok(resp) => {
29                if resp.code == 0 {
30                    tracing::info!("今日投币获得经验: {:?}", resp.data.unwrap());
31                } else {
32                    tracing::info!("请求失败: code={}, message={}", resp.code, resp.message);
33                }
34            }
35            Err(err) => {
36                panic!("请求出错: {}", err);
37            }
38        }
39    }
40}