-
Notifications
You must be signed in to change notification settings - Fork 327
/
fields.go
26 lines (22 loc) · 618 Bytes
/
fields.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package jira
import (
"encoding/json"
"github.com/go-jira/jira/jiradata"
)
// https://docs.atlassian.com/jira/REST/cloud/#api/2/field-getFields
func (j *Jira) GetFields() ([]jiradata.Field, error) {
return GetFields(j.UA, j.Endpoint)
}
func GetFields(ua HttpClient, endpoint string) ([]jiradata.Field, error) {
uri := URLJoin(endpoint, "rest/api/2/field")
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := []jiradata.Field{}
return results, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}