@@ -13,49 +13,45 @@ import (
1313
1414type Milestone struct {
1515 ID int64 `json:"id"`
16- State StateType `json:"state"`
1716 Title string `json:"title"`
1817 Description string `json:"description"`
18+ State StateType `json:"state"`
1919 OpenIssues int `json:"open_issues"`
2020 ClosedIssues int `json:"closed_issues"`
2121 Closed * time.Time `json:"closed_at"`
2222 Deadline * time.Time `json:"due_on"`
2323}
2424
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-
4125func (c * Client ) ListRepoMilestones (owner , repo string ) ([]* Milestone , error ) {
4226 milestones := make ([]* Milestone , 0 , 10 )
4327 return milestones , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/milestones" , owner , repo ), nil , nil , & milestones )
4428}
4529
46- func (c * Client ) GetRepoMilestone (owner , repo string , id int64 ) (* Milestone , error ) {
30+ func (c * Client ) GetMilestone (owner , repo string , id int64 ) (* Milestone , error ) {
4731 milestone := new (Milestone )
4832 return milestone , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/milestones/%d" , owner , repo , id ), nil , nil , milestone )
4933}
5034
35+ type CreateMilestoneOption struct {
36+ Title string `json:"title"`
37+ Description string `json:"description"`
38+ Deadline * time.Time `json:"due_on"`
39+ }
40+
5141func (c * Client ) CreateMilestone (owner , repo string , opt CreateMilestoneOption ) (* Milestone , error ) {
5242 body , err := json .Marshal (& opt )
5343 if err != nil {
5444 return nil , err
5545 }
5646 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"`
5955}
6056
6157func (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 {
7167 _ , err := c .getResponse ("DELETE" , fmt .Sprintf ("/repos/%s/%s/milestones/%d" , owner , repo , id ), nil , nil )
7268 return err
7369}
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