transferzero-sdk 1.12.2 → 1.14.2
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.
- checksums.yaml +4 -4
- data/README.md +9 -4
- data/docs/PayoutMethod.md +1 -1
- data/docs/PayoutMethodCountryEnumUSDBank.md +16 -0
- data/docs/PayoutMethodDetails.md +16 -6
- data/docs/PayoutMethodDetailsGHSCash.md +21 -0
- data/docs/PayoutMethodDetailsMADCash.md +3 -3
- data/docs/PayoutMethodDetailsUSDBank.md +27 -0
- data/docs/PayoutMethodDetailsXOFMobile.md +3 -1
- data/docs/PayoutMethodDetailsZARBank.md +13 -1
- data/docs/PayoutMethodLegalEntityTypeEnum.md +16 -0
- data/docs/PayoutMethodNatureOfBusinessEnum.md +16 -0
- data/docs/TransactionsApi.md +2 -0
- data/lib/transferzero-sdk.rb +5 -0
- data/lib/transferzero-sdk/api/transactions_api.rb +6 -0
- data/lib/transferzero-sdk/api_client.rb +2 -2
- data/lib/transferzero-sdk/models/account_validation_request.rb +4 -4
- data/lib/transferzero-sdk/models/payout_method.rb +1 -1
- data/lib/transferzero-sdk/models/payout_method_country_enum.rb +234 -8
- data/lib/transferzero-sdk/models/payout_method_country_enum_usd_bank.rb +269 -0
- data/lib/transferzero-sdk/models/payout_method_details.rb +65 -28
- data/lib/transferzero-sdk/models/payout_method_details_ghs_cash.rb +236 -0
- data/lib/transferzero-sdk/models/payout_method_details_mad_cash.rb +1 -16
- data/lib/transferzero-sdk/models/payout_method_details_usd_bank.rb +278 -0
- data/lib/transferzero-sdk/models/payout_method_details_xof_cash.rb +1 -1
- data/lib/transferzero-sdk/models/payout_method_details_xof_mobile.rb +14 -5
- data/lib/transferzero-sdk/models/payout_method_details_zar_bank.rb +59 -5
- data/lib/transferzero-sdk/models/payout_method_legal_entity_type_enum.rb +37 -0
- data/lib/transferzero-sdk/models/payout_method_mobile_provider_enum.rb +1 -0
- data/lib/transferzero-sdk/models/payout_method_nature_of_business_enum.rb +65 -0
- data/lib/transferzero-sdk/version.rb +1 -1
- data/spec/models/payout_method_country_enum_usd_bank_spec.rb +35 -0
- data/spec/models/payout_method_details_ghs_cash_spec.rb +53 -0
- data/spec/models/payout_method_details_usd_bank_spec.rb +71 -0
- data/spec/models/payout_method_legal_entity_type_enum_spec.rb +35 -0
- data/spec/models/payout_method_nature_of_business_enum_spec.rb +35 -0
- metadata +32 -13
- data/transferzero-sdk-1.9.0.gem +0 -0
@@ -28,6 +28,8 @@ class PayoutMethodDetails
|
|
28
28
|
|
29
29
|
attr_accessor :mobile_provider
|
30
30
|
|
31
|
+
attr_accessor :country
|
32
|
+
|
31
33
|
attr_accessor :iban
|
32
34
|
|
33
35
|
attr_accessor :bank_name
|
@@ -36,8 +38,6 @@ class PayoutMethodDetails
|
|
36
38
|
|
37
39
|
attr_accessor :cash_provider
|
38
40
|
|
39
|
-
attr_accessor :country
|
40
|
-
|
41
41
|
attr_accessor :sort_code
|
42
42
|
|
43
43
|
attr_accessor :bic
|
@@ -74,6 +74,16 @@ class PayoutMethodDetails
|
|
74
74
|
|
75
75
|
attr_accessor :transfer_reason_code
|
76
76
|
|
77
|
+
attr_accessor :contact_first_name
|
78
|
+
|
79
|
+
attr_accessor :contact_last_name
|
80
|
+
|
81
|
+
attr_accessor :registration_number
|
82
|
+
|
83
|
+
attr_accessor :nature_of_business
|
84
|
+
|
85
|
+
attr_accessor :legal_entity_type
|
86
|
+
|
77
87
|
# Attribute mapping from ruby-style variable name to JSON key.
|
78
88
|
def self.attribute_map
|
79
89
|
{
|
@@ -84,11 +94,11 @@ class PayoutMethodDetails
|
|
84
94
|
:'bank_account_type' => :'bank_account_type',
|
85
95
|
:'phone_number' => :'phone_number',
|
86
96
|
:'mobile_provider' => :'mobile_provider',
|
97
|
+
:'country' => :'country',
|
87
98
|
:'iban' => :'iban',
|
88
99
|
:'bank_name' => :'bank_name',
|
89
100
|
:'bank_country' => :'bank_country',
|
90
101
|
:'cash_provider' => :'cash_provider',
|
91
|
-
:'country' => :'country',
|
92
102
|
:'sort_code' => :'sort_code',
|
93
103
|
:'bic' => :'bic',
|
94
104
|
:'sender_identity_card_type' => :'sender_identity_card_type',
|
@@ -106,7 +116,12 @@ class PayoutMethodDetails
|
|
106
116
|
:'postal_code' => :'postal_code',
|
107
117
|
:'city' => :'city',
|
108
118
|
:'email' => :'email',
|
109
|
-
:'transfer_reason_code' => :'transfer_reason_code'
|
119
|
+
:'transfer_reason_code' => :'transfer_reason_code',
|
120
|
+
:'contact_first_name' => :'contact_first_name',
|
121
|
+
:'contact_last_name' => :'contact_last_name',
|
122
|
+
:'registration_number' => :'registration_number',
|
123
|
+
:'nature_of_business' => :'nature_of_business',
|
124
|
+
:'legal_entity_type' => :'legal_entity_type'
|
110
125
|
}
|
111
126
|
end
|
112
127
|
|
@@ -120,11 +135,11 @@ class PayoutMethodDetails
|
|
120
135
|
:'bank_account_type' => :'PayoutMethodBankAccountTypeEnum',
|
121
136
|
:'phone_number' => :'String',
|
122
137
|
:'mobile_provider' => :'PayoutMethodMobileProviderEnum',
|
138
|
+
:'country' => :'PayoutMethodCountryEnumUSDBank',
|
123
139
|
:'iban' => :'String',
|
124
140
|
:'bank_name' => :'String',
|
125
141
|
:'bank_country' => :'String',
|
126
142
|
:'cash_provider' => :'PayoutMethodCashProviderEnum',
|
127
|
-
:'country' => :'PayoutMethodCountryEnum',
|
128
143
|
:'sort_code' => :'String',
|
129
144
|
:'bic' => :'String',
|
130
145
|
:'sender_identity_card_type' => :'PayoutMethodIdentityCardTypeEnum',
|
@@ -142,7 +157,12 @@ class PayoutMethodDetails
|
|
142
157
|
:'postal_code' => :'String',
|
143
158
|
:'city' => :'String',
|
144
159
|
:'email' => :'String',
|
145
|
-
:'transfer_reason_code' => :'String'
|
160
|
+
:'transfer_reason_code' => :'String',
|
161
|
+
:'contact_first_name' => :'String',
|
162
|
+
:'contact_last_name' => :'String',
|
163
|
+
:'registration_number' => :'String',
|
164
|
+
:'nature_of_business' => :'PayoutMethodNatureOfBusinessEnum',
|
165
|
+
:'legal_entity_type' => :'PayoutMethodLegalEntityTypeEnum'
|
146
166
|
}
|
147
167
|
end
|
148
168
|
|
@@ -153,10 +173,12 @@ class PayoutMethodDetails
|
|
153
173
|
:'PayoutMethodDetailsBalance',
|
154
174
|
:'PayoutMethodDetailsGBPBank',
|
155
175
|
:'PayoutMethodDetailsGHSBank',
|
176
|
+
:'PayoutMethodDetailsGHSCash',
|
156
177
|
:'PayoutMethodDetailsIBAN',
|
157
178
|
:'PayoutMethodDetailsMADCash',
|
158
179
|
:'PayoutMethodDetailsMobile',
|
159
180
|
:'PayoutMethodDetailsNGNBank',
|
181
|
+
:'PayoutMethodDetailsUSDBank',
|
160
182
|
:'PayoutMethodDetailsXOFBank',
|
161
183
|
:'PayoutMethodDetailsXOFCash',
|
162
184
|
:'PayoutMethodDetailsXOFMobile',
|
@@ -207,6 +229,10 @@ class PayoutMethodDetails
|
|
207
229
|
self.mobile_provider = attributes[:'mobile_provider']
|
208
230
|
end
|
209
231
|
|
232
|
+
if attributes.key?(:'country')
|
233
|
+
self.country = attributes[:'country']
|
234
|
+
end
|
235
|
+
|
210
236
|
if attributes.key?(:'iban')
|
211
237
|
self.iban = attributes[:'iban']
|
212
238
|
end
|
@@ -223,10 +249,6 @@ class PayoutMethodDetails
|
|
223
249
|
self.cash_provider = attributes[:'cash_provider']
|
224
250
|
end
|
225
251
|
|
226
|
-
if attributes.key?(:'country')
|
227
|
-
self.country = attributes[:'country']
|
228
|
-
end
|
229
|
-
|
230
252
|
if attributes.key?(:'sort_code')
|
231
253
|
self.sort_code = attributes[:'sort_code']
|
232
254
|
end
|
@@ -298,6 +320,26 @@ class PayoutMethodDetails
|
|
298
320
|
if attributes.key?(:'transfer_reason_code')
|
299
321
|
self.transfer_reason_code = attributes[:'transfer_reason_code']
|
300
322
|
end
|
323
|
+
|
324
|
+
if attributes.key?(:'contact_first_name')
|
325
|
+
self.contact_first_name = attributes[:'contact_first_name']
|
326
|
+
end
|
327
|
+
|
328
|
+
if attributes.key?(:'contact_last_name')
|
329
|
+
self.contact_last_name = attributes[:'contact_last_name']
|
330
|
+
end
|
331
|
+
|
332
|
+
if attributes.key?(:'registration_number')
|
333
|
+
self.registration_number = attributes[:'registration_number']
|
334
|
+
end
|
335
|
+
|
336
|
+
if attributes.key?(:'nature_of_business')
|
337
|
+
self.nature_of_business = attributes[:'nature_of_business']
|
338
|
+
end
|
339
|
+
|
340
|
+
if attributes.key?(:'legal_entity_type')
|
341
|
+
self.legal_entity_type = attributes[:'legal_entity_type']
|
342
|
+
end
|
301
343
|
end
|
302
344
|
|
303
345
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -328,6 +370,10 @@ class PayoutMethodDetails
|
|
328
370
|
invalid_properties.push('invalid value for "mobile_provider", mobile_provider cannot be nil.')
|
329
371
|
end
|
330
372
|
|
373
|
+
if @country.nil?
|
374
|
+
invalid_properties.push('invalid value for "country", country cannot be nil.')
|
375
|
+
end
|
376
|
+
|
331
377
|
if @iban.nil?
|
332
378
|
invalid_properties.push('invalid value for "iban", iban cannot be nil.')
|
333
379
|
end
|
@@ -348,18 +394,6 @@ class PayoutMethodDetails
|
|
348
394
|
invalid_properties.push('invalid value for "sender_identity_card_id", sender_identity_card_id cannot be nil.')
|
349
395
|
end
|
350
396
|
|
351
|
-
if @sender_city_of_birth.nil?
|
352
|
-
invalid_properties.push('invalid value for "sender_city_of_birth", sender_city_of_birth cannot be nil.')
|
353
|
-
end
|
354
|
-
|
355
|
-
if @sender_country_of_birth.nil?
|
356
|
-
invalid_properties.push('invalid value for "sender_country_of_birth", sender_country_of_birth cannot be nil.')
|
357
|
-
end
|
358
|
-
|
359
|
-
if @sender_gender.nil?
|
360
|
-
invalid_properties.push('invalid value for "sender_gender", sender_gender cannot be nil.')
|
361
|
-
end
|
362
|
-
|
363
397
|
if @name.nil?
|
364
398
|
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
365
399
|
end
|
@@ -392,14 +426,12 @@ class PayoutMethodDetails
|
|
392
426
|
return false if @bank_account.nil?
|
393
427
|
return false if @phone_number.nil?
|
394
428
|
return false if @mobile_provider.nil?
|
429
|
+
return false if @country.nil?
|
395
430
|
return false if @iban.nil?
|
396
431
|
return false if @bank_name.nil?
|
397
432
|
return false if @bank_country.nil?
|
398
433
|
return false if @sender_identity_card_type.nil?
|
399
434
|
return false if @sender_identity_card_id.nil?
|
400
|
-
return false if @sender_city_of_birth.nil?
|
401
|
-
return false if @sender_country_of_birth.nil?
|
402
|
-
return false if @sender_gender.nil?
|
403
435
|
return false if @name.nil?
|
404
436
|
return false if @address.nil?
|
405
437
|
return false if @street.nil?
|
@@ -436,11 +468,11 @@ class PayoutMethodDetails
|
|
436
468
|
bank_account_type == o.bank_account_type &&
|
437
469
|
phone_number == o.phone_number &&
|
438
470
|
mobile_provider == o.mobile_provider &&
|
471
|
+
country == o.country &&
|
439
472
|
iban == o.iban &&
|
440
473
|
bank_name == o.bank_name &&
|
441
474
|
bank_country == o.bank_country &&
|
442
475
|
cash_provider == o.cash_provider &&
|
443
|
-
country == o.country &&
|
444
476
|
sort_code == o.sort_code &&
|
445
477
|
bic == o.bic &&
|
446
478
|
sender_identity_card_type == o.sender_identity_card_type &&
|
@@ -458,7 +490,12 @@ class PayoutMethodDetails
|
|
458
490
|
postal_code == o.postal_code &&
|
459
491
|
city == o.city &&
|
460
492
|
email == o.email &&
|
461
|
-
transfer_reason_code == o.transfer_reason_code
|
493
|
+
transfer_reason_code == o.transfer_reason_code &&
|
494
|
+
contact_first_name == o.contact_first_name &&
|
495
|
+
contact_last_name == o.contact_last_name &&
|
496
|
+
registration_number == o.registration_number &&
|
497
|
+
nature_of_business == o.nature_of_business &&
|
498
|
+
legal_entity_type == o.legal_entity_type
|
462
499
|
end
|
463
500
|
|
464
501
|
# @see the `==` method
|
@@ -470,7 +507,7 @@ class PayoutMethodDetails
|
|
470
507
|
# Calculates hash code according to all attributes.
|
471
508
|
# @return [Integer] Hash code
|
472
509
|
def hash
|
473
|
-
[first_name, last_name, bank_code, bank_account, bank_account_type, phone_number, mobile_provider, iban, bank_name, bank_country, cash_provider,
|
510
|
+
[first_name, last_name, bank_code, bank_account, bank_account_type, phone_number, mobile_provider, country, iban, bank_name, bank_country, cash_provider, sort_code, bic, sender_identity_card_type, sender_identity_card_id, sender_city_of_birth, sender_country_of_birth, sender_gender, reason, identity_card_type, identity_card_id, reference, name, address, street, postal_code, city, email, transfer_reason_code, contact_first_name, contact_last_name, registration_number, nature_of_business, legal_entity_type].hash
|
474
511
|
end
|
475
512
|
|
476
513
|
require 'active_support/core_ext/hash'
|
@@ -0,0 +1,236 @@
|
|
1
|
+
=begin
|
2
|
+
#TransferZero API
|
3
|
+
|
4
|
+
#Reference documentation for the TransferZero API V1
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-beta3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module TransferZero
|
16
|
+
# ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"0322023144\" } ```
|
17
|
+
class PayoutMethodDetailsGHSCash
|
18
|
+
attr_accessor :first_name
|
19
|
+
|
20
|
+
attr_accessor :last_name
|
21
|
+
|
22
|
+
attr_accessor :phone_number
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'first_name' => :'first_name',
|
28
|
+
:'last_name' => :'last_name',
|
29
|
+
:'phone_number' => :'phone_number'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.openapi_types
|
35
|
+
{
|
36
|
+
:'first_name' => :'String',
|
37
|
+
:'last_name' => :'String',
|
38
|
+
:'phone_number' => :'String'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
# Initializes the object
|
43
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
44
|
+
def initialize(attributes = {})
|
45
|
+
if (!attributes.is_a?(Hash))
|
46
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayoutMethodDetailsGHSCash` initialize method"
|
47
|
+
end
|
48
|
+
|
49
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
50
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
51
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
52
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayoutMethodDetailsGHSCash`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
53
|
+
end
|
54
|
+
h[k.to_sym] = v
|
55
|
+
}
|
56
|
+
|
57
|
+
if attributes.key?(:'first_name')
|
58
|
+
self.first_name = attributes[:'first_name']
|
59
|
+
end
|
60
|
+
|
61
|
+
if attributes.key?(:'last_name')
|
62
|
+
self.last_name = attributes[:'last_name']
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.key?(:'phone_number')
|
66
|
+
self.phone_number = attributes[:'phone_number']
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
71
|
+
# @return Array for valid properties with the reasons
|
72
|
+
def list_invalid_properties
|
73
|
+
invalid_properties = Array.new
|
74
|
+
if @first_name.nil?
|
75
|
+
invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
|
76
|
+
end
|
77
|
+
|
78
|
+
if @last_name.nil?
|
79
|
+
invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
|
80
|
+
end
|
81
|
+
|
82
|
+
if @phone_number.nil?
|
83
|
+
invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
|
84
|
+
end
|
85
|
+
|
86
|
+
invalid_properties
|
87
|
+
end
|
88
|
+
|
89
|
+
# Check to see if the all the properties in the model are valid
|
90
|
+
# @return true if the model is valid
|
91
|
+
def valid?
|
92
|
+
return false if @first_name.nil?
|
93
|
+
return false if @last_name.nil?
|
94
|
+
return false if @phone_number.nil?
|
95
|
+
true
|
96
|
+
end
|
97
|
+
|
98
|
+
# Checks equality by comparing each attribute.
|
99
|
+
# @param [Object] Object to be compared
|
100
|
+
def ==(o)
|
101
|
+
return true if self.equal?(o)
|
102
|
+
self.class == o.class &&
|
103
|
+
first_name == o.first_name &&
|
104
|
+
last_name == o.last_name &&
|
105
|
+
phone_number == o.phone_number
|
106
|
+
end
|
107
|
+
|
108
|
+
# @see the `==` method
|
109
|
+
# @param [Object] Object to be compared
|
110
|
+
def eql?(o)
|
111
|
+
self == o
|
112
|
+
end
|
113
|
+
|
114
|
+
# Calculates hash code according to all attributes.
|
115
|
+
# @return [Integer] Hash code
|
116
|
+
def hash
|
117
|
+
[first_name, last_name, phone_number].hash
|
118
|
+
end
|
119
|
+
|
120
|
+
require 'active_support/core_ext/hash'
|
121
|
+
require 'active_support/hash_with_indifferent_access.rb'
|
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.openapi_types.each_pair do |key, type|
|
128
|
+
if type =~ /\AArray<(.*)>/i
|
129
|
+
# check to ensure the input is an array given that the 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 = TransferZero.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
|
+
::ActiveSupport::HashWithIndifferentAccess.new(hash)
|
206
|
+
end
|
207
|
+
|
208
|
+
def [](key)
|
209
|
+
to_hash[key]
|
210
|
+
end
|
211
|
+
|
212
|
+
def dig(*args)
|
213
|
+
to_hash.dig(*args)
|
214
|
+
end
|
215
|
+
|
216
|
+
# Outputs non-array value in the form of hash
|
217
|
+
# For object, use to_hash. Otherwise, just return the value
|
218
|
+
# @param [Object] value Any valid value
|
219
|
+
# @return [Hash] Returns the value in the form of hash
|
220
|
+
def _to_hash(value)
|
221
|
+
if value.is_a?(Array)
|
222
|
+
value.compact.map { |v| _to_hash(v) }
|
223
|
+
elsif value.is_a?(Hash)
|
224
|
+
{}.tap do |hash|
|
225
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
226
|
+
end
|
227
|
+
elsif value.respond_to? :to_hash
|
228
|
+
value.to_hash
|
229
|
+
else
|
230
|
+
value
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|