conekta 6.0.3 → 6.0.5

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -5
  3. data/VERSION +1 -1
  4. data/config-ruby.json +1 -1
  5. data/docs/ChargeRequest.md +1 -1
  6. data/docs/ChargeRequestPaymentMethod.md +39 -18
  7. data/docs/ChargeResponse.md +6 -6
  8. data/docs/ChargesApi.md +79 -1
  9. data/docs/ChargesDataResponse.md +6 -6
  10. data/docs/ChargesOrderResponse.md +22 -0
  11. data/docs/ChargesOrderResponseAllOfData.md +52 -0
  12. data/docs/Checkout.md +2 -0
  13. data/docs/CheckoutRequest.md +2 -0
  14. data/docs/CreateCustomerPaymentMethodsRequest.md +4 -4
  15. data/docs/Customer.md +4 -0
  16. data/docs/CustomerPaymentMethodsRequest.md +4 -4
  17. data/docs/CustomerResponse.md +4 -0
  18. data/docs/OrderRefundRequest.md +2 -2
  19. data/docs/OrderRequest.md +1 -1
  20. data/docs/OrderResponseCheckout.md +2 -0
  21. data/docs/PaymentMethodBankTransfer.md +3 -1
  22. data/docs/PaymentMethodCard.md +12 -10
  23. data/docs/PaymentMethodCardRequest.md +12 -2
  24. data/docs/PaymentMethodCash.md +7 -1
  25. data/docs/PaymentMethodGeneralRequest.md +32 -0
  26. data/docs/PaymentMethodTokenRequest.md +20 -0
  27. data/docs/PaymentMethodsApi.md +1 -1
  28. data/docs/PayoutOrdersApi.md +74 -0
  29. data/docs/SubscriptionResponse.md +2 -0
  30. data/docs/UpdateCustomer.md +4 -0
  31. data/lib/conekta/api/charges_api.rb +84 -0
  32. data/lib/conekta/api/payout_orders_api.rb +70 -0
  33. data/lib/conekta/models/charge_request.rb +1 -0
  34. data/lib/conekta/models/charge_request_payment_method.rb +74 -239
  35. data/lib/conekta/models/charge_response.rb +4 -0
  36. data/lib/conekta/models/charges_data_response.rb +4 -0
  37. data/lib/conekta/models/charges_order_response.rb +258 -0
  38. data/lib/conekta/models/charges_order_response_all_of_data.rb +382 -0
  39. data/lib/conekta/models/checkout.rb +11 -1
  40. data/lib/conekta/models/checkout_request.rb +11 -1
  41. data/lib/conekta/models/create_customer_payment_methods_request.rb +2 -2
  42. data/lib/conekta/models/customer.rb +21 -1
  43. data/lib/conekta/models/customer_payment_methods_request.rb +2 -2
  44. data/lib/conekta/models/customer_response.rb +21 -1
  45. data/lib/conekta/models/order_refund_request.rb +2 -1
  46. data/lib/conekta/models/order_request.rb +1 -1
  47. data/lib/conekta/models/order_response_checkout.rb +12 -1
  48. data/lib/conekta/models/payment_method_bank_transfer.rb +14 -5
  49. data/lib/conekta/models/payment_method_card.rb +22 -4
  50. data/lib/conekta/models/payment_method_card_request.rb +174 -12
  51. data/lib/conekta/models/payment_method_cash.rb +33 -4
  52. data/lib/conekta/models/payment_method_general_request.rb +291 -0
  53. data/lib/conekta/models/payment_method_token_request.rb +246 -0
  54. data/lib/conekta/models/subscription_response.rb +11 -1
  55. data/lib/conekta/models/update_customer.rb +21 -1
  56. data/lib/conekta/version.rb +1 -1
  57. data/lib/conekta.rb +4 -0
  58. data/spec/api/charges_api_spec.rb +18 -10
  59. data/spec/api/customers_api_spec.rb +10 -4
  60. data/spec/api/orders_api_spec.rb +6 -6
  61. metadata +32 -24
