|
| 1 | +package habitify |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "time" |
| 7 | +) |
| 8 | + |
| 9 | +type Journal struct { |
| 10 | + ID string `json:"id"` |
| 11 | + Name string `json:"name"` |
| 12 | + IsArchived bool `json:"is_archived"` |
| 13 | + StartDate time.Time `json:"start_date"` |
| 14 | + TimeOfDay []string `json:"time_of_day"` |
| 15 | + Goal struct { |
| 16 | + UnitType string `json:"unit_type"` |
| 17 | + Value int `json:"value"` |
| 18 | + Periodicity string `json:"periodicity"` |
| 19 | + } `json:"goal"` |
| 20 | + GoalHistoryItems []struct { |
| 21 | + UnitType string `json:"unit_type"` |
| 22 | + Value int `json:"value"` |
| 23 | + Periodicity string `json:"periodicity"` |
| 24 | + } `json:"goal_history_items"` |
| 25 | + LogMethod string `json:"log_method"` |
| 26 | + Recurrence string `json:"recurrence"` |
| 27 | + Remind []string `json:"remind"` |
| 28 | + Area struct { |
| 29 | + ID string `json:"id"` |
| 30 | + Name string `json:"name"` |
| 31 | + Priority string `json:"priority"` |
| 32 | + } `json:"area"` |
| 33 | + CreatedDate time.Time `json:"created_date"` |
| 34 | + Priority float64 `json:"priority"` |
| 35 | + Status string `json:"status"` |
| 36 | + Progress struct { |
| 37 | + CurrentValue int `json:"current_value"` |
| 38 | + TargetValue int `json:"target_value"` |
| 39 | + UnitType string `json:"unit_type"` |
| 40 | + Periodicity string `json:"periodicity"` |
| 41 | + ReferenceDate time.Time `json:"reference_date"` |
| 42 | + } `json:"progress"` |
| 43 | +} |
| 44 | + |
| 45 | +func (c *Client) ListJournals(ctx context.Context, targetDate time.Time) ([]*Journal, error) { |
| 46 | + var journals []*Journal |
| 47 | + err := c.get(ctx, fmt.Sprintf("%s?target_date=%s", urlJournal, formatTime(targetDate)), &journals) |
| 48 | + if err != nil { |
| 49 | + return nil, err |
| 50 | + } |
| 51 | + |
| 52 | + return journals, nil |
| 53 | +} |
0 commit comments