wallee-ruby-sdk 2.2.4 → 2.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/lib/wallee-ruby-sdk.rb +23 -1
  4. data/lib/wallee-ruby-sdk/api/charge_bank_transaction_service_api.rb +213 -0
  5. data/lib/wallee-ruby-sdk/api/external_transfer_bank_transaction_service_api.rb +213 -0
  6. data/lib/wallee-ruby-sdk/api/internal_transfer_bank_transaction_service_api.rb +213 -0
  7. data/lib/wallee-ruby-sdk/api/refund_bank_transaction_service_api.rb +213 -0
  8. data/lib/wallee-ruby-sdk/api/refund_recovery_bank_transaction_service_api.rb +213 -0
  9. data/lib/wallee-ruby-sdk/api_client.rb +2 -1
  10. data/lib/wallee-ruby-sdk/models/abstract_payment_link_update.rb +15 -15
  11. data/lib/wallee-ruby-sdk/models/bank_account.rb +291 -0
  12. data/lib/wallee-ruby-sdk/models/bank_account_environment.rb +35 -0
  13. data/lib/wallee-ruby-sdk/models/bank_account_state.rb +37 -0
  14. data/lib/wallee-ruby-sdk/models/bank_account_type.rb +227 -0
  15. data/lib/wallee-ruby-sdk/models/bank_transaction.rb +387 -0
  16. data/lib/wallee-ruby-sdk/models/bank_transaction_flow_direction.rb +35 -0
  17. data/lib/wallee-ruby-sdk/models/bank_transaction_source.rb +215 -0
  18. data/lib/wallee-ruby-sdk/models/bank_transaction_state.rb +35 -0
  19. data/lib/wallee-ruby-sdk/models/bank_transaction_type.rb +215 -0
  20. data/lib/wallee-ruby-sdk/models/charge_bank_transaction.rb +291 -0
  21. data/lib/wallee-ruby-sdk/models/currency_bank_account.rb +241 -0
  22. data/lib/wallee-ruby-sdk/models/external_transfer_bank_transaction.rb +251 -0
  23. data/lib/wallee-ruby-sdk/models/internal_transfer_bank_transaction.rb +231 -0
  24. data/lib/wallee-ruby-sdk/models/payment_adjustment.rb +231 -0
  25. data/lib/wallee-ruby-sdk/models/payment_adjustment_type.rb +215 -0
  26. data/lib/wallee-ruby-sdk/models/payment_link.rb +15 -15
  27. data/lib/wallee-ruby-sdk/models/payment_link_active.rb +15 -15
  28. data/lib/wallee-ruby-sdk/models/payment_link_address_handling_mode.rb +36 -0
  29. data/lib/wallee-ruby-sdk/models/payment_link_create.rb +15 -15
  30. data/lib/wallee-ruby-sdk/models/payment_link_update.rb +15 -15
  31. data/lib/wallee-ruby-sdk/models/payment_terminal_address.rb +0 -60
  32. data/lib/wallee-ruby-sdk/models/payment_terminal_location.rb +2 -12
  33. data/lib/wallee-ruby-sdk/models/refund_bank_transaction.rb +281 -0
  34. data/lib/wallee-ruby-sdk/models/refund_recovery_bank_transaction.rb +293 -0
  35. data/lib/wallee-ruby-sdk/models/subscription_ledger_entry.rb +11 -1
  36. data/lib/wallee-ruby-sdk/models/transaction.rb +64 -4
  37. data/lib/wallee-ruby-sdk/version.rb +1 -1
  38. data/test/condition_type_service_test.rb +22 -0
  39. metadata +27 -3
  40. data/lib/wallee-ruby-sdk/models/payment_terminal_contact_address.rb +0 -396