@@ -14,257 +14,92 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Conekta
17
- # Payment method used in the charge. Go to the [payment methods](https://developers.conekta.com/reference/m%C3%A9todos-de-pago) section for more details
18
- class ChargeRequestPaymentMethod
19
- # Method expiration date as unix timestamp
20
- attr_accessor :expires_at
21
-
22
- # How many months without interest to apply, it can be 3, 6, 9, 12 or 18
23
- attr_accessor :monthly_installments
24
-
25
- attr_accessor :type
26
-
27
- attr_accessor :token_id
28
-
29
- attr_accessor :payment_source_id
30
-
31
- # Optional id sent to indicate the bank contract for recurrent card charges.
32
- attr_accessor :contract_id
33
-
34
- # Attribute mapping from ruby-style variable name to JSON key.
35
- def self.attribute_map
36
- {
37
- :'expires_at' => :'expires_at',
38
- :'monthly_installments' => :'monthly_installments',
39
- :'type' => :'type',
40
- :'token_id' => :'token_id',
41
- :'payment_source_id' => :'payment_source_id',
42
- :'contract_id' => :'contract_id'
43
- }
44
- end
45
-
46
- # Returns all the JSON keys this model knows about
47
- def self.acceptable_attributes
48
- attribute_map.values
49
- end
50
-
51
- # Attribute type mapping.
52
- def self.openapi_types
53
- {
54
- :'expires_at' => :'Integer',
55
- :'monthly_installments' => :'Integer',
56
- :'type' => :'String',
57
- :'token_id' => :'String',
58
- :'payment_source_id' => :'String',
59
- :'contract_id' => :'String'
60
- }
61
- end
62
-
63
- # List of attributes with nullable: true
64
- def self.openapi_nullable
65
- Set.new([
66
- ])
67
- end
68
-
69
- # Initializes the object
70
- # @param [Hash] attributes Model attributes in the form of hash
71
- def initialize(attributes = {})
72
- if (!attributes.is_a?(Hash))
73
- fail ArgumentError, "The input argument (attributes) must be a hash in `Conekta::ChargeRequestPaymentMethod` initialize method"
17
+ module ChargeRequestPaymentMethod
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'PaymentMethodCardRequest',
23
+ :'PaymentMethodGeneralRequest'
24
+ ]
74
25
  end
75
26
 
76
- # check to see if the attribute exists and convert string to symbol for hash key
77
- attributes = attributes.each_with_object({}) { |(k, v), h|
78
- if (!self.class.attribute_map.key?(k.to_sym))
79
- fail ArgumentError, "`#{k}` is not a valid attribute in `Conekta::ChargeRequestPaymentMethod`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of oneOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - We do not attempt to check whether exactly one item matches.
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_one_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ typed_data = find_and_cast_into_type(klass, data)
42
+ return typed_data if typed_data
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
80
45
  end
81
- h[k.to_sym] = v
82
- }
83
46
 
84
- if attributes.key?(:'expires_at')
85
- self.expires_at = attributes[:'expires_at']
47
+ openapi_one_of.include?(:AnyType) ? data : nil
86
48
  end
87
49
 
88
- if attributes.key?(:'monthly_installments')
89
- self.monthly_installments = attributes[:'monthly_installments']
90
- end
91
-
92
- if attributes.key?(:'type')
93
- self.type = attributes[:'type']
94
- else
95
- self.type = nil
96
- end
97
-
98
- if attributes.key?(:'token_id')
99
- self.token_id = attributes[:'token_id']
100
- end
101
-
102
- if attributes.key?(:'payment_source_id')
103
- self.payment_source_id = attributes[:'payment_source_id']
104
- end
105
-
106
- if attributes.key?(:'contract_id')
107
- self.contract_id = attributes[:'contract_id']
108
- end
109
- end
110
-
111
- # Show invalid properties with the reasons. Usually used together with valid?
112
- # @return Array for valid properties with the reasons
113
- def list_invalid_properties
114
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
115
- invalid_properties = Array.new
116
- if @type.nil?
117
- invalid_properties.push('invalid value for "type", type cannot be nil.')
118
- end
119
-
120
- invalid_properties
121
- end
122
-
123
- # Check to see if the all the properties in the model are valid
124
- # @return true if the model is valid
125
- def valid?
126
- warn '[DEPRECATED] the `valid?` method is obsolete'
127
- return false if @type.nil?
128
- true
129
- end
130
-
131
- # Checks equality by comparing each attribute.
132
- # @param [Object] Object to be compared
133
- def ==(o)
134
- return true if self.equal?(o)
135
- self.class == o.class &&
136
- expires_at == o.expires_at &&
137
- monthly_installments == o.monthly_installments &&
138
- type == o.type &&
139
- token_id == o.token_id &&
140
- payment_source_id == o.payment_source_id &&
141
- contract_id == o.contract_id
142
- end
143
-
144
- # @see the `==` method
145
- # @param [Object] Object to be compared
146
- def eql?(o)
147
- self == o
148
- end
149
-
150
- # Calculates hash code according to all attributes.
151
- # @return [Integer] Hash code
152
- def hash
153
- [expires_at, monthly_installments, type, token_id, payment_source_id, contract_id].hash
154
- end
155
-
156
- # Builds the object from hash
157
- # @param [Hash] attributes Model attributes in the form of hash
158
- # @return [Object] Returns the model itself
159
- def self.build_from_hash(attributes)
160
- return nil unless attributes.is_a?(Hash)
161
- attributes = attributes.transform_keys(&:to_sym)
162
- transformed_hash = {}
163
- openapi_types.each_pair do |key, type|
164
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
165
- transformed_hash["#{key}"] = nil
166
- elsif type =~ /\AArray<(.*)>/i
167
- # check to ensure the input is an array given that the attribute
168
- # is documented as an array but the input is not
169
- if attributes[attribute_map[key]].is_a?(Array)
170
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.parse(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
171
77
  end
172
- elsif !attributes[attribute_map[key]].nil?
173
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
174
- end
175
- end
176
- new(transformed_hash)
177
- end
178
-
179
- # Deserializes the data based on type
180
- # @param string type Data type
181
- # @param string value Value to be deserialized
182
- # @return [Object] Deserialized data
183
- def self._deserialize(type, value)
184
- case type.to_sym
185
- when :Time
186
- Time.parse(value)
187
- when :Date
188
- Date.parse(value)
189
- when :String
190
- value.to_s
191
- when :Integer
192
- value.to_i
193
- when :Float
194
- value.to_f
195
- when :Boolean
196
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
197
- true
198
- else
199
- false
200
- end
201
- when :Object
202
- # generic object (usually a Hash), return directly
203
- value
204
- when /\AArray<(?<inner_type>.+)>\z/
205
- inner_type = Regexp.last_match[:inner_type]
206
- value.map { |v| _deserialize(inner_type, v) }
207
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
- k_type = Regexp.last_match[:k_type]
209
- v_type = Regexp.last_match[:v_type]
210
- {}.tap do |hash|
211
- value.each do |k, v|
212
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = Conekta.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
213
95
  end
214
- end
215
- else # model
216
- # models (e.g. Pet) or oneOf
217
- klass = Conekta.const_get(type)
218
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
219
- end
220
- end
221
-
222
- # Returns the string representation of the object
223
- # @return [String] String presentation of the object
224
- def to_s
225
- to_hash.to_s
226
- end
227
-
228
- # to_body is an alias to to_hash (backward compatibility)
229
- # @return [Hash] Returns the object in the form of hash
230
- def to_body
231
- to_hash
232
- end
233
-
234
- # Returns the object in the form of hash
235
- # @return [Hash] Returns the object in the form of hash
236
- def to_hash
237
- hash = {}
238
- self.class.attribute_map.each_pair do |attr, param|
239
- value = self.send(attr)
240
- if value.nil?
241
- is_nullable = self.class.openapi_nullable.include?(attr)
242
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
243
96
  end
244
97
 
245
- hash[param] = _to_hash(value)
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
246
101
  end
247
- hash
248
102
  end
249
-
250
- # Outputs non-array value in the form of hash
251
- # For object, use to_hash. Otherwise, just return the value
252
- # @param [Object] value Any valid value
253
- # @return [Hash] Returns the value in the form of hash
254
- def _to_hash(value)
255
- if value.is_a?(Array)
256
- value.compact.map { |v| _to_hash(v) }
257
- elsif value.is_a?(Hash)
258
- {}.tap do |hash|
259
- value.each { |k, v| hash[k] = _to_hash(v) }
260
- end
261
- elsif value.respond_to? :to_hash
262
- value.to_hash
263
- else
264
- value
265
- end
266
- end
267
-
268
103
  end
269
104
 
270
105
  end
@@ -33,14 +33,18 @@ module Conekta
33
33
 
34
34
  attr_accessor :failure_message
35
35
 
36
+ # Charge ID
36
37
  attr_accessor :id
37
38
 
39
+ # Whether the charge was made in live mode or not
38
40
  attr_accessor :livemode
39
41
 
40
42
  attr_accessor :object
41
43
 
44
+ # Order ID
42
45
  attr_accessor :order_id
43
46
 
47
+ # Payment date
44
48
  attr_accessor :paid_at
45
49
 
46
50
  attr_accessor :payment_method
@@ -33,14 +33,18 @@ module Conekta
33
33
 
34
34
  attr_accessor :failure_message
35
35
 
36
+ # Charge ID
36
37
  attr_accessor :id
37
38
 
39
+ # Whether the charge was made in live mode or not
38
40
  attr_accessor :livemode
39
41
 
40
42
  attr_accessor :object
41
43
 
44
+ # Order ID
42
45
  attr_accessor :order_id
43
46
 
47
+ # Payment date
44
48
  attr_accessor :paid_at
45
49
 
46
50
  attr_accessor :payment_method
@@ -0,0 +1,258 @@
1
+ =begin
2
+ #Conekta API
3
+
4
+ #Conekta sdk
5
+
6
+ The version of the OpenAPI document: 2.1.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
+ # The charges associated with the order
18
+ class ChargesOrderResponse
19
+ # Indicates if there are more pages to be requested
20
+ attr_accessor :has_more
21
+
22
+ # Object type, in this case is list
23
+ attr_accessor :object
24
+
25
+ attr_accessor :data
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'has_more' => :'has_more',
31
+ :'object' => :'object',
32
+ :'data' => :'data'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'has_more' => :'Boolean',
45
+ :'object' => :'String',
46
+ :'data' => :'Array<ChargesOrderResponseAllOfData>'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # List of class defined in allOf (OpenAPI v3)
57
+ def self.openapi_all_of
58
+ [
59
+ :'Pagination'
60
+ ]
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Conekta::ChargesOrderResponse` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Conekta::ChargesOrderResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'has_more')
79
+ self.has_more = attributes[:'has_more']
80
+ else
81
+ self.has_more = nil
82
+ end
83
+
84
+ if attributes.key?(:'object')
85
+ self.object = attributes[:'object']
86
+ else
87
+ self.object = nil
88
+ end
89
+
90
+ if attributes.key?(:'data')
91
+ if (value = attributes[:'data']).is_a?(Array)
92
+ self.data = value
93
+ end
94
+ end
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properties with the reasons
99
+ def list_invalid_properties
100
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
101
+ invalid_properties = Array.new
102
+ if @has_more.nil?
103
+ invalid_properties.push('invalid value for "has_more", has_more cannot be nil.')
104
+ end
105
+
106
+ if @object.nil?
107
+ invalid_properties.push('invalid value for "object", object cannot be nil.')
108
+ end
109
+
110
+ invalid_properties
111
+ end
112
+
113
+ # Check to see if the all the properties in the model are valid
114
+ # @return true if the model is valid
115
+ def valid?
116
+ warn '[DEPRECATED] the `valid?` method is obsolete'
117
+ return false if @has_more.nil?
118
+ return false if @object.nil?
119
+ true
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ has_more == o.has_more &&
128
+ object == o.object &&
129
+ data == o.data
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
140
+ def hash
141
+ [has_more, object, data].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def self.build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ transformed_hash = {}
151
+ openapi_types.each_pair do |key, type|
152
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
153
+ transformed_hash["#{key}"] = nil
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[attribute_map[key]].is_a?(Array)
158
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
159
+ end
160
+ elsif !attributes[attribute_map[key]].nil?
161
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
162
+ end
163
+ end
164
+ new(transformed_hash)
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def self._deserialize(type, value)
172
+ case type.to_sym
173
+ when :Time
174
+ Time.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ # models (e.g. Pet) or oneOf
205
+ klass = Conekta.const_get(type)
206
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end