wallee-ruby-sdk 2.2.5 → 3.0.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/lib/wallee-ruby-sdk.rb +22 -2
  3. data/lib/wallee-ruby-sdk/api/bank_account_service_api.rb +213 -0
  4. data/lib/wallee-ruby-sdk/api/bank_transaction_service_api.rb +213 -0
  5. data/lib/wallee-ruby-sdk/api/currency_bank_account_service_api.rb +213 -0
  6. data/lib/wallee-ruby-sdk/api/payment_terminal_till_service_api.rb +71 -0
  7. data/lib/wallee-ruby-sdk/api/shopify_subscriber_service_api.rb +62 -0
  8. data/lib/wallee-ruby-sdk/api/transaction_terminal_service_api.rb +21 -32
  9. data/lib/wallee-ruby-sdk/api/web_app_service_api.rb +200 -0
  10. data/lib/wallee-ruby-sdk/models/authenticated_card_data.rb +221 -0
  11. data/lib/wallee-ruby-sdk/models/{unencrypted_card_data.rb → authenticated_card_data_create.rb} +86 -12
  12. data/lib/wallee-ruby-sdk/models/card_authentication_response.rb +38 -0
  13. data/lib/wallee-ruby-sdk/models/card_authentication_version.rb +35 -0
  14. data/lib/wallee-ruby-sdk/models/card_cryptogram.rb +201 -0
  15. data/lib/wallee-ruby-sdk/models/card_cryptogram_create.rb +211 -0
  16. data/lib/wallee-ruby-sdk/models/card_cryptogram_type.rb +34 -0
  17. data/lib/wallee-ruby-sdk/models/cardholder_authentication.rb +231 -0
  18. data/lib/wallee-ruby-sdk/models/cardholder_authentication_create.rb +241 -0
  19. data/lib/wallee-ruby-sdk/models/charge_bank_transaction.rb +1 -1
  20. data/lib/wallee-ruby-sdk/models/payment_terminal.rb +11 -1
  21. data/lib/wallee-ruby-sdk/models/payment_terminal_configuration_version.rb +11 -1
  22. data/lib/wallee-ruby-sdk/models/payment_terminal_receipt_type.rb +215 -0
  23. data/lib/wallee-ruby-sdk/models/permission.rb +14 -4
  24. data/lib/wallee-ruby-sdk/models/recurring_indicator.rb +37 -0
  25. data/lib/wallee-ruby-sdk/models/refund_bank_transaction.rb +1 -1
  26. data/lib/wallee-ruby-sdk/models/refund_recovery_bank_transaction.rb +1 -1
  27. data/lib/wallee-ruby-sdk/models/rendered_terminal_receipt.rb +26 -6
  28. data/lib/wallee-ruby-sdk/models/shopify_subscriber_active.rb +241 -0
  29. data/lib/wallee-ruby-sdk/models/shopify_subscription.rb +11 -1
  30. data/lib/wallee-ruby-sdk/models/shopify_subscription_creation_request.rb +11 -1
  31. data/lib/wallee-ruby-sdk/models/subscription_product_component.rb +1 -1
  32. data/lib/wallee-ruby-sdk/models/subscription_product_component_update.rb +1 -1
  33. data/lib/wallee-ruby-sdk/models/tax_calculation.rb +2 -2
  34. data/lib/wallee-ruby-sdk/models/terminal_receipt_fetch_request.rb +221 -0
  35. data/lib/wallee-ruby-sdk/models/terminal_receipt_format.rb +35 -0
  36. data/lib/wallee-ruby-sdk/models/tokenized_card_data.rb +211 -0
  37. data/lib/wallee-ruby-sdk/models/{unencrypted_card_data_create.rb → tokenized_card_data_create.rb} +60 -5
  38. data/lib/wallee-ruby-sdk/models/web_app_confirmation_request.rb +206 -0
  39. data/lib/wallee-ruby-sdk/models/web_app_confirmation_response.rb +231 -0
  40. data/lib/wallee-ruby-sdk/models/webhook_url.rb +11 -1
  41. data/lib/wallee-ruby-sdk/version.rb +1 -1
  42. metadata +24 -4
