Skip to main content

ncm_api_rs/api/
banner.rs

1use super::Query;
2use crate::error::Result;
3/// 首页 Banner
4/// 对应 Node.js module/banner.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 首页 Banner
10    /// 对应 /banner
11    pub async fn banner(&self, query: &Query) -> Result<ApiResponse> {
12        let type_val = query.get_or("type", "0");
13        let client_type = match type_val.as_str() {
14            "0" => "pc",
15            "1" => "android",
16            "2" => "iphone",
17            "3" => "ipad",
18            _ => "pc",
19        };
20        let data = json!({
21            "clientType": client_type
22        });
23        self.request(
24            "/api/v2/banner/get",
25            data,
26            query.to_option(CryptoType::default()),
27        )
28        .await
29    }
30}