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
links.go
4
links.go
|
|
@ -27,7 +27,7 @@ func (c *Client) CreateTaskLink(ctx context.Context, taskID, oppositeTaskID, lin
|
|||
"link_id": linkID,
|
||||
}
|
||||
|
||||
var result int
|
||||
var result IntOrFalse
|
||||
if err := c.call(ctx, "createTaskLink", params, &result); err != nil {
|
||||
return 0, fmt.Errorf("createTaskLink: %w", err)
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ func (c *Client) CreateTaskLink(ctx context.Context, taskID, oppositeTaskID, lin
|
|||
return 0, fmt.Errorf("createTaskLink: failed to create link")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return int(result), nil
|
||||
}
|
||||
|
||||
// RemoveTaskLink deletes a task link.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue