transferzero-sdk 1.7.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +93 -0
  3. data/README.md +11 -4
  4. data/docs/Currency.md +0 -2
  5. data/docs/CurrencyExchange.md +0 -2
  6. data/docs/CurrencyOpposite.md +3 -3
  7. data/docs/Document.md +4 -0
  8. data/docs/PayoutMethod.md +1 -1
  9. data/docs/PayoutMethodCashProviderEnum.md +16 -0
  10. data/docs/PayoutMethodDetails.md +13 -1
  11. data/docs/PayoutMethodDetailsMobile.md +3 -1
  12. data/docs/PayoutMethodDetailsXOFCash.md +23 -0
  13. data/docs/PayoutMethodDetailsZARBank.md +35 -0
  14. data/docs/ProofOfPayment.md +23 -0
  15. data/docs/ProofOfPaymentListResponse.md +17 -0
  16. data/docs/Recipient.md +4 -0
  17. data/docs/RecipientStateReasonDetails.md +23 -0
  18. data/docs/RecipientsApi.md +62 -0
  19. data/docs/Sender.md +18 -8
  20. data/example/client.rb +55 -18
  21. data/lib/transferzero-sdk.rb +6 -0
  22. data/lib/transferzero-sdk/api/recipients_api.rb +54 -0
  23. data/lib/transferzero-sdk/api_client.rb +1 -1
  24. data/lib/transferzero-sdk/models/currency.rb +1 -11
  25. data/lib/transferzero-sdk/models/currency_exchange.rb +1 -11
  26. data/lib/transferzero-sdk/models/currency_opposite.rb +14 -14
  27. data/lib/transferzero-sdk/models/document.rb +21 -1
  28. data/lib/transferzero-sdk/models/payout_method.rb +1 -1
  29. data/lib/transferzero-sdk/models/payout_method_cash_provider_enum.rb +31 -0
  30. data/lib/transferzero-sdk/models/payout_method_details.rb +76 -5
  31. data/lib/transferzero-sdk/models/payout_method_details_mobile.rb +13 -4
  32. data/lib/transferzero-sdk/models/payout_method_details_xof_bank.rb +1 -1
  33. data/lib/transferzero-sdk/models/payout_method_details_xof_cash.rb +245 -0
  34. data/lib/transferzero-sdk/models/payout_method_details_xof_mobile.rb +1 -1
  35. data/lib/transferzero-sdk/models/payout_method_details_zar_bank.rb +324 -0
  36. data/lib/transferzero-sdk/models/payout_method_mobile_provider_enum.rb +3 -0
  37. data/lib/transferzero-sdk/models/proof_of_payment.rb +233 -0
  38. data/lib/transferzero-sdk/models/proof_of_payment_list_response.rb +204 -0
  39. data/lib/transferzero-sdk/models/recipient.rb +20 -1
  40. data/lib/transferzero-sdk/models/recipient_state_reason_details.rb +235 -0
  41. data/lib/transferzero-sdk/models/sender.rb +88 -14
  42. data/lib/transferzero-sdk/version.rb +1 -1
  43. data/spec/models/payout_method_cash_provider_enum_spec.rb +35 -0
  44. data/spec/models/payout_method_details_xof_cash_spec.rb +71 -0
  45. data/spec/models/payout_method_details_zar_bank_spec.rb +89 -0
  46. data/spec/models/proof_of_payment_list_response_spec.rb +41 -0
  47. data/spec/models/proof_of_payment_spec.rb +59 -0
  48. data/spec/models/recipient_state_reason_details_spec.rb +59 -0
  49. data/transferzero-sdk-1.10.0.gem +0 -0
  50. metadata +28 -2
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.0.0-beta3
13
13
  require 'date'
14
14
 
15
15
  module TransferZero
