// @generated DO NOT EDIT.
//
// Generated from the CNB OpenAPI specification by `cnb-codegen`.
// Run `cargo run -p cnb-codegen --manifest-path codegen/Cargo.toml \
//      -- --spec codegen/spec/swagger.json --out src` to refresh.

#![allow(clippy::all)]
#![allow(missing_docs)]
#![allow(unused_imports)]
#![allow(unused_mut)]

use reqwest::Method;
use serde::Serialize;

use crate::error::{ApiError, Result};
use crate::http::HttpInner;
use crate::models;

// `Badge` resource client (generated, 3 operations).

/// Resource client.
#[derive(Debug, Clone)]
pub struct BadgeClient {
    inner: HttpInner,
}

impl BadgeClient {
    /// Construct a new resource client. Normally obtained
    /// via [`crate::ApiClient`] rather than directly.
    pub fn new(inner: HttpInner) -> Self {
        Self { inner }
    }

    /// 获取徽章 svg 或 JSON 数据。Get badge svg or JSON data.
    ///
    /// `GET /{repo}/-/badge/git/{sha}/{badge}`
    pub async fn get_badge(
        &self,
        repo: String,
        sha: String,
        badge: String,
        body: &crate::models::GetBadgeReq,
    ) -> Result<crate::models::GetBadgeResult> {
        let path = format!("/{}/-/badge/git/{}/{}", repo, sha, badge);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::GetBadgeResult, _>(Method::GET, url, body)
            .await
    }

    /// 获取徽章列表数据。List badge data
    ///
    /// `GET /{repo}/-/badge/list`
    pub async fn list_badge(
        &self,
        repo: String,
        body: &crate::models::ListBadgeReq,
    ) -> Result<crate::models::ListBadgeResult> {
        let path = format!("/{}/-/badge/list", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::ListBadgeResult, _>(Method::GET, url, body)
            .await
    }

    /// 上传徽章数据。Upload badge data
    ///
    /// `POST /{repo}/-/badge/upload`
    pub async fn upload_badge(
        &self,
        repo: String,
        body: &crate::models::UploadBadgeReq,
    ) -> Result<crate::models::UploadBadgeResult> {
        let path = format!("/{}/-/badge/upload", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::UploadBadgeResult, _>(Method::POST, url, body)
            .await
    }
}
