-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependencies.go
60 lines (51 loc) · 1.3 KB
/
dependencies.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
48
49
50
51
52
53
54
55
56
57
58
59
60
package zenhub
import (
"fmt"
"net/http"
)
type Dependencies struct {
Dependencies []Dependency `json:"dependencies"`
}
type Dependency struct {
Blocking SimpleIssue `json:"blocking"`
Blocked SimpleIssue `json:"blocked"`
}
func (c *Client) GetDependencies(repositoryID int) (*Dependencies, *http.Response, error) {
u := fmt.Sprintf("p1/repositories/%d/dependencies", repositoryID)
req, err := c.NewRequest(http.MethodGet, u, nil)
if err != nil {
return nil, nil, err
}
dependencies := new(Dependencies)
resp, err := c.Do(req, dependencies)
if err != nil {
return nil, resp, err
}
return dependencies, resp, nil
}
func (c *Client) CreateDependency(dependency Dependency) (*Dependency, *http.Response, error) {
u := fmt.Sprintf("p1/dependencies")
req, err := c.NewRequest(http.MethodPost, u, dependency)
if err != nil {
return nil, nil, err
}
dep := new(Dependency)
resp, err := c.Do(req, dep)
if err != nil {
return nil, resp, err
}
return dep, resp, nil
}
func (c *Client) RemoveDependency(dependency Dependency) (*http.Response, error) {
u := fmt.Sprintf("p1/dependencies")
req, err := c.NewRequest(http.MethodDelete, u, dependency)
if err != nil {
return nil, err
}
dep := new(Dependency)
resp, err := c.Do(req, dep)
if err != nil {
return resp, err
}
return resp, nil
}