conekta 7.0.2 → 7.0.3

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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -5
  3. data/VERSION +1 -1
  4. data/config-ruby.json +1 -1
  5. data/docs/ChargeOrderResponsePaymentMethod.md +5 -2
  6. data/docs/ChargeRequestPaymentMethod.md +3 -1
  7. data/docs/ChargeResponsePaymentMethod.md +5 -2
  8. data/docs/CompaniesApi.md +2 -2
  9. data/docs/CompanyDocumentRequest.md +1 -1
  10. data/docs/CreateCustomerPaymentMethodsResponse.md +3 -2
  11. data/docs/CustomerPaymentMethodRequest.md +1 -1
  12. data/docs/CustomerPaymentMethodsData.md +3 -2
  13. data/docs/EventsResendResponse.md +1 -1
  14. data/docs/GetCustomerPaymentMethodDataResponse.md +3 -2
  15. data/docs/OrderResponseCheckout.md +1 -1
  16. data/docs/PaymentMethodCardRequest.md +1 -1
  17. data/docs/PaymentMethodCashRecurrentResponse.md +38 -0
  18. data/docs/PaymentMethodCashRequest.md +1 -1
  19. data/docs/PaymentMethodPbbPayment.md +30 -0
  20. data/docs/PaymentMethodPbbRequest.md +22 -0
  21. data/docs/PaymentMethodSpeiRequest.md +1 -1
  22. data/docs/PaymentMethodTokenRequest.md +1 -1
  23. data/docs/PaymentMethodsApi.md +1 -1
  24. data/docs/UpdateCustomerPaymentMethodsResponse.md +3 -2
  25. data/docs/UpdatePaymentMethods.md +4 -2
  26. data/docs/WebhookLog.md +1 -1
  27. data/docs/WebhookResponse.md +1 -1
  28. data/examples/one_time_charge_bnpl.rb +3 -0
  29. data/examples/one_time_charge_pbb.rb +47 -0
  30. data/lib/conekta/models/charge_order_response_payment_method.rb +4 -2
  31. data/lib/conekta/models/charge_request_payment_method.rb +2 -1
  32. data/lib/conekta/models/charge_response_payment_method.rb +4 -2
  33. data/lib/conekta/models/create_customer_payment_methods_response.rb +2 -2
  34. data/lib/conekta/models/customer_payment_methods_data.rb +2 -2
  35. data/lib/conekta/models/get_customer_payment_method_data_response.rb +2 -2
  36. data/lib/conekta/models/payment_method_cash_recurrent_response.rb +343 -0
  37. data/lib/conekta/models/payment_method_pbb_payment.rb +341 -0
  38. data/lib/conekta/models/payment_method_pbb_request.rb +309 -0
  39. data/lib/conekta/models/update_customer_payment_methods_response.rb +2 -2
  40. data/lib/conekta/models/update_payment_methods.rb +34 -4
  41. data/lib/conekta/version.rb +1 -1
  42. data/lib/conekta.rb +3 -0
  43. metadata +9 -2
@@ -20,6 +20,7 @@ module Conekta
20
20
  def openapi_one_of
21
21
  [
22
22
  :'PaymentMethodCardResponse',
23
+ :'PaymentMethodCashRecurrentResponse',
23
24
  :'PaymentMethodCashResponse',
24
25
  :'PaymentMethodSpeiRecurrent'
25
26
  ]
@@ -35,8 +36,7 @@ module Conekta
35
36
  {
36
37
  :'card' => :'PaymentMethodCardResponse',
37
38
  :'cash' => :'PaymentMethodCashResponse',
38
- :'cash_recurrent' => :'PaymentMethodCashResponse',
39
- :'oxxo_recurrent' => :'PaymentMethodCashResponse',
39
+ :'cash_recurrent' => :'PaymentMethodCashRecurrentResponse',
40
40
  :'spei_recurrent' => :'PaymentMethodSpeiRecurrent'
41
41
  }
42
42
  end
