Class: Payabli::Internal::Multipart::FormDataPart Private

Inherits:
Object
  • Object
show all
Defined in:
lib/payabli/internal/multipart/multipart_form_data_part.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, value:, filename: nil, headers: nil) ⇒ FormDataPart

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FormDataPart.

Parameters:

  • The name of the form field

  • The value of the field

  • (defaults to: nil)

    Optional filename for file uploads

  • (defaults to: nil)

    Optional additional headers

API:

  • private



16
17
18
19
20
21
# File 'lib/payabli/internal/multipart/multipart_form_data_part.rb', line 16

def initialize(name:, value:, filename: nil, headers: nil)
  @name = name
  @contents = convert_to_content(value)
  @filename = filename
  @headers = headers
end

Instance Attribute Details

#contentsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



10
11
12
# File 'lib/payabli/internal/multipart/multipart_form_data_part.rb', line 10

def contents
  @contents
end

#filenameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



10
11
12
# File 'lib/payabli/internal/multipart/multipart_form_data_part.rb', line 10

def filename
  @filename
end

#headersObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



10
11
12
# File 'lib/payabli/internal/multipart/multipart_form_data_part.rb', line 10

def headers
  @headers
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



10
11
12
# File 'lib/payabli/internal/multipart/multipart_form_data_part.rb', line 10

def name
  @name
end

Instance Method Details

#to_hashHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts the part to a hash suitable for serialization.

Returns:

  • A hash representation of the part

API:

  • private



26
27
28
29
30
31
32
33
34
# File 'lib/payabli/internal/multipart/multipart_form_data_part.rb', line 26

def to_hash
  result = {
    name: @name,
    contents: @contents
  }
  result[:filename] = @filename if @filename
  result[:headers] = @headers if @headers
  result
end