conekta 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -8
  3. data/VERSION +1 -1
  4. data/config-ruby.json +1 -1
  5. data/docs/ChargesApi.md +2 -2
  6. data/docs/CheckoutOrderTemplate.md +2 -0
  7. data/docs/CheckoutRequest.md +3 -1
  8. data/docs/CheckoutResponse.md +2 -0
  9. data/docs/CompaniesApi.md +296 -0
  10. data/docs/CompanyDocumentRequest.md +26 -0
  11. data/docs/CompanyDocumentResponse.md +22 -0
  12. data/docs/CompanyResponse.md +18 -16
  13. data/docs/CompanyResponseDocumentsInner.md +22 -0
  14. data/docs/CreateCompanyRequest.md +26 -0
  15. data/docs/CreateCompanyRequestBankAccountInfo.md +18 -0
  16. data/docs/CreateCompanyRequestComercialInfo.md +24 -0
  17. data/docs/CreateCompanyRequestFiscalInfo.md +20 -0
  18. data/docs/PaymentMethodBnplRequest.md +1 -1
  19. data/docs/PaymentMethodSpeiRecurrent.md +2 -0
  20. data/examples/README.md +15 -0
  21. data/examples/one_time_charge_bnpl.rb +46 -0
  22. data/lib/conekta/api/companies_api.rb +300 -0
  23. data/lib/conekta/models/checkout_order_template.rb +13 -1
  24. data/lib/conekta/models/checkout_request.rb +36 -2
  25. data/lib/conekta/models/checkout_response.rb +13 -1
  26. data/lib/conekta/models/company_document_request.rb +318 -0
  27. data/lib/conekta/models/company_document_response.rb +291 -0
  28. data/lib/conekta/models/company_response.rb +110 -74
  29. data/lib/conekta/models/company_response_documents_inner.rb +270 -0
  30. data/lib/conekta/models/create_company_request.rb +252 -0
  31. data/lib/conekta/models/create_company_request_bank_account_info.rb +216 -0
  32. data/lib/conekta/models/create_company_request_comercial_info.rb +246 -0
  33. data/lib/conekta/models/create_company_request_fiscal_info.rb +226 -0
  34. data/lib/conekta/models/payment_method_bnpl_request.rb +2 -2
  35. data/lib/conekta/models/payment_method_spei_recurrent.rb +11 -1
  36. data/lib/conekta/version.rb +1 -1
  37. data/lib/conekta.rb +7 -3
  38. data/spec/api/companies_api_spec.rb +53 -0
  39. metadata +35 -22
  40. data/docs/CompanyFiscalInfoAddressResponse.md +0 -34
  41. data/docs/CompanyFiscalInfoResponse.md +0 -30
  42. data/docs/CompanyPayoutDestinationResponse.md +0 -28
@@ -0,0 +1,318 @@
1
+ =begin
2
+ #Conekta API
3
+
4
+ #Conekta sdk
5
+
6
+ The version of the OpenAPI document: 2.2.0
7
+ Contact: engineering@conekta.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Conekta
17
+ # Request body for uploading a company document.
18
+ class CompanyDocumentRequest
19
+ # Classification of the document. | Tipo de archivo | Descripción | | :--------------------------- | :-------------------------------------------------------- | | `id_legal_representative` | identificación oficial frente | | `id_legal_representative_back` | identificación oficial atrás | | `cfdi` | Prueba de situación fiscal | | `constitutive_act_basic` | Acta constitutiva | | `proof_of_address` | Comprobante de domicilio del negocio | | `power_of_attonery` | Poderes de representación | | `deposit_account_cover` | Carátula de la cuenta de depósito | | `permit_casino` | Permiso ante SEGOB | | `license_sanitation` | Licencia sanitaria de COFEPRIS | | `registration_tourism` | Inscripción ante el Registro Nacional de Turismo (SECTUR) |
20
+ attr_accessor :file_classification
21
+
22
+ # MIME type of the file. Allowed values depend on the `file_classification`. - `image/jpeg` - `image/png` - `application/pdf`
23
+ attr_accessor :content_type
24
+
25
+ # Indicates if the document is international. Defaults to false.
26
+ attr_accessor :international
27
+
28
+ # Name of the file being uploaded.
29
+ attr_accessor :file_name
30
+
31
+ # Base64 encoded content of the file.
32
+ attr_accessor :file_data
33
+
34
+ class EnumAttributeValidator
35
+ attr_reader :datatype
36
+ attr_reader :allowable_values
37
+
38
+ def initialize(datatype, allowable_values)
39
+ @allowable_values = allowable_values.map do |value|
40
+ case datatype.to_s
41
+ when /Integer/i
42
+ value.to_i
43
+ when /Float/i
44
+ value.to_f
45
+ else
46
+ value
47
+ end
48
+ end
49
+ end
50
+
51
+ def valid?(value)
52
+ !value || allowable_values.include?(value)
53
+ end
54
+ end
55
+
56
+ # Attribute mapping from ruby-style variable name to JSON key.
57
+ def self.attribute_map
58
+ {
59
+ :'file_classification' => :'file_classification',
60
+ :'content_type' => :'content_type',
61
+ :'international' => :'international',
62
+ :'file_name' => :'file_name',
63
+ :'file_data' => :'file_data'
64
+ }
65
+ end
66
+
67
+ # Returns all the JSON keys this model knows about
68
+ def self.acceptable_attributes
69
+ attribute_map.values
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.openapi_types
74
+ {
75
+ :'file_classification' => :'String',
76
+ :'content_type' => :'String',
77
+ :'international' => :'Boolean',
78
+ :'file_name' => :'String',
79
+ :'file_data' => :'String'
80
+ }
81
+ end
82
+
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new([
86
+ ])
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ if (!attributes.is_a?(Hash))
93
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Conekta::CompanyDocumentRequest` initialize method"
94
+ end
95
+
96
+ # check to see if the attribute exists and convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}) { |(k, v), h|
98
+ if (!self.class.attribute_map.key?(k.to_sym))
99
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Conekta::CompanyDocumentRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
100
+ end
101
+ h[k.to_sym] = v
102
+ }
103
+
104
+ if attributes.key?(:'file_classification')
105
+ self.file_classification = attributes[:'file_classification']
106
+ else
107
+ self.file_classification = nil
108
+ end
109
+
110
+ if attributes.key?(:'content_type')
111
+ self.content_type = attributes[:'content_type']
112
+ else
113
+ self.content_type = nil
114
+ end
115
+
116
+ if attributes.key?(:'international')
117
+ self.international = attributes[:'international']
118
+ end
119
+
120
+ if attributes.key?(:'file_name')
121
+ self.file_name = attributes[:'file_name']
122
+ else
123
+ self.file_name = nil
124
+ end
125
+
126
+ if attributes.key?(:'file_data')
127
+ self.file_data = attributes[:'file_data']
128
+ else
129
+ self.file_data = nil
130
+ end
131
+ end
132
+
133
+ # Show invalid properties with the reasons. Usually used together with valid?
134
+ # @return Array for valid properties with the reasons
135
+ def list_invalid_properties
136
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
137
+ invalid_properties = Array.new
138
+ if @file_classification.nil?
139
+ invalid_properties.push('invalid value for "file_classification", file_classification cannot be nil.')
140
+ end
141
+
142
+ if @content_type.nil?
143
+ invalid_properties.push('invalid value for "content_type", content_type cannot be nil.')
144
+ end
145
+
146
+ if @file_name.nil?
147
+ invalid_properties.push('invalid value for "file_name", file_name cannot be nil.')
148
+ end
149
+
150
+ if @file_data.nil?
151
+ invalid_properties.push('invalid value for "file_data", file_data cannot be nil.')
152
+ end
153
+
154
+ invalid_properties
155
+ end
156
+
157
+ # Check to see if the all the properties in the model are valid
158
+ # @return true if the model is valid
159
+ def valid?
160
+ warn '[DEPRECATED] the `valid?` method is obsolete'
161
+ return false if @file_classification.nil?
162
+ file_classification_validator = EnumAttributeValidator.new('String', ["id_legal_representative", "id_legal_representative_back", "cfdi", "constitutive_act_basic", "proof_of_address", "power_of_attonery", "deposit_account_cover", "permit_casino", "license_sanitation", "registration_tourism"])
163
+ return false unless file_classification_validator.valid?(@file_classification)
164
+ return false if @content_type.nil?
165
+ return false if @file_name.nil?
166
+ return false if @file_data.nil?
167
+ true
168
+ end
169
+
170
+ # Custom attribute writer method checking allowed values (enum).
171
+ # @param [Object] file_classification Object to be assigned
172
+ def file_classification=(file_classification)
173
+ validator = EnumAttributeValidator.new('String', ["id_legal_representative", "id_legal_representative_back", "cfdi", "constitutive_act_basic", "proof_of_address", "power_of_attonery", "deposit_account_cover", "permit_casino", "license_sanitation", "registration_tourism"])
174
+ unless validator.valid?(file_classification)
175
+ fail ArgumentError, "invalid value for \"file_classification\", must be one of #{validator.allowable_values}."
176
+ end
177
+ @file_classification = file_classification
178
+ end
179
+
180
+ # Checks equality by comparing each attribute.
181
+ # @param [Object] Object to be compared
182
+ def ==(o)
183
+ return true if self.equal?(o)
184
+ self.class == o.class &&
185
+ file_classification == o.file_classification &&
186
+ content_type == o.content_type &&
187
+ international == o.international &&
188
+ file_name == o.file_name &&
189
+ file_data == o.file_data
190
+ end
191
+
192
+ # @see the `==` method
193
+ # @param [Object] Object to be compared
194
+ def eql?(o)
195
+ self == o
196
+ end
197
+
198
+ # Calculates hash code according to all attributes.
199
+ # @return [Integer] Hash code
200
+ def hash
201
+ [file_classification, content_type, international, file_name, file_data].hash
202
+ end
203
+
204
+ # Builds the object from hash
205
+ # @param [Hash] attributes Model attributes in the form of hash
206
+ # @return [Object] Returns the model itself
207
+ def self.build_from_hash(attributes)
208
+ return nil unless attributes.is_a?(Hash)
209
+ attributes = attributes.transform_keys(&:to_sym)
210
+ transformed_hash = {}
211
+ openapi_types.each_pair do |key, type|
212
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
213
+ transformed_hash["#{key}"] = nil
214
+ elsif type =~ /\AArray<(.*)>/i
215
+ # check to ensure the input is an array given that the attribute
216
+ # is documented as an array but the input is not
217
+ if attributes[attribute_map[key]].is_a?(Array)
218
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
219
+ end
220
+ elsif !attributes[attribute_map[key]].nil?
221
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
222
+ end
223
+ end
224
+ new(transformed_hash)
225
+ end
226
+
227
+ # Deserializes the data based on type
228
+ # @param string type Data type
229
+ # @param string value Value to be deserialized
230
+ # @return [Object] Deserialized data
231
+ def self._deserialize(type, value)
232
+ case type.to_sym
233
+ when :Time
234
+ Time.parse(value)
235
+ when :Date
236
+ Date.parse(value)
237
+ when :String
238
+ value.to_s
239
+ when :Integer
240
+ value.to_i
241
+ when :Float
242
+ value.to_f
243
+ when :Boolean
244
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
245
+ true
246
+ else
247
+ false
248
+ end
249
+ when :Object
250
+ # generic object (usually a Hash), return directly
251
+ value
252
+ when /\AArray<(?<inner_type>.+)>\z/
253
+ inner_type = Regexp.last_match[:inner_type]
254
+ value.map { |v| _deserialize(inner_type, v) }
255
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
256
+ k_type = Regexp.last_match[:k_type]
257
+ v_type = Regexp.last_match[:v_type]
258
+ {}.tap do |hash|
259
+ value.each do |k, v|
260
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
261
+ end
262
+ end
263
+ else # model
264
+ # models (e.g. Pet) or oneOf
265
+ klass = Conekta.const_get(type)
266
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
267
+ end
268
+ end
269
+
270
+ # Returns the string representation of the object
271
+ # @return [String] String presentation of the object
272
+ def to_s
273
+ to_hash.to_s
274
+ end
275
+
276
+ # to_body is an alias to to_hash (backward compatibility)
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_body
279
+ to_hash
280
+ end
281
+
282
+ # Returns the object in the form of hash
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_hash
285
+ hash = {}
286
+ self.class.attribute_map.each_pair do |attr, param|
287
+ value = self.send(attr)
288
+ if value.nil?
289
+ is_nullable = self.class.openapi_nullable.include?(attr)
290
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
291
+ end
292
+
293
+ hash[param] = _to_hash(value)
294
+ end
295
+ hash
296
+ end
297
+
298
+ # Outputs non-array value in the form of hash
299
+ # For object, use to_hash. Otherwise, just return the value
300
+ # @param [Object] value Any valid value
301
+ # @return [Hash] Returns the value in the form of hash
302
+ def _to_hash(value)
303
+ if value.is_a?(Array)
304
+ value.compact.map { |v| _to_hash(v) }
305
+ elsif value.is_a?(Hash)
306
+ {}.tap do |hash|
307
+ value.each { |k, v| hash[k] = _to_hash(v) }
308
+ end
309
+ elsif value.respond_to? :to_hash
310
+ value.to_hash
311
+ else
312
+ value
313
+ end
314
+ end
315
+
316
+ end
317
+
318
+ end
@@ -0,0 +1,291 @@
1
+ =begin
2
+ #Conekta API
3
+
4
+ #Conekta sdk
5
+
6
+ The version of the OpenAPI document: 2.2.0
7
+ Contact: engineering@conekta.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Conekta
17
+ # Response body after uploading a company document.
18
+ class CompanyDocumentResponse
19
+ # Classification of the document. | Tipo de archivo | Descripción | | :--------------------------- | :-------------------------------------------------------- | | `id_legal_representative` | identificación oficial frente | | `id_legal_representative_back` | identificación oficial atrás | | `cfdi` | Prueba de situación fiscal | | `constitutive_act_basic` | Acta constitutiva | | `proof_of_address` | Comprobante de domicilio del negocio | | `power_of_attonery` | Poderes de representación | | `deposit_account_cover` | Carátula de la cuenta de depósito | | `permit_casino` | Permiso ante SEGOB | | `license_sanitation` | Licencia sanitaria de COFEPRIS | | `registration_tourism` | Inscripción ante el Registro Nacional de Turismo (SECTUR) |
20
+ attr_accessor :file_classification
21
+
22
+ # Name of the file as stored or processed.
23
+ attr_accessor :file_name
24
+
25
+ # Current status of the document.
26
+ attr_accessor :status
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'file_classification' => :'file_classification',
54
+ :'file_name' => :'file_name',
55
+ :'status' => :'status'
56
+ }
57
+ end
58
+
59
+ # Returns all the JSON keys this model knows about
60
+ def self.acceptable_attributes
61
+ attribute_map.values
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.openapi_types
66
+ {
67
+ :'file_classification' => :'String',
68
+ :'file_name' => :'String',
69
+ :'status' => :'String'
70
+ }
71
+ end
72
+
73
+ # List of attributes with nullable: true
74
+ def self.openapi_nullable
75
+ Set.new([
76
+ ])
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ if (!attributes.is_a?(Hash))
83
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Conekta::CompanyDocumentResponse` initialize method"
84
+ end
85
+
86
+ # check to see if the attribute exists and convert string to symbol for hash key
87
+ attributes = attributes.each_with_object({}) { |(k, v), h|
88
+ if (!self.class.attribute_map.key?(k.to_sym))
89
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Conekta::CompanyDocumentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
90
+ end
91
+ h[k.to_sym] = v
92
+ }
93
+
94
+ if attributes.key?(:'file_classification')
95
+ self.file_classification = attributes[:'file_classification']
96
+ else
97
+ self.file_classification = nil
98
+ end
99
+
100
+ if attributes.key?(:'file_name')
101
+ self.file_name = attributes[:'file_name']
102
+ else
103
+ self.file_name = nil
104
+ end
105
+
106
+ if attributes.key?(:'status')
107
+ self.status = attributes[:'status']
108
+ else
109
+ self.status = nil
110
+ end
111
+ end
112
+
113
+ # Show invalid properties with the reasons. Usually used together with valid?
114
+ # @return Array for valid properties with the reasons
115
+ def list_invalid_properties
116
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
117
+ invalid_properties = Array.new
118
+ if @file_classification.nil?
119
+ invalid_properties.push('invalid value for "file_classification", file_classification cannot be nil.')
120
+ end
121
+
122
+ if @file_name.nil?
123
+ invalid_properties.push('invalid value for "file_name", file_name cannot be nil.')
124
+ end
125
+
126
+ if @status.nil?
127
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
128
+ end
129
+
130
+ invalid_properties
131
+ end
132
+
133
+ # Check to see if the all the properties in the model are valid
134
+ # @return true if the model is valid
135
+ def valid?
136
+ warn '[DEPRECATED] the `valid?` method is obsolete'
137
+ return false if @file_classification.nil?
138
+ file_classification_validator = EnumAttributeValidator.new('String', ["id_legal_representative", "id_legal_representative_back", "cfdi", "constitutive_act_basic", "proof_of_address", "power_of_attonery", "deposit_account_cover", "permit_casino", "license_sanitation", "registration_tourism"])
139
+ return false unless file_classification_validator.valid?(@file_classification)
140
+ return false if @file_name.nil?
141
+ return false if @status.nil?
142
+ true
143
+ end
144
+
145
+ # Custom attribute writer method checking allowed values (enum).
146
+ # @param [Object] file_classification Object to be assigned
147
+ def file_classification=(file_classification)
148
+ validator = EnumAttributeValidator.new('String', ["id_legal_representative", "id_legal_representative_back", "cfdi", "constitutive_act_basic", "proof_of_address", "power_of_attonery", "deposit_account_cover", "permit_casino", "license_sanitation", "registration_tourism"])
149
+ unless validator.valid?(file_classification)
150
+ fail ArgumentError, "invalid value for \"file_classification\", must be one of #{validator.allowable_values}."
151
+ end
152
+ @file_classification = file_classification
153
+ end
154
+
155
+ # Checks equality by comparing each attribute.
156
+ # @param [Object] Object to be compared
157
+ def ==(o)
158
+ return true if self.equal?(o)
159
+ self.class == o.class &&
160
+ file_classification == o.file_classification &&
161
+ file_name == o.file_name &&
162
+ status == o.status
163
+ end
164
+
165
+ # @see the `==` method
166
+ # @param [Object] Object to be compared
167
+ def eql?(o)
168
+ self == o
169
+ end
170
+
171
+ # Calculates hash code according to all attributes.
172
+ # @return [Integer] Hash code
173
+ def hash
174
+ [file_classification, file_name, status].hash
175
+ end
176
+
177
+ # Builds the object from hash
178
+ # @param [Hash] attributes Model attributes in the form of hash
179
+ # @return [Object] Returns the model itself
180
+ def self.build_from_hash(attributes)
181
+ return nil unless attributes.is_a?(Hash)
182
+ attributes = attributes.transform_keys(&:to_sym)
183
+ transformed_hash = {}
184
+ openapi_types.each_pair do |key, type|
185
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
186
+ transformed_hash["#{key}"] = nil
187
+ elsif type =~ /\AArray<(.*)>/i
188
+ # check to ensure the input is an array given that the attribute
189
+ # is documented as an array but the input is not
190
+ if attributes[attribute_map[key]].is_a?(Array)
191
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
192
+ end
193
+ elsif !attributes[attribute_map[key]].nil?
194
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
195
+ end
196
+ end
197
+ new(transformed_hash)
198
+ end
199
+
200
+ # Deserializes the data based on type
201
+ # @param string type Data type
202
+ # @param string value Value to be deserialized
203
+ # @return [Object] Deserialized data
204
+ def self._deserialize(type, value)
205
+ case type.to_sym
206
+ when :Time
207
+ Time.parse(value)
208
+ when :Date
209
+ Date.parse(value)
210
+ when :String
211
+ value.to_s
212
+ when :Integer
213
+ value.to_i
214
+ when :Float
215
+ value.to_f
216
+ when :Boolean
217
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
218
+ true
219
+ else
220
+ false
221
+ end
222
+ when :Object
223
+ # generic object (usually a Hash), return directly
224
+ value
225
+ when /\AArray<(?<inner_type>.+)>\z/
226
+ inner_type = Regexp.last_match[:inner_type]
227
+ value.map { |v| _deserialize(inner_type, v) }
228
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
229
+ k_type = Regexp.last_match[:k_type]
230
+ v_type = Regexp.last_match[:v_type]
231
+ {}.tap do |hash|
232
+ value.each do |k, v|
233
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
234
+ end
235
+ end
236
+ else # model
237
+ # models (e.g. Pet) or oneOf
238
+ klass = Conekta.const_get(type)
239
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
240
+ end
241
+ end
242
+
243
+ # Returns the string representation of the object
244
+ # @return [String] String presentation of the object
245
+ def to_s
246
+ to_hash.to_s
247
+ end
248
+
249
+ # to_body is an alias to to_hash (backward compatibility)
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_body
252
+ to_hash
253
+ end
254
+
255
+ # Returns the object in the form of hash
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_hash
258
+ hash = {}
259
+ self.class.attribute_map.each_pair do |attr, param|
260
+ value = self.send(attr)
261
+ if value.nil?
262
+ is_nullable = self.class.openapi_nullable.include?(attr)
263
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
264
+ end
265
+
266
+ hash[param] = _to_hash(value)
267
+ end
268
+ hash
269
+ end
270
+
271
+ # Outputs non-array value in the form of hash
272
+ # For object, use to_hash. Otherwise, just return the value
273
+ # @param [Object] value Any valid value
274
+ # @return [Hash] Returns the value in the form of hash
275
+ def _to_hash(value)
276
+ if value.is_a?(Array)
277
+ value.compact.map { |v| _to_hash(v) }
278
+ elsif value.is_a?(Hash)
279
+ {}.tap do |hash|
280
+ value.each { |k, v| hash[k] = _to_hash(v) }
281
+ end
282
+ elsif value.respond_to? :to_hash
283
+ value.to_hash
284
+ else
285
+ value
286
+ end
287
+ end
288
+
289
+ end
290
+
291
+ end