@@ -0,0 +1,343 @@
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
+ # Alias of cash response used when type=cash_recurrent
18
+ class PaymentMethodCashRecurrentResponse
19
+ attr_accessor :type
20
+
21
+ attr_accessor :id
22
+
23
+ attr_accessor :object
24
+
25
+ attr_accessor :created_at
26
+
27
+ attr_accessor :parent_id
28
+
29
+ attr_accessor :agreements
30
+
31
+ attr_accessor :reference
32
+
33
+ attr_accessor :barcode
34
+
35
+ # URL to the barcode image, reference is the same as barcode
36
+ attr_accessor :barcode_url
37
+
38
+ attr_accessor :expires_at
39
+
40
+ attr_accessor :provider
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'type' => :'type',
46
+ :'id' => :'id',
47
+ :'object' => :'object',
48
+ :'created_at' => :'created_at',
49
+ :'parent_id' => :'parent_id',
50
+ :'agreements' => :'agreements',
51
+ :'reference' => :'reference',
52
+ :'barcode' => :'barcode',
53
+ :'barcode_url' => :'barcode_url',
54
+ :'expires_at' => :'expires_at',
55
+ :'provider' => :'provider'
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
+ :'type' => :'String',
68
+ :'id' => :'String',
69
+ :'object' => :'String',
70
+ :'created_at' => :'Integer',
71
+ :'parent_id' => :'String',
72
+ :'agreements' => :'Array<PaymentMethodCashResponseAllOfAgreements>',
73
+ :'reference' => :'String',
74
+ :'barcode' => :'String',
75
+ :'barcode_url' => :'String',
76
+ :'expires_at' => :'Integer',
77
+ :'provider' => :'String'
78
+ }
79
+ end
80
+
81
+ # List of attributes with nullable: true
82
+ def self.openapi_nullable
83
+ Set.new([
84
+ ])
85
+ end
86
+
87
+ # List of class defined in allOf (OpenAPI v3)
88
+ def self.openapi_all_of
89
+ [
90
+ :'PaymentMethodCashResponse'
91
+ ]
92
+ end
93
+
94
+ # Initializes the object
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ def initialize(attributes = {})
97
+ if (!attributes.is_a?(Hash))
98
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Conekta::PaymentMethodCashRecurrentResponse` initialize method"
99
+ end
100
+
101
+ # check to see if the attribute exists and convert string to symbol for hash key
102
+ attributes = attributes.each_with_object({}) { |(k, v), h|
103
+ if (!self.class.attribute_map.key?(k.to_sym))
104
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Conekta::PaymentMethodCashRecurrentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
105
+ end
106
+ h[k.to_sym] = v
107
+ }
108
+
109
+ if attributes.key?(:'type')
110
+ self.type = attributes[:'type']
111
+ else
112
+ self.type = nil
113
+ end
114
+
115
+ if attributes.key?(:'id')
116
+ self.id = attributes[:'id']
117
+ else
118
+ self.id = nil
119
+ end
120
+
121
+ if attributes.key?(:'object')
122
+ self.object = attributes[:'object']
123
+ else
124
+ self.object = nil
125
+ end
126
+
127
+ if attributes.key?(:'created_at')
128
+ self.created_at = attributes[:'created_at']
129
+ else
130
+ self.created_at = nil
131
+ end
132
+
133
+ if attributes.key?(:'parent_id')
134
+ self.parent_id = attributes[:'parent_id']
135
+ end
136
+
137
+ if attributes.key?(:'agreements')
138
+ if (value = attributes[:'agreements']).is_a?(Array)
139
+ self.agreements = value
140
+ end
141
+ end
142
+
143
+ if attributes.key?(:'reference')
144
+ self.reference = attributes[:'reference']
145
+ end
146
+
147
+ if attributes.key?(:'barcode')
148
+ self.barcode = attributes[:'barcode']
149
+ end
150
+
151
+ if attributes.key?(:'barcode_url')
152
+ self.barcode_url = attributes[:'barcode_url']
153
+ end
154
+
155
+ if attributes.key?(:'expires_at')
156
+ self.expires_at = attributes[:'expires_at']
157
+ end
158
+
159
+ if attributes.key?(:'provider')
160
+ self.provider = attributes[:'provider']
161
+ end
162
+ end
163
+
164
+ # Show invalid properties with the reasons. Usually used together with valid?
165
+ # @return Array for valid properties with the reasons
166
+ def list_invalid_properties
167
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
168
+ invalid_properties = Array.new
169
+ if @type.nil?
170
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
171
+ end
172
+
173
+ if @id.nil?
174
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
175
+ end
176
+
177
+ if @object.nil?
178
+ invalid_properties.push('invalid value for "object", object cannot be nil.')
179
+ end
180
+
181
+ if @created_at.nil?
182
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
183
+ end
184
+
185
+ invalid_properties
186
+ end
187
+
188
+ # Check to see if the all the properties in the model are valid
189
+ # @return true if the model is valid
190
+ def valid?
191
+ warn '[DEPRECATED] the `valid?` method is obsolete'
192
+ return false if @type.nil?
193
+ return false if @id.nil?
194
+ return false if @object.nil?
195
+ return false if @created_at.nil?
196
+ true
197
+ end
198
+
199
+ # Checks equality by comparing each attribute.
200
+ # @param [Object] Object to be compared
201
+ def ==(o)
202
+ return true if self.equal?(o)
203
+ self.class == o.class &&
204
+ type == o.type &&
205
+ id == o.id &&
206
+ object == o.object &&
207
+ created_at == o.created_at &&
208
+ parent_id == o.parent_id &&
209
+ agreements == o.agreements &&
210
+ reference == o.reference &&
211
+ barcode == o.barcode &&
212
+ barcode_url == o.barcode_url &&
213
+ expires_at == o.expires_at &&
214
+ provider == o.provider
215
+ end
216
+
217
+ # @see the `==` method
218
+ # @param [Object] Object to be compared
219
+ def eql?(o)
220
+ self == o
221
+ end
222
+
223
+ # Calculates hash code according to all attributes.
224
+ # @return [Integer] Hash code
225
+ def hash
226
+ [type, id, object, created_at, parent_id, agreements, reference, barcode, barcode_url, expires_at, provider].hash
227
+ end
228
+
229
+ # Builds the object from hash
230
+ # @param [Hash] attributes Model attributes in the form of hash
231
+ # @return [Object] Returns the model itself
232
+ def self.build_from_hash(attributes)
233
+ return nil unless attributes.is_a?(Hash)
234
+ attributes = attributes.transform_keys(&:to_sym)
235
+ transformed_hash = {}
236
+ openapi_types.each_pair do |key, type|
237
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
238
+ transformed_hash["#{key}"] = nil
239
+ elsif type =~ /\AArray<(.*)>/i
240
+ # check to ensure the input is an array given that the attribute
241
+ # is documented as an array but the input is not
242
+ if attributes[attribute_map[key]].is_a?(Array)
243
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
244
+ end
245
+ elsif !attributes[attribute_map[key]].nil?
246
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
247
+ end
248
+ end
249
+ new(transformed_hash)
250
+ end
251
+
252
+ # Deserializes the data based on type
253
+ # @param string type Data type
254
+ # @param string value Value to be deserialized
255
+ # @return [Object] Deserialized data
256
+ def self._deserialize(type, value)
257
+ case type.to_sym
258
+ when :Time
259
+ Time.parse(value)
260
+ when :Date
261
+ Date.parse(value)
262
+ when :String
263
+ value.to_s
264
+ when :Integer
265
+ value.to_i
266
+ when :Float
267
+ value.to_f
268
+ when :Boolean
269
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
270
+ true
271
+ else
272
+ false
273
+ end
274
+ when :Object
275
+ # generic object (usually a Hash), return directly
276
+ value
277
+ when /\AArray<(?<inner_type>.+)>\z/
278
+ inner_type = Regexp.last_match[:inner_type]
279
+ value.map { |v| _deserialize(inner_type, v) }
280
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
281
+ k_type = Regexp.last_match[:k_type]
282
+ v_type = Regexp.last_match[:v_type]
283
+ {}.tap do |hash|
284
+ value.each do |k, v|
285
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
286
+ end
287
+ end
288
+ else # model
289
+ # models (e.g. Pet) or oneOf
290
+ klass = Conekta.const_get(type)
291
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
292
+ end
293
+ end
294
+
295
+ # Returns the string representation of the object
296
+ # @return [String] String presentation of the object
297
+ def to_s
298
+ to_hash.to_s
299
+ end
300
+
301
+ # to_body is an alias to to_hash (backward compatibility)
302
+ # @return [Hash] Returns the object in the form of hash
303
+ def to_body
304
+ to_hash
305
+ end
306
+
307
+ # Returns the object in the form of hash
308
+ # @return [Hash] Returns the object in the form of hash
309
+ def to_hash
310
+ hash = {}
311
+ self.class.attribute_map.each_pair do |attr, param|
312
+ value = self.send(attr)
313
+ if value.nil?
314
+ is_nullable = self.class.openapi_nullable.include?(attr)
315
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
316
+ end
317
+
318
+ hash[param] = _to_hash(value)
319
+ end
320
+ hash
321
+ end
322
+
323
+ # Outputs non-array value in the form of hash
324
+ # For object, use to_hash. Otherwise, just return the value
325
+ # @param [Object] value Any valid value
326
+ # @return [Hash] Returns the value in the form of hash
327
+ def _to_hash(value)
328
+ if value.is_a?(Array)
329
+ value.compact.map { |v| _to_hash(v) }
330
+ elsif value.is_a?(Hash)
331
+ {}.tap do |hash|
332
+ value.each { |k, v| hash[k] = _to_hash(v) }
333
+ end
334
+ elsif value.respond_to? :to_hash
335
+ value.to_hash
336
+ else
337
+ value
338
+ end
339
+ end
340
+
341
+ end
342
+
343
+ end
@@ -0,0 +1,341 @@
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
+ class PaymentMethodPbbPayment
18
+ attr_accessor :type
19
+
20
+ attr_accessor :object
21
+
22
+ # Deep link for the payment, use for mobile apps/flows
23
+ attr_accessor :deep_link
24
+
25
+ # Expiration date of the charge
26
+ attr_accessor :expires_at
27
+
28
+ # Product type of the charge
29
+ attr_accessor :product_type
30
+
31
+ # URL to redirect the customer to complete the payment
32
+ attr_accessor :redirect_url
33
+
34
+ # Reference for the payment
35
+ attr_accessor :reference
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'type' => :'type',
41
+ :'object' => :'object',
42
+ :'deep_link' => :'deep_link',
43
+ :'expires_at' => :'expires_at',
44
+ :'product_type' => :'product_type',
45
+ :'redirect_url' => :'redirect_url',
46
+ :'reference' => :'reference'
47
+ }
48
+ end
49
+
50
+ # Returns all the JSON keys this model knows about
51
+ def self.acceptable_attributes
52
+ attribute_map.values
53
+ end
54
+
55
+ # Attribute type mapping.
56
+ def self.openapi_types
57
+ {
58
+ :'type' => :'String',
59
+ :'object' => :'String',
60
+ :'deep_link' => :'String',
61
+ :'expires_at' => :'Integer',
62
+ :'product_type' => :'String',
63
+ :'redirect_url' => :'String',
64
+ :'reference' => :'String'
65
+ }
66
+ end
67
+
68
+ # List of attributes with nullable: true
69
+ def self.openapi_nullable
70
+ Set.new([
71
+ ])
72
+ end
73
+
74
+ # List of class defined in allOf (OpenAPI v3)
75
+ def self.openapi_all_of
76
+ [
77
+ :'PaymentMethod'
78
+ ]
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Conekta::PaymentMethodPbbPayment` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!self.class.attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Conekta::PaymentMethodPbbPayment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'type')
97
+ self.type = attributes[:'type']
98
+ end
99
+
100
+ if attributes.key?(:'object')
101
+ self.object = attributes[:'object']
102
+ else
103
+ self.object = nil
104
+ end
105
+
106
+ if attributes.key?(:'deep_link')
107
+ self.deep_link = attributes[:'deep_link']
108
+ else
109
+ self.deep_link = nil
110
+ end
111
+
112
+ if attributes.key?(:'expires_at')
113
+ self.expires_at = attributes[:'expires_at']
114
+ else
115
+ self.expires_at = nil
116
+ end
117
+
118
+ if attributes.key?(:'product_type')
119
+ self.product_type = attributes[:'product_type']
120
+ else
121
+ self.product_type = nil
122
+ end
123
+
124
+ if attributes.key?(:'redirect_url')
125
+ self.redirect_url = attributes[:'redirect_url']
126
+ else
127
+ self.redirect_url = nil
128
+ end
129
+
130
+ if attributes.key?(:'reference')
131
+ self.reference = attributes[:'reference']
132
+ else
133
+ self.reference = nil
134
+ end
135
+ end
136
+
137
+ # Show invalid properties with the reasons. Usually used together with valid?
138
+ # @return Array for valid properties with the reasons
139
+ def list_invalid_properties
140
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
141
+ invalid_properties = Array.new
142
+ if @object.nil?
143
+ invalid_properties.push('invalid value for "object", object cannot be nil.')
144
+ end
145
+
146
+ if @deep_link.nil?
147
+ invalid_properties.push('invalid value for "deep_link", deep_link cannot be nil.')
148
+ end
149
+
150
+ if @expires_at.nil?
151
+ invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.')
152
+ end
153
+
154
+ if @expires_at <= 0
155
+ invalid_properties.push('invalid value for "expires_at", must be greater than 0.')
156
+ end
157
+
158
+ if @product_type.nil?
159
+ invalid_properties.push('invalid value for "product_type", product_type cannot be nil.')
160
+ end
161
+
162
+ if @redirect_url.nil?
163
+ invalid_properties.push('invalid value for "redirect_url", redirect_url cannot be nil.')
164
+ end
165
+
166
+ if @reference.nil?
167
+ invalid_properties.push('invalid value for "reference", reference cannot be nil.')
168
+ end
169
+
170
+ invalid_properties
171
+ end
172
+
173
+ # Check to see if the all the properties in the model are valid
174
+ # @return true if the model is valid
175
+ def valid?
176
+ warn '[DEPRECATED] the `valid?` method is obsolete'
177
+ return false if @object.nil?
178
+ return false if @deep_link.nil?
179
+ return false if @expires_at.nil?
180
+ return false if @expires_at <= 0
181
+ return false if @product_type.nil?
182
+ return false if @redirect_url.nil?
183
+ return false if @reference.nil?
184
+ true
185
+ end
186
+
187
+ # Custom attribute writer method with validation
188
+ # @param [Object] expires_at Value to be assigned
189
+ def expires_at=(expires_at)
190
+ if expires_at.nil?
191
+ fail ArgumentError, 'expires_at cannot be nil'
192
+ end
193
+
194
+ if expires_at <= 0
195
+ fail ArgumentError, 'invalid value for "expires_at", must be greater than 0.'
196
+ end
197
+
198
+ @expires_at = expires_at
199
+ end
200
+
201
+ # Checks equality by comparing each attribute.
202
+ # @param [Object] Object to be compared
203
+ def ==(o)
204
+ return true if self.equal?(o)
205
+ self.class == o.class &&
206
+ type == o.type &&
207
+ object == o.object &&
208
+ deep_link == o.deep_link &&
209
+ expires_at == o.expires_at &&
210
+ product_type == o.product_type &&
211
+ redirect_url == o.redirect_url &&
212
+ reference == o.reference
213
+ end
214
+
215
+ # @see the `==` method
216
+ # @param [Object] Object to be compared
217
+ def eql?(o)
218
+ self == o
219
+ end
220
+
221
+ # Calculates hash code according to all attributes.
222
+ # @return [Integer] Hash code
223
+ def hash
224
+ [type, object, deep_link, expires_at, product_type, redirect_url, reference].hash
225
+ end
226
+
227
+ # Builds the object from hash
228
+ # @param [Hash] attributes Model attributes in the form of hash
229
+ # @return [Object] Returns the model itself
230
+ def self.build_from_hash(attributes)
231
+ return nil unless attributes.is_a?(Hash)
232
+ attributes = attributes.transform_keys(&:to_sym)
233
+ transformed_hash = {}
234
+ openapi_types.each_pair do |key, type|
235
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
236
+ transformed_hash["#{key}"] = nil
237
+ elsif type =~ /\AArray<(.*)>/i
238
+ # check to ensure the input is an array given that the attribute
239
+ # is documented as an array but the input is not
240
+ if attributes[attribute_map[key]].is_a?(Array)
241
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
242
+ end
243
+ elsif !attributes[attribute_map[key]].nil?
244
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
245
+ end
246
+ end
247
+ new(transformed_hash)
248
+ end
249
+
250
+ # Deserializes the data based on type
251
+ # @param string type Data type
252
+ # @param string value Value to be deserialized
253
+ # @return [Object] Deserialized data
254
+ def self._deserialize(type, value)
255
+ case type.to_sym
256
+ when :Time
257
+ Time.parse(value)
258
+ when :Date
259
+ Date.parse(value)
260
+ when :String
261
+ value.to_s
262
+ when :Integer
263
+ value.to_i
264
+ when :Float
265
+ value.to_f
266
+ when :Boolean
267
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
268
+ true
269
+ else
270
+ false
271
+ end
272
+ when :Object
273
+ # generic object (usually a Hash), return directly
274
+ value
275
+ when /\AArray<(?<inner_type>.+)>\z/
276
+ inner_type = Regexp.last_match[:inner_type]
277
+ value.map { |v| _deserialize(inner_type, v) }
278
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
279
+ k_type = Regexp.last_match[:k_type]
280
+ v_type = Regexp.last_match[:v_type]
281
+ {}.tap do |hash|
282
+ value.each do |k, v|
283
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
284
+ end
285
+ end
286
+ else # model
287
+ # models (e.g. Pet) or oneOf
288
+ klass = Conekta.const_get(type)
289
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
290
+ end
291
+ end
292
+
293
+ # Returns the string representation of the object
294
+ # @return [String] String presentation of the object
295
+ def to_s
296
+ to_hash.to_s
297
+ end
298
+
299
+ # to_body is an alias to to_hash (backward compatibility)
300
+ # @return [Hash] Returns the object in the form of hash
301
+ def to_body
302
+ to_hash
303
+ end
304
+
305
+ # Returns the object in the form of hash
306
+ # @return [Hash] Returns the object in the form of hash
307
+ def to_hash
308
+ hash = {}
309
+ self.class.attribute_map.each_pair do |attr, param|
310
+ value = self.send(attr)
311
+ if value.nil?
312
+ is_nullable = self.class.openapi_nullable.include?(attr)
313
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
314
+ end
315
+
316
+ hash[param] = _to_hash(value)
317
+ end
318
+ hash
319
+ end
320
+
321
+ # Outputs non-array value in the form of hash
322
+ # For object, use to_hash. Otherwise, just return the value
323
+ # @param [Object] value Any valid value
324
+ # @return [Hash] Returns the value in the form of hash
325
+ def _to_hash(value)
326
+ if value.is_a?(Array)
327
+ value.compact.map { |v| _to_hash(v) }
328
+ elsif value.is_a?(Hash)
329
+ {}.tap do |hash|
330
+ value.each { |k, v| hash[k] = _to_hash(v) }
331
+ end
332
+ elsif value.respond_to? :to_hash
333
+ value.to_hash
334
+ else
335
+ value
336
+ end
337
+ end
338
+
339
+ end
340
+
341
+ end