1use serde::{ Deserialize, Serialize };
2
3use crate::{ BilibiliRequest, BpiClient, BpiError, BpiResponse };
4
5#[derive(Debug, Serialize, Clone, Deserialize)]
8pub struct GiftTypeItem {
9 pub gift_id: i64,
11 pub gift_name: String,
13 #[serde(default)]
15 pub price: i64,
16}
17
18impl BpiClient {
19 pub async fn live_gift_types(&self) -> Result<BpiResponse<Vec<GiftTypeItem>>, BpiError> {
24 let resp = self
25 .get("https://api.live.bilibili.com/gift/v1/master/getGiftTypes")
26 .send_bpi("获取所有礼物列表").await?;
27
28 Ok(resp)
29 }
30}
31
32#[cfg(test)]
33mod tests {
34 use super::*;
35
36 #[tokio::test]
37 async fn test_get_gift_types() -> Result<(), Box<BpiError>> {
38 let bpi = BpiClient::new();
39 let resp = bpi.live_gift_types().await?;
40
41 assert_eq!(resp.code, 0);
42 Ok(())
43 }
44}