From e107192be5efb65807c7da3b6aa99ce3555944d0 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Tue, 13 Jan 2026 14:18:24 -1000 Subject: Implement Todoist write operations - API layer (Part 1) Add CreateTask and CompleteTask methods to Todoist API client: Models: - Add Project struct (ID, Name) to types.go - Add Projects []Project field to DashboardData API Interface: - Change GetProjects signature to return []models.Project - Ensure CreateTask and CompleteTask are defined Todoist Client: - Add baseURL field for testability - Refactor GetProjects to return []models.Project - Update GetTasks to build project map from new GetProjects - Implement CreateTask with JSON payload support - Implement CompleteTask using POST to /tasks/{id}/close Tests: - Create comprehensive todoist_test.go - Test CreateTask, CreateTask with due date, CompleteTask - Test error handling and GetProjects - Update mock client in handlers tests All tests pass. Ready for handlers and UI integration. Co-Authored-By: Claude Sonnet 4.5 --- internal/api/interfaces.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'internal/api/interfaces.go') diff --git a/internal/api/interfaces.go b/internal/api/interfaces.go index 31da0a8..db7e6c0 100644 --- a/internal/api/interfaces.go +++ b/internal/api/interfaces.go @@ -10,7 +10,7 @@ import ( // TodoistAPI defines the interface for Todoist operations type TodoistAPI interface { GetTasks(ctx context.Context) ([]models.Task, error) - GetProjects(ctx context.Context) (map[string]string, error) + GetProjects(ctx context.Context) ([]models.Project, error) CreateTask(ctx context.Context, content, projectID string, dueDate *time.Time, priority int) (*models.Task, error) CompleteTask(ctx context.Context, taskID string) error } -- cgit v1.2.3