mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-26 07:38:31 +02:00
Add 'vote' and 'unvote'
This adds support for voting on issues via CmdVote() and CmdUnvote() Voting on issues is always done as the logged in user, it appears you can't case a vote for another user: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-addVote This required adding a cli.delete() handler, naturally with no content (as per RFC2616) This is ripe for DRY-ing out, but I will leave that for a future PR. Worth noting is that you cannot vote for your own issues, this results in: 2016-01-13T21:35:41.315Z ERROR [cli.go:184] response status: 404 Not Found 2016-01-13T21:35:41.315Z ERROR [commands.go:439] Unexpected Response From POST: {snip} {"errorMessages":["You cannot vote for an issue you have reported."],"errors":{}}
This commit is contained in:
@@ -106,6 +106,24 @@ func (c *Cli) put(uri string, content string) (*http.Response, error) {
|
||||
return c.makeRequestWithContent("PUT", uri, content)
|
||||
}
|
||||
|
||||
func (c *Cli) delete(uri string) (*http.Response, error) {
|
||||
method := "DELETE"
|
||||
req, _ := http.NewRequest(method, uri, nil)
|
||||
log.Info("%s %s", req.Method, req.URL.String())
|
||||
if resp, err := c.makeRequest(req); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
if resp.StatusCode == 401 {
|
||||
if err := c.CmdLogin(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, _ = http.NewRequest(method, uri, nil)
|
||||
return c.makeRequest(req)
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cli) makeRequestWithContent(method string, uri string, content string) (*http.Response, error) {
|
||||
buffer := bytes.NewBufferString(content)
|
||||
req, _ := http.NewRequest(method, uri, buffer)
|
||||
|
||||
Reference in New Issue
Block a user