use serde::{Deserialize, Serialize};
#[cfg(test)]
use super::params::VideoRankingListParams;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RankingVideoItem {
#[serde(flatten)]
pub inner: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RankingListData {
pub note: String,
pub list: Vec<RankingVideoItem>,
}
#[cfg(test)]
mod tests {
use super::super::params::VideoRankingType;
use super::*;
use crate::BpiClient;
use tracing::info;
#[ignore = "legacy live API test; requires explicit BPI_LIVE_TEST review"]
#[tokio::test]
async fn test_video_ranking_list() {
let bpi = BpiClient::new().expect("client should build");
let resp = bpi
.video_ranking()
.ranking_list(VideoRankingListParams::new())
.await;
info!("{:?}", resp);
assert!(resp.is_ok());
let data = resp.unwrap();
info!("note: {}", data.note);
info!("排行榜视频数: {}", data.list.len());
if let Some(first_item) = data.list.first() {
info!(
"first item: {}",
serde_json::to_string_pretty(&first_item).unwrap()
);
}
}
#[ignore = "legacy live API test; requires explicit BPI_LIVE_TEST review"]
#[tokio::test]
async fn test_video_ranking_list_with_rid() {
let bpi = BpiClient::new().expect("client should build");
let params = VideoRankingListParams::new()
.with_rid(21)
.expect("rid is valid");
let resp = bpi.video_ranking().ranking_list(params).await;
info!("{:?}", resp);
assert!(resp.is_ok());
let data = resp.unwrap();
info!("note: {}", data.note);
info!("排行榜视频数: {}", data.list.len());
}
#[ignore = "legacy live API test; requires explicit BPI_LIVE_TEST review"]
#[tokio::test]
async fn test_video_ranking_list_with_type() {
let bpi = BpiClient::new().expect("client should build");
let params = VideoRankingListParams::new().with_type(VideoRankingType::Rookie);
let resp = bpi.video_ranking().ranking_list(params).await;
info!("{:?}", resp);
assert!(resp.is_ok());
let data = resp.unwrap();
info!("note: {}", data.note);
info!("排行榜视频数: {}", data.list.len());
}
}