gitverse-sdk 1.2.1

Rust SDK for GitVerse API
Documentation
// Code generated by gitverse-codegen. DO NOT EDIT.

use crate::client::{Client, decode_response, handle_empty_response};
use crate::errors::Error;
use crate::types::*;

impl Client {
    /// List issues and pull requests
    pub async fn list_issues(
        &self,
        owner: &str,
        repo: &str,
        opts: Option<&QueryOptions>,
    ) -> Result<Vec<Issue>, Error> {
        let path = format!("/repos/{}/{}/issues", owner, repo);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Get a specific issue comment
    pub async fn get_comment(&self, owner: &str, repo: &str, id: f64) -> Result<Comment, Error> {
        let path = format!("/repos/{}/{}/issues/comments/{}", owner, repo, id);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// Get issue or pull request
    pub async fn get_issues(&self, owner: &str, repo: &str, index: f64) -> Result<Issue, Error> {
        let path = format!("/repos/{}/{}/issues/{}", owner, repo, index);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// List issue comments
    pub async fn list_comments(
        &self,
        owner: &str,
        repo: &str,
        index: f64,
        opts: Option<&QueryOptions>,
    ) -> Result<Vec<Comment>, Error> {
        let path = format!("/repos/{}/{}/issues/{}/comments", owner, repo, index);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Create issue comment
    pub async fn create_comment(
        &self,
        owner: &str,
        repo: &str,
        index: f64,
        params: &CreateIssueCommentParams,
    ) -> Result<Comment, Error> {
        let path = format!("/repos/{}/{}/issues/{}/comments", owner, repo, index);
        let resp = self.send_post(&path, Some(params)).await?;
        decode_response(resp).await
    }

    /// Update issue comment
    pub async fn update_comment(
        &self,
        owner: &str,
        repo: &str,
        index: f64,
        comment_id: f64,
        params: &UpdateIssueCommentParams,
    ) -> Result<(), Error> {
        let path = format!(
            "/repos/{}/{}/issues/{}/comments/{}",
            owner, repo, index, comment_id
        );
        let resp = self.send_patch(&path, Some(params)).await?;
        handle_empty_response(resp).await
    }

    /// Delete issue comment
    pub async fn delete_comment(
        &self,
        owner: &str,
        repo: &str,
        index: f64,
        comment_id: f64,
    ) -> Result<(), Error> {
        let path = format!(
            "/repos/{}/{}/issues/{}/comments/{}",
            owner, repo, index, comment_id
        );
        let resp = self.send_delete(&path, Option::<&()>::None).await?;
        handle_empty_response(resp).await
    }

    /// Create reaction to issue comment
    pub async fn create_comment_reaction(
        &self,
        owner: &str,
        repo: &str,
        index: f64,
        comment_id: f64,
        params: &CreateIssueCommentReactionParams,
    ) -> Result<Reaction, Error> {
        let path = format!(
            "/repos/{}/{}/issues/{}/comments/{}/reactions",
            owner, repo, index, comment_id
        );
        let resp = self.send_post(&path, Some(params)).await?;
        decode_response(resp).await
    }

    /// Delete reaction from issue comment
    pub async fn delete_comment_reaction(
        &self,
        owner: &str,
        repo: &str,
        index: f64,
        comment_id: f64,
        reaction_id: f64,
    ) -> Result<(), Error> {
        let path = format!(
            "/repos/{}/{}/issues/{}/comments/{}/reactions/{}",
            owner, repo, index, comment_id, reaction_id
        );
        let resp = self.send_delete(&path, Option::<&()>::None).await?;
        handle_empty_response(resp).await
    }

    /// List issue labels
    pub async fn list_labels(
        &self,
        owner: &str,
        repo: &str,
        index: f64,
    ) -> Result<Vec<Label>, Error> {
        let path = format!("/repos/{}/{}/issues/{}/labels", owner, repo, index);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// List issue comments and timeline events
    pub async fn list_timeline(
        &self,
        owner: &str,
        repo: &str,
        index: f64,
        opts: Option<&QueryOptions>,
    ) -> Result<Vec<TimelineComment>, Error> {
        let path = format!("/repos/{}/{}/issues/{}/timeline", owner, repo, index);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }
}