Class: Merge::Filestorage::MultipartFormFieldRequest
- Inherits:
-
Object
- Object
- Merge::Filestorage::MultipartFormFieldRequest
- Defined in:
- lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb
Overview
# The MultipartFormField Object
### Description
The `MultipartFormField` object is used to represent fields in an HTTP request
using `multipart/form-data`.
### Usage Example
Create a `MultipartFormField` to define a multipart form entry.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#content_type ⇒ String
readonly
The MIME type of the file, if the field is for a file.
-
#data ⇒ String
readonly
The data for the form field.
-
#encoding ⇒ Merge::Filestorage::EncodingEnum
readonly
The encoding of the value of ‘data`.
-
#file_name ⇒ String
readonly
The file name of the form field, if the field is for a file.
-
#name ⇒ String
readonly
The name of the form field.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Filestorage::MultipartFormFieldRequest
Deserialize a JSON object to an instance of MultipartFormFieldRequest.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(name:, data:, encoding: OMIT, file_name: OMIT, content_type: OMIT, additional_properties: nil) ⇒ Merge::Filestorage::MultipartFormFieldRequest constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of MultipartFormFieldRequest to a JSON object.
Constructor Details
#initialize(name:, data:, encoding: OMIT, file_name: OMIT, content_type: OMIT, additional_properties: nil) ⇒ Merge::Filestorage::MultipartFormFieldRequest
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 47 def initialize(name:, data:, encoding: OMIT, file_name: OMIT, content_type: OMIT, additional_properties: nil) @name = name @data = data @encoding = encoding if encoding != OMIT @file_name = file_name if file_name != OMIT @content_type = content_type if content_type != OMIT @additional_properties = additional_properties @_field_set = { "name": name, "data": data, "encoding": encoding, "file_name": file_name, "content_type": content_type }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
30 31 32 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 30 def additional_properties @additional_properties end |
#content_type ⇒ String (readonly)
Returns The MIME type of the file, if the field is for a file.
28 29 30 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 28 def content_type @content_type end |
#data ⇒ String (readonly)
Returns The data for the form field.
19 20 21 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 19 def data @data end |
#encoding ⇒ Merge::Filestorage::EncodingEnum (readonly)
Returns The encoding of the value of ‘data`. Defaults to `RAW` if not defined.
-
‘RAW` - RAW
-
‘BASE64` - BASE64
-
‘GZIP_BASE64` - GZIP_BASE64.
24 25 26 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 24 def encoding @encoding end |
#file_name ⇒ String (readonly)
Returns The file name of the form field, if the field is for a file.
26 27 28 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 26 def file_name @file_name end |
#name ⇒ String (readonly)
Returns The name of the form field.
17 18 19 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 17 def name @name end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Filestorage::MultipartFormFieldRequest
Deserialize a JSON object to an instance of MultipartFormFieldRequest
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 69 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) name = parsed_json["name"] data = parsed_json["data"] encoding = parsed_json["encoding"] file_name = parsed_json["file_name"] content_type = parsed_json["content_type"] new( name: name, data: data, encoding: encoding, file_name: file_name, content_type: content_type, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
100 101 102 103 104 105 106 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 100 def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.data.is_a?(String) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") obj.encoding&.is_a?(Merge::Filestorage::EncodingEnum) != false || raise("Passed value for field obj.encoding is not the expected type, validation failed.") obj.file_name&.is_a?(String) != false || raise("Passed value for field obj.file_name is not the expected type, validation failed.") obj.content_type&.is_a?(String) != false || raise("Passed value for field obj.content_type is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of MultipartFormFieldRequest to a JSON object
90 91 92 |
# File 'lib/merge_ruby_client/filestorage/types/multipart_form_field_request.rb', line 90 def to_json(*_args) @_field_set&.to_json end |