2018-06-25 17:48:53 +02:00
|
|
|
package jira
|
|
|
|
|
2020-05-03 09:38:32 -04:00
|
|
|
import "context"
|
|
|
|
|
2020-05-14 17:18:31 +02:00
|
|
|
// ResolutionService handles resolutions for the Jira instance / API.
|
2018-06-25 17:48:53 +02:00
|
|
|
//
|
2020-05-14 17:18:31 +02:00
|
|
|
// Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-Resolution
|
2018-06-25 17:48:53 +02:00
|
|
|
type ResolutionService struct {
|
|
|
|
client *Client
|
|
|
|
}
|
|
|
|
|
2020-05-14 17:18:31 +02:00
|
|
|
// Resolution represents a resolution of a Jira issue.
|
2018-06-25 17:48:53 +02:00
|
|
|
// Typical types are "Fixed", "Suspended", "Won't Fix", ...
|
|
|
|
type Resolution struct {
|
|
|
|
Self string `json:"self" structs:"self"`
|
|
|
|
ID string `json:"id" structs:"id"`
|
|
|
|
Description string `json:"description" structs:"description"`
|
|
|
|
Name string `json:"name" structs:"name"`
|
|
|
|
}
|
|
|
|
|
2020-05-14 17:18:31 +02:00
|
|
|
// GetListWithContext gets all resolutions from Jira
|
2018-06-25 17:48:53 +02:00
|
|
|
//
|
2020-05-14 17:18:31 +02:00
|
|
|
// Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-resolution-get
|
2020-05-03 09:38:32 -04:00
|
|
|
func (s *ResolutionService) GetListWithContext(ctx context.Context) ([]Resolution, *Response, error) {
|
2018-06-25 17:48:53 +02:00
|
|
|
apiEndpoint := "rest/api/2/resolution"
|
2020-05-03 09:38:32 -04:00
|
|
|
req, err := s.client.NewRequestWithContext(ctx, "GET", apiEndpoint, nil)
|
2018-06-25 17:48:53 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resolutionList := []Resolution{}
|
|
|
|
resp, err := s.client.Do(req, &resolutionList)
|
|
|
|
if err != nil {
|
|
|
|
return nil, resp, NewJiraError(resp, err)
|
|
|
|
}
|
|
|
|
return resolutionList, resp, nil
|
|
|
|
}
|
2020-05-03 09:38:32 -04:00
|
|
|
|
|
|
|
// GetList wraps GetListWithContext using the background context.
|
|
|
|
func (s *ResolutionService) GetList() ([]Resolution, *Response, error) {
|
|
|
|
return s.GetListWithContext(context.Background())
|
|
|
|
}
|