Skip to content

Commit

Permalink
feat: Add get all priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiht committed Jun 8, 2018
1 parent 98ede9f commit 1c63e25
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
9 changes: 0 additions & 9 deletions issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,6 @@ type Resolution struct {
Name string `json:"name" structs:"name"`
}

// Priority represents a priority of a JIRA issue.
// Typical types are "Normal", "Moderate", "Urgent", ...
type Priority struct {
Self string `json:"self,omitempty" structs:"self,omitempty"`
IconURL string `json:"iconUrl,omitempty" structs:"iconUrl,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitempty"`
ID string `json:"id,omitempty" structs:"id,omitempty"`
}

// Watches represents a type of how many and which user are "observing" a JIRA issue to track the status / updates.
type Watches struct {
Self string `json:"self,omitempty" structs:"self,omitempty"`
Expand Down
37 changes: 37 additions & 0 deletions priority.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package jira

// PriorityService handles priorities for the JIRA instance / API.
//
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-Priority
type PriorityService struct {
client *Client
}

// Priority represents a priority of a JIRA issue.
// Typical types are "Normal", "Moderate", "Urgent", ...
type Priority struct {
Self string `json:"self,omitempty" structs:"self,omitempty"`
IconURL string `json:"iconUrl,omitempty" structs:"iconUrl,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitempty"`
ID string `json:"id,omitempty" structs:"id,omitempty"`
StatusColor string `json:"statusColor,omitempty" structs:"statusColor,omitempty"`
Description string `json:"description,omitempty" structs:"description,omitempty"`
}

// GetList gets all priorities from JIRA
//
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-priority-get
func (s *PriorityService) GetList() ([]Priority, *Response, error) {
apiEndpoint := "rest/api/2/priority"
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
if err != nil {
return nil, nil, err
}

priorityList := []Priority{}
resp, err := s.client.Do(req, priorityList)
if err != nil {
return nil, resp, NewJiraError(resp, err)
}
return priorityList, resp, nil
}

0 comments on commit 1c63e25

Please sign in to comment.