Merge pull request #7 from go-gitea/fix/issue-comment

Finish Issue-Comments
This commit is contained in:
Kim "BKC" Carlbäcker 2016-11-10 10:24:19 +01:00 committed by GitHub
commit 163100bc1a

View file

@ -13,11 +13,14 @@ import (
// Comment represents a comment in commit and issue page. // Comment represents a comment in commit and issue page.
type Comment struct { type Comment struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Poster *User `json:"user"` HTMLURL string `json:"html_url"`
Body string `json:"body"` PRURL string `json:"pull_request_url"`
Created time.Time `json:"created_at"` IssueURL string `json:"issue_url"`
Updated time.Time `json:"updated_at"` 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. // ListIssueComments list comments on an issue.
@ -26,6 +29,12 @@ func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment,
return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), nil, nil, &comments) return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), nil, nil, &comments)
} }
// ListRepoIssueComments list comments for a given repo.
func (c *Client) ListRepoIssuecomments(owner, repo string) ([]*Comment, error) {
comments := make([]*Comment, 0, 10)
return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments)
}
// CreateIssueCommentOption is option when creating an issue comment. // CreateIssueCommentOption is option when creating an issue comment.
type CreateIssueCommentOption struct { type CreateIssueCommentOption struct {
Body string `json:"body" binding:"Required"` Body string `json:"body" binding:"Required"`
@ -55,3 +64,9 @@ func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, op
comment := new(Comment) 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) return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/:%s/:%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment)
} }
// DeleteIssueComment deletes an issue comment.
func (c *Client) DeleteIssueComment(owner, repo string, index, commentID int64) error {
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), nil, nil)
return err
}