feat: add GetTaskFile and RemoveAllTaskFiles methods
Complete the Task File API implementation with: - GetTaskFile: retrieve single file metadata by ID - RemoveAllTaskFiles: remove all files attached to a task - Add Username/UserName fields to TaskFile struct - Add TaskScope convenience methods: GetFile, RemoveFile, DownloadFile, RemoveAllFiles - Comprehensive tests for all new methods Closes: kanboard-amh
This commit is contained in:
parent
c15d52633f
commit
280fff21a3
6 changed files with 297 additions and 2 deletions
32
files.go
32
files.go
|
|
@ -75,3 +75,35 @@ func (c *Client) RemoveTaskFile(ctx context.Context, fileID int) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTaskFile returns a single file's metadata by its ID.
|
||||
func (c *Client) GetTaskFile(ctx context.Context, fileID int) (*TaskFile, error) {
|
||||
params := map[string]int{"file_id": fileID}
|
||||
|
||||
var result *TaskFile
|
||||
if err := c.call(ctx, "getTaskFile", params, &result); err != nil {
|
||||
return nil, fmt.Errorf("getTaskFile: %w", err)
|
||||
}
|
||||
|
||||
if result == nil {
|
||||
return nil, fmt.Errorf("%w: file %d", ErrNotFound, fileID)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RemoveAllTaskFiles removes all files attached to a task.
|
||||
func (c *Client) RemoveAllTaskFiles(ctx context.Context, taskID int) error {
|
||||
params := map[string]int{"task_id": taskID}
|
||||
|
||||
var success bool
|
||||
if err := c.call(ctx, "removeAllTaskFiles", params, &success); err != nil {
|
||||
return fmt.Errorf("removeAllTaskFiles: %w", err)
|
||||
}
|
||||
|
||||
if !success {
|
||||
return fmt.Errorf("removeAllTaskFiles: delete failed")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue