Commit graph

9 commits

Author SHA1 Message Date
d92a1b90c2 Fix Task.tasks field type: rename Children []*Task to ChildIDs []int
The Checkvist API returns the 'tasks' field as an array of child task IDs
(integers), not as full Task objects. This was causing JSON unmarshal errors.

BREAKING CHANGE: Task.Children []*Task renamed to Task.ChildIDs []int
2026-01-18 14:41:42 +01:00
b716d4d0fe Fix Close/Invalidate/Reopen to handle API array response
The Checkvist API returns an array of tasks (containing the modified task
and potentially its subtasks) for close, reopen, and invalidate operations.
The code was incorrectly trying to decode into a single Task struct.

Changes:
- Decode response into []Task instead of Task
- Return first element (the modified task)
- Add defensive error handling for empty arrays
- Update tests to mock array responses

Fixes: checkvist-api-2zr
2026-01-15 10:48:38 +01:00
ff67719aed Fix DueDate format: remove caret prefix for API compatibility
The Checkvist API expects due_date values without the caret (^) prefix.
The ^ prefix is only used in task content smart syntax, not in API parameters.

- Remove ^ prefix from DueToday and DueTomorrow constants
- Remove unused DueASAP and DueMonday constants
- Update DueAt() and DueInDays() to not add ^ prefix
- Update tests to expect new format

Closes checkvist-api-4pz
2026-01-15 10:18:01 +01:00
8c9f888927 Fix DueDate parsing to support Checkvist API slash format
The Checkvist API returns due dates in slash format (2026/01/15),
but parseDueDate() only supported ISO format with dashes.

- Extend parseDueDate() to try both formats (slashes and dashes)
- Add test case for Checkvist API format parsing
- Fix TestTaskBuilder to use existing DueTomorrow constant

Closes checkvist-api-otm
2026-01-15 09:29:34 +01:00
773da6323d gofmt 2026-01-14 21:24:46 +01:00
895b76d9e1 Fix TaskBuilder parameters not sent to API
- Add createTaskWrapper and updateTaskWrapper structs to wrap request
  bodies in nested JSON format expected by Checkvist API
- Change JSON tag from "due" to "due_date" as required by API
- Update DueDate constants to use valid Checkvist smart syntax values
  (^Today, ^Tomorrow, ^ASAP, ^Monday)
- Update tests to verify nested format and correct field names

Fixes checkvist-api-a5b
2026-01-14 19:02:34 +01:00
762b4daf8d Add tests documenting TaskBuilder parameters bug 2026-01-14 18:23:17 +01:00
e4862b8e9b Fix date parsing for Checkvist API format
Add custom APITime type with UnmarshalJSON to handle the non-standard
date format returned by the Checkvist API ("2026/01/14 16:07:31 +0000")
instead of the expected RFC3339 format.

Changes:
- Add APITime type with custom JSON marshaling/unmarshaling in models.go
- Replace time.Time with APITime for UpdatedAt/CreatedAt fields in
  Checklist, Task, and Note structs
- Add NewAPITime constructor for convenience
- Update test fixtures to use real API date format
- Add comprehensive unit tests for APITime in models_test.go

Fixes: checkvist-api-4qn
2026-01-14 18:10:02 +01:00
e2d0f2299c Add unit tests for Tasks
Create tasks_test.go with comprehensive tests:
- TestTasks_List: list all tasks in checklist
- TestTasks_Get: get single task by ID
- TestTasks_Create: create basic task
- TestTasks_Create_WithBuilder: create task with all options
- TestTasks_Update: update task properties
- TestTasks_Delete: delete task
- TestTasks_Close: mark task as completed
- TestTasks_Reopen: reopen closed task
- TestTasks_Invalidate: invalidate task
- TestDueDate_Parsing: table-driven due date parsing tests
- TestTaskBuilder: builder pattern validation

Add testdata/tasks/ fixtures:
- list.json: sample task list
- single.json: single task response

All 11 tests pass using httptest.Server mocking.

Closes checkvist-api-v2f
2026-01-14 13:46:08 +01:00