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
tags.go
4
tags.go
|
|
@ -75,11 +75,11 @@ func (c *Client) CreateTag(ctx context.Context, projectID int, name, colorID str
|
|||
params["color_id"] = colorID
|
||||
}
|
||||
|
||||
var result int
|
||||
var result IntOrFalse
|
||||
if err := c.call(ctx, "createTag", params, &result); err != nil {
|
||||
return 0, fmt.Errorf("createTag: %w", err)
|
||||
}
|
||||
return result, nil
|
||||
return int(result), nil
|
||||
}
|
||||
|
||||
// UpdateTag updates an existing tag's name and/or color.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue