gitea_sdk/api/issues/comments/mod.rs
1pub mod create;
2pub mod delete;
3pub mod edit;
4pub mod get;
5pub mod list;
6
7pub struct Comments {
8 pub(crate) owner: String,
9 pub(crate) repo: String,
10}
11
12impl Comments {
13 /// Create a comment on an issue.
14 ///
15 /// # Example
16 /// ```
17 /// # use gitea_sdk::{Client, Auth};
18 /// # async fn create_comment() {
19 /// let client = Client::new(
20 /// "https://gitea.example.com",
21 /// Auth::Token("your-token")
22 /// );
23 /// let comment = client
24 /// .issues("owner", "repo")
25 /// .comments()
26 /// .create(1, "This is a comment")
27 /// .send(&client)
28 /// .await
29 /// .unwrap();
30 /// # }
31 /// ```
32 pub fn create(&self, issue: i64, body: impl ToString) -> create::CreateCommentBuilder {
33 create::CreateCommentBuilder::new(&self.owner, &self.repo, issue, body)
34 }
35 /// List an issue's comments.
36 ///
37 /// # Example
38 /// ```
39 /// # use gitea_sdk::{Client, Auth};
40 /// # async fn list_comments() {
41 /// let client = Client::new(
42 /// "https://gitea.example.com",
43 /// Auth::Token("your-token")
44 /// );
45 /// let comments = client
46 /// .issues("owner", "repo")
47 /// .comments()
48 /// .list(1)
49 /// .send(&client)
50 /// .await
51 /// .unwrap();
52 /// # }
53 /// ```
54 pub fn list(&self, issue: i64) -> list::ListCommentsBuilder {
55 list::ListCommentsBuilder::new(&self.owner, &self.repo, issue)
56 }
57 /// List all comments in a repository.
58 /// This will return a list of all comments in the repository.
59 ///
60 /// # Example
61 /// ```
62 /// # use gitea_sdk::{Client, Auth};
63 /// # async fn list_all_comments() {
64 /// let client = Client::new(
65 /// "https://gitea.example.com",
66 /// Auth::Token("your-token")
67 /// );
68 /// let comments = client
69 /// .issues("owner", "repo")
70 /// .comments()
71 /// .list_all()
72 /// .send(&client)
73 /// .await
74 /// .unwrap();
75 /// # }
76 /// ```
77 pub fn list_all(&self) -> list::ListAllCommentsBuilder {
78 list::ListAllCommentsBuilder::new(&self.owner, &self.repo)
79 }
80
81 /// Edit a comment on an issue.
82 ///
83 /// # Example
84 /// ```
85 /// # use gitea_sdk::{Client, Auth};
86 /// # async fn edit_comment() {
87 /// let client = Client::new(
88 /// "https://gitea.example.com",
89 /// Auth::Token("your-token")
90 /// );
91 /// let comment = client
92 /// .issues("owner", "repo")
93 /// .comments()
94 /// .edit(1, "This is an edited comment")
95 /// .send(&client)
96 /// .await
97 /// .unwrap();
98 /// # }
99 /// ```
100 pub fn edit(&self, comment: i64, body: impl ToString) -> edit::EditCommentBuilder {
101 edit::EditCommentBuilder::new(&self.owner, &self.repo, comment, body)
102 }
103
104 /// Delete a comment on an issue.
105 ///
106 /// # Example
107 /// ```
108 /// # use gitea_sdk::{Client, Auth};
109 /// # async fn delete_comment() {
110 /// let client = Client::new(
111 /// "https://gitea.example.com",
112 /// Auth::Token("your-token")
113 /// );
114 /// client
115 /// .issues("owner", "repo")
116 /// .comments()
117 /// .delete(1)
118 /// .send(&client)
119 /// .await
120 /// .unwrap();
121 /// # }
122 /// ```
123 pub fn delete(&self, comment: i64) -> delete::DeleteCommentBuilder {
124 delete::DeleteCommentBuilder::new(&self.owner, &self.repo, comment)
125 }
126}