@@ -0,0 +1,35 @@
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
+ class TerminalReceiptFormat
22
+
23
+ PDF = 'PDF'.freeze
24
+ TXT = 'TXT'.freeze
25
+
26
+ # Builds the enum from string
27
+ # @param [String] The enum value in the form of the string
28
+ # @return [String] The enum value
29
+ def build_from_hash(value)
30
+ constantValues = TerminalReceiptFormat.constants.select { |c| TerminalReceiptFormat::const_get(c) == value }
31
+ raise "Invalid ENUM value #{value} for class #TerminalReceiptFormat" if constantValues.empty?
32
+ value
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,211 @@
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
+ # This model holds the card data in plain.
22
+ class TokenizedCardData
23
+ # The additional authentication value used to secure the tokenized card transactions.
24
+ attr_accessor :cryptogram
25
+
26
+ #
27
+ attr_accessor :recurring_indicator
28
+
29
+ #
30
+ attr_accessor :token_requestor_id
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'cryptogram' => :'cryptogram',
36
+ :'recurring_indicator' => :'recurringIndicator',
37
+ :'token_requestor_id' => :'tokenRequestorId'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.swagger_types
43
+ {
44
+ :'cryptogram' => :'CardCryptogram',
45
+ :'recurring_indicator' => :'RecurringIndicator',
46
+ :'token_requestor_id' => :'String'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
57
+
58
+ if attributes.has_key?(:'cryptogram')
59
+ self.cryptogram = attributes[:'cryptogram']
60
+ end
61
+
62
+ if attributes.has_key?(:'recurringIndicator')
63
+ self.recurring_indicator = attributes[:'recurringIndicator']
64
+ end
65
+
66
+ if attributes.has_key?(:'tokenRequestorId')
67
+ self.token_requestor_id = attributes[:'tokenRequestorId']
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ invalid_properties = Array.new
75
+ invalid_properties
76
+ end
77
+
78
+ # Check to see if the all the properties in the model are valid
79
+ # @return true if the model is valid
80
+ def valid?
81
+ true
82
+ end
83
+
84
+ # Checks equality by comparing each attribute.
85
+ # @param [Object] Object to be compared
86
+ def ==(o)
87
+ return true if self.equal?(o)
88
+ self.class == o.class &&
89
+ cryptogram == o.cryptogram &&
90
+ recurring_indicator == o.recurring_indicator &&
91
+ token_requestor_id == o.token_requestor_id
92
+ end
93
+
94
+ # @see the `==` method
95
+ # @param [Object] Object to be compared
96
+ def eql?(o)
97
+ self == o
98
+ end
99
+
100
+ # Calculates hash code according to all attributes.
101
+ # @return [Fixnum] Hash code
102
+ def hash
103
+ [cryptogram, recurring_indicator, token_requestor_id].hash
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ self.class.swagger_types.each_pair do |key, type|
112
+ if type =~ /\AArray<(.*)>/i
113
+ # check to ensure the input is an array given that the attribute
114
+ # is documented as an array but the input is not
115
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
116
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
117
+ end
118
+ elsif !attributes[self.class.attribute_map[key]].nil?
119
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
121
+ end
122
+
123
+ self
124
+ end
125
+
126
+ # Deserializes the data based on type
127
+ # @param string type Data type
128
+ # @param string value Value to be deserialized
129
+ # @return [Object] Deserialized data
130
+ def _deserialize(type, value)
131
+ case type.to_sym
132
+ when :DateTime
133
+ DateTime.parse(value)
134
+ when :Date
135
+ Date.parse(value)
136
+ when :String
137
+ value.to_s
138
+ when :Integer
139
+ value.to_i
140
+ when :Float
141
+ value.to_f
142
+ when :BOOLEAN
143
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
144
+ true
145
+ else
146
+ false
147
+ end
148
+ when :Object
149
+ # generic object (usually a Hash), return directly
150
+ value
151
+ when /\AArray<(?<inner_type>.+)>\z/
152
+ inner_type = Regexp.last_match[:inner_type]
153
+ value.map { |v| _deserialize(inner_type, v) }
154
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
155
+ k_type = Regexp.last_match[:k_type]
156
+ v_type = Regexp.last_match[:v_type]
157
+ {}.tap do |hash|
158
+ value.each do |k, v|
159
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
160
+ end
161
+ end
162
+ else # model
163
+ temp_model = Wallee.const_get(type).new
164
+ temp_model.build_from_hash(value)
165
+ end
166
+ end
167
+
168
+ # Returns the string representation of the object
169
+ # @return [String] String presentation of the object
170
+ def to_s
171
+ to_hash.to_s
172
+ end
173
+
174
+ # to_body is an alias to to_hash (backward compatibility)
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_body
177
+ to_hash
178
+ end
179
+
180
+ # Returns the object in the form of hash
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_hash
183
+ hash = {}
184
+ self.class.attribute_map.each_pair do |attr, param|
185
+ value = self.send(attr)
186
+ next if value.nil?
187
+ hash[param] = _to_hash(value)
188
+ end
189
+ hash
190
+ end
191
+
192
+ # Outputs non-array value in the form of hash
193
+ # For object, use to_hash. Otherwise, just return the value
194
+ # @param [Object] value Any valid value
195
+ # @return [Hash] Returns the value in the form of hash
196
+ def _to_hash(value)
197
+ if value.is_a?(Array)
198
+ value.compact.map{ |v| _to_hash(v) }
199
+ elsif value.is_a?(Hash)
200
+ {}.tap do |hash|
201
+ value.each { |k, v| hash[k] = _to_hash(v) }
202
+ end
203
+ elsif value.respond_to? :to_hash
204
+ value.to_hash
205
+ else
206
+ value
207
+ end
208
+ end
209
+
210
+ end
211
+ end
@@ -19,26 +19,42 @@ require 'date'
19
19
 
20
20
  module Wallee
21
21
  # This model holds the card data in plain.
22
- class UnencryptedCardDataCreate
22
+ class TokenizedCardDataCreate
23
23
  # The card holder name is the name printed onto the card. It identifies the person who owns the card.
24
24
  attr_accessor :card_holder_name
25
25
 
26
26
  # The card verification code (CVC) is a 3 to 4 digit code typically printed on the back of the card. It helps to ensure that the card holder is authorizing the transaction. For card not-present transactions this field is optional.
27
27
  attr_accessor :card_verification_code
28
28
 
29
+ # The additional authentication value used to secure the tokenized card transactions.
30
+ attr_accessor :cryptogram
31
+
29
32
  # The card expiry date indicates when the card expires. The format is the format yyyy-mm where yyyy is the year (e.g. 2019) and the mm is the month (e.g. 09).
30
33
  attr_accessor :expiry_date
31
34
 
32
35
  # The primary account number (PAN) identifies the card. The number is numeric and typically printed on the front of the card.
33
36
  attr_accessor :primary_account_number
34
37
 
38
+ #
39
+ attr_accessor :recurring_indicator
40
+
41
+ #
42
+ attr_accessor :scheme_transaction_reference
43
+
44
+ #
45
+ attr_accessor :token_requestor_id
46
+
35
47
  # Attribute mapping from ruby-style variable name to JSON key.
36
48
  def self.attribute_map
37
49
  {
38
50
  :'card_holder_name' => :'cardHolderName',
39
51
  :'card_verification_code' => :'cardVerificationCode',
52
+ :'cryptogram' => :'cryptogram',
40
53
  :'expiry_date' => :'expiryDate',
41
- :'primary_account_number' => :'primaryAccountNumber'
54
+ :'primary_account_number' => :'primaryAccountNumber',
55
+ :'recurring_indicator' => :'recurringIndicator',
56
+ :'scheme_transaction_reference' => :'schemeTransactionReference',
57
+ :'token_requestor_id' => :'tokenRequestorId'
42
58
  }
43
59
  end
44
60
 
@@ -47,8 +63,12 @@ module Wallee
47
63
  {
48
64
  :'card_holder_name' => :'String',
49
65
  :'card_verification_code' => :'String',
66
+ :'cryptogram' => :'CardCryptogramCreate',
50
67
  :'expiry_date' => :'String',
51
- :'primary_account_number' => :'String'
68
+ :'primary_account_number' => :'String',
69
+ :'recurring_indicator' => :'RecurringIndicator',
70
+ :'scheme_transaction_reference' => :'String',
71
+ :'token_requestor_id' => :'String'
52
72
  }
53
73
  end
54
74
 
@@ -68,6 +88,10 @@ module Wallee
68
88
  self.card_verification_code = attributes[:'cardVerificationCode']
69
89
  end
70
90
 
91
+ if attributes.has_key?(:'cryptogram')
92
+ self.cryptogram = attributes[:'cryptogram']
93
+ end
94
+
71
95
  if attributes.has_key?(:'expiryDate')
72
96
  self.expiry_date = attributes[:'expiryDate']
73
97
  end
@@ -75,6 +99,18 @@ module Wallee
75
99
  if attributes.has_key?(:'primaryAccountNumber')
76
100
  self.primary_account_number = attributes[:'primaryAccountNumber']
77
101
  end
102
+
103
+ if attributes.has_key?(:'recurringIndicator')
104
+ self.recurring_indicator = attributes[:'recurringIndicator']
105
+ end
106
+
107
+ if attributes.has_key?(:'schemeTransactionReference')
108
+ self.scheme_transaction_reference = attributes[:'schemeTransactionReference']
109
+ end
110
+
111
+ if attributes.has_key?(:'tokenRequestorId')
112
+ self.token_requestor_id = attributes[:'tokenRequestorId']
113
+ end
78
114
  end
79
115
 
80
116
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -105,6 +141,10 @@ module Wallee
105
141
  invalid_properties.push('invalid value for "primary_account_number", the character length must be great than or equal to 10.')
106
142
  end
107
143
 
144
+ if !@scheme_transaction_reference.nil? && @scheme_transaction_reference.to_s.length > 100
145
+ invalid_properties.push('invalid value for "scheme_transaction_reference", the character length must be smaller than or equal to 100.')
146
+ end
147
+
108
148
  invalid_properties
109
149
  end
110
150
 
@@ -117,6 +157,7 @@ module Wallee
117
157
  return false if @primary_account_number.nil?
118
158
  return false if @primary_account_number.to_s.length > 30
119
159
  return false if @primary_account_number.to_s.length < 10
160
+ return false if !@scheme_transaction_reference.nil? && @scheme_transaction_reference.to_s.length > 100
120
161
  true
121
162
  end
122
163
 
@@ -162,6 +203,16 @@ module Wallee
162
203
  @primary_account_number = primary_account_number
163
204
  end
164
205
 
206
+ # Custom attribute writer method with validation
207
+ # @param [Object] scheme_transaction_reference Value to be assigned
208
+ def scheme_transaction_reference=(scheme_transaction_reference)
209
+ if !scheme_transaction_reference.nil? && scheme_transaction_reference.to_s.length > 100
210
+ fail ArgumentError, 'invalid value for "scheme_transaction_reference", the character length must be smaller than or equal to 100.'
211
+ end
212
+
213
+ @scheme_transaction_reference = scheme_transaction_reference
214
+ end
215
+
165
216
  # Checks equality by comparing each attribute.
166
217
  # @param [Object] Object to be compared
167
218
  def ==(o)
@@ -169,8 +220,12 @@ module Wallee
169
220
  self.class == o.class &&
170
221
  card_holder_name == o.card_holder_name &&
171
222
  card_verification_code == o.card_verification_code &&
223
+ cryptogram == o.cryptogram &&
172
224
  expiry_date == o.expiry_date &&
173
- primary_account_number == o.primary_account_number
225
+ primary_account_number == o.primary_account_number &&
226
+ recurring_indicator == o.recurring_indicator &&
227
+ scheme_transaction_reference == o.scheme_transaction_reference &&
228
+ token_requestor_id == o.token_requestor_id
174
229
  end
175
230
 
176
231
  # @see the `==` method
@@ -182,7 +237,7 @@ module Wallee
182
237
  # Calculates hash code according to all attributes.
183
238
  # @return [Fixnum] Hash code
184
239
  def hash
185
- [card_holder_name, card_verification_code, expiry_date, primary_account_number].hash
240
+ [card_holder_name, card_verification_code, cryptogram, expiry_date, primary_account_number, recurring_indicator, scheme_transaction_reference, token_requestor_id].hash
186
241
  end
187
242
 
188
243
  # Builds the object from hash
@@ -0,0 +1,206 @@
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 WebAppConfirmationRequest
23
+ # The user returns to the web app after granting the permission. The HTTP request contains the code. Provide it here to confirm the web app installation.
24
+ attr_accessor :code
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'code' => :'code'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'code' => :'String'
37
+ }
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ return unless attributes.is_a?(Hash)
44
+
45
+ # convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
47
+
48
+ if attributes.has_key?(:'code')
49
+ self.code = attributes[:'code']
50
+ end
51
+ end
52
+
53
+ # Show invalid properties with the reasons. Usually used together with valid?
54
+ # @return Array for valid properties with the reasons
55
+ def list_invalid_properties
56
+ invalid_properties = Array.new
57
+ if !@code.nil? && @code.to_s.length > 100
58
+ invalid_properties.push('invalid value for "code", the character length must be smaller than or equal to 100.')
59
+ end
60
+
61
+ invalid_properties
62
+ end
63
+
64
+ # Check to see if the all the properties in the model are valid
65
+ # @return true if the model is valid
66
+ def valid?
67
+ return false if !@code.nil? && @code.to_s.length > 100
68
+ true
69
+ end
70
+
71
+ # Custom attribute writer method with validation
72
+ # @param [Object] code Value to be assigned
73
+ def code=(code)
74
+ if !code.nil? && code.to_s.length > 100
75
+ fail ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 100.'
76
+ end
77
+
78
+ @code = code
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ code == o.code
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Fixnum] Hash code
97
+ def hash
98
+ [code].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ self.class.swagger_types.each_pair do |key, type|
107
+ if type =~ /\AArray<(.*)>/i
108
+ # check to ensure the input is an array given that the attribute
109
+ # is documented as an array but the input is not
110
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
111
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
112
+ end
113
+ elsif !attributes[self.class.attribute_map[key]].nil?
114
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
115
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
116
+ end
117
+
118
+ self
119
+ end
120
+
121
+ # Deserializes the data based on type
122
+ # @param string type Data type
123
+ # @param string value Value to be deserialized
124
+ # @return [Object] Deserialized data
125
+ def _deserialize(type, value)
126
+ case type.to_sym
127
+ when :DateTime
128
+ DateTime.parse(value)
129
+ when :Date
130
+ Date.parse(value)
131
+ when :String
132
+ value.to_s
133
+ when :Integer
134
+ value.to_i
135
+ when :Float
136
+ value.to_f
137
+ when :BOOLEAN
138
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
139
+ true
140
+ else
141
+ false
142
+ end
143
+ when :Object
144
+ # generic object (usually a Hash), return directly
145
+ value
146
+ when /\AArray<(?<inner_type>.+)>\z/
147
+ inner_type = Regexp.last_match[:inner_type]
148
+ value.map { |v| _deserialize(inner_type, v) }
149
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
150
+ k_type = Regexp.last_match[:k_type]
151
+ v_type = Regexp.last_match[:v_type]
152
+ {}.tap do |hash|
153
+ value.each do |k, v|
154
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
155
+ end
156
+ end
157
+ else # model
158
+ temp_model = Wallee.const_get(type).new
159
+ temp_model.build_from_hash(value)
160
+ end
161
+ end
162
+
163
+ # Returns the string representation of the object
164
+ # @return [String] String presentation of the object
165
+ def to_s
166
+ to_hash.to_s
167
+ end
168
+
169
+ # to_body is an alias to to_hash (backward compatibility)
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_body
172
+ to_hash
173
+ end
174
+
175
+ # Returns the object in the form of hash
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_hash
178
+ hash = {}
179
+ self.class.attribute_map.each_pair do |attr, param|
180
+ value = self.send(attr)
181
+ next if value.nil?
182
+ hash[param] = _to_hash(value)
183
+ end
184
+ hash
185
+ end
186
+
187
+ # Outputs non-array value in the form of hash
188
+ # For object, use to_hash. Otherwise, just return the value
189
+ # @param [Object] value Any valid value
190
+ # @return [Hash] Returns the value in the form of hash
191
+ def _to_hash(value)
192
+ if value.is_a?(Array)
193
+ value.compact.map{ |v| _to_hash(v) }
194
+ elsif value.is_a?(Hash)
195
+ {}.tap do |hash|
196
+ value.each { |k, v| hash[k] = _to_hash(v) }
197
+ end
198
+ elsif value.respond_to? :to_hash
199
+ value.to_hash
200
+ else
201
+ value
202
+ end
203
+ end
204
+
205
+ end
206
+ end