transferzero-sdk 1.26.1 → 1.27.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/docs/CurrencyExchangeAllOf.md +17 -0
- data/docs/CurrencyOppositeAllOf.md +21 -0
- data/docs/DocumentWebhookAllOf.md +17 -0
- data/docs/PaymentMethodOppositeAllOf.md +17 -0
- data/docs/PayoutMethod.md +1 -1
- data/docs/PayoutMethodDetails.md +1 -1
- data/docs/PayoutMethodDetailsUGXBank.md +33 -0
- data/docs/PayoutMethodWebhookAllOf.md +17 -0
- data/docs/RecipientWebhookAllOf.md +17 -0
- data/docs/SenderWebhookAllOf.md +17 -0
- data/docs/TransactionWebhookAllOf.md +17 -0
- data/lib/transferzero-sdk/api_client.rb +1 -1
- data/lib/transferzero-sdk/models/currency_exchange_all_of.rb +205 -0
- data/lib/transferzero-sdk/models/currency_opposite_all_of.rb +223 -0
- data/lib/transferzero-sdk/models/document_webhook_all_of.rb +202 -0
- data/lib/transferzero-sdk/models/payment_method_opposite_all_of.rb +205 -0
- data/lib/transferzero-sdk/models/payout_method.rb +1 -1
- data/lib/transferzero-sdk/models/payout_method_bank_account_type_enum.rb +2 -0
- data/lib/transferzero-sdk/models/payout_method_details.rb +2 -1
- data/lib/transferzero-sdk/models/payout_method_details_ugx_bank.rb +320 -0
- data/lib/transferzero-sdk/models/payout_method_webhook_all_of.rb +202 -0
- data/lib/transferzero-sdk/models/recipient_webhook_all_of.rb +202 -0
- data/lib/transferzero-sdk/models/sender_webhook_all_of.rb +202 -0
- data/lib/transferzero-sdk/models/transaction_webhook_all_of.rb +202 -0
- data/lib/transferzero-sdk/version.rb +1 -1
- data/lib/transferzero-sdk.rb +1 -0
- data/spec/models/currency_exchange_all_of_spec.rb +41 -0
- data/spec/models/currency_opposite_all_of_spec.rb +53 -0
- data/spec/models/document_webhook_all_of_spec.rb +41 -0
- data/spec/models/payment_method_opposite_all_of_spec.rb +41 -0
- data/spec/models/payout_method_details_ugx_bank_spec.rb +89 -0
- data/spec/models/payout_method_webhook_all_of_spec.rb +41 -0
- data/spec/models/recipient_webhook_all_of_spec.rb +41 -0
- data/spec/models/sender_webhook_all_of_spec.rb +41 -0
- data/spec/models/transaction_webhook_all_of_spec.rb +41 -0
- data/transferzero-sdk-1.26.1.gem +0 -0
- metadata +40 -4
- data/Gemfile.lock +0 -88
@@ -0,0 +1,320 @@
|
|
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\", \"street\": \"1, Old Taxi Park\", \"city\": \"Kampala\", \"postal_code\": \"10102\", \"identity_card_id\": \"3081900101123411\", \"bank_account\": \"1234567890\", \"branch_code\": \"130547\", \"transfer_reason\": \"personal_account\" } ``` See [UGX Bank](https://docs.transferzero.com/docs/payout-details/#ugxbank) documentation for the branch_code list
|
17
|
+
class PayoutMethodDetailsUGXBank
|
18
|
+
attr_accessor :first_name
|
19
|
+
|
20
|
+
attr_accessor :last_name
|
21
|
+
|
22
|
+
attr_accessor :street
|
23
|
+
|
24
|
+
attr_accessor :city
|
25
|
+
|
26
|
+
attr_accessor :postal_code
|
27
|
+
|
28
|
+
attr_accessor :identity_card_id
|
29
|
+
|
30
|
+
attr_accessor :bank_account
|
31
|
+
|
32
|
+
attr_accessor :branch_code
|
33
|
+
|
34
|
+
attr_accessor :transfer_reason
|
35
|
+
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
37
|
+
def self.attribute_map
|
38
|
+
{
|
39
|
+
:'first_name' => :'first_name',
|
40
|
+
:'last_name' => :'last_name',
|
41
|
+
:'street' => :'street',
|
42
|
+
:'city' => :'city',
|
43
|
+
:'postal_code' => :'postal_code',
|
44
|
+
:'identity_card_id' => :'identity_card_id',
|
45
|
+
:'bank_account' => :'bank_account',
|
46
|
+
:'branch_code' => :'branch_code',
|
47
|
+
:'transfer_reason' => :'transfer_reason'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute type mapping.
|
52
|
+
def self.openapi_types
|
53
|
+
{
|
54
|
+
:'first_name' => :'String',
|
55
|
+
:'last_name' => :'String',
|
56
|
+
:'street' => :'String',
|
57
|
+
:'city' => :'String',
|
58
|
+
:'postal_code' => :'String',
|
59
|
+
:'identity_card_id' => :'String',
|
60
|
+
:'bank_account' => :'String',
|
61
|
+
:'branch_code' => :'String',
|
62
|
+
:'transfer_reason' => :'String'
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
# Initializes the object
|
67
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
68
|
+
def initialize(attributes = {})
|
69
|
+
if (!attributes.is_a?(Hash))
|
70
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayoutMethodDetailsUGXBank` initialize method"
|
71
|
+
end
|
72
|
+
|
73
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
74
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
75
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
76
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayoutMethodDetailsUGXBank`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
77
|
+
end
|
78
|
+
h[k.to_sym] = v
|
79
|
+
}
|
80
|
+
|
81
|
+
if attributes.key?(:'first_name')
|
82
|
+
self.first_name = attributes[:'first_name']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'last_name')
|
86
|
+
self.last_name = attributes[:'last_name']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'street')
|
90
|
+
self.street = attributes[:'street']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'city')
|
94
|
+
self.city = attributes[:'city']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'postal_code')
|
98
|
+
self.postal_code = attributes[:'postal_code']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'identity_card_id')
|
102
|
+
self.identity_card_id = attributes[:'identity_card_id']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'bank_account')
|
106
|
+
self.bank_account = attributes[:'bank_account']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'branch_code')
|
110
|
+
self.branch_code = attributes[:'branch_code']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'transfer_reason')
|
114
|
+
self.transfer_reason = attributes[:'transfer_reason']
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
119
|
+
# @return Array for valid properties with the reasons
|
120
|
+
def list_invalid_properties
|
121
|
+
invalid_properties = Array.new
|
122
|
+
if @first_name.nil?
|
123
|
+
invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
|
124
|
+
end
|
125
|
+
|
126
|
+
if @last_name.nil?
|
127
|
+
invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
|
128
|
+
end
|
129
|
+
|
130
|
+
if @street.nil?
|
131
|
+
invalid_properties.push('invalid value for "street", street cannot be nil.')
|
132
|
+
end
|
133
|
+
|
134
|
+
if @city.nil?
|
135
|
+
invalid_properties.push('invalid value for "city", city cannot be nil.')
|
136
|
+
end
|
137
|
+
|
138
|
+
if @postal_code.nil?
|
139
|
+
invalid_properties.push('invalid value for "postal_code", postal_code cannot be nil.')
|
140
|
+
end
|
141
|
+
|
142
|
+
if @identity_card_id.nil?
|
143
|
+
invalid_properties.push('invalid value for "identity_card_id", identity_card_id cannot be nil.')
|
144
|
+
end
|
145
|
+
|
146
|
+
if @bank_account.nil?
|
147
|
+
invalid_properties.push('invalid value for "bank_account", bank_account cannot be nil.')
|
148
|
+
end
|
149
|
+
|
150
|
+
if @branch_code.nil?
|
151
|
+
invalid_properties.push('invalid value for "branch_code", branch_code cannot be nil.')
|
152
|
+
end
|
153
|
+
|
154
|
+
if @transfer_reason.nil?
|
155
|
+
invalid_properties.push('invalid value for "transfer_reason", transfer_reason cannot be nil.')
|
156
|
+
end
|
157
|
+
|
158
|
+
invalid_properties
|
159
|
+
end
|
160
|
+
|
161
|
+
# Check to see if the all the properties in the model are valid
|
162
|
+
# @return true if the model is valid
|
163
|
+
def valid?
|
164
|
+
return false if @first_name.nil?
|
165
|
+
return false if @last_name.nil?
|
166
|
+
return false if @street.nil?
|
167
|
+
return false if @city.nil?
|
168
|
+
return false if @postal_code.nil?
|
169
|
+
return false if @identity_card_id.nil?
|
170
|
+
return false if @bank_account.nil?
|
171
|
+
return false if @branch_code.nil?
|
172
|
+
return false if @transfer_reason.nil?
|
173
|
+
true
|
174
|
+
end
|
175
|
+
|
176
|
+
# Checks equality by comparing each attribute.
|
177
|
+
# @param [Object] Object to be compared
|
178
|
+
def ==(o)
|
179
|
+
return true if self.equal?(o)
|
180
|
+
self.class == o.class &&
|
181
|
+
first_name == o.first_name &&
|
182
|
+
last_name == o.last_name &&
|
183
|
+
street == o.street &&
|
184
|
+
city == o.city &&
|
185
|
+
postal_code == o.postal_code &&
|
186
|
+
identity_card_id == o.identity_card_id &&
|
187
|
+
bank_account == o.bank_account &&
|
188
|
+
branch_code == o.branch_code &&
|
189
|
+
transfer_reason == o.transfer_reason
|
190
|
+
end
|
191
|
+
|
192
|
+
# @see the `==` method
|
193
|
+
# @param [Object] Object to be compared
|
194
|
+
def eql?(o)
|
195
|
+
self == o
|
196
|
+
end
|
197
|
+
|
198
|
+
# Calculates hash code according to all attributes.
|
199
|
+
# @return [Integer] Hash code
|
200
|
+
def hash
|
201
|
+
[first_name, last_name, street, city, postal_code, identity_card_id, bank_account, branch_code, transfer_reason].hash
|
202
|
+
end
|
203
|
+
|
204
|
+
require 'active_support/core_ext/hash'
|
205
|
+
require 'active_support/hash_with_indifferent_access.rb'
|
206
|
+
# Builds the object from hash
|
207
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
208
|
+
# @return [Object] Returns the model itself
|
209
|
+
def build_from_hash(attributes)
|
210
|
+
return nil unless attributes.is_a?(Hash)
|
211
|
+
self.class.openapi_types.each_pair do |key, type|
|
212
|
+
if type =~ /\AArray<(.*)>/i
|
213
|
+
# check to ensure the input is an array given that the the attribute
|
214
|
+
# is documented as an array but the input is not
|
215
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
216
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
217
|
+
end
|
218
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
219
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
220
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
221
|
+
end
|
222
|
+
|
223
|
+
self
|
224
|
+
end
|
225
|
+
|
226
|
+
# Deserializes the data based on type
|
227
|
+
# @param string type Data type
|
228
|
+
# @param string value Value to be deserialized
|
229
|
+
# @return [Object] Deserialized data
|
230
|
+
def _deserialize(type, value)
|
231
|
+
case type.to_sym
|
232
|
+
when :DateTime
|
233
|
+
DateTime.parse(value)
|
234
|
+
when :Date
|
235
|
+
Date.parse(value)
|
236
|
+
when :String
|
237
|
+
value.to_s
|
238
|
+
when :Integer
|
239
|
+
value.to_i
|
240
|
+
when :Float
|
241
|
+
value.to_f
|
242
|
+
when :Boolean
|
243
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
244
|
+
true
|
245
|
+
else
|
246
|
+
false
|
247
|
+
end
|
248
|
+
when :Object
|
249
|
+
# generic object (usually a Hash), return directly
|
250
|
+
value
|
251
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
252
|
+
inner_type = Regexp.last_match[:inner_type]
|
253
|
+
value.map { |v| _deserialize(inner_type, v) }
|
254
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
255
|
+
k_type = Regexp.last_match[:k_type]
|
256
|
+
v_type = Regexp.last_match[:v_type]
|
257
|
+
{}.tap do |hash|
|
258
|
+
value.each do |k, v|
|
259
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
else # model
|
263
|
+
temp_model = TransferZero.const_get(type).new
|
264
|
+
temp_model.build_from_hash(value)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
# Returns the string representation of the object
|
269
|
+
# @return [String] String presentation of the object
|
270
|
+
def to_s
|
271
|
+
to_hash.to_s
|
272
|
+
end
|
273
|
+
|
274
|
+
# to_body is an alias to to_hash (backward compatibility)
|
275
|
+
# @return [Hash] Returns the object in the form of hash
|
276
|
+
def to_body
|
277
|
+
to_hash
|
278
|
+
end
|
279
|
+
|
280
|
+
# Returns the object in the form of hash
|
281
|
+
# @return [Hash] Returns the object in the form of hash
|
282
|
+
def to_hash
|
283
|
+
hash = {}
|
284
|
+
self.class.attribute_map.each_pair do |attr, param|
|
285
|
+
value = self.send(attr)
|
286
|
+
next if value.nil?
|
287
|
+
hash[param] = _to_hash(value)
|
288
|
+
end
|
289
|
+
::ActiveSupport::HashWithIndifferentAccess.new(hash)
|
290
|
+
end
|
291
|
+
|
292
|
+
def [](key)
|
293
|
+
to_hash[key]
|
294
|
+
end
|
295
|
+
|
296
|
+
def dig(*args)
|
297
|
+
to_hash.dig(*args)
|
298
|
+
end
|
299
|
+
|
300
|
+
# Outputs non-array value in the form of hash
|
301
|
+
# For object, use to_hash. Otherwise, just return the value
|
302
|
+
# @param [Object] value Any valid value
|
303
|
+
# @return [Hash] Returns the value in the form of hash
|
304
|
+
def _to_hash(value)
|
305
|
+
if value.is_a?(Array)
|
306
|
+
value.compact.map { |v| _to_hash(v) }
|
307
|
+
elsif value.is_a?(Hash)
|
308
|
+
{}.tap do |hash|
|
309
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
310
|
+
end
|
311
|
+
elsif value.respond_to? :to_hash
|
312
|
+
value.to_hash
|
313
|
+
else
|
314
|
+
value
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
|
320
|
+
end
|
@@ -0,0 +1,202 @@
|
|
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
|
+
class PayoutMethodWebhookAllOf
|
17
|
+
attr_accessor :object
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:'object' => :'object'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.openapi_types
|
28
|
+
{
|
29
|
+
:'object' => :'PayoutMethod'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Initializes the object
|
34
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
35
|
+
def initialize(attributes = {})
|
36
|
+
if (!attributes.is_a?(Hash))
|
37
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayoutMethodWebhookAllOf` initialize method"
|
38
|
+
end
|
39
|
+
|
40
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
41
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
42
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
43
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayoutMethodWebhookAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
44
|
+
end
|
45
|
+
h[k.to_sym] = v
|
46
|
+
}
|
47
|
+
|
48
|
+
if attributes.key?(:'object')
|
49
|
+
self.object = attributes[:'object']
|
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
|
+
invalid_properties
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check to see if the all the properties in the model are valid
|
61
|
+
# @return true if the model is valid
|
62
|
+
def valid?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks equality by comparing each attribute.
|
67
|
+
# @param [Object] Object to be compared
|
68
|
+
def ==(o)
|
69
|
+
return true if self.equal?(o)
|
70
|
+
self.class == o.class &&
|
71
|
+
object == o.object
|
72
|
+
end
|
73
|
+
|
74
|
+
# @see the `==` method
|
75
|
+
# @param [Object] Object to be compared
|
76
|
+
def eql?(o)
|
77
|
+
self == o
|
78
|
+
end
|
79
|
+
|
80
|
+
# Calculates hash code according to all attributes.
|
81
|
+
# @return [Integer] Hash code
|
82
|
+
def hash
|
83
|
+
[object].hash
|
84
|
+
end
|
85
|
+
|
86
|
+
require 'active_support/core_ext/hash'
|
87
|
+
require 'active_support/hash_with_indifferent_access.rb'
|
88
|
+
# Builds the object from hash
|
89
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
90
|
+
# @return [Object] Returns the model itself
|
91
|
+
def build_from_hash(attributes)
|
92
|
+
return nil unless attributes.is_a?(Hash)
|
93
|
+
self.class.openapi_types.each_pair do |key, type|
|
94
|
+
if type =~ /\AArray<(.*)>/i
|
95
|
+
# check to ensure the input is an array given that the the attribute
|
96
|
+
# is documented as an array but the input is not
|
97
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
98
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
99
|
+
end
|
100
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
101
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
102
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
103
|
+
end
|
104
|
+
|
105
|
+
self
|
106
|
+
end
|
107
|
+
|
108
|
+
# Deserializes the data based on type
|
109
|
+
# @param string type Data type
|
110
|
+
# @param string value Value to be deserialized
|
111
|
+
# @return [Object] Deserialized data
|
112
|
+
def _deserialize(type, value)
|
113
|
+
case type.to_sym
|
114
|
+
when :DateTime
|
115
|
+
DateTime.parse(value)
|
116
|
+
when :Date
|
117
|
+
Date.parse(value)
|
118
|
+
when :String
|
119
|
+
value.to_s
|
120
|
+
when :Integer
|
121
|
+
value.to_i
|
122
|
+
when :Float
|
123
|
+
value.to_f
|
124
|
+
when :Boolean
|
125
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
126
|
+
true
|
127
|
+
else
|
128
|
+
false
|
129
|
+
end
|
130
|
+
when :Object
|
131
|
+
# generic object (usually a Hash), return directly
|
132
|
+
value
|
133
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
134
|
+
inner_type = Regexp.last_match[:inner_type]
|
135
|
+
value.map { |v| _deserialize(inner_type, v) }
|
136
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
137
|
+
k_type = Regexp.last_match[:k_type]
|
138
|
+
v_type = Regexp.last_match[:v_type]
|
139
|
+
{}.tap do |hash|
|
140
|
+
value.each do |k, v|
|
141
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
else # model
|
145
|
+
temp_model = TransferZero.const_get(type).new
|
146
|
+
temp_model.build_from_hash(value)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Returns the string representation of the object
|
151
|
+
# @return [String] String presentation of the object
|
152
|
+
def to_s
|
153
|
+
to_hash.to_s
|
154
|
+
end
|
155
|
+
|
156
|
+
# to_body is an alias to to_hash (backward compatibility)
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
158
|
+
def to_body
|
159
|
+
to_hash
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the object in the form of hash
|
163
|
+
# @return [Hash] Returns the object in the form of hash
|
164
|
+
def to_hash
|
165
|
+
hash = {}
|
166
|
+
self.class.attribute_map.each_pair do |attr, param|
|
167
|
+
value = self.send(attr)
|
168
|
+
next if value.nil?
|
169
|
+
hash[param] = _to_hash(value)
|
170
|
+
end
|
171
|
+
::ActiveSupport::HashWithIndifferentAccess.new(hash)
|
172
|
+
end
|
173
|
+
|
174
|
+
def [](key)
|
175
|
+
to_hash[key]
|
176
|
+
end
|
177
|
+
|
178
|
+
def dig(*args)
|
179
|
+
to_hash.dig(*args)
|
180
|
+
end
|
181
|
+
|
182
|
+
# Outputs non-array value in the form of hash
|
183
|
+
# For object, use to_hash. Otherwise, just return the value
|
184
|
+
# @param [Object] value Any valid value
|
185
|
+
# @return [Hash] Returns the value in the form of hash
|
186
|
+
def _to_hash(value)
|
187
|
+
if value.is_a?(Array)
|
188
|
+
value.compact.map { |v| _to_hash(v) }
|
189
|
+
elsif value.is_a?(Hash)
|
190
|
+
{}.tap do |hash|
|
191
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
192
|
+
end
|
193
|
+
elsif value.respond_to? :to_hash
|
194
|
+
value.to_hash
|
195
|
+
else
|
196
|
+
value
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|