Skip to main content

gitverse_sdk/
issues.rs

1// Code generated by gitverse-codegen. DO NOT EDIT.
2
3use crate::client::{Client, decode_response, handle_empty_response};
4use crate::errors::Error;
5use crate::types::*;
6
7impl Client {
8    /// List issues and pull requests
9    pub async fn list_issues(
10        &self,
11        owner: &str,
12        repo: &str,
13        opts: Option<&QueryOptions>,
14    ) -> Result<Vec<Issue>, Error> {
15        let path = format!("/repos/{}/{}/issues", owner, repo);
16        let resp = self.send_get(&path, opts).await?;
17        decode_response(resp).await
18    }
19
20    /// Get a specific issue comment
21    pub async fn get_comment(&self, owner: &str, repo: &str, id: f64) -> Result<Comment, Error> {
22        let path = format!("/repos/{}/{}/issues/comments/{}", owner, repo, id);
23        let resp = self.send_get(&path, None).await?;
24        decode_response(resp).await
25    }
26
27    /// Get issue or pull request
28    pub async fn get_issues(&self, owner: &str, repo: &str, index: f64) -> Result<Issue, Error> {
29        let path = format!("/repos/{}/{}/issues/{}", owner, repo, index);
30        let resp = self.send_get(&path, None).await?;
31        decode_response(resp).await
32    }
33
34    /// List issue comments
35    pub async fn list_comments(
36        &self,
37        owner: &str,
38        repo: &str,
39        index: f64,
40        opts: Option<&QueryOptions>,
41    ) -> Result<Vec<Comment>, Error> {
42        let path = format!("/repos/{}/{}/issues/{}/comments", owner, repo, index);
43        let resp = self.send_get(&path, opts).await?;
44        decode_response(resp).await
45    }
46
47    /// Create issue comment
48    pub async fn create_comment(
49        &self,
50        owner: &str,
51        repo: &str,
52        index: f64,
53        params: &CreateIssueCommentParams,
54    ) -> Result<Comment, Error> {
55        let path = format!("/repos/{}/{}/issues/{}/comments", owner, repo, index);
56        let resp = self.send_post(&path, Some(params)).await?;
57        decode_response(resp).await
58    }
59
60    /// Update issue comment
61    pub async fn update_comment(
62        &self,
63        owner: &str,
64        repo: &str,
65        index: f64,
66        comment_id: f64,
67        params: &UpdateIssueCommentParams,
68    ) -> Result<(), Error> {
69        let path = format!(
70            "/repos/{}/{}/issues/{}/comments/{}",
71            owner, repo, index, comment_id
72        );
73        let resp = self.send_patch(&path, Some(params)).await?;
74        handle_empty_response(resp).await
75    }
76
77    /// Delete issue comment
78    pub async fn delete_comment(
79        &self,
80        owner: &str,
81        repo: &str,
82        index: f64,
83        comment_id: f64,
84    ) -> Result<(), Error> {
85        let path = format!(
86            "/repos/{}/{}/issues/{}/comments/{}",
87            owner, repo, index, comment_id
88        );
89        let resp = self.send_delete(&path, Option::<&()>::None).await?;
90        handle_empty_response(resp).await
91    }
92
93    /// Create reaction to issue comment
94    pub async fn create_comment_reaction(
95        &self,
96        owner: &str,
97        repo: &str,
98        index: f64,
99        comment_id: f64,
100        params: &CreateIssueCommentReactionParams,
101    ) -> Result<Reaction, Error> {
102        let path = format!(
103            "/repos/{}/{}/issues/{}/comments/{}/reactions",
104            owner, repo, index, comment_id
105        );
106        let resp = self.send_post(&path, Some(params)).await?;
107        decode_response(resp).await
108    }
109
110    /// Delete reaction from issue comment
111    pub async fn delete_comment_reaction(
112        &self,
113        owner: &str,
114        repo: &str,
115        index: f64,
116        comment_id: f64,
117        reaction_id: f64,
118    ) -> Result<(), Error> {
119        let path = format!(
120            "/repos/{}/{}/issues/{}/comments/{}/reactions/{}",
121            owner, repo, index, comment_id, reaction_id
122        );
123        let resp = self.send_delete(&path, Option::<&()>::None).await?;
124        handle_empty_response(resp).await
125    }
126
127    /// List issue labels
128    pub async fn list_labels(
129        &self,
130        owner: &str,
131        repo: &str,
132        index: f64,
133    ) -> Result<Vec<Label>, Error> {
134        let path = format!("/repos/{}/{}/issues/{}/labels", owner, repo, index);
135        let resp = self.send_get(&path, None).await?;
136        decode_response(resp).await
137    }
138
139    /// List issue comments and timeline events
140    pub async fn list_timeline(
141        &self,
142        owner: &str,
143        repo: &str,
144        index: f64,
145        opts: Option<&QueryOptions>,
146    ) -> Result<Vec<TimelineComment>, Error> {
147        let path = format!("/repos/{}/{}/issues/{}/timeline", owner, repo, index);
148        let resp = self.send_get(&path, opts).await?;
149        decode_response(resp).await
150    }
151}