|
|
@ -11,7 +11,7 @@ import "fmt" |
|
|
// which issues may be assigned.
|
|
|
// which issues may be assigned.
|
|
|
//
|
|
|
//
|
|
|
// GitHub API docs: http://developer.github.com/v3/issues/assignees/#list-assignees
|
|
|
// GitHub API docs: http://developer.github.com/v3/issues/assignees/#list-assignees
|
|
|
func (s *IssuesService) ListAssignees(owner string, repo string, opt *ListOptions) ([]User, *Response, error) { |
|
|
|
|
|
|
|
|
func (s *IssuesService) ListAssignees(owner, repo string, opt *ListOptions) ([]User, *Response, error) { |
|
|
u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo) |
|
|
u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo) |
|
|
u, err := addOptions(u, opt) |
|
|
u, err := addOptions(u, opt) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
@ -34,7 +34,7 @@ func (s *IssuesService) ListAssignees(owner string, repo string, opt *ListOption |
|
|
// IsAssignee checks if a user is an assignee for the specified repository.
|
|
|
// IsAssignee checks if a user is an assignee for the specified repository.
|
|
|
//
|
|
|
//
|
|
|
// GitHub API docs: http://developer.github.com/v3/issues/assignees/#check-assignee
|
|
|
// GitHub API docs: http://developer.github.com/v3/issues/assignees/#check-assignee
|
|
|
func (s *IssuesService) IsAssignee(owner string, repo string, user string) (bool, *Response, error) { |
|
|
|
|
|
|
|
|
func (s *IssuesService) IsAssignee(owner, repo, user string) (bool, *Response, error) { |
|
|
u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user) |
|
|
u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user) |
|
|
req, err := s.client.NewRequest("GET", u, nil) |
|
|
req, err := s.client.NewRequest("GET", u, nil) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
@ -44,3 +44,45 @@ func (s *IssuesService) IsAssignee(owner string, repo string, user string) (bool |
|
|
assignee, err := parseBoolResponse(err) |
|
|
assignee, err := parseBoolResponse(err) |
|
|
return assignee, resp, err |
|
|
return assignee, resp, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// AddAssignees adds the provided GitHub users as assignees to the issue.
|
|
|
|
|
|
//
|
|
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue
|
|
|
|
|
|
func (s *IssuesService) AddAssignees(owner, repo string, number int, assignees []string) (*Issue, *Response, error) { |
|
|
|
|
|
users := &struct { |
|
|
|
|
|
Assignees []string `json:"assignees,omitempty"` |
|
|
|
|
|
}{Assignees: assignees} |
|
|
|
|
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number) |
|
|
|
|
|
req, err := s.client.NewRequest("POST", u, users) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, nil, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: remove custom Accept header when this API fully launches.
|
|
|
|
|
|
req.Header.Set("Accept", mediaTypeMultipleAssigneesPreview) |
|
|
|
|
|
|
|
|
|
|
|
issue := &Issue{} |
|
|
|
|
|
resp, err := s.client.Do(req, issue) |
|
|
|
|
|
return issue, resp, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RemoveAssignees removes the provided GitHub users as assignees from the issue.
|
|
|
|
|
|
//
|
|
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue
|
|
|
|
|
|
func (s *IssuesService) RemoveAssignees(owner, repo string, number int, assignees []string) (*Issue, *Response, error) { |
|
|
|
|
|
users := &struct { |
|
|
|
|
|
Assignees []string `json:"assignees,omitempty"` |
|
|
|
|
|
}{Assignees: assignees} |
|
|
|
|
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number) |
|
|
|
|
|
req, err := s.client.NewRequest("DELETE", u, users) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, nil, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: remove custom Accept header when this API fully launches.
|
|
|
|
|
|
req.Header.Set("Accept", mediaTypeMultipleAssigneesPreview) |
|
|
|
|
|
|
|
|
|
|
|
issue := &Issue{} |
|
|
|
|
|
resp, err := s.client.Do(req, issue) |
|
|
|
|
|
return issue, resp, err |
|
|
|
|
|
} |