@@ -0,0 +1,227 @@
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 BankAccountType
23
+ #
24
+ attr_accessor :description
25
+
26
+ # The ID is the primary key of the entity. The ID identifies the entity uniquely.
27
+ attr_accessor :id
28
+
29
+ #
30
+ attr_accessor :identifier_name
31
+
32
+ #
33
+ attr_accessor :name
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'description' => :'description',
39
+ :'id' => :'id',
40
+ :'identifier_name' => :'identifierName',
41
+ :'name' => :'name'
42
+ }
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.swagger_types
47
+ {
48
+ :'description' => :'Hash<String, String>',
49
+ :'id' => :'Integer',
50
+ :'identifier_name' => :'Hash<String, String>',
51
+ :'name' => :'Hash<String, String>'
52
+ }
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ return unless attributes.is_a?(Hash)
59
+
60
+ # convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
62
+
63
+ if attributes.has_key?(:'description')
64
+ if (value = attributes[:'description']).is_a?(Hash)
65
+ self.description = value
66
+ end
67
+ end
68
+
69
+ if attributes.has_key?(:'id')
70
+ self.id = attributes[:'id']
71
+ end
72
+
73
+ if attributes.has_key?(:'identifierName')
74
+ if (value = attributes[:'identifierName']).is_a?(Hash)
75
+ self.identifier_name = value
76
+ end
77
+ end
78
+
79
+ if attributes.has_key?(:'name')
80
+ if (value = attributes[:'name']).is_a?(Hash)
81
+ self.name = value
82
+ end
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ true
97
+ end
98
+
99
+ # Checks equality by comparing each attribute.
100
+ # @param [Object] Object to be compared
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ description == o.description &&
105
+ id == o.id &&
106
+ identifier_name == o.identifier_name &&
107
+ name == o.name
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Fixnum] Hash code
118
+ def hash
119
+ [description, id, identifier_name, name].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ self.class.swagger_types.each_pair do |key, type|
128
+ if type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def _deserialize(type, value)
147
+ case type.to_sym
148
+ when :DateTime
149
+ DateTime.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :BOOLEAN
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ temp_model = Wallee.const_get(type).new
180
+ temp_model.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ # Returns the string representation of the object
185
+ # @return [String] String presentation of the object
186
+ def to_s
187
+ to_hash.to_s
188
+ end
189
+
190
+ # to_body is an alias to to_hash (backward compatibility)
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_body
193
+ to_hash
194
+ end
195
+
196
+ # Returns the object in the form of hash
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_hash
199
+ hash = {}
200
+ self.class.attribute_map.each_pair do |attr, param|
201
+ value = self.send(attr)
202
+ next if value.nil?
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map{ |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+
226
+ end
227
+ end
@@ -0,0 +1,387 @@
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 BankTransaction
23
+ # The adjustments applied on this bank transaction.
24
+ attr_accessor :adjustments
25
+
26
+ # The created by indicates the user which has created the bank transaction.
27
+ attr_accessor :created_by
28
+
29
+ # The created on date indicates the date on which the entity was stored into the database.
30
+ attr_accessor :created_on
31
+
32
+ # The currency bank account which is used to handle money flow.
33
+ attr_accessor :currency_bank_account
34
+
35
+ #
36
+ attr_accessor :external_id
37
+
38
+ #
39
+ attr_accessor :flow_direction
40
+
41
+ # The ID is the primary key of the entity. The ID identifies the entity uniquely.
42
+ attr_accessor :id
43
+
44
+ # The linked space id holds the ID of the space to which the entity belongs to.
45
+ attr_accessor :linked_space_id
46
+
47
+ # The planned purge date indicates when the entity is permanently removed. When the date is null the entity is not planned to be removed.
48
+ attr_accessor :planned_purge_date
49
+
50
+ # The posting amount indicates the amount including adjustments.
51
+ attr_accessor :posting_amount
52
+
53
+ #
54
+ attr_accessor :reference
55
+
56
+ #
57
+ attr_accessor :source
58
+
59
+ #
60
+ attr_accessor :state
61
+
62
+ #
63
+ attr_accessor :total_adjustment_amount_including_tax
64
+
65
+ #
66
+ attr_accessor :type
67
+
68
+ #
69
+ attr_accessor :value_amount
70
+
71
+ # The value date describes the date the amount is effective on the account.
72
+ attr_accessor :value_date
73
+
74
+ # The version number indicates the version of the entity. The version is incremented whenever the entity is changed.
75
+ attr_accessor :version
76
+
77
+ # Attribute mapping from ruby-style variable name to JSON key.
78
+ def self.attribute_map
79
+ {
80
+ :'adjustments' => :'adjustments',
81
+ :'created_by' => :'createdBy',
82
+ :'created_on' => :'createdOn',
83
+ :'currency_bank_account' => :'currencyBankAccount',
84
+ :'external_id' => :'externalId',
85
+ :'flow_direction' => :'flowDirection',
86
+ :'id' => :'id',
87
+ :'linked_space_id' => :'linkedSpaceId',
88
+ :'planned_purge_date' => :'plannedPurgeDate',
89
+ :'posting_amount' => :'postingAmount',
90
+ :'reference' => :'reference',
91
+ :'source' => :'source',
92
+ :'state' => :'state',
93
+ :'total_adjustment_amount_including_tax' => :'totalAdjustmentAmountIncludingTax',
94
+ :'type' => :'type',
95
+ :'value_amount' => :'valueAmount',
96
+ :'value_date' => :'valueDate',
97
+ :'version' => :'version'
98
+ }
99
+ end
100
+
101
+ # Attribute type mapping.
102
+ def self.swagger_types
103
+ {
104
+ :'adjustments' => :'Array<PaymentAdjustment>',
105
+ :'created_by' => :'Integer',
106
+ :'created_on' => :'DateTime',
107
+ :'currency_bank_account' => :'CurrencyBankAccount',
108
+ :'external_id' => :'String',
109
+ :'flow_direction' => :'BankTransactionFlowDirection',
110
+ :'id' => :'Integer',
111
+ :'linked_space_id' => :'Integer',
112
+ :'planned_purge_date' => :'DateTime',
113
+ :'posting_amount' => :'Float',
114
+ :'reference' => :'String',
115
+ :'source' => :'Integer',
116
+ :'state' => :'BankTransactionState',
117
+ :'total_adjustment_amount_including_tax' => :'Float',
118
+ :'type' => :'Integer',
119
+ :'value_amount' => :'Float',
120
+ :'value_date' => :'DateTime',
121
+ :'version' => :'Integer'
122
+ }
123
+ end
124
+
125
+ # Initializes the object
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ def initialize(attributes = {})
128
+ return unless attributes.is_a?(Hash)
129
+
130
+ # convert string to symbol for hash key
131
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
132
+
133
+ if attributes.has_key?(:'adjustments')
134
+ if (value = attributes[:'adjustments']).is_a?(Array)
135
+ self.adjustments = value
136
+ end
137
+ end
138
+
139
+ if attributes.has_key?(:'createdBy')
140
+ self.created_by = attributes[:'createdBy']
141
+ end
142
+
143
+ if attributes.has_key?(:'createdOn')
144
+ self.created_on = attributes[:'createdOn']
145
+ end
146
+
147
+ if attributes.has_key?(:'currencyBankAccount')
148
+ self.currency_bank_account = attributes[:'currencyBankAccount']
149
+ end
150
+
151
+ if attributes.has_key?(:'externalId')
152
+ self.external_id = attributes[:'externalId']
153
+ end
154
+
155
+ if attributes.has_key?(:'flowDirection')
156
+ self.flow_direction = attributes[:'flowDirection']
157
+ end
158
+
159
+ if attributes.has_key?(:'id')
160
+ self.id = attributes[:'id']
161
+ end
162
+
163
+ if attributes.has_key?(:'linkedSpaceId')
164
+ self.linked_space_id = attributes[:'linkedSpaceId']
165
+ end
166
+
167
+ if attributes.has_key?(:'plannedPurgeDate')
168
+ self.planned_purge_date = attributes[:'plannedPurgeDate']
169
+ end
170
+
171
+ if attributes.has_key?(:'postingAmount')
172
+ self.posting_amount = attributes[:'postingAmount']
173
+ end
174
+
175
+ if attributes.has_key?(:'reference')
176
+ self.reference = attributes[:'reference']
177
+ end
178
+
179
+ if attributes.has_key?(:'source')
180
+ self.source = attributes[:'source']
181
+ end
182
+
183
+ if attributes.has_key?(:'state')
184
+ self.state = attributes[:'state']
185
+ end
186
+
187
+ if attributes.has_key?(:'totalAdjustmentAmountIncludingTax')
188
+ self.total_adjustment_amount_including_tax = attributes[:'totalAdjustmentAmountIncludingTax']
189
+ end
190
+
191
+ if attributes.has_key?(:'type')
192
+ self.type = attributes[:'type']
193
+ end
194
+
195
+ if attributes.has_key?(:'valueAmount')
196
+ self.value_amount = attributes[:'valueAmount']
197
+ end
198
+
199
+ if attributes.has_key?(:'valueDate')
200
+ self.value_date = attributes[:'valueDate']
201
+ end
202
+
203
+ if attributes.has_key?(:'version')
204
+ self.version = attributes[:'version']
205
+ end
206
+ end
207
+
208
+ # Show invalid properties with the reasons. Usually used together with valid?
209
+ # @return Array for valid properties with the reasons
210
+ def list_invalid_properties
211
+ invalid_properties = Array.new
212
+ if !@external_id.nil? && @external_id.to_s.length > 100
213
+ invalid_properties.push('invalid value for "external_id", the character length must be smaller than or equal to 100.')
214
+ end
215
+
216
+ if !@external_id.nil? && @external_id.to_s.length < 1
217
+ invalid_properties.push('invalid value for "external_id", the character length must be great than or equal to 1.')
218
+ end
219
+
220
+ invalid_properties
221
+ end
222
+
223
+ # Check to see if the all the properties in the model are valid
224
+ # @return true if the model is valid
225
+ def valid?
226
+ return false if !@external_id.nil? && @external_id.to_s.length > 100
227
+ return false if !@external_id.nil? && @external_id.to_s.length < 1
228
+ true
229
+ end
230
+
231
+ # Custom attribute writer method with validation
232
+ # @param [Object] external_id Value to be assigned
233
+ def external_id=(external_id)
234
+ if !external_id.nil? && external_id.to_s.length > 100
235
+ fail ArgumentError, 'invalid value for "external_id", the character length must be smaller than or equal to 100.'
236
+ end
237
+
238
+ if !external_id.nil? && external_id.to_s.length < 1
239
+ fail ArgumentError, 'invalid value for "external_id", the character length must be great than or equal to 1.'
240
+ end
241
+
242
+ @external_id = external_id
243
+ end
244
+
245
+ # Checks equality by comparing each attribute.
246
+ # @param [Object] Object to be compared
247
+ def ==(o)
248
+ return true if self.equal?(o)
249
+ self.class == o.class &&
250
+ adjustments == o.adjustments &&
251
+ created_by == o.created_by &&
252
+ created_on == o.created_on &&
253
+ currency_bank_account == o.currency_bank_account &&
254
+ external_id == o.external_id &&
255
+ flow_direction == o.flow_direction &&
256
+ id == o.id &&
257
+ linked_space_id == o.linked_space_id &&
258
+ planned_purge_date == o.planned_purge_date &&
259
+ posting_amount == o.posting_amount &&
260
+ reference == o.reference &&
261
+ source == o.source &&
262
+ state == o.state &&
263
+ total_adjustment_amount_including_tax == o.total_adjustment_amount_including_tax &&
264
+ type == o.type &&
265
+ value_amount == o.value_amount &&
266
+ value_date == o.value_date &&
267
+ version == o.version
268
+ end
269
+
270
+ # @see the `==` method
271
+ # @param [Object] Object to be compared
272
+ def eql?(o)
273
+ self == o
274
+ end
275
+
276
+ # Calculates hash code according to all attributes.
277
+ # @return [Fixnum] Hash code
278
+ def hash
279
+ [adjustments, created_by, created_on, currency_bank_account, external_id, flow_direction, id, linked_space_id, planned_purge_date, posting_amount, reference, source, state, total_adjustment_amount_including_tax, type, value_amount, value_date, version].hash
280
+ end
281
+
282
+ # Builds the object from hash
283
+ # @param [Hash] attributes Model attributes in the form of hash
284
+ # @return [Object] Returns the model itself
285
+ def build_from_hash(attributes)
286
+ return nil unless attributes.is_a?(Hash)
287
+ self.class.swagger_types.each_pair do |key, type|
288
+ if type =~ /\AArray<(.*)>/i
289
+ # check to ensure the input is an array given that the attribute
290
+ # is documented as an array but the input is not
291
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
292
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
293
+ end
294
+ elsif !attributes[self.class.attribute_map[key]].nil?
295
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
296
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
297
+ end
298
+
299
+ self
300
+ end
301
+
302
+ # Deserializes the data based on type
303
+ # @param string type Data type
304
+ # @param string value Value to be deserialized
305
+ # @return [Object] Deserialized data
306
+ def _deserialize(type, value)
307
+ case type.to_sym
308
+ when :DateTime
309
+ DateTime.parse(value)
310
+ when :Date
311
+ Date.parse(value)
312
+ when :String
313
+ value.to_s
314
+ when :Integer
315
+ value.to_i
316
+ when :Float
317
+ value.to_f
318
+ when :BOOLEAN
319
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
320
+ true
321
+ else
322
+ false
323
+ end
324
+ when :Object
325
+ # generic object (usually a Hash), return directly
326
+ value
327
+ when /\AArray<(?<inner_type>.+)>\z/
328
+ inner_type = Regexp.last_match[:inner_type]
329
+ value.map { |v| _deserialize(inner_type, v) }
330
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
331
+ k_type = Regexp.last_match[:k_type]
332
+ v_type = Regexp.last_match[:v_type]
333
+ {}.tap do |hash|
334
+ value.each do |k, v|
335
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
336
+ end
337
+ end
338
+ else # model
339
+ temp_model = Wallee.const_get(type).new
340
+ temp_model.build_from_hash(value)
341
+ end
342
+ end
343
+
344
+ # Returns the string representation of the object
345
+ # @return [String] String presentation of the object
346
+ def to_s
347
+ to_hash.to_s
348
+ end
349
+
350
+ # to_body is an alias to to_hash (backward compatibility)
351
+ # @return [Hash] Returns the object in the form of hash
352
+ def to_body
353
+ to_hash
354
+ end
355
+
356
+ # Returns the object in the form of hash
357
+ # @return [Hash] Returns the object in the form of hash
358
+ def to_hash
359
+ hash = {}
360
+ self.class.attribute_map.each_pair do |attr, param|
361
+ value = self.send(attr)
362
+ next if value.nil?
363
+ hash[param] = _to_hash(value)
364
+ end
365
+ hash
366
+ end
367
+
368
+ # Outputs non-array value in the form of hash
369
+ # For object, use to_hash. Otherwise, just return the value
370
+ # @param [Object] value Any valid value
371
+ # @return [Hash] Returns the value in the form of hash
372
+ def _to_hash(value)
373
+ if value.is_a?(Array)
374
+ value.compact.map{ |v| _to_hash(v) }
375
+ elsif value.is_a?(Hash)
376
+ {}.tap do |hash|
377
+ value.each { |k, v| hash[k] = _to_hash(v) }
378
+ end
379
+ elsif value.respond_to? :to_hash
380
+ value.to_hash
381
+ else
382
+ value
383
+ end
384
+ end
385
+
386
+ end
387
+ end