forked from go-jira/jira
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.go
47 lines (39 loc) · 1.39 KB
/
project.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package jira
import (
"encoding/json"
"github.com/Kuchenm0nster/jira/jiradata"
)
// https://docs.atlassian.com/jira/REST/cloud/#api/2/project-getProjectComponents
func (j *Jira) GetProjectComponents(project string) (*jiradata.Components, error) {
return GetProjectComponents(j.UA, j.Endpoint, project)
}
func GetProjectComponents(ua HttpClient, endpoint string, project string) (*jiradata.Components, error) {
uri := URLJoin(endpoint, "rest/api/2/project", project, "components")
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := jiradata.Components{}
return &results, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}
// https://developer.atlassian.com/cloud/jira/platform/rest/v2#api-api-2-project-projectIdOrKey-versions-get
func (j *Jira) GetProjectVersions(project string) (*jiradata.Versions, error) {
return GetProjectVersions(j.UA, j.Endpoint, project)
}
func GetProjectVersions(ua HttpClient, endpoint string, project string) (*jiradata.Versions, error) {
uri := URLJoin(endpoint, "rest/api/2/project", project, "versions")
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := jiradata.Versions{}
return &results, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}