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
files.go
4
files.go
|
|
@ -29,7 +29,7 @@ func (c *Client) CreateTaskFile(ctx context.Context, projectID, taskID int, file
|
|||
"blob": base64.StdEncoding.EncodeToString(content),
|
||||
}
|
||||
|
||||
var result int
|
||||
var result IntOrFalse
|
||||
if err := c.call(ctx, "createTaskFile", params, &result); err != nil {
|
||||
return 0, fmt.Errorf("createTaskFile: %w", err)
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ func (c *Client) CreateTaskFile(ctx context.Context, projectID, taskID int, file
|
|||
return 0, fmt.Errorf("createTaskFile: failed to upload file")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return int(result), nil
|
||||
}
|
||||
|
||||
// DownloadTaskFile downloads a file's content by its ID.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue