Class: Uploadcare::Collections::BatchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/uploadcare/collections/batch_result.rb

Overview

Result object for batch file operations (store/delete).

Wraps the response from batch operations and provides access to:

  • Successfully processed files
  • Files that encountered problems
  • Overall operation status

Examples:

result = client.files.batch_store(uuids: ["uuid1", "uuid2"])
result.result.each { |file| puts file.uuid }
result.problems.each { |uuid, error| puts "#{uuid}: #{error}" }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, result:, problems:, client:) ⇒ BatchResult

Initialize a new BatchResult.

Parameters:

  • status (Integer, nil)

    HTTP status code

  • result (Array<Hash>)

    Array of file data hashes from the API

  • problems (Hash)

    Hash of UUIDs to error messages

  • client (Uploadcare::Client)

    Client for creating File objects



30
31
32
33
34
# File 'lib/uploadcare/collections/batch_result.rb', line 30

def initialize(status:, result:, problems:, client:)
  @status = status
  @result = result ? result.map { |file_data| Uploadcare::Resources::File.new(file_data, client) } : []
  @problems = problems || {}
end

Instance Attribute Details

#problemsHash (readonly)

Returns Hash mapping UUIDs to error messages.

Returns:

  • (Hash)

    Hash mapping UUIDs to error messages



22
23
24
# File 'lib/uploadcare/collections/batch_result.rb', line 22

def problems
  @problems
end

#resultArray<Uploadcare::Resources::File> (readonly)

Returns Successfully processed File objects.

Returns:



19
20
21
# File 'lib/uploadcare/collections/batch_result.rb', line 19

def result
  @result
end

#statusInteger? (readonly)

Returns HTTP status code of the operation.

Returns:

  • (Integer, nil)

    HTTP status code of the operation



16
17
18
# File 'lib/uploadcare/collections/batch_result.rb', line 16

def status
  @status
end