wallee-ruby-sdk 2.2.4 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/lib/wallee-ruby-sdk.rb +46 -3
  4. data/lib/wallee-ruby-sdk/api/bank_account_service_api.rb +213 -0
  5. data/lib/wallee-ruby-sdk/api/bank_transaction_service_api.rb +213 -0
  6. data/lib/wallee-ruby-sdk/api/charge_bank_transaction_service_api.rb +213 -0
  7. data/lib/wallee-ruby-sdk/api/currency_bank_account_service_api.rb +213 -0
  8. data/lib/wallee-ruby-sdk/api/external_transfer_bank_transaction_service_api.rb +213 -0
  9. data/lib/wallee-ruby-sdk/api/internal_transfer_bank_transaction_service_api.rb +213 -0
  10. data/lib/wallee-ruby-sdk/api/payment_terminal_till_service_api.rb +71 -0
  11. data/lib/wallee-ruby-sdk/api/refund_bank_transaction_service_api.rb +213 -0
  12. data/lib/wallee-ruby-sdk/api/refund_recovery_bank_transaction_service_api.rb +213 -0
  13. data/lib/wallee-ruby-sdk/api/shopify_subscriber_service_api.rb +62 -0
  14. data/lib/wallee-ruby-sdk/api/token_service_api.rb +63 -0
  15. data/lib/wallee-ruby-sdk/api/transaction_terminal_service_api.rb +21 -32
  16. data/lib/wallee-ruby-sdk/api/web_app_service_api.rb +200 -0
  17. data/lib/wallee-ruby-sdk/api_client.rb +2 -1
  18. data/lib/wallee-ruby-sdk/models/abstract_payment_link_update.rb +15 -15
  19. data/lib/wallee-ruby-sdk/models/abstract_subscription_product_active.rb +11 -1
  20. data/lib/wallee-ruby-sdk/models/authenticated_card_data.rb +221 -0
  21. data/lib/wallee-ruby-sdk/models/{unencrypted_card_data.rb → authenticated_card_data_create.rb} +86 -12
  22. data/lib/wallee-ruby-sdk/models/bank_account.rb +291 -0
  23. data/lib/wallee-ruby-sdk/models/bank_account_environment.rb +35 -0
  24. data/lib/wallee-ruby-sdk/models/bank_account_state.rb +37 -0
  25. data/lib/wallee-ruby-sdk/models/bank_account_type.rb +227 -0
  26. data/lib/wallee-ruby-sdk/models/bank_transaction.rb +387 -0
  27. data/lib/wallee-ruby-sdk/models/bank_transaction_flow_direction.rb +35 -0
  28. data/lib/wallee-ruby-sdk/models/bank_transaction_source.rb +215 -0
  29. data/lib/wallee-ruby-sdk/models/bank_transaction_state.rb +35 -0
  30. data/lib/wallee-ruby-sdk/models/bank_transaction_type.rb +215 -0
  31. data/lib/wallee-ruby-sdk/models/card_authentication_response.rb +38 -0
  32. data/lib/wallee-ruby-sdk/models/card_authentication_version.rb +35 -0
  33. data/lib/wallee-ruby-sdk/models/card_cryptogram.rb +201 -0
  34. data/lib/wallee-ruby-sdk/models/card_cryptogram_create.rb +211 -0
  35. data/lib/wallee-ruby-sdk/models/card_cryptogram_type.rb +34 -0
  36. data/lib/wallee-ruby-sdk/models/cardholder_authentication.rb +231 -0
  37. data/lib/wallee-ruby-sdk/models/cardholder_authentication_create.rb +241 -0
  38. data/lib/wallee-ruby-sdk/models/charge_bank_transaction.rb +291 -0
  39. data/lib/wallee-ruby-sdk/models/currency_bank_account.rb +241 -0
  40. data/lib/wallee-ruby-sdk/models/debt_collection_case.rb +1 -1
  41. data/lib/wallee-ruby-sdk/models/debt_collection_case_create.rb +1 -1
  42. data/lib/wallee-ruby-sdk/models/external_transfer_bank_transaction.rb +251 -0
  43. data/lib/wallee-ruby-sdk/models/internal_transfer_bank_transaction.rb +231 -0
  44. data/lib/wallee-ruby-sdk/models/payment_adjustment.rb +231 -0
  45. data/lib/wallee-ruby-sdk/models/payment_adjustment_type.rb +215 -0
  46. data/lib/wallee-ruby-sdk/models/payment_contract.rb +1 -25
  47. data/lib/wallee-ruby-sdk/models/payment_link.rb +16 -40
  48. data/lib/wallee-ruby-sdk/models/payment_link_active.rb +15 -15
  49. data/lib/wallee-ruby-sdk/models/payment_link_address_handling_mode.rb +36 -0
  50. data/lib/wallee-ruby-sdk/models/payment_link_create.rb +16 -44
  51. data/lib/wallee-ruby-sdk/models/payment_link_update.rb +15 -15
  52. data/lib/wallee-ruby-sdk/models/payment_terminal.rb +11 -1
  53. data/lib/wallee-ruby-sdk/models/payment_terminal_address.rb +0 -60
  54. data/lib/wallee-ruby-sdk/models/payment_terminal_configuration_version.rb +11 -1
  55. data/lib/wallee-ruby-sdk/models/payment_terminal_location.rb +2 -22
  56. data/lib/wallee-ruby-sdk/models/payment_terminal_receipt_type.rb +215 -0
  57. data/lib/wallee-ruby-sdk/models/permission.rb +14 -4
  58. data/lib/wallee-ruby-sdk/models/recurring_indicator.rb +37 -0
  59. data/lib/wallee-ruby-sdk/models/refund_bank_transaction.rb +281 -0
  60. data/lib/wallee-ruby-sdk/models/refund_recovery_bank_transaction.rb +293 -0
  61. data/lib/wallee-ruby-sdk/models/rendered_terminal_receipt.rb +26 -6
  62. data/lib/wallee-ruby-sdk/models/role.rb +1 -1
  63. data/lib/wallee-ruby-sdk/models/role_state.rb +37 -0
  64. data/lib/wallee-ruby-sdk/models/shopify_subscriber.rb +1 -1
  65. data/lib/wallee-ruby-sdk/models/shopify_subscriber_active.rb +241 -0
  66. data/lib/wallee-ruby-sdk/models/shopify_subscription.rb +11 -1
  67. data/lib/wallee-ruby-sdk/models/shopify_subscription_creation_request.rb +12 -2
  68. data/lib/wallee-ruby-sdk/models/shopify_subscription_model_billing_configuration.rb +11 -1
  69. data/lib/wallee-ruby-sdk/models/shopify_subscription_version.rb +11 -1
  70. data/lib/wallee-ruby-sdk/models/subscriber.rb +1 -1
  71. data/lib/wallee-ruby-sdk/models/subscriber_create.rb +1 -1
  72. data/lib/wallee-ruby-sdk/models/subscription_affiliate.rb +1 -25
  73. data/lib/wallee-ruby-sdk/models/subscription_affiliate_create.rb +1 -29
  74. data/lib/wallee-ruby-sdk/models/subscription_affiliate_deleted.rb +1 -25
  75. data/lib/wallee-ruby-sdk/models/subscription_affiliate_deleting.rb +1 -25
  76. data/lib/wallee-ruby-sdk/models/subscription_charge.rb +1 -1
  77. data/lib/wallee-ruby-sdk/models/subscription_charge_create.rb +1 -1
  78. data/lib/wallee-ruby-sdk/models/subscription_ledger_entry.rb +12 -2
  79. data/lib/wallee-ruby-sdk/models/subscription_ledger_entry_create.rb +1 -1
  80. data/lib/wallee-ruby-sdk/models/subscription_product.rb +11 -1
  81. data/lib/wallee-ruby-sdk/models/subscription_product_active.rb +11 -1
  82. data/lib/wallee-ruby-sdk/models/subscription_product_component.rb +1 -1
  83. data/lib/wallee-ruby-sdk/models/subscription_product_component_update.rb +1 -1
  84. data/lib/wallee-ruby-sdk/models/subscription_product_create.rb +11 -1
  85. data/lib/wallee-ruby-sdk/models/tax_calculation.rb +2 -2
  86. data/lib/wallee-ruby-sdk/models/terminal_receipt_fetch_request.rb +221 -0
  87. data/lib/wallee-ruby-sdk/models/terminal_receipt_format.rb +35 -0
  88. data/lib/wallee-ruby-sdk/models/token.rb +1 -25
  89. data/lib/wallee-ruby-sdk/models/token_create.rb +1 -29
  90. data/lib/wallee-ruby-sdk/models/tokenized_card_data.rb +211 -0
  91. data/lib/wallee-ruby-sdk/models/{unencrypted_card_data_create.rb → tokenized_card_data_create.rb} +60 -5
  92. data/lib/wallee-ruby-sdk/models/transaction.rb +64 -4
  93. data/lib/wallee-ruby-sdk/models/web_app_confirmation_request.rb +206 -0
  94. data/lib/wallee-ruby-sdk/models/web_app_confirmation_response.rb +231 -0
  95. data/lib/wallee-ruby-sdk/models/webhook_url.rb +11 -1
  96. data/lib/wallee-ruby-sdk/version.rb +1 -1
  97. data/test/condition_type_service_test.rb +22 -0
  98. metadata +50 -5
  99. data/lib/wallee-ruby-sdk/models/payment_terminal_contact_address.rb +0 -396
