rust-cnb 0.1.2

[DEPRECATED - use `cnb` crate instead] rust-cnb with Generated API client
Documentation
//! RepoContributor API 客户端

use crate::error::{ApiError, Result};
use reqwest::Client;
use serde_json::Value;
use url::Url;

/// RepoContributor API 客户端
pub struct RepoContributorClient {
    base_url: String,
    client: Client,
}

impl RepoContributorClient {
    /// 创建新的 RepoContributor API 客户端
    pub fn new(base_url: String, client: Client) -> Self {
        Self { base_url, client }
    }

    /// 设置认证信息
    pub fn with_auth(self, token: &str) -> Self {
        // 这里可以扩展认证逻辑
        self
    }

    /// 查询仓库贡献者前 100 名的详细趋势数据。Query detailed trend data for top 100 contributors of the repository.
    pub async fn get_repo_contributor_trend(
        &self,
        repo: String,
        limit: Option<i64>,
        exclude_external_users: Option<bool>,
    ) -> Result<Value> {
        let path = format!("/{}/-/contributor/trend", repo);
        let mut url = Url::parse(&format!("{}{}", self.base_url, path))?;
        
        if let Some(value) = limit {
            url.query_pairs_mut().append_pair("limit", &value.to_string());
        }
        if let Some(value) = exclude_external_users {
            url.query_pairs_mut().append_pair("exclude_external_users", &value.to_string());
        }

                let request = self.client.request(
            reqwest::Method::GET,
            url
        );
        



        let response = request.send().await?;
        
        if response.status().is_success() {
            let json: Value = response.json().await?;
            Ok(json)
        } else {
            Err(ApiError::HttpError(response.status().as_u16()))
        }
    }

}