Skip to content

Commit 1c63e25

Browse files
committed
feat: Add get all priorities
1 parent 98ede9f commit 1c63e25

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

issue.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,6 @@ type Resolution struct {
235235
Name string `json:"name" structs:"name"`
236236
}
237237

238-
// Priority represents a priority of a JIRA issue.
239-
// Typical types are "Normal", "Moderate", "Urgent", ...
240-
type Priority struct {
241-
Self string `json:"self,omitempty" structs:"self,omitempty"`
242-
IconURL string `json:"iconUrl,omitempty" structs:"iconUrl,omitempty"`
243-
Name string `json:"name,omitempty" structs:"name,omitempty"`
244-
ID string `json:"id,omitempty" structs:"id,omitempty"`
245-
}
246-
247238
// Watches represents a type of how many and which user are "observing" a JIRA issue to track the status / updates.
248239
type Watches struct {
249240
Self string `json:"self,omitempty" structs:"self,omitempty"`

priority.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package jira
2+
3+
// PriorityService handles priorities for the JIRA instance / API.
4+
//
5+
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-Priority
6+
type PriorityService struct {
7+
client *Client
8+
}
9+
10+
// Priority represents a priority of a JIRA issue.
11+
// Typical types are "Normal", "Moderate", "Urgent", ...
12+
type Priority struct {
13+
Self string `json:"self,omitempty" structs:"self,omitempty"`
14+
IconURL string `json:"iconUrl,omitempty" structs:"iconUrl,omitempty"`
15+
Name string `json:"name,omitempty" structs:"name,omitempty"`
16+
ID string `json:"id,omitempty" structs:"id,omitempty"`
17+
StatusColor string `json:"statusColor,omitempty" structs:"statusColor,omitempty"`
18+
Description string `json:"description,omitempty" structs:"description,omitempty"`
19+
}
20+
21+
// GetList gets all priorities from JIRA
22+
//
23+
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-priority-get
24+
func (s *PriorityService) GetList() ([]Priority, *Response, error) {
25+
apiEndpoint := "rest/api/2/priority"
26+
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
27+
if err != nil {
28+
return nil, nil, err
29+
}
30+
31+
priorityList := []Priority{}
32+
resp, err := s.client.Do(req, priorityList)
33+
if err != nil {
34+
return nil, resp, NewJiraError(resp, err)
35+
}
36+
return priorityList, resp, nil
37+
}

0 commit comments

Comments
 (0)