diff options
Diffstat (limited to 'internal/api/todoist.go')
| -rw-r--r-- | internal/api/todoist.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/internal/api/todoist.go b/internal/api/todoist.go index 6c998cf..2c94e08 100644 --- a/internal/api/todoist.go +++ b/internal/api/todoist.go @@ -41,11 +41,8 @@ type todoistTaskResponse struct { ProjectID string `json:"project_id"` Priority int `json:"priority"` Labels []string `json:"labels"` - Due *struct { - Date string `json:"date"` - Datetime string `json:"datetime"` - } `json:"due"` - URL string `json:"url"` + Due *dueInfo `json:"due"` + URL string `json:"url"` CreatedAt string `json:"created_at"` } @@ -73,11 +70,8 @@ type SyncItemResponse struct { ProjectID string `json:"project_id"` Priority int `json:"priority"` Labels []string `json:"labels"` - Due *struct { - Date string `json:"date"` - Datetime string `json:"datetime"` - } `json:"due"` - IsCompleted bool `json:"is_completed"` + Due *dueInfo `json:"due"` + IsCompleted bool `json:"is_completed"` IsDeleted bool `json:"is_deleted"` AddedAt string `json:"added_at"` } @@ -125,6 +119,9 @@ func (c *TodoistClient) GetTasks(ctx context.Context) ([]models.Task, error) { } task.DueDate = parseDueDate(apiTask.Due) + if apiTask.Due != nil { + task.IsRecurring = apiTask.Due.IsRecurring + } tasks = append(tasks, task) } @@ -276,10 +273,14 @@ func (c *TodoistClient) ReopenTask(ctx context.Context, taskID string) error { } // parseDueDate parses due date from API response -func parseDueDate(due *struct { - Date string `json:"date"` - Datetime string `json:"datetime"` -}) *time.Time { +// dueInfo represents the due date structure from Todoist API +type dueInfo struct { + Date string `json:"date"` + Datetime string `json:"datetime"` + IsRecurring bool `json:"is_recurring"` +} + +func parseDueDate(due *dueInfo) *time.Time { if due == nil { return nil } |