@@ -0,0 +1,241 @@
1
+ =begin
2
+ The wallee API allows an easy interaction with the wallee web service.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ =end
17
+
18
+ require 'date'
19
+
20
+ module Wallee
21
+ #
22
+ class CurrencyBankAccount
23
+ #
24
+ attr_accessor :bank_account
25
+
26
+ #
27
+ attr_accessor :currency
28
+
29
+ #
30
+ attr_accessor :environment
31
+
32
+ # The ID is the primary key of the entity. The ID identifies the entity uniquely.
33
+ attr_accessor :id
34
+
35
+ # The linked space id holds the ID of the space to which the entity belongs to.
36
+ attr_accessor :linked_space_id
37
+
38
+ # The version number indicates the version of the entity. The version is incremented whenever the entity is changed.
39
+ attr_accessor :version
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'bank_account' => :'bankAccount',
45
+ :'currency' => :'currency',
46
+ :'environment' => :'environment',
47
+ :'id' => :'id',
48
+ :'linked_space_id' => :'linkedSpaceId',
49
+ :'version' => :'version'
50
+ }
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.swagger_types
55
+ {
56
+ :'bank_account' => :'BankAccount',
57
+ :'currency' => :'String',
58
+ :'environment' => :'BankAccountEnvironment',
59
+ :'id' => :'Integer',
60
+ :'linked_space_id' => :'Integer',
61
+ :'version' => :'Integer'
62
+ }
63
+ end
64
+
65
+ # Initializes the object
66
+ # @param [Hash] attributes Model attributes in the form of hash
67
+ def initialize(attributes = {})
68
+ return unless attributes.is_a?(Hash)
69
+
70
+ # convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
72
+
73
+ if attributes.has_key?(:'bankAccount')
74
+ self.bank_account = attributes[:'bankAccount']
75
+ end
76
+
77
+ if attributes.has_key?(:'currency')
78
+ self.currency = attributes[:'currency']
79
+ end
80
+
81
+ if attributes.has_key?(:'environment')
82
+ self.environment = attributes[:'environment']
83
+ end
84
+
85
+ if attributes.has_key?(:'id')
86
+ self.id = attributes[:'id']
87
+ end
88
+
89
+ if attributes.has_key?(:'linkedSpaceId')
90
+ self.linked_space_id = attributes[:'linkedSpaceId']
91
+ end
92
+
93
+ if attributes.has_key?(:'version')
94
+ self.version = attributes[:'version']
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ invalid_properties = Array.new
102
+ invalid_properties
103
+ end
104
+
105
+ # Check to see if the all the properties in the model are valid
106
+ # @return true if the model is valid
107
+ def valid?
108
+ true
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(o)
114
+ return true if self.equal?(o)
115
+ self.class == o.class &&
116
+ bank_account == o.bank_account &&
117
+ currency == o.currency &&
118
+ environment == o.environment &&
119
+ id == o.id &&
120
+ linked_space_id == o.linked_space_id &&
121
+ version == o.version
122
+ end
123
+
124
+ # @see the `==` method
125
+ # @param [Object] Object to be compared
126
+ def eql?(o)
127
+ self == o
128
+ end
129
+
130
+ # Calculates hash code according to all attributes.
131
+ # @return [Fixnum] Hash code
132
+ def hash
133
+ [bank_account, currency, environment, id, linked_space_id, version].hash
134
+ end
135
+
136
+ # Builds the object from hash
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ # @return [Object] Returns the model itself
139
+ def build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ self.class.swagger_types.each_pair do |key, type|
142
+ if type =~ /\AArray<(.*)>/i
143
+ # check to ensure the input is an array given that the attribute
144
+ # is documented as an array but the input is not
145
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
146
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
147
+ end
148
+ elsif !attributes[self.class.attribute_map[key]].nil?
149
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
150
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
151
+ end
152
+
153
+ self
154
+ end
155
+
156
+ # Deserializes the data based on type
157
+ # @param string type Data type
158
+ # @param string value Value to be deserialized
159
+ # @return [Object] Deserialized data
160
+ def _deserialize(type, value)
161
+ case type.to_sym
162
+ when :DateTime
163
+ DateTime.parse(value)
164
+ when :Date
165
+ Date.parse(value)
166
+ when :String
167
+ value.to_s
168
+ when :Integer
169
+ value.to_i
170
+ when :Float
171
+ value.to_f
172
+ when :BOOLEAN
173
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
174
+ true
175
+ else
176
+ false
177
+ end
178
+ when :Object
179
+ # generic object (usually a Hash), return directly
180
+ value
181
+ when /\AArray<(?<inner_type>.+)>\z/
182
+ inner_type = Regexp.last_match[:inner_type]
183
+ value.map { |v| _deserialize(inner_type, v) }
184
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
185
+ k_type = Regexp.last_match[:k_type]
186
+ v_type = Regexp.last_match[:v_type]
187
+ {}.tap do |hash|
188
+ value.each do |k, v|
189
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
190
+ end
191
+ end
192
+ else # model
193
+ temp_model = Wallee.const_get(type).new
194
+ temp_model.build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ # Returns the object in the form of hash
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_hash
213
+ hash = {}
214
+ self.class.attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ next if value.nil?
217
+ hash[param] = _to_hash(value)
218
+ end
219
+ hash
220
+ end
221
+
222
+ # Outputs non-array value in the form of hash
223
+ # For object, use to_hash. Otherwise, just return the value
224
+ # @param [Object] value Any valid value
225
+ # @return [Hash] Returns the value in the form of hash
226
+ def _to_hash(value)
227
+ if value.is_a?(Array)
228
+ value.compact.map{ |v| _to_hash(v) }
229
+ elsif value.is_a?(Hash)
230
+ {}.tap do |hash|
231
+ value.each { |k, v| hash[k] = _to_hash(v) }
232
+ end
233
+ elsif value.respond_to? :to_hash
234
+ value.to_hash
235
+ else
236
+ value
237
+ end
238
+ end
239
+
240
+ end
241
+ end
@@ -50,7 +50,7 @@ module Wallee
50
50
  # The environment in which this case will be processed. There must be a debt collector configuration present which supports the chosen environment.