16
- # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"iban\": \"SN08SN0000000000000000000000\", \"bank_name\": \"BRM\", \"bank_country\": \"SN\" # ISO country code for Senegal } ``` *** Currently in Beta phase ***
16
+ # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"iban\": \"SN08SN0000000000000000000000\", \"bank_name\": \"BRM\", \"bank_country\": \"SN\" # ISO country code for Senegal } ```
17
17
  class PayoutMethodDetailsXOFBank
18
18
  attr_accessor :first_name
19
19
 
@@ -0,0 +1,245 @@
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\": \"774044436\", // local or international Senegalese format \"cash_provider\": \"wizall\" // Optional; Values: \"wari\" or \"wizall; Default value is \"wari\" } ``` Please note when sending Wari cash pickup requests you should subscribe to the recipient.pending webhook, as that will broadcast the payment reference ID the customer need to use to obtain the funds. Example webhook response excerpt - ```JSON { (...) \"state\":\"pending\", \"metadata\": { \"payment_reference\":\"9M5GJRJUBCY\" }, (...) } ``` Please note all senders trying to create Wizall cash pickup requests must have `identity_type` and `\"identity_number` present. The fields above are generally considered optional for senders for other payment corridors. If you wish to use an existing sender who has some of these fields missing you can provide them alongside the `id` or `external_id` field in the sender details. For example - ```JSON { \"transaction\": { \"sender\": { \"external_id\": \"<id of sender>\", \"identity_type\": \"ID\", \"identity_number\": \"AB12345678\", (...) }, (...) } } ```
17
+ class PayoutMethodDetailsXOFCash
18
+ attr_accessor :first_name
19
+
20
+ attr_accessor :last_name
21
+
22
+ attr_accessor :phone_number
23
+
24
+ attr_accessor :cash_provider
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'first_name' => :'first_name',
30
+ :'last_name' => :'last_name',
31
+ :'phone_number' => :'phone_number',
32
+ :'cash_provider' => :'cash_provider'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'first_name' => :'String',
40
+ :'last_name' => :'String',
41
+ :'phone_number' => :'String',
42
+ :'cash_provider' => :'PayoutMethodCashProviderEnum'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayoutMethodDetailsXOFCash` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayoutMethodDetailsXOFCash`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'first_name')
62
+ self.first_name = attributes[:'first_name']
63
+ end
64
+
65
+ if attributes.key?(:'last_name')
66
+ self.last_name = attributes[:'last_name']
67
+ end
68
+
69
+ if attributes.key?(:'phone_number')
70
+ self.phone_number = attributes[:'phone_number']
71
+ end
72
+
73
+ if attributes.key?(:'cash_provider')
74
+ self.cash_provider = attributes[:'cash_provider']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ if @first_name.nil?
83
+ invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
84
+ end
85
+
86
+ if @last_name.nil?
87
+ invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
88
+ end
89
+
90
+ if @phone_number.nil?
91
+ invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
92
+ end
93
+
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ return false if @first_name.nil?
101
+ return false if @last_name.nil?
102
+ return false if @phone_number.nil?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ first_name == o.first_name &&
112
+ last_name == o.last_name &&
113
+ phone_number == o.phone_number &&
114
+ cash_provider == o.cash_provider
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(o)
120
+ self == o
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [first_name, last_name, phone_number, cash_provider].hash
127
+ end
128
+
129
+ require 'active_support/core_ext/hash'
130
+ require 'active_support/hash_with_indifferent_access.rb'
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+ self.class.openapi_types.each_pair do |key, type|
137
+ if type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
141
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
142
+ end
143
+ elsif !attributes[self.class.attribute_map[key]].nil?
144
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
145
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
146
+ end
147
+
148
+ self
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def _deserialize(type, value)
156
+ case type.to_sym
157
+ when :DateTime
158
+ DateTime.parse(value)
159
+ when :Date
160
+ Date.parse(value)
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :Boolean
168
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
169
+ true
170
+ else
171
+ false
172
+ end
173
+ when :Object
174
+ # generic object (usually a Hash), return directly
175
+ value
176
+ when /\AArray<(?<inner_type>.+)>\z/
177
+ inner_type = Regexp.last_match[:inner_type]
178
+ value.map { |v| _deserialize(inner_type, v) }
179
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
180
+ k_type = Regexp.last_match[:k_type]
181
+ v_type = Regexp.last_match[:v_type]
182
+ {}.tap do |hash|
183
+ value.each do |k, v|
184
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
185
+ end
186
+ end
187
+ else # model
188
+ temp_model = TransferZero.const_get(type).new
189
+ temp_model.build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ next if value.nil?
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ ::ActiveSupport::HashWithIndifferentAccess.new(hash)
215
+ end
216
+
217
+ def [](key)
218
+ to_hash[key]
219
+ end
220
+
221
+ def dig(*args)
222
+ to_hash.dig(*args)
223
+ end
224
+
225
+ # Outputs non-array value in the form of hash
226
+ # For object, use to_hash. Otherwise, just return the value
227
+ # @param [Object] value Any valid value
228
+ # @return [Hash] Returns the value in the form of hash
229
+ def _to_hash(value)
230
+ if value.is_a?(Array)
231
+ value.compact.map { |v| _to_hash(v) }
232
+ elsif value.is_a?(Hash)
233
+ {}.tap do |hash|
234
+ value.each { |k, v| hash[k] = _to_hash(v) }
235
+ end
236
+ elsif value.respond_to? :to_hash
237
+ value.to_hash
238
+ else
239
+ value
240
+ end
241
+ end
242
+
243
+ end
244
+
245
+ end
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.0.0-beta3
13
13
  require 'date'
