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:
Oliver Jakoubek 2026-01-15 20:23:53 +01:00
commit a34a40cb12
7 changed files with 63 additions and 10 deletions

View file

@ -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.