Skip to main content

cloudreve_sdk_api/api/
site.rs

1use crate::client::{Client, RequestOptions};
2use crate::error::ApiResult;
3use crate::models::site::*;
4use async_trait::async_trait;
5
6/// Site configuration API methods
7#[async_trait]
8pub trait SiteApi {
9    /// Get site configuration
10    async fn get_site_config(&self, section: &str) -> ApiResult<SiteConfig>;
11    
12    /// Get captcha
13    async fn get_captcha(&self) -> ApiResult<CaptchaResponse>;
14    
15    /// Create abuse report
16    async fn create_abuse_report(&self, request: &CreateAbuseReportService) -> ApiResult<()>;
17}
18
19#[async_trait]
20impl SiteApi for Client {
21    async fn get_site_config(&self, section: &str) -> ApiResult<SiteConfig> {
22        self.get(
23            &format!("/site/config/{}", section),
24            RequestOptions::new().no_credential(),
25        ).await
26    }
27    
28    async fn get_captcha(&self) -> ApiResult<CaptchaResponse> {
29        self.get("/site/captcha", RequestOptions::new().no_credential()).await
30    }
31    
32    async fn create_abuse_report(&self, request: &CreateAbuseReportService) -> ApiResult<()> {
33        self.post(
34            "/site/abuse",
35            request,
36            RequestOptions::new().no_credential(),
37        ).await
38    }
39}
40