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
|
|
@ -42,7 +42,7 @@ func (c *Client) CreateComment(ctx context.Context, taskID, userID int, content
|
|||
"content": content,
|
||||
}
|
||||
|
||||
var commentID int
|
||||
var commentID IntOrFalse
|
||||
if err := c.call(ctx, "createComment", params, &commentID); err != nil {
|
||||
return nil, fmt.Errorf("createComment: %w", err)
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ func (c *Client) CreateComment(ctx context.Context, taskID, userID int, content
|
|||
}
|
||||
|
||||
// Fetch the created comment to return full details
|
||||
return c.GetComment(ctx, commentID)
|
||||
return c.GetComment(ctx, int(commentID))
|
||||
}
|
||||
|
||||
// UpdateComment updates the content of a comment.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue