-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
35 lines (30 loc) · 823 Bytes
/
status.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
package habitify
import (
"context"
"fmt"
"time"
)
const (
StatusInProgress = "in_progress"
StatusCompleted = "completed"
StatusSkipped = "skipped"
StatusFailed = "failed"
)
type Status struct {
Status string `json:"status"`
Progress struct {
CurrentValue int `json:"current_value"`
TargetValue int `json:"target_value"`
UnitType string `json:"unit_type"`
Periodicity string `json:"periodicity"`
ReferenceDate time.Time `json:"reference_date"`
} `json:"progress"`
}
func (c *Client) GetStatus(ctx context.Context, habitID string, targetDate time.Time) (*Status, error) {
var status *Status
err := c.get(ctx, fmt.Sprintf("%s/%s?target_date=%s", urlStatus, habitID, formatTime(targetDate)), &status)
if err != nil {
return nil, err
}
return status, nil
}