2026-01-15 18:29:35 +01:00
|
|
|
package kanboard
|
|
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
|
|
// BoardScope provides fluent project-scoped operations.
|
|
|
|
|
type BoardScope struct {
|
|
|
|
|
client *Client
|
|
|
|
|
projectID int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Board returns a BoardScope for fluent project-scoped operations.
|
|
|
|
|
func (c *Client) Board(projectID int) *BoardScope {
|
|
|
|
|
return &BoardScope{
|
|
|
|
|
client: c,
|
|
|
|
|
projectID: projectID,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetColumns returns all columns for the project, sorted by position.
|
|
|
|
|
func (b *BoardScope) GetColumns(ctx context.Context) ([]Column, error) {
|
|
|
|
|
return b.client.GetColumns(ctx, b.projectID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetCategories returns all categories for the project.
|
|
|
|
|
func (b *BoardScope) GetCategories(ctx context.Context) ([]Category, error) {
|
|
|
|
|
return b.client.GetAllCategories(ctx, b.projectID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetTasks returns all tasks for the project with the specified status.
|
|
|
|
|
func (b *BoardScope) GetTasks(ctx context.Context, status TaskStatus) ([]Task, error) {
|
|
|
|
|
return b.client.GetAllTasks(ctx, b.projectID, status)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SearchTasks searches for tasks in the project using Kanboard query syntax.
|
|
|
|
|
func (b *BoardScope) SearchTasks(ctx context.Context, query string) ([]Task, error) {
|
|
|
|
|
return b.client.SearchTasks(ctx, b.projectID, query)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateTask creates a new task in the project.
|
|
|
|
|
// The ProjectID field in the request is overwritten with the board's project ID.
|
|
|
|
|
func (b *BoardScope) CreateTask(ctx context.Context, req CreateTaskRequest) (*Task, error) {
|
|
|
|
|
req.ProjectID = b.projectID
|
|
|
|
|
return b.client.CreateTask(ctx, req)
|
|
|
|
|
}
|
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
|
|
|
|
2026-01-29 09:20:13 +01:00
|
|
|
// CreateCategory creates a new category in the project and returns its ID.
|
|
|
|
|
func (b *BoardScope) CreateCategory(ctx context.Context, name string, colorID string) (int, error) {
|
|
|
|
|
return b.client.CreateCategory(ctx, b.projectID, name, colorID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetCategoryByName returns a category by name within the project.
|
|
|
|
|
func (b *BoardScope) GetCategoryByName(ctx context.Context, name string) (*Category, error) {
|
|
|
|
|
return b.client.GetCategoryByName(ctx, b.projectID, name)
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
// CreateTaskFromParams creates a new task in the project using TaskParams.
|
|
|
|
|
// This provides a fluent interface for task creation.
|
|
|
|
|
func (b *BoardScope) CreateTaskFromParams(ctx context.Context, params *TaskParams) (*Task, error) {
|
|
|
|
|
req := params.toCreateTaskRequest(b.projectID)
|
|
|
|
|
return b.client.CreateTask(ctx, req)
|
|
|
|
|
}
|