Class: Plaid::Internal::Multipart::FormData Private
- Inherits:
-
Object
- Object
- Plaid::Internal::Multipart::FormData
- Defined in:
- lib/plaid/internal/multipart/multipart_form_data.rb
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.
Instance Attribute Summary collapse
-
#parts ⇒ Array<FormDataPart>
readonly
private
The parts in this multipart form data.
Instance Method Summary collapse
-
#add(name:, value:, content_type: nil) ⇒ self
private
Adds a new part to the multipart form data.
-
#add_file(name:, file:, filename: nil, content_type: nil) ⇒ self
private
Adds a file to the multipart form data.
-
#add_part(part) ⇒ self
private
Adds a pre-created part to the multipart form data.
-
#content_type ⇒ String
private
Gets the content type string including the boundary.
-
#encode ⇒ String
private
Encode the multipart form data into a multipart/form-data payload.
-
#initialize ⇒ FormData
constructor
private
A new instance of FormData.
Constructor Details
#initialize ⇒ FormData
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 FormData.
14 15 16 17 |
# File 'lib/plaid/internal/multipart/multipart_form_data.rb', line 14 def initialize @encoder = Encoder.new @parts = [] end |
Instance Attribute Details
#parts ⇒ Array<FormDataPart> (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.
Returns The parts in this multipart form data.
9 10 11 |
# File 'lib/plaid/internal/multipart/multipart_form_data.rb', line 9 def parts @parts end |
Instance Method Details
#add(name:, value:, content_type: nil) ⇒ self
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.
Adds a new part to the multipart form data.
25 26 27 28 |
# File 'lib/plaid/internal/multipart/multipart_form_data.rb', line 25 def add(name:, value:, content_type: nil) headers = content_type ? { "Content-Type" => content_type } : nil add_part(FormDataPart.new(name:, value:, headers:)) end |
#add_file(name:, file:, filename: nil, content_type: nil) ⇒ self
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.
Adds a file to the multipart form data.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/plaid/internal/multipart/multipart_form_data.rb', line 38 def add_file(name:, file:, filename: nil, content_type: nil) headers = content_type ? { "Content-Type" => content_type } : nil if file.is_a?(::String) filename ||= ::File.basename(file) file = ::File.binread(file) else filename ||= filename_for(file) || name end add_part(FormDataPart.new(name:, value: file, filename:, headers:)) end |
#add_part(part) ⇒ self
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.
Adds a pre-created part to the multipart form data.
53 54 55 56 |
# File 'lib/plaid/internal/multipart/multipart_form_data.rb', line 53 def add_part(part) @parts << part self end |
#content_type ⇒ String
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.
Gets the content type string including the boundary.
61 62 63 |
# File 'lib/plaid/internal/multipart/multipart_form_data.rb', line 61 def content_type @encoder.content_type end |
#encode ⇒ String
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.
Encode the multipart form data into a multipart/form-data payload.
68 69 70 |
# File 'lib/plaid/internal/multipart/multipart_form_data.rb', line 68 def encode @encoder.encode(self) end |