From 1c63e25a257ef9e65c27bdde51aa5bf5b8ca6f8a Mon Sep 17 00:00:00 2001 From: Thibaut Rousseau Date: Fri, 8 Jun 2018 17:57:07 +0200 Subject: [PATCH] feat: Add get all priorities --- issue.go | 9 --------- priority.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 priority.go diff --git a/issue.go b/issue.go index 0c57b5ac..a9e5f738 100644 --- a/issue.go +++ b/issue.go @@ -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"` diff --git a/priority.go b/priority.go new file mode 100644 index 00000000..852e7cdc --- /dev/null +++ b/priority.go @@ -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 +}