@@ -13,49 +13,45 @@ import (
13
13
14
14
type Milestone struct {
15
15
ID int64 `json:"id"`
16
- State StateType `json:"state"`
17
16
Title string `json:"title"`
18
17
Description string `json:"description"`
18
+ State StateType `json:"state"`
19
19
OpenIssues int `json:"open_issues"`
20
20
ClosedIssues int `json:"closed_issues"`
21
21
Closed * time.Time `json:"closed_at"`
22
22
Deadline * time.Time `json:"due_on"`
23
23
}
24
24
25
- type CreateMilestoneOption struct {
26
- Title string `json:"title"`
27
- Description string `json:"description"`
28
- Deadline * time.Time `json:"due_on"`
29
- }
30
-
31
- type EditMilestoneOption struct {
32
- Title string `json:"title"`
33
- Description string `json:"description"`
34
- Deadline * time.Time `json:"due_on"`
35
- }
36
-
37
- type SetIssueMilestoneOption struct {
38
- ID int64 `json:"id"`
39
- }
40
-
41
25
func (c * Client ) ListRepoMilestones (owner , repo string ) ([]* Milestone , error ) {
42
26
milestones := make ([]* Milestone , 0 , 10 )
43
27
return milestones , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/milestones" , owner , repo ), nil , nil , & milestones )
44
28
}
45
29
46
- func (c * Client ) GetRepoMilestone (owner , repo string , id int64 ) (* Milestone , error ) {
30
+ func (c * Client ) GetMilestone (owner , repo string , id int64 ) (* Milestone , error ) {
47
31
milestone := new (Milestone )
48
32
return milestone , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/milestones/%d" , owner , repo , id ), nil , nil , milestone )
49
33
}
50
34
35
+ type CreateMilestoneOption struct {
36
+ Title string `json:"title"`
37
+ Description string `json:"description"`
38
+ Deadline * time.Time `json:"due_on"`
39
+ }
40
+
51
41
func (c * Client ) CreateMilestone (owner , repo string , opt CreateMilestoneOption ) (* Milestone , error ) {
52
42
body , err := json .Marshal (& opt )
53
43
if err != nil {
54
44
return nil , err
55
45
}
56
46
milestone := new (Milestone )
57
- return milestone , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/milestones" , owner , repo ),
58
- jsonHeader , bytes .NewReader (body ), milestone )
47
+ return milestone , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/milestones" , owner , repo ), jsonHeader , bytes .NewReader (body ), milestone )
48
+ }
49
+
50
+ type EditMilestoneOption struct {
51
+ Title * string `json:"title"`
52
+ Description * string `json:"description"`
53
+ State * string `json:"state"`
54
+ Deadline * time.Time `json:"due_on"`
59
55
}
60
56
61
57
func (c * Client ) EditMilestone (owner , repo string , id int64 , opt EditMilestoneOption ) (* Milestone , error ) {
@@ -71,34 +67,3 @@ func (c *Client) DeleteMilestone(owner, repo string, id int64) error {
71
67
_ , err := c .getResponse ("DELETE" , fmt .Sprintf ("/repos/%s/%s/milestones/%d" , owner , repo , id ), nil , nil )
72
68
return err
73
69
}
74
-
75
- func (c * Client ) ChangeMilestoneStatus (owner , repo string , id int64 , open bool ) (* Milestone , error ) {
76
- var action string
77
- if open {
78
- action = "open"
79
- } else {
80
- action = "close"
81
- }
82
-
83
- milestone := new (Milestone )
84
- return milestone , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/milestones/%d/%s" , owner , repo , id , action ), nil , nil , milestone )
85
- }
86
-
87
- func (c * Client ) GetIssueMilestone (owner , repo string , index int64 ) (* Milestone , error ) {
88
- milestone := new (Milestone )
89
- return milestone , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/issues/%d/milestone" , owner , repo , index ), nil , nil , & milestone )
90
- }
91
-
92
- func (c * Client ) SetIssueMilestone (owner , repo string , index int64 , opt SetIssueMilestoneOption ) (* Milestone , error ) {
93
- body , err := json .Marshal (& opt )
94
- if err != nil {
95
- return nil , err
96
- }
97
- milestone := new (Milestone )
98
- return milestone , c .getParsedResponse ("POST" , fmt .Sprintf ("/repos/%s/%s/issues/%d/milestone" , owner , repo , index ), jsonHeader , bytes .NewReader (body ), & milestone )
99
- }
100
-
101
- func (c * Client ) DeleteIssueMilestone (owner , repo string , index int64 ) error {
102
- _ , err := c .getResponse ("DELETE" , fmt .Sprintf ("/repos/%s/%s/issues/%d/milestone" , owner , repo , index ), nil , nil )
103
- return err
104
- }
0 commit comments