-
Notifications
You must be signed in to change notification settings - Fork 0
/
milestones.go
38 lines (32 loc) · 1.08 KB
/
milestones.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
package zenhub
import (
"fmt"
"net/http"
"time"
)
type startDate struct {
// TODO: use ISO8601 format
StartDate string `json:"start_date"`
}
func (c *Client) SetMilestoneStartDate(repositoryID, milestoneNumber int, date time.Time) (*time.Time, *http.Response, error) {
u := fmt.Sprintf("p1/repositories/%d/milestones/%d/start_date", repositoryID, milestoneNumber)
req, err := c.NewRequest(http.MethodPost, u, startDate{date.Format(time.RFC3339)})
startDate := new(startDate)
resp, err := c.Do(req, startDate)
if err != nil {
return nil, resp, err
}
value, _ := time.Parse(time.RFC3339, startDate.StartDate)
return &value, resp, nil
}
func (c *Client) GetMilestoneStartDate(repositoryID, milestoneNumber int) (*time.Time, *http.Response, error) {
u := fmt.Sprintf("p1/repositories/%d/milestones/%d/start_date", repositoryID, milestoneNumber)
req, err := c.NewRequest(http.MethodGet, u, nil)
startDate := new(startDate)
resp, err := c.Do(req, startDate)
if err != nil {
return nil, resp, err
}
value, _ := time.Parse(time.RFC3339, startDate.StartDate)
return &value, resp, nil
}