mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
27 lines
624 B
Go
27 lines
624 B
Go
package jira
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/Kuchenm0nster/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)
|
|
}
|