summaryrefslogtreecommitdiffstats
path: root/vendor/code.gitea.io/go-sdk/gitea/issue_comment.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/code.gitea.io/go-sdk/gitea/issue_comment.go')
-rw-r--r--vendor/code.gitea.io/go-sdk/gitea/issue_comment.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/code.gitea.io/go-sdk/gitea/issue_comment.go b/vendor/code.gitea.io/go-sdk/gitea/issue_comment.go
new file mode 100644
index 0000000000..59f064a8ad
--- /dev/null
+++ b/vendor/code.gitea.io/go-sdk/gitea/issue_comment.go
@@ -0,0 +1,57 @@
+// Copyright 2016 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package gitea
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "time"
+)
+
+// Comment represents a comment in commit and issue page.
+type Comment struct {
+ ID int64 `json:"id"`
+ Poster *User `json:"user"`
+ Body string `json:"body"`
+ Created time.Time `json:"created_at"`
+ Updated time.Time `json:"updated_at"`
+}
+
+// ListIssueComments list comments on an issue.
+func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment, error) {
+ comments := make([]*Comment, 0, 10)
+ return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), nil, nil, &comments)
+}
+
+// CreateIssueCommentOption is option when creating an issue comment.
+type CreateIssueCommentOption struct {
+ Body string `json:"body" binding:"Required"`
+}
+
+// CreateIssueComment create comment on an issue.
+func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateIssueCommentOption) (*Comment, error) {
+ body, err := json.Marshal(&opt)
+ if err != nil {
+ return nil, err
+ }
+ comment := new(Comment)
+ return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/:%s/:%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment)
+}
+
+// EditIssueCommentOption is option when editing an issue comment.
+type EditIssueCommentOption struct {
+ Body string `json:"body" binding:"Required"`
+}
+
+// EditIssueComment edits an issue comment.
+func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, opt EditIssueCommentOption) (*Comment, error) {
+ body, err := json.Marshal(&opt)
+ if err != nil {
+ return nil, err
+ }
+ comment := new(Comment)
+ return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/:%s/:%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment)
+}