postfinancecheckout-ruby-sdk 6.2.0 → 6.3.0

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.
@@ -0,0 +1,332 @@
1
+ =begin
2
+ # PostFinance Ruby SDK
3
+ #
4
+ # This library allows to interact with the PostFinance payment service.
5
+ #
6
+ # Copyright owner: Wallee AG
7
+ # Website: https://www.postfinance.ch/en/private.html
8
+ # Developer email: ecosystem-team@wallee.com
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+ =end
22
+
23
+ require 'date'
24
+ require 'time'
25
+
26
+ module PostfinancecheckoutRubySdk
27
+ # Represents the aggregated transaction data for a specific brand and currency, including regular and DCC (Dynamic Currency Conversion) transactions.
28
+ class PaymentTerminalTransactionSum
29
+ # The total amount of tips from regular (non-DCC) transactions in the transaction currency.
30
+ attr_accessor :transaction_tip_amount
31
+
32
+ # The product within the brand for which transactions are summarized.
33
+ attr_accessor :product
34
+
35
+ # The base currency in which the transactions were processed and settled, excluding any DCC conversions.
36
+ attr_accessor :transaction_currency
37
+
38
+ # The total monetary value of all transactions in the transaction currency, excluding DCC transactions.
39
+ attr_accessor :transaction_amount
40
+
41
+ # The total amount of tips from DCC transactions, converted and presented in the transaction currency.
42
+ attr_accessor :dcc_tip_amount
43
+
44
+ # A unique identifier for the object.
45
+ attr_accessor :id
46
+
47
+ # The total count of regular (non-DCC) transactions processed within this summary period.
48
+ attr_accessor :transaction_count
49
+
50
+ # The payment brand for which the transactions are summarized.
51
+ attr_accessor :brand
52
+
53
+ # The number of transactions where Dynamic Currency Conversion (DCC) was applied, allowing customers to pay in their home currency.
54
+ attr_accessor :dcc_transaction_count
55
+
56
+ # The version is used for optimistic locking and incremented whenever the object is updated.
57
+ attr_accessor :version
58
+
59
+ # The total monetary value of DCC transactions, converted and presented in the transaction currency.
60
+ attr_accessor :dcc_transaction_amount
61
+
62
+ # Attribute mapping from ruby-style variable name to JSON key.
63
+ def self.attribute_map
64
+ {
65
+ :'transaction_tip_amount' => :'transactionTipAmount',
66
+ :'product' => :'product',
67
+ :'transaction_currency' => :'transactionCurrency',
68
+ :'transaction_amount' => :'transactionAmount',
69
+ :'dcc_tip_amount' => :'dccTipAmount',
70
+ :'id' => :'id',
71
+ :'transaction_count' => :'transactionCount',
72
+ :'brand' => :'brand',
73
+ :'dcc_transaction_count' => :'dccTransactionCount',
74
+ :'version' => :'version',
75
+ :'dcc_transaction_amount' => :'dccTransactionAmount'
76
+ }
77
+ end
78
+
79
+ # Returns attribute mapping this model knows about
80
+ def self.acceptable_attribute_map
81
+ attribute_map
82
+ end
83
+
84
+ # Returns all the JSON keys this model knows about
85
+ def self.acceptable_attributes
86
+ acceptable_attribute_map.values
87
+ end
88
+
89
+ # Attribute type mapping.
90
+ def self.openapi_types
91
+ {
92
+ :'transaction_tip_amount' => :'Float',
93
+ :'product' => :'String',
94
+ :'transaction_currency' => :'String',
95
+ :'transaction_amount' => :'Float',
96
+ :'dcc_tip_amount' => :'Float',
97
+ :'id' => :'Integer',
98
+ :'transaction_count' => :'Integer',
99
+ :'brand' => :'String',
100
+ :'dcc_transaction_count' => :'Integer',
101
+ :'version' => :'Integer',
102
+ :'dcc_transaction_amount' => :'Float'
103
+ }
104
+ end
105
+
106
+ # List of attributes with nullable: true
107
+ def self.openapi_nullable
108
+ Set.new([
109
+ ])
110
+ end
111
+
112
+ # Initializes the object
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ def initialize(attributes = {})
115
+ if (!attributes.is_a?(Hash))
116
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PostfinancecheckoutRubySdk::PaymentTerminalTransactionSum` initialize method"
117
+ end
118
+
119
+ # check to see if the attribute exists and convert string to symbol for hash key
120
+ acceptable_attribute_map = self.class.acceptable_attribute_map
121
+ attributes = attributes.each_with_object({}) { |(k, v), h|
122
+ if (!acceptable_attribute_map.key?(k.to_sym))
123
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PostfinancecheckoutRubySdk::PaymentTerminalTransactionSum`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
124
+ end
125
+ h[k.to_sym] = v
126
+ }
127
+
128
+ if attributes.key?(:'transaction_tip_amount')
129
+ self.transaction_tip_amount = attributes[:'transaction_tip_amount']
130
+ end
131
+
132
+ if attributes.key?(:'product')
133
+ self.product = attributes[:'product']
134
+ end
135
+
136
+ if attributes.key?(:'transaction_currency')
137
+ self.transaction_currency = attributes[:'transaction_currency']
138
+ end
139
+
140
+ if attributes.key?(:'transaction_amount')
141
+ self.transaction_amount = attributes[:'transaction_amount']
142
+ end
143
+
144
+ if attributes.key?(:'dcc_tip_amount')
145
+ self.dcc_tip_amount = attributes[:'dcc_tip_amount']
146
+ end
147
+
148
+ if attributes.key?(:'id')
149
+ self.id = attributes[:'id']
150
+ end
151
+
152
+ if attributes.key?(:'transaction_count')
153
+ self.transaction_count = attributes[:'transaction_count']
154
+ end
155
+
156
+ if attributes.key?(:'brand')
157
+ self.brand = attributes[:'brand']
158
+ end
159
+
160
+ if attributes.key?(:'dcc_transaction_count')
161
+ self.dcc_transaction_count = attributes[:'dcc_transaction_count']
162
+ end
163
+
164
+ if attributes.key?(:'version')
165
+ self.version = attributes[:'version']
166
+ end
167
+
168
+ if attributes.key?(:'dcc_transaction_amount')
169
+ self.dcc_transaction_amount = attributes[:'dcc_transaction_amount']
170
+ end
171
+ end
172
+
173
+ # Show invalid properties with the reasons. Usually used together with valid?
174
+ # @return Array for valid properties with the reasons
175
+ def list_invalid_properties
176
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
177
+ invalid_properties = Array.new
178
+ invalid_properties
179
+ end
180
+
181
+ # Check to see if the all the properties in the model are valid
182
+ # @return true if the model is valid
183
+ def valid?
184
+ warn '[DEPRECATED] the `valid?` method is obsolete'
185
+ true
186
+ end
187
+
188
+ # Checks equality by comparing each attribute.
189
+ # @param [Object] Object to be compared
190
+ def ==(o)
191
+ return true if self.equal?(o)
192
+ self.class == o.class &&
193
+ transaction_tip_amount == o.transaction_tip_amount &&
194
+ product == o.product &&
195
+ transaction_currency == o.transaction_currency &&
196
+ transaction_amount == o.transaction_amount &&
197
+ dcc_tip_amount == o.dcc_tip_amount &&
198
+ id == o.id &&
199
+ transaction_count == o.transaction_count &&
200
+ brand == o.brand &&
201
+ dcc_transaction_count == o.dcc_transaction_count &&
202
+ version == o.version &&
203
+ dcc_transaction_amount == o.dcc_transaction_amount
204
+ end
205
+
206
+ # @see the `==` method
207
+ # @param [Object] Object to be compared
208
+ def eql?(o)
209
+ self == o
210
+ end
211
+
212
+ # Calculates hash code according to all attributes.
213
+ # @return [Integer] Hash code
214
+ def hash
215
+ [transaction_tip_amount, product, transaction_currency, transaction_amount, dcc_tip_amount, id, transaction_count, brand, dcc_transaction_count, version, dcc_transaction_amount].hash
216
+ end
217
+
218
+ # Builds the object from hash
219
+ # @param [Hash] attributes Model attributes in the form of hash
220
+ # @return [Object] Returns the model itself
221
+ def self.build_from_hash(attributes)
222
+ return nil unless attributes.is_a?(Hash)
223
+ attributes = attributes.transform_keys(&:to_sym)
224
+ transformed_hash = {}
225
+ openapi_types.each_pair do |key, type|
226
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
227
+ transformed_hash["#{key}"] = nil
228
+ elsif type =~ /\AArray<(.*)>/i
229
+ # check to ensure the input is an array given that the attribute
230
+ # is documented as an array but the input is not
231
+ if attributes[attribute_map[key]].is_a?(Array)
232
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
233
+ end
234
+ elsif !attributes[attribute_map[key]].nil?
235
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
236
+ end
237
+ end
238
+ new(transformed_hash)
239
+ end
240
+
241
+ # Deserializes the data based on type
242
+ # @param string type Data type
243
+ # @param string value Value to be deserialized
244
+ # @return [Object] Deserialized data
245
+ def self._deserialize(type, value)
246
+ case type.to_sym
247
+ when :Time
248
+ Time.parse(value)
249
+ when :Date
250
+ Date.parse(value)
251
+ when :String
252
+ value.to_s
253
+ when :Integer
254
+ value.to_i
255
+ when :Float
256
+ value.to_f
257
+ when :Boolean
258
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
259
+ true
260
+ else
261
+ false
262
+ end
263
+ when :Object
264
+ # generic object (usually a Hash), return directly
265
+ value
266
+ when /\AArray<(?<inner_type>.+)>\z/
267
+ inner_type = Regexp.last_match[:inner_type]
268
+ value.map { |v| _deserialize(inner_type, v) }
269
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
270
+ k_type = Regexp.last_match[:k_type]
271
+ v_type = Regexp.last_match[:v_type]
272
+ {}.tap do |hash|
273
+ value.each do |k, v|
274
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
275
+ end
276
+ end
277
+ else # model
278
+ # models (e.g. Pet) or oneOf
279
+ klass = PostfinancecheckoutRubySdk.const_get(type)
280
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
281
+ end
282
+ end
283
+
284
+ # Returns the string representation of the object
285
+ # @return [String] String presentation of the object
286
+ def to_s
287
+ to_hash.to_s
288
+ end
289
+
290
+ # to_body is an alias to to_hash (backward compatibility)
291
+ # @return [Hash] Returns the object in the form of hash
292
+ def to_body
293
+ to_hash
294
+ end
295
+
296
+ # Returns the object in the form of hash
297
+ # @return [Hash] Returns the object in the form of hash
298
+ def to_hash
299
+ hash = {}
300
+ self.class.attribute_map.each_pair do |attr, param|
301
+ value = self.send(attr)
302
+ if value.nil?
303
+ is_nullable = self.class.openapi_nullable.include?(attr)
304
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
305
+ end
306
+
307
+ hash[param] = _to_hash(value)
308
+ end
309
+ hash
310
+ end
311
+
312
+ # Outputs non-array value in the form of hash
313
+ # For object, use to_hash. Otherwise, just return the value
314
+ # @param [Object] value Any valid value
315
+ # @return [Hash] Returns the value in the form of hash
316
+ def _to_hash(value)
317
+ if value.is_a?(Array)
318
+ value.compact.map { |v| _to_hash(v) }
319
+ elsif value.is_a?(Hash)
320
+ {}.tap do |hash|
321
+ value.each { |k, v| hash[k] = _to_hash(v) }
322
+ end
323
+ elsif value.respond_to? :to_hash
324
+ value.to_hash
325
+ else
326
+ value
327
+ end
328
+ end
329
+
330
+ end
331
+
332
+ end
@@ -0,0 +1,347 @@
1
+ =begin
2
+ # PostFinance Ruby SDK
3
+ #
4
+ # This library allows to interact with the PostFinance payment service.
5
+ #
6
+ # Copyright owner: Wallee AG
7
+ # Website: https://www.postfinance.ch/en/private.html
8
+ # Developer email: ecosystem-team@wallee.com
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+ =end
22
+
23
+ require 'date'
24
+ require 'time'
25
+
26
+ module PostfinancecheckoutRubySdk
27
+ class PaymentTerminalTransactionSummary
28
+ # The unique reference assigned to this transaction summary.
29
+ attr_accessor :reference
30
+
31
+ # The ID of the space this object belongs to.
32
+ attr_accessor :linked_space_id
33
+
34
+ # The total monetary amounts of all transactions, organized and grouped by brand and currency.
35
+ attr_accessor :transaction_sums
36
+
37
+ # Detailed breakdown of Dynamic Currency Conversion (DCC) transactions, showing transaction amounts in both original and converted currencies, grouped by payment brand.
38
+ attr_accessor :dcc_transaction_sums
39
+
40
+ # The end of the time period covered by this summary report.
41
+ attr_accessor :ended_on
42
+
43
+ # The overall transaction volume in each processed currency.
44
+ attr_accessor :balance_amount_per_currency
45
+
46
+ # The payment terminal that processed the transactions included in this summary report.
47
+ attr_accessor :payment_terminal
48
+
49
+ # The HTML content of the transaction summary receipt.
50
+ attr_accessor :receipt
51
+
52
+ # A unique identifier for the object.
53
+ attr_accessor :id
54
+
55
+ # The total count of all transactions processed by the terminal during the summary period.
56
+ attr_accessor :number_of_transactions
57
+
58
+ # The beginning of the time period covered by this summary report.
59
+ attr_accessor :started_on
60
+
61
+ # The version is used for optimistic locking and incremented whenever the object is updated.
62
+ attr_accessor :version
63
+
64
+ # Attribute mapping from ruby-style variable name to JSON key.
65
+ def self.attribute_map
66
+ {
67
+ :'reference' => :'reference',
68
+ :'linked_space_id' => :'linkedSpaceId',
69
+ :'transaction_sums' => :'transactionSums',
70
+ :'dcc_transaction_sums' => :'dccTransactionSums',
71
+ :'ended_on' => :'endedOn',
72
+ :'balance_amount_per_currency' => :'balanceAmountPerCurrency',
73
+ :'payment_terminal' => :'paymentTerminal',
74
+ :'receipt' => :'receipt',
75
+ :'id' => :'id',
76
+ :'number_of_transactions' => :'numberOfTransactions',
77
+ :'started_on' => :'startedOn',
78
+ :'version' => :'version'
79
+ }
80
+ end
81
+
82
+ # Returns attribute mapping this model knows about
83
+ def self.acceptable_attribute_map
84
+ attribute_map
85
+ end
86
+
87
+ # Returns all the JSON keys this model knows about
88
+ def self.acceptable_attributes
89
+ acceptable_attribute_map.values
90
+ end
91
+
92
+ # Attribute type mapping.
93
+ def self.openapi_types
94
+ {
95
+ :'reference' => :'Integer',
96
+ :'linked_space_id' => :'Integer',
97
+ :'transaction_sums' => :'Array<PaymentTerminalTransactionSum>',
98
+ :'dcc_transaction_sums' => :'Array<PaymentTerminalDccTransactionSum>',
99
+ :'ended_on' => :'Time',
100
+ :'balance_amount_per_currency' => :'Hash<String, Float>',
101
+ :'payment_terminal' => :'Integer',
102
+ :'receipt' => :'String',
103
+ :'id' => :'Integer',
104
+ :'number_of_transactions' => :'Integer',
105
+ :'started_on' => :'Time',
106
+ :'version' => :'Integer'
107
+ }
108
+ end
109
+
110
+ # List of attributes with nullable: true
111
+ def self.openapi_nullable
112
+ Set.new([
113
+ ])
114
+ end
115
+
116
+ # Initializes the object
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ def initialize(attributes = {})
119
+ if (!attributes.is_a?(Hash))
120
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PostfinancecheckoutRubySdk::PaymentTerminalTransactionSummary` initialize method"
121
+ end
122
+
123
+ # check to see if the attribute exists and convert string to symbol for hash key
124
+ acceptable_attribute_map = self.class.acceptable_attribute_map
125
+ attributes = attributes.each_with_object({}) { |(k, v), h|
126
+ if (!acceptable_attribute_map.key?(k.to_sym))
127
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PostfinancecheckoutRubySdk::PaymentTerminalTransactionSummary`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
128
+ end
129
+ h[k.to_sym] = v
130
+ }
131
+
132
+ if attributes.key?(:'reference')
133
+ self.reference = attributes[:'reference']
134
+ end
135
+
136
+ if attributes.key?(:'linked_space_id')
137
+ self.linked_space_id = attributes[:'linked_space_id']
138
+ end
139
+
140
+ if attributes.key?(:'transaction_sums')
141
+ if (value = attributes[:'transaction_sums']).is_a?(Array)
142
+ self.transaction_sums = value
143
+ end
144
+ end
145
+
146
+ if attributes.key?(:'dcc_transaction_sums')
147
+ if (value = attributes[:'dcc_transaction_sums']).is_a?(Array)
148
+ self.dcc_transaction_sums = value
149
+ end
150
+ end
151
+
152
+ if attributes.key?(:'ended_on')
153
+ self.ended_on = attributes[:'ended_on']
154
+ end
155
+
156
+ if attributes.key?(:'balance_amount_per_currency')
157
+ if (value = attributes[:'balance_amount_per_currency']).is_a?(Hash)
158
+ self.balance_amount_per_currency = value
159
+ end
160
+ end
161
+
162
+ if attributes.key?(:'payment_terminal')
163
+ self.payment_terminal = attributes[:'payment_terminal']
164
+ end
165
+
166
+ if attributes.key?(:'receipt')
167
+ self.receipt = attributes[:'receipt']
168
+ end
169
+
170
+ if attributes.key?(:'id')
171
+ self.id = attributes[:'id']
172
+ end
173
+
174
+ if attributes.key?(:'number_of_transactions')
175
+ self.number_of_transactions = attributes[:'number_of_transactions']
176
+ end
177
+
178
+ if attributes.key?(:'started_on')
179
+ self.started_on = attributes[:'started_on']
180
+ end
181
+
182
+ if attributes.key?(:'version')
183
+ self.version = attributes[:'version']
184
+ end
185
+ end
186
+
187
+ # Show invalid properties with the reasons. Usually used together with valid?
188
+ # @return Array for valid properties with the reasons
189
+ def list_invalid_properties
190
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
191
+ invalid_properties = Array.new
192
+ invalid_properties
193
+ end
194
+
195
+ # Check to see if the all the properties in the model are valid
196
+ # @return true if the model is valid
197
+ def valid?
198
+ warn '[DEPRECATED] the `valid?` method is obsolete'
199
+ true
200
+ end
201
+
202
+ # Checks equality by comparing each attribute.
203
+ # @param [Object] Object to be compared
204
+ def ==(o)
205
+ return true if self.equal?(o)
206
+ self.class == o.class &&
207
+ reference == o.reference &&
208
+ linked_space_id == o.linked_space_id &&
209
+ transaction_sums == o.transaction_sums &&
210
+ dcc_transaction_sums == o.dcc_transaction_sums &&
211
+ ended_on == o.ended_on &&
212
+ balance_amount_per_currency == o.balance_amount_per_currency &&
213
+ payment_terminal == o.payment_terminal &&
214
+ receipt == o.receipt &&
215
+ id == o.id &&
216
+ number_of_transactions == o.number_of_transactions &&
217
+ started_on == o.started_on &&
218
+ version == o.version
219
+ end
220
+
221
+ # @see the `==` method
222
+ # @param [Object] Object to be compared
223
+ def eql?(o)
224
+ self == o
225
+ end
226
+
227
+ # Calculates hash code according to all attributes.
228
+ # @return [Integer] Hash code
229
+ def hash
230
+ [reference, linked_space_id, transaction_sums, dcc_transaction_sums, ended_on, balance_amount_per_currency, payment_terminal, receipt, id, number_of_transactions, started_on, version].hash
231
+ end
232
+
233
+ # Builds the object from hash
234
+ # @param [Hash] attributes Model attributes in the form of hash
235
+ # @return [Object] Returns the model itself
236
+ def self.build_from_hash(attributes)
237
+ return nil unless attributes.is_a?(Hash)
238
+ attributes = attributes.transform_keys(&:to_sym)
239
+ transformed_hash = {}
240
+ openapi_types.each_pair do |key, type|
241
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
242
+ transformed_hash["#{key}"] = nil
243
+ elsif type =~ /\AArray<(.*)>/i
244
+ # check to ensure the input is an array given that the attribute
245
+ # is documented as an array but the input is not
246
+ if attributes[attribute_map[key]].is_a?(Array)
247
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
248
+ end
249
+ elsif !attributes[attribute_map[key]].nil?
250
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
251
+ end
252
+ end
253
+ new(transformed_hash)
254
+ end
255
+
256
+ # Deserializes the data based on type
257
+ # @param string type Data type
258
+ # @param string value Value to be deserialized
259
+ # @return [Object] Deserialized data
260
+ def self._deserialize(type, value)
261
+ case type.to_sym
262
+ when :Time
263
+ Time.parse(value)
264
+ when :Date
265
+ Date.parse(value)
266
+ when :String
267
+ value.to_s
268
+ when :Integer
269
+ value.to_i
270
+ when :Float
271
+ value.to_f
272
+ when :Boolean
273
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
274
+ true
275
+ else
276
+ false
277
+ end
278
+ when :Object
279
+ # generic object (usually a Hash), return directly
280
+ value
281
+ when /\AArray<(?<inner_type>.+)>\z/
282
+ inner_type = Regexp.last_match[:inner_type]
283
+ value.map { |v| _deserialize(inner_type, v) }
284
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
285
+ k_type = Regexp.last_match[:k_type]
286
+ v_type = Regexp.last_match[:v_type]
287
+ {}.tap do |hash|
288
+ value.each do |k, v|
289
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
290
+ end
291
+ end
292
+ else # model
293
+ # models (e.g. Pet) or oneOf
294
+ klass = PostfinancecheckoutRubySdk.const_get(type)
295
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
296
+ end
297
+ end
298
+
299
+ # Returns the string representation of the object
300
+ # @return [String] String presentation of the object
301
+ def to_s
302
+ to_hash.to_s
303
+ end
304
+
305
+ # to_body is an alias to to_hash (backward compatibility)
306
+ # @return [Hash] Returns the object in the form of hash
307
+ def to_body
308
+ to_hash
309
+ end
310
+
311
+ # Returns the object in the form of hash
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_hash
314
+ hash = {}
315
+ self.class.attribute_map.each_pair do |attr, param|
316
+ value = self.send(attr)
317
+ if value.nil?
318
+ is_nullable = self.class.openapi_nullable.include?(attr)
319
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
320
+ end
321
+
322
+ hash[param] = _to_hash(value)
323
+ end
324
+ hash
325
+ end
326
+
327
+ # Outputs non-array value in the form of hash
328
+ # For object, use to_hash. Otherwise, just return the value
329
+ # @param [Object] value Any valid value
330
+ # @return [Hash] Returns the value in the form of hash
331
+ def _to_hash(value)
332
+ if value.is_a?(Array)
333
+ value.compact.map { |v| _to_hash(v) }
334
+ elsif value.is_a?(Hash)
335
+ {}.tap do |hash|
336
+ value.each { |k, v| hash[k] = _to_hash(v) }
337
+ end
338
+ elsif value.respond_to? :to_hash
339
+ value.to_hash
340
+ else
341
+ value
342
+ end
343
+ end
344
+
345
+ end
346
+
347
+ end