51
51
  attr_accessor :environment
52
52
 
53
- # The external id helps to identify the entity and a subsequent creation of an entity with the same ID will not create a new entity.
53
+ # A client generated nonce which identifies the entity to be created. Subsequent creation requests with the same external ID will not create new entities but return the initially created entity instead.
54
54
  attr_accessor :external_id
55
55
 
56
56
  # The failed on date indicates when the case is failed on.
@@ -47,7 +47,7 @@ module Wallee
47
47
  # The collector configuration determines how the debt collection case is processed.
48
48
  attr_accessor :collector_configuration
49
49
 
50
- # The external id helps to identify the entity and a subsequent creation of an entity with the same ID will not create a new entity.
50
+ # A client generated nonce which identifies the entity to be created. Subsequent creation requests with the same external ID will not create new entities but return the initially created entity instead.
51
51
  attr_accessor :external_id
52
52
 
53
53
  # The case reference is used in the communication with the debtor. It should be unique and it should be linkable with the source of the debt collection case.
@@ -0,0 +1,251 @@
1
+ =begin
2
+ The wallee API allows an easy interaction with the wallee web service.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ =end
17
+
18
+ require 'date'
19
+
20
+ module Wallee
21
+ #
22
+ class ExternalTransferBankTransaction
23
+ #
24
+ attr_accessor :bank_transaction
25
+
26
+ #
27
+ attr_accessor :external_account_identifier
28
+
29
+ #
30
+ attr_accessor :external_account_type
31
+
32
+ #
33
+ attr_accessor :external_bank_name
34
+
35
+ # The ID is the primary key of the entity. The ID identifies the entity uniquely.
36
+ attr_accessor :id
37
+
38
+ # The linked space id holds the ID of the space to which the entity belongs to.
39
+ attr_accessor :linked_space_id
40
+
41
+ # The version number indicates the version of the entity. The version is incremented whenever the entity is changed.
42
+ attr_accessor :version
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'bank_transaction' => :'bankTransaction',
48
+ :'external_account_identifier' => :'externalAccountIdentifier',
49
+ :'external_account_type' => :'externalAccountType',
50
+ :'external_bank_name' => :'externalBankName',
51
+ :'id' => :'id',
52
+ :'linked_space_id' => :'linkedSpaceId',
53
+ :'version' => :'version'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.swagger_types
59
+ {
60
+ :'bank_transaction' => :'BankTransaction',
61
+ :'external_account_identifier' => :'String',
62
+ :'external_account_type' => :'String',
63
+ :'external_bank_name' => :'String',
64
+ :'id' => :'Integer',
65
+ :'linked_space_id' => :'Integer',
66
+ :'version' => :'Integer'
67
+ }
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ return unless attributes.is_a?(Hash)
74
+
75
+ # convert string to symbol for hash key
76
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
77
+
78
+ if attributes.has_key?(:'bankTransaction')
79
+ self.bank_transaction = attributes[:'bankTransaction']
80
+ end
81
+
82
+ if attributes.has_key?(:'externalAccountIdentifier')
83
+ self.external_account_identifier = attributes[:'externalAccountIdentifier']
84
+ end
85
+
86
+ if attributes.has_key?(:'externalAccountType')
87
+ self.external_account_type = attributes[:'externalAccountType']
88
+ end
89
+
90
+ if attributes.has_key?(:'externalBankName')
91
+ self.external_bank_name = attributes[:'externalBankName']
92
+ end
93
+
94
+ if attributes.has_key?(:'id')
95
+ self.id = attributes[:'id']
96
+ end
97
+
98
+ if attributes.has_key?(:'linkedSpaceId')
99
+ self.linked_space_id = attributes[:'linkedSpaceId']
100
+ end
101
+
102
+ if attributes.has_key?(:'version')
103
+ self.version = attributes[:'version']
104
+ end
105
+ end
106
+
107
+ # Show invalid properties with the reasons. Usually used together with valid?
108
+ # @return Array for valid properties with the reasons
109
+ def list_invalid_properties
110
+ invalid_properties = Array.new
111
+ invalid_properties
112
+ end
113
+
114
+ # Check to see if the all the properties in the model are valid
115
+ # @return true if the model is valid
116
+ def valid?
117
+ true
118
+ end
119
+
120
+ # Checks equality by comparing each attribute.
121
+ # @param [Object] Object to be compared
122
+ def ==(o)
123
+ return true if self.equal?(o)
124
+ self.class == o.class &&
125
+ bank_transaction == o.bank_transaction &&
126
+ external_account_identifier == o.external_account_identifier &&
127
+ external_account_type == o.external_account_type &&
128
+ external_bank_name == o.external_bank_name &&
129
+ id == o.id &&
130
+ linked_space_id == o.linked_space_id &&
131
+ version == o.version
132
+ end
133
+
134
+ # @see the `==` method
135
+ # @param [Object] Object to be compared
136
+ def eql?(o)
137
+ self == o
138
+ end
139
+
140
+ # Calculates hash code according to all attributes.
141
+ # @return [Fixnum] Hash code
142
+ def hash
143
+ [bank_transaction, external_account_identifier, external_account_type, external_bank_name, id, linked_space_id, version].hash
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ self.class.swagger_types.each_pair do |key, type|
152
+ if type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
156
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
157
+ end
158
+ elsif !attributes[self.class.attribute_map[key]].nil?
159
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
160
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
161
+ end
162
+
163
+ self
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def _deserialize(type, value)
171
+ case type.to_sym
172
+ when :DateTime
173
+ DateTime.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :BOOLEAN
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ temp_model = Wallee.const_get(type).new
204
+ temp_model.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ next if value.nil?
227
+ hash[param] = _to_hash(value)
228
+ end
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map{ |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to? :to_hash
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+
250
+ end
251
+ end