1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-28 08:39:03 +02:00

Merge pull request #177 from namely/master

Adds ability to configure whether updates notify users
This commit is contained in:
rbriski 2018-10-18 13:36:16 -07:00 committed by GitHub
commit bbce4afa54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 27 deletions

View File

@ -29,6 +29,13 @@ type IssueService struct {
client *Client
}
// UpdateQueryOptions specifies the optional parameters to the Edit issue
type UpdateQueryOptions struct {
NotifyUsers bool `url:"notifyUsers,omitempty"`
OverrideScreenSecurity bool `url:"overrideScreenSecurity,omitempty"`
OverrideEditableFlag bool `url:"overrideEditableFlag,omitempty"`
}
// Issue represents a JIRA issue.
type Issue struct {
Expand string `json:"expand,omitempty" structs:"expand,omitempty"`
@ -655,12 +662,17 @@ func (s *IssueService) Create(issue *Issue) (*Issue, *Response, error) {
return responseIssue, resp, nil
}
// Update updates an issue from a JSON representation. The issue is found by key.
// UpdateWithOptions updates an issue from a JSON representation,
// while also specifiying query params. The issue is found by key.
//
// JIRA API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue
func (s *IssueService) Update(issue *Issue) (*Issue, *Response, error) {
func (s *IssueService) UpdateWithOptions(issue *Issue, opts *UpdateQueryOptions) (*Issue, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%v", issue.Key)
req, err := s.client.NewRequest("PUT", apiEndpoint, issue)
url, err := addOptions(apiEndpoint, opts)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("PUT", url, issue)
if err != nil {
return nil, nil, err
}
@ -676,6 +688,13 @@ func (s *IssueService) Update(issue *Issue) (*Issue, *Response, error) {
return &ret, resp, nil
}
// Update updates an issue from a JSON representation. The issue is found by key.
//
// JIRA API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue
func (s *IssueService) Update(issue *Issue) (*Issue, *Response, error) {
return s.UpdateWithOptions(issue, nil)
}
// UpdateIssue updates an issue from a JSON representation. The issue is found by key.
//
// https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue

View File

@ -440,30 +440,6 @@ func TestClient_GetBaseURL_WithURL(t *testing.T) {
}
}
// REMOVED : This actually calls a live URL. It's not a unit test.
// I'm also not really sure what it's testing.
// func TestClient_Do_PagingInfoEmptyByDefault(t *testing.T) {
// c, _ := NewClient(nil, testJIRAInstanceURL)
// req, _ := c.NewRequest("GET", "/", nil)
// t.Errorf("%v\n", req)
// type foo struct {
// A string
// }
// body := new(foo)
// resp, _ := c.Do(req, body)
// if resp.StartAt != 0 {
// t.Errorf("StartAt not equal to 0")
// }
// if resp.MaxResults != 0 {
// t.Errorf("StartAt not equal to 0")
// }
// if resp.Total != 0 {
// t.Errorf("StartAt not equal to 0")
// }
// }
func TestBasicAuthTransport(t *testing.T) {
setup()
defer teardown()