14
14
 
15
15
  module TransferZero
16
- # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"774044436\" # local or international Senegalese format \"mobile_provider\": \"orange\", # \"orange\" or \"tigo\" }
16
+ # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"774044436\" # local or international Senegalese format \"mobile_provider\": \"orange\", # \"orange\" or \"tigo\" } ```
17
17
  class PayoutMethodDetailsXOFMobile
18
18
  attr_accessor :first_name
19
19
 
@@ -0,0 +1,324 @@
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\": \"Main Street\", \"postal_code\": \"AB0001\", \"city\": \"Cape Town\", \"email\": \"recipient@email.com\", \"bank_code\": \"334810\", \"bank_account\": \"12345678\", \"phone_number\": \"+27119785313\", \"transfer_reason_code\": \"185\" } ``` See [ZAR Bank](https://docs.transferzero.com/docs/payout-details/#zarbank) documentation for the bank_code and transfer_reason_code lists
17
+ class PayoutMethodDetailsZARBank
18
+ attr_accessor :first_name
19
+
20
+ attr_accessor :last_name
21
+
22
+ attr_accessor :street
23
+
24
+ attr_accessor :postal_code
25
+
26
+ attr_accessor :city
27
+
28
+ attr_accessor :email
29
+
30
+ attr_accessor :bank_code
31
+
32
+ attr_accessor :bank_account
33
+
34
+ attr_accessor :phone_number
35
+
36
+ attr_accessor :transfer_reason_code
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'first_name' => :'first_name',
42
+ :'last_name' => :'last_name',
43
+ :'street' => :'street',
44
+ :'postal_code' => :'postal_code',
45
+ :'city' => :'city',
46
+ :'email' => :'email',
47
+ :'bank_code' => :'bank_code',
48
+ :'bank_account' => :'bank_account',
49
+ :'phone_number' => :'phone_number',
50
+ :'transfer_reason_code' => :'transfer_reason_code'
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'first_name' => :'String',
58
+ :'last_name' => :'String',
59
+ :'street' => :'String',
60
+ :'postal_code' => :'String',
61
+ :'city' => :'String',
62
+ :'email' => :'String',
63
+ :'bank_code' => :'String',
64
+ :'bank_account' => :'String',
65
+ :'phone_number' => :'String',
66
+ :'transfer_reason_code' => :'String'
67
+ }
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ if (!attributes.is_a?(Hash))
74
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayoutMethodDetailsZARBank` initialize method"
75
+ end
76
+
77
+ # check to see if the attribute exists and convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}) { |(k, v), h|
79
+ if (!self.class.attribute_map.key?(k.to_sym))
80
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayoutMethodDetailsZARBank`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
81
+ end
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:'first_name')
86
+ self.first_name = attributes[:'first_name']
87
+ end
88
+
89
+ if attributes.key?(:'last_name')
90
+ self.last_name = attributes[:'last_name']
91
+ end
92
+
93
+ if attributes.key?(:'street')
94
+ self.street = attributes[:'street']
95
+ end
96
+
97
+ if attributes.key?(:'postal_code')
98
+ self.postal_code = attributes[:'postal_code']
99
+ end
100
+
101
+ if attributes.key?(:'city')
102
+ self.city = attributes[:'city']
103
+ end
104
+
105
+ if attributes.key?(:'email')
106
+ self.email = attributes[:'email']
107
+ end
108
+
109
+ if attributes.key?(:'bank_code')
110
+ self.bank_code = attributes[:'bank_code']
111
+ end
112
+
113
+ if attributes.key?(:'bank_account')
114
+ self.bank_account = attributes[:'bank_account']
115
+ end
116
+
117
+ if attributes.key?(:'phone_number')
118
+ self.phone_number = attributes[:'phone_number']
119
+ end
120
+
121
+ if attributes.key?(:'transfer_reason_code')
122
+ self.transfer_reason_code = attributes[:'transfer_reason_code']
123
+ end
124
+ end
125
+
126
+ # Show invalid properties with the reasons. Usually used together with valid?
127
+ # @return Array for valid properties with the reasons
128
+ def list_invalid_properties
129
+ invalid_properties = Array.new
130
+ if @first_name.nil?
131
+ invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
132
+ end
133
+
134
+ if @last_name.nil?
135
+ invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
136
+ end
137
+
138
+ if @street.nil?
139
+ invalid_properties.push('invalid value for "street", street cannot be nil.')
140
+ end
141
+
142
+ if @postal_code.nil?
143
+ invalid_properties.push('invalid value for "postal_code", postal_code cannot be nil.')
144
+ end
145
+
146
+ if @city.nil?
147
+ invalid_properties.push('invalid value for "city", city cannot be nil.')
148
+ end
149
+
150
+ if @bank_code.nil?
151
+ invalid_properties.push('invalid value for "bank_code", bank_code cannot be nil.')
152
+ end
153
+
154
+ if @bank_account.nil?
155
+ invalid_properties.push('invalid value for "bank_account", bank_account cannot be nil.')
156
+ end
157
+
158
+ if @phone_number.nil?
159
+ invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
160
+ end
161
+
162
+ invalid_properties
163
+ end
164
+
165
+ # Check to see if the all the properties in the model are valid
166
+ # @return true if the model is valid
167
+ def valid?
168
+ return false if @first_name.nil?
169
+ return false if @last_name.nil?
170
+ return false if @street.nil?
171
+ return false if @postal_code.nil?
172
+ return false if @city.nil?
173
+ return false if @bank_code.nil?
174
+ return false if @bank_account.nil?
175
+ return false if @phone_number.nil?
176
+ true
177
+ end
178
+
179
+ # Checks equality by comparing each attribute.
180
+ # @param [Object] Object to be compared
181
+ def ==(o)
182
+ return true if self.equal?(o)
183
+ self.class == o.class &&
184
+ first_name == o.first_name &&
185
+ last_name == o.last_name &&
186
+ street == o.street &&
187
+ postal_code == o.postal_code &&
188
+ city == o.city &&
189
+ email == o.email &&
190
+ bank_code == o.bank_code &&
191
+ bank_account == o.bank_account &&
192
+ phone_number == o.phone_number &&
193
+ transfer_reason_code == o.transfer_reason_code
194
+ end
195
+
196
+ # @see the `==` method
197
+ # @param [Object] Object to be compared
198
+ def eql?(o)
199
+ self == o
200
+ end
201
+
202
+ # Calculates hash code according to all attributes.
203
+ # @return [Integer] Hash code
204
+ def hash
205
+ [first_name, last_name, street, postal_code, city, email, bank_code, bank_account, phone_number, transfer_reason_code].hash
206
+ end
207
+
208
+ require 'active_support/core_ext/hash'
209
+ require 'active_support/hash_with_indifferent_access.rb'
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+ self.class.openapi_types.each_pair do |key, type|
216
+ if type =~ /\AArray<(.*)>/i
217
+ # check to ensure the input is an array given that the the attribute
218
+ # is documented as an array but the input is not
219
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
220
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
221
+ end
222
+ elsif !attributes[self.class.attribute_map[key]].nil?
223
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
224
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
225
+ end
226
+
227
+ self
228
+ end
229
+
230
+ # Deserializes the data based on type
231
+ # @param string type Data type
232
+ # @param string value Value to be deserialized
233
+ # @return [Object] Deserialized data
234
+ def _deserialize(type, value)
235
+ case type.to_sym
236
+ when :DateTime
237
+ DateTime.parse(value)
238
+ when :Date
239
+ Date.parse(value)
240
+ when :String
241
+ value.to_s
242
+ when :Integer
243
+ value.to_i
244
+ when :Float
245
+ value.to_f
246
+ when :Boolean
247
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
248
+ true
249
+ else
250
+ false
251
+ end
252
+ when :Object
253
+ # generic object (usually a Hash), return directly
254
+ value
255
+ when /\AArray<(?<inner_type>.+)>\z/
256
+ inner_type = Regexp.last_match[:inner_type]
257
+ value.map { |v| _deserialize(inner_type, v) }
258
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
259
+ k_type = Regexp.last_match[:k_type]
260
+ v_type = Regexp.last_match[:v_type]
261
+ {}.tap do |hash|
262
+ value.each do |k, v|
263
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
264
+ end
265
+ end
266
+ else # model
267
+ temp_model = TransferZero.const_get(type).new
268
+ temp_model.build_from_hash(value)
269
+ end
270
+ end
271
+
272
+ # Returns the string representation of the object
273
+ # @return [String] String presentation of the object
274
+ def to_s
275
+ to_hash.to_s
276
+ end
277
+
278
+ # to_body is an alias to to_hash (backward compatibility)
279
+ # @return [Hash] Returns the object in the form of hash
280
+ def to_body
281
+ to_hash
282
+ end
283
+
284
+ # Returns the object in the form of hash
285
+ # @return [Hash] Returns the object in the form of hash
286
+ def to_hash
287
+ hash = {}
288
+ self.class.attribute_map.each_pair do |attr, param|
289
+ value = self.send(attr)
290
+ next if value.nil?
291
+ hash[param] = _to_hash(value)
292
+ end
293
+ ::ActiveSupport::HashWithIndifferentAccess.new(hash)
294
+ end
295
+
296
+ def [](key)
297
+ to_hash[key]
298
+ end
299
+
300
+ def dig(*args)
301
+ to_hash.dig(*args)
302
+ end
303
+
304
+ # Outputs non-array value in the form of hash
305
+ # For object, use to_hash. Otherwise, just return the value
306
+ # @param [Object] value Any valid value
307
+ # @return [Hash] Returns the value in the form of hash
308
+ def _to_hash(value)
309
+ if value.is_a?(Array)
310
+ value.compact.map { |v| _to_hash(v) }
311
+ elsif value.is_a?(Hash)
312
+ {}.tap do |hash|
313
+ value.each { |k, v| hash[k] = _to_hash(v) }
314
+ end
315
+ elsif value.respond_to? :to_hash
316
+ value.to_hash
317
+ else
318
+ value
319
+ end
320
+ end
321
+
322
+ end
323
+
324
+ end