summaryrefslogtreecommitdiff
path: root/grocy/chores.go
diff options
context:
space:
mode:
Diffstat (limited to 'grocy/chores.go')
-rw-r--r--grocy/chores.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/grocy/chores.go b/grocy/chores.go
new file mode 100644
index 0000000..3dcdf2e
--- /dev/null
+++ b/grocy/chores.go
@@ -0,0 +1,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
+}