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
|
package grocy
import (
"context"
"fmt"
"net/http"
)
type Chore struct {
ID int `json:"id"`
ChoreID int `json:"chore_id"`
ChoreName string `json:"chore_name"`
LastTrackedTime string `json:"last_tracked_time"`
NextEstimatedExecutionTime string `json:"next_estimated_execution_time"`
TrackDateOnly int `json:"track_date_only"`
NextExecutionAssignedToUserID int `json:"next_execution_assigned_to_user_id"`
IsRescheduled int `json:"is_rescheduled"`
IsReassigned int `json:"is_reassigned"`
NextExecutionAssignedUser User `json:"next_execution_assigned_user"`
}
type ChoreList []Chore
func (c *Client) GetChores(ctx context.Context) (ChoreList, error) {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/chores", c.BaseUrl), nil)
if err != nil {
return nil, err
}
req.WithContext(ctx)
var res ChoreList
if err := c.sendRequest(req, &res); err != nil {
return nil, err
}
return res, nil
}
func (c *Client) GetChore(ctx context.Context, choreId int) (Chore, error) {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/chores/%d", c.BaseUrl, choreId), nil)
if err != nil {
return *new(Chore), err
}
req.WithContext(ctx)
var res Chore
if err := c.sendRequest(req, &res); err != nil {
return *new(Chore), err
}
return res, nil
}
|