Class: Worldline::Acquiring::SDK::Domain::UploadableFile

Inherits:
Object
  • Object
show all
Defined in:
lib/worldline/acquiring/sdk/domain/uploadable_file.rb

Overview

A file that can be uploaded

The allowed forms of content are defined by the Connection implementation The default implementation supports file paths and IO objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name, content, content_type, content_length = -1)) ⇒ UploadableFile

Returns a new instance of UploadableFile.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 16

def initialize(file_name, content, content_type, content_length = -1)
  raise ArgumentError.new("file_name is required") if file_name.nil? or !file_name.strip
  raise ArgumentError.new("content is required") if content.nil?
  raise ArgumentError.new("content_type is required") if content_type.nil? or !content_type.strip

  @file_name = file_name
  @content = content
  @content_type = content_type
  @content_length = [content_length, -1].max
end

Instance Attribute Details

#contentString, IO (readonly)

The file’s content.

Returns:

  • (String, IO)

    the current value of content



14
15
16
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 14

def content
  @content
end

#content_lengthInteger (readonly)

The file’s content length, or -1 if not known.

Returns:

  • (Integer)

    the current value of content_length



14
15
16
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 14

def content_length
  @content_length
end

#content_typeString (readonly)

The file’s content type.

Returns:

  • (String)

    the current value of content_type



14
15
16
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 14

def content_type
  @content_type
end

#file_nameString (readonly)

The name of the file.

Returns:

  • (String)

    the current value of file_name



14
15
16
# File 'lib/worldline/acquiring/sdk/domain/uploadable_file.rb', line 14

def file_name
  @file_name
end