gitverse-sdk 1.2.0

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 {
    /// Create a pull request
    pub async fn create(
        &self,
        owner: &str,
        repo: &str,
        params: &CreatePullRequestParams,
    ) -> Result<PullRequest, Error> {
        let path = format!("/repos/{}/{}/pulls", owner, repo);
        let resp = self.send_post(&path, Some(params)).await?;
        decode_response(resp).await
    }

    /// List pull request commits
    pub async fn list_commits_pull_requests(
        &self,
        owner: &str,
        repo: &str,
        pull_number: f64,
        opts: Option<&QueryOptions>,
    ) -> Result<Vec<Commit>, Error> {
        let path = format!("/repos/{}/{}/pulls/{}/commits", owner, repo, pull_number);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// List pull request files
    pub async fn list_files(
        &self,
        owner: &str,
        repo: &str,
        pull_number: f64,
        opts: Option<&QueryOptions>,
    ) -> Result<Vec<CommitFiles>, Error> {
        let path = format!("/repos/{}/{}/pulls/{}/files", owner, repo, pull_number);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Checks if a pull request has been merged into the base branch.
    pub async fn is_merged(&self, owner: &str, repo: &str, pull_number: f64) -> Result<(), Error> {
        let path = format!("/repos/{}/{}/pulls/{}/merge", owner, repo, pull_number);
        let resp = self.send_get(&path, None).await?;
        handle_empty_response(resp).await
    }

    /// Update a pull request branch
    pub async fn update_branch(
        &self,
        owner: &str,
        repo: &str,
        pull_number: f64,
        params: &UpdateBranchParams,
    ) -> Result<UpdateBranchResponse, Error> {
        let path = format!(
            "/repos/{}/{}/pulls/{}/update-branch",
            owner, repo, pull_number
        );
        let resp = self.send_put(&path, Some(params)).await?;
        decode_response(resp).await
    }
}