summaryrefslogtreecommitdiff
path: root/internal/api/todoist.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/todoist.go')
-rw-r--r--internal/api/todoist.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/api/todoist.go b/internal/api/todoist.go
index 689bf10..b3d4579 100644
--- a/internal/api/todoist.go
+++ b/internal/api/todoist.go
@@ -442,3 +442,26 @@ func (c *TodoistClient) CompleteTask(ctx context.Context, taskID string) error {
return nil
}
+
+// ReopenTask marks a completed task as active in Todoist
+func (c *TodoistClient) ReopenTask(ctx context.Context, taskID string) error {
+ url := fmt.Sprintf("%s/tasks/%s/reopen", c.baseURL, taskID)
+ req, err := http.NewRequestWithContext(ctx, "POST", url, nil)
+ if err != nil {
+ return fmt.Errorf("failed to create request: %w", err)
+ }
+ req.Header.Set("Authorization", "Bearer "+c.apiKey)
+
+ resp, err := c.httpClient.Do(req)
+ if err != nil {
+ return fmt.Errorf("failed to reopen task: %w", err)
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusOK {
+ body, _ := io.ReadAll(resp.Body)
+ return fmt.Errorf("todoist API error (status %d): %s", resp.StatusCode, string(body))
+ }
+
+ return nil
+}