Add IntOrFalse type to handle polymorphic API responses
Kanboard API returns int (ID) on success and false (bool) on failure for create operations. Add IntOrFalse type that handles both cases and update CreateTask, CreateComment, CreateTag, CreateTaskFile, and CreateTaskLink to use it.
This commit is contained in:
parent
59252a3f63
commit
a34a40cb12
7 changed files with 63 additions and 10 deletions
4
tasks.go
4
tasks.go
|
|
@ -41,7 +41,7 @@ func (c *Client) GetAllTasks(ctx context.Context, projectID int, status TaskStat
|
|||
|
||||
// CreateTask creates a new task and returns the created task.
|
||||
func (c *Client) CreateTask(ctx context.Context, req CreateTaskRequest) (*Task, error) {
|
||||
var taskID int
|
||||
var taskID IntOrFalse
|
||||
if err := c.call(ctx, "createTask", req, &taskID); err != nil {
|
||||
return nil, fmt.Errorf("createTask: %w", err)
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ func (c *Client) CreateTask(ctx context.Context, req CreateTaskRequest) (*Task,
|
|||
}
|
||||
|
||||
// Fetch the created task to return full details
|
||||
return c.GetTask(ctx, taskID)
|
||||
return c.GetTask(ctx, int(taskID))
|
||||
}
|
||||
|
||||
// UpdateTask updates an existing task.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue