postfinancecheckout-ruby-sdk 6.2.0 → 6.4.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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +56 -14
  3. data/LICENSE +1 -1
  4. data/README.md +57 -29
  5. data/lib/postfinancecheckout-ruby-sdk/api_client.rb +1 -1
  6. data/lib/postfinancecheckout-ruby-sdk/api_exception_error_codes.rb +60 -0
  7. data/lib/postfinancecheckout-ruby-sdk/models/bogus_express_checkout_approval_request.rb +230 -0
  8. data/lib/postfinancecheckout-ruby-sdk/models/bogus_express_checkout_payment_data.rb +241 -0
  9. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_approval_response.rb +270 -0
  10. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_create_response.rb +13 -4
  11. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_session.rb +39 -1
  12. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_session_create.rb +21 -1
  13. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_shipping_address_change_request.rb +239 -0
  14. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_shipping_address_change_response.rb +241 -0
  15. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_shipping_method_change_request.rb +231 -0
  16. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_shipping_method_change_response.rb +241 -0
  17. data/lib/postfinancecheckout-ruby-sdk/models/express_checkout_shipping_option.rb +1 -1
  18. data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_address.rb +43 -5
  19. data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_dcc_transaction_sum.rb +302 -0
  20. data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_transaction_sum.rb +332 -0
  21. data/lib/postfinancecheckout-ruby-sdk/models/payment_terminal_transaction_summary.rb +347 -0
  22. data/lib/postfinancecheckout-ruby-sdk/models/refund.rb +13 -1
  23. data/lib/postfinancecheckout-ruby-sdk/models/refund_create.rb +13 -1
  24. data/lib/postfinancecheckout-ruby-sdk/models/rendered_terminal_transaction_summary.rb +241 -0
  25. data/lib/postfinancecheckout-ruby-sdk/models/scope.rb +15 -15
  26. data/lib/postfinancecheckout-ruby-sdk/models/subscription_update_request.rb +45 -22
  27. data/lib/postfinancecheckout-ruby-sdk/models/terminal_transaction_summary_list_response.rb +253 -0
  28. data/lib/postfinancecheckout-ruby-sdk/models/terminal_transaction_summary_search_response.rb +263 -0
  29. data/lib/postfinancecheckout-ruby-sdk/models/transaction_completion.rb +13 -1
  30. data/lib/postfinancecheckout-ruby-sdk/models/transaction_completion_details.rb +26 -4
  31. data/lib/postfinancecheckout-ruby-sdk/models/transaction_user_interface_type.rb +2 -1
  32. data/lib/postfinancecheckout-ruby-sdk/postfinancecheckout_sdk_exception.rb +2 -33
  33. data/lib/postfinancecheckout-ruby-sdk/sdk_exception_error_codes.rb +55 -0
  34. data/lib/postfinancecheckout-ruby-sdk/service/bogus_express_checkout_service.rb +114 -0
  35. data/lib/postfinancecheckout-ruby-sdk/service/express_checkout_service.rb +162 -0
  36. data/lib/postfinancecheckout-ruby-sdk/service/payment_terminal_transaction_summaries_service.rb +372 -0
  37. data/lib/postfinancecheckout-ruby-sdk/service/webhook_encryption_keys_service.rb +2 -2
  38. data/lib/postfinancecheckout-ruby-sdk/utils/encryption_util.rb +5 -5
  39. data/lib/postfinancecheckout-ruby-sdk/version.rb +1 -1
  40. data/lib/postfinancecheckout-ruby-sdk.rb +20 -1
  41. data/test/test_querying.rb +11 -0
  42. metadata +19 -2
@@ -0,0 +1,302 @@
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 summary of Dynamic Currency Conversion (DCC) transactions grouped by brand and currency combinations in a transaction summary receipt.
28
+ class PaymentTerminalDccTransactionSum
29
+ # The original currency of the transactions before DCC conversion (typically the merchant's local currency).
30
+ attr_accessor :transaction_currency
31
+
32
+ # The total sum of all transactions in the original transaction currency (the amount in merchant's local currency before DCC conversion).
33
+ attr_accessor :transaction_amount
34
+
35
+ # The total sum of all transactions in the converted DCC currency (the amount paid by customers in their chosen currency).
36
+ attr_accessor :dcc_amount
37
+
38
+ # A unique identifier for the object.
39
+ attr_accessor :id
40
+
41
+ # The total count of DCC transactions processed for this specific brand and currency combination.
42
+ attr_accessor :transaction_count
43
+
44
+ # The converted currency used in DCC transactions (the currency chosen by the customer for payment).
45
+ attr_accessor :dcc_currency
46
+
47
+ # The payment brand for which these DCC transactions are summarized.
48
+ attr_accessor :brand
49
+
50
+ # The version is used for optimistic locking and incremented whenever the object is updated.
51
+ attr_accessor :version
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'transaction_currency' => :'transactionCurrency',
57
+ :'transaction_amount' => :'transactionAmount',
58
+ :'dcc_amount' => :'dccAmount',
59
+ :'id' => :'id',
60
+ :'transaction_count' => :'transactionCount',
61
+ :'dcc_currency' => :'dccCurrency',
62
+ :'brand' => :'brand',
63
+ :'version' => :'version'
64
+ }
65
+ end
66
+
67
+ # Returns attribute mapping this model knows about
68
+ def self.acceptable_attribute_map
69
+ attribute_map
70
+ end
71
+
72
+ # Returns all the JSON keys this model knows about
73
+ def self.acceptable_attributes
74
+ acceptable_attribute_map.values
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.openapi_types
79
+ {
80
+ :'transaction_currency' => :'String',
81
+ :'transaction_amount' => :'Float',
82
+ :'dcc_amount' => :'Float',
83
+ :'id' => :'Integer',
84
+ :'transaction_count' => :'Integer',
85
+ :'dcc_currency' => :'String',
86
+ :'brand' => :'String',
87
+ :'version' => :'Integer'
88
+ }
89
+ end
90
+
91
+ # List of attributes with nullable: true
92
+ def self.openapi_nullable
93
+ Set.new([
94
+ ])
95
+ end
96
+
97
+ # Initializes the object
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ def initialize(attributes = {})
100
+ if (!attributes.is_a?(Hash))
101
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PostfinancecheckoutRubySdk::PaymentTerminalDccTransactionSum` initialize method"
102
+ end
103
+
104
+ # check to see if the attribute exists and convert string to symbol for hash key
105
+ acceptable_attribute_map = self.class.acceptable_attribute_map
106
+ attributes = attributes.each_with_object({}) { |(k, v), h|
107
+ if (!acceptable_attribute_map.key?(k.to_sym))
108
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PostfinancecheckoutRubySdk::PaymentTerminalDccTransactionSum`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
109
+ end
110
+ h[k.to_sym] = v
111
+ }
112
+
113
+ if attributes.key?(:'transaction_currency')
114
+ self.transaction_currency = attributes[:'transaction_currency']
115
+ end
116
+
117
+ if attributes.key?(:'transaction_amount')
118
+ self.transaction_amount = attributes[:'transaction_amount']
119
+ end
120
+
121
+ if attributes.key?(:'dcc_amount')
122
+ self.dcc_amount = attributes[:'dcc_amount']
123
+ end
124
+
125
+ if attributes.key?(:'id')
126
+ self.id = attributes[:'id']
127
+ end
128
+
129
+ if attributes.key?(:'transaction_count')
130
+ self.transaction_count = attributes[:'transaction_count']
131
+ end
132
+
133
+ if attributes.key?(:'dcc_currency')
134
+ self.dcc_currency = attributes[:'dcc_currency']
135
+ end
136
+
137
+ if attributes.key?(:'brand')
138
+ self.brand = attributes[:'brand']
139
+ end
140
+
141
+ if attributes.key?(:'version')
142
+ self.version = attributes[:'version']
143
+ end
144
+ end
145
+
146
+ # Show invalid properties with the reasons. Usually used together with valid?
147
+ # @return Array for valid properties with the reasons
148
+ def list_invalid_properties
149
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
150
+ invalid_properties = Array.new
151
+ invalid_properties
152
+ end
153
+
154
+ # Check to see if the all the properties in the model are valid
155
+ # @return true if the model is valid
156
+ def valid?
157
+ warn '[DEPRECATED] the `valid?` method is obsolete'
158
+ true
159
+ end
160
+
161
+ # Checks equality by comparing each attribute.
162
+ # @param [Object] Object to be compared
163
+ def ==(o)
164
+ return true if self.equal?(o)
165
+ self.class == o.class &&
166
+ transaction_currency == o.transaction_currency &&
167
+ transaction_amount == o.transaction_amount &&
168
+ dcc_amount == o.dcc_amount &&
169
+ id == o.id &&
170
+ transaction_count == o.transaction_count &&
171
+ dcc_currency == o.dcc_currency &&
172
+ brand == o.brand &&
173
+ version == o.version
174
+ end
175
+
176
+ # @see the `==` method
177
+ # @param [Object] Object to be compared
178
+ def eql?(o)
179
+ self == o
180
+ end
181
+
182
+ # Calculates hash code according to all attributes.
183
+ # @return [Integer] Hash code
184
+ def hash
185
+ [transaction_currency, transaction_amount, dcc_amount, id, transaction_count, dcc_currency, brand, version].hash
186
+ end
187
+
188
+ # Builds the object from hash
189
+ # @param [Hash] attributes Model attributes in the form of hash
190
+ # @return [Object] Returns the model itself
191
+ def self.build_from_hash(attributes)
192
+ return nil unless attributes.is_a?(Hash)
193
+ attributes = attributes.transform_keys(&:to_sym)
194
+ transformed_hash = {}
195
+ openapi_types.each_pair do |key, type|
196
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
197
+ transformed_hash["#{key}"] = nil
198
+ elsif type =~ /\AArray<(.*)>/i
199
+ # check to ensure the input is an array given that the attribute
200
+ # is documented as an array but the input is not
201
+ if attributes[attribute_map[key]].is_a?(Array)
202
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
203
+ end
204
+ elsif !attributes[attribute_map[key]].nil?
205
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
206
+ end
207
+ end
208
+ new(transformed_hash)
209
+ end
210
+
211
+ # Deserializes the data based on type
212
+ # @param string type Data type
213
+ # @param string value Value to be deserialized
214
+ # @return [Object] Deserialized data
215
+ def self._deserialize(type, value)
216
+ case type.to_sym
217
+ when :Time
218
+ Time.parse(value)
219
+ when :Date
220
+ Date.parse(value)
221
+ when :String
222
+ value.to_s
223
+ when :Integer
224
+ value.to_i
225
+ when :Float
226
+ value.to_f
227
+ when :Boolean
228
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
229
+ true
230
+ else
231
+ false
232
+ end
233
+ when :Object
234
+ # generic object (usually a Hash), return directly
235
+ value
236
+ when /\AArray<(?<inner_type>.+)>\z/
237
+ inner_type = Regexp.last_match[:inner_type]
238
+ value.map { |v| _deserialize(inner_type, v) }
239
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
240
+ k_type = Regexp.last_match[:k_type]
241
+ v_type = Regexp.last_match[:v_type]
242
+ {}.tap do |hash|
243
+ value.each do |k, v|
244
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
245
+ end
246
+ end
247
+ else # model
248
+ # models (e.g. Pet) or oneOf
249
+ klass = PostfinancecheckoutRubySdk.const_get(type)
250
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
251
+ end
252
+ end
253
+
254
+ # Returns the string representation of the object
255
+ # @return [String] String presentation of the object
256
+ def to_s
257
+ to_hash.to_s
258
+ end
259
+
260
+ # to_body is an alias to to_hash (backward compatibility)
261
+ # @return [Hash] Returns the object in the form of hash
262
+ def to_body
263
+ to_hash
264
+ end
265
+
266
+ # Returns the object in the form of hash
267
+ # @return [Hash] Returns the object in the form of hash
268
+ def to_hash
269
+ hash = {}
270
+ self.class.attribute_map.each_pair do |attr, param|
271
+ value = self.send(attr)
272
+ if value.nil?
273
+ is_nullable = self.class.openapi_nullable.include?(attr)
274
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
275
+ end
276
+
277
+ hash[param] = _to_hash(value)
278
+ end
279
+ hash
280
+ end
281
+
282
+ # Outputs non-array value in the form of hash
283
+ # For object, use to_hash. Otherwise, just return the value
284
+ # @param [Object] value Any valid value
285
+ # @return [Hash] Returns the value in the form of hash
286
+ def _to_hash(value)
287
+ if value.is_a?(Array)
288
+ value.compact.map { |v| _to_hash(v) }
289
+ elsif value.is_a?(Hash)
290
+ {}.tap do |hash|
291
+ value.each { |k, v| hash[k] = _to_hash(v) }
292
+ end
293
+ elsif value.respond_to? :to_hash
294
+ value.to_hash
295
+ else
296
+ value
297
+ end
298
+ end
299
+
300
+ end
301
+
302
+ end
@@ -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