Commit graph

15 commits

Author SHA1 Message Date
28e517289a Implement TaskParams builder (Options Pattern)
- TaskParams struct with fluent setter methods
- NewTask(title) constructor
- Setters: WithDescription, InColumn, WithCategory, WithOwner, WithCreator,
  WithColor, WithPriority, WithScore, WithDueDate, WithStartDate,
  InSwimlane, WithReference, WithTags
- toCreateTaskRequest for conversion to CreateTaskRequest
- BoardScope.CreateTaskFromParams for fluent task creation
- Comprehensive test coverage for all setters and chaining
2026-01-15 18:31:13 +01:00
f04ea8866f Implement BoardScope fluent builder
- BoardScope struct for project-scoped operations
- Client.Board(projectID) returns a BoardScope
- Methods: GetColumns, GetCategories, GetTasks, SearchTasks, CreateTask
- All methods delegate to direct Client methods
- CreateTask automatically sets project ID from scope
- Comprehensive test coverage
2026-01-15 18:29:35 +01:00
c2a107054f Implement Task search and move methods
- SearchTasks: search tasks using Kanboard query syntax
- MoveTaskPosition: move task to specific position in column/swimlane
- MoveTaskToProject: move task to different project
- Comprehensive test coverage for all methods
2026-01-15 18:28:11 +01:00
d27aabe4c4 Implement Task API methods (CRUD operations)
- GetTask: retrieve single task by ID
- GetAllTasks: retrieve all tasks for a project with status filter
- CreateTask: create new task and return the created task
- UpdateTask: partial updates via pointer fields
- CloseTask/OpenTask: status operations with proper error handling
- Returns ErrTaskNotFound, ErrTaskClosed, ErrTaskOpen as appropriate
- Comprehensive test coverage for all methods and edge cases
2026-01-15 18:26:55 +01:00
fc4577e729 Implement Category API methods (GetAllCategories, GetCategory)
- GetAllCategories returns all categories for a project
- GetCategory returns a single category by ID
- Returns ErrCategoryNotFound for non-existent categories
- Added ErrCategoryNotFound to IsNotFound helper
- Comprehensive test coverage
2026-01-15 18:25:12 +01:00
2d3be3619c Implement Column API methods (GetColumns, GetColumn)
- GetColumns returns all columns for a project, sorted by position
- GetColumn returns a single column by ID
- Returns ErrColumnNotFound for non-existent columns
- Comprehensive test coverage including edge cases
2026-01-15 18:23:44 +01:00
7c8ebcc491 Implement Project API methods
Add direct client methods for project/board operations:

- GetAllProjects(ctx) - list all accessible projects
- GetProjectByID(ctx, projectID) - get project by ID
- GetProjectByName(ctx, name) - get project by name

All methods:
- Use context for cancellation support
- Return ErrProjectNotFound when project doesn't exist
- Properly wrap errors with context

Closes: kanboard-api-apl
2026-01-15 18:21:42 +01:00
88b92aa028 Implement Tag API methods (CRITICAL)
Add direct client methods for tag operations:

Must-have methods:
- GetTaskTags(ctx, taskID) - returns map[tagID]tagName
- SetTaskTags(ctx, projectID, taskID, tags) - replaces all tags

Nice-to-have methods:
- GetAllTags(ctx) - list all tags in system
- GetTagsByProject(ctx, projectID) - list project tags
- CreateTag(ctx, projectID, name, colorID) - create new tag
- UpdateTag(ctx, tagID, name, colorID) - update existing tag
- RemoveTag(ctx, tagID) - delete tag

Note: setTaskTags REPLACES all tags. Individual add/remove
requires read-modify-write pattern (to be implemented in TaskScope).

Closes: kanboard-api-16r
2026-01-15 18:20:23 +01:00
a38e62e77a Implement entity structs for Kanboard API responses
Add all entity structs matching Kanboard's JSON-RPC API format:

Entity structs:
- Project, Task, Column, Category, Comment
- TaskLink, TaskFile, Tag
- TaskStatus enum (StatusActive, StatusInactive)

Request structs:
- CreateTaskRequest with omitempty for optional fields
- UpdateTaskRequest with pointer fields for zero-value distinction

Custom JSON types for Kanboard's string-encoded values:
- StringBool - handles "0"/"1" string booleans
- StringInt - handles string-encoded integers
- StringInt64 - handles string-encoded int64 values

All structs properly handle Kanboard's quirky JSON format where
numeric fields are often returned as quoted strings.

Closes: kanboard-api-cyc
2026-01-15 18:18:47 +01:00
dbac08ac1e Implement Timestamp type for Unix timestamp JSON handling
Add custom Timestamp type that wraps time.Time for Kanboard's
Unix timestamp format:

UnmarshalJSON supports:
- Unix timestamps as integers
- Empty strings and "0" strings as zero time
- Null values as zero time
- Numeric strings (e.g., "1609459200")

MarshalJSON returns:
- 0 for zero time
- Unix timestamp for non-zero time

Includes comprehensive tests for round-trip marshaling
and struct embedding scenarios.

Closes: kanboard-api-25y
2026-01-15 18:15:33 +01:00
a56456cc00 Complete Client struct with fluent configuration
Add full client configuration with fluent builder pattern:

- WithTimeout(duration) - configurable request timeout
- WithLogger(slog.Logger) - optional debug logging
- DefaultTimeout constant (30 seconds)
- Default HTTP client with timeout on construction

All fluent methods return same client instance for chaining.
Client is thread-safe for concurrent use.

Closes: kanboard-api-uls
2026-01-15 18:14:22 +01:00
79385df87b Implement comprehensive error types and handling
Add complete error handling system for Kanboard API client:

Sentinel errors:
- Network: ErrConnectionFailed, ErrTimeout
- Auth: ErrUnauthorized, ErrForbidden
- Resources: ErrNotFound, ErrProjectNotFound, ErrTaskNotFound,
  ErrColumnNotFound, ErrCommentNotFound
- Logic: ErrAlreadyInLastColumn, ErrAlreadyInFirstColumn,
  ErrTaskClosed, ErrTaskOpen
- Validation: ErrEmptyTitle, ErrInvalidProjectID

Helper functions:
- IsNotFound() - checks all not-found error variants
- IsUnauthorized() - checks auth errors
- IsAPIError() - checks for API errors via errors.As

All errors support errors.Is/errors.As for proper error
wrapping and context preservation.

Closes: kanboard-api-s7k
2026-01-15 18:13:09 +01:00
ba942f3b52 Add authentication system tests
Add comprehensive tests for HTTP Basic Auth support:
- API token authentication (jsonrpc + token)
- Username/password authentication
- Verify no auth header when unconfigured
- Fluent configuration method chaining
- Auth overwrite behavior

The auth implementation was completed in the previous commit
as a dependency for JSON-RPC client.

Closes: kanboard-api-k33
2026-01-15 18:11:48 +01:00
a486a73ce1 Implement JSON-RPC client foundation
Add core JSON-RPC 2.0 protocol implementation for Kanboard API:

- JSONRPCRequest/Response/Error structs with proper JSON tags
- Generic call() method for sending requests and parsing responses
- Thread-safe request ID generation using atomic.Int64
- Automatic /jsonrpc.php path appending to baseURL
- Support for subdirectory installations
- HTTP Basic Auth support (API token and username/password)
- Error handling for unauthorized/forbidden responses

Includes comprehensive tests with httptest mock server.

Closes: kanboard-api-2g1
2026-01-15 18:10:35 +01:00
347fb75f11 Initial commit 2026-01-15 17:48:46 +01:00