transferzero-sdk 1.23.5 → 1.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/docs/PayoutMethod.md +1 -1
- data/docs/PayoutMethodDetails.md +4 -2
- data/docs/PayoutMethodDetailsBRLBank.md +4 -0
- data/docs/PayoutMethodDetailsBWPBank.md +25 -0
- data/docs/PayoutMethodDetailsINRBank.md +33 -0
- data/docs/PayoutMethodDetailsNZDBank.md +23 -0
- data/docs/PayoutMethodDetailsZMWBank.md +23 -0
- data/docs/Sender.md +1 -3
- data/lib/transferzero-sdk/api_client.rb +1 -1
- data/lib/transferzero-sdk/models/payout_method.rb +1 -1
- data/lib/transferzero-sdk/models/payout_method_country_enum.rb +1 -0
- data/lib/transferzero-sdk/models/payout_method_details.rb +28 -5
- data/lib/transferzero-sdk/models/payout_method_details_brl_bank.rb +30 -2
- data/lib/transferzero-sdk/models/payout_method_details_bwp_bank.rb +264 -0
- data/lib/transferzero-sdk/models/payout_method_details_inr_bank.rb +320 -0
- data/lib/transferzero-sdk/models/payout_method_details_nzd_bank.rb +250 -0
- data/lib/transferzero-sdk/models/payout_method_details_zmw_bank.rb +250 -0
- data/lib/transferzero-sdk/models/sender.rb +2 -12
- data/lib/transferzero-sdk/version.rb +1 -1
- data/lib/transferzero-sdk.rb +4 -0
- data/spec/models/payout_method_details_bwp_bank_spec.rb +65 -0
- data/spec/models/payout_method_details_inr_bank_spec.rb +89 -0
- data/spec/models/payout_method_details_nzd_bank_spec.rb +59 -0
- data/spec/models/payout_method_details_zmw_bank_spec.rb +59 -0
- metadata +18 -13
- data/Gemfile.lock +0 -92
- data/transferzero-sdk-1.19.0.gem +0 -0
- data/transferzero-sdk-1.19.2.gem +0 -0
- data/transferzero-sdk-1.19.3.gem +0 -0
- data/transferzero-sdk-1.19.4.gem +0 -0
- data/transferzero-sdk-1.19.5.gem +0 -0
- data/transferzero-sdk-1.20.1.gem +0 -0
- data/transferzero-sdk-1.21.0.gem +0 -0
- data/transferzero-sdk-1.22.0.gem +0 -0
- data/transferzero-sdk-1.23.0.gem +0 -0
- data/transferzero-sdk-1.23.3.gem +0 -0
@@ -0,0 +1,264 @@
|
|
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\", \"bank_name\": \"Banc ABC\", \"bank_account\": \"12345678912345678\", \"branch_code\": \"550067\", } ``` See [BWP Bank](https://docs.transferzero.com/docs/payout-details/#bwpbank) documentation for the bank_name & branch_code list
|
17
|
+
class PayoutMethodDetailsBWPBank
|
18
|
+
attr_accessor :first_name
|
19
|
+
|
20
|
+
attr_accessor :last_name
|
21
|
+
|
22
|
+
attr_accessor :bank_name
|
23
|
+
|
24
|
+
attr_accessor :bank_account
|
25
|
+
|
26
|
+
attr_accessor :branch_code
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'first_name' => :'first_name',
|
32
|
+
:'last_name' => :'last_name',
|
33
|
+
:'bank_name' => :'bank_name',
|
34
|
+
:'bank_account' => :'bank_account',
|
35
|
+
:'branch_code' => :'branch_code'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.openapi_types
|
41
|
+
{
|
42
|
+
:'first_name' => :'String',
|
43
|
+
:'last_name' => :'String',
|
44
|
+
:'bank_name' => :'String',
|
45
|
+
:'bank_account' => :'String',
|
46
|
+
:'branch_code' => :'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
|
+
if (!attributes.is_a?(Hash))
|
54
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayoutMethodDetailsBWPBank` initialize method"
|
55
|
+
end
|
56
|
+
|
57
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
58
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
59
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
60
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayoutMethodDetailsBWPBank`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
61
|
+
end
|
62
|
+
h[k.to_sym] = v
|
63
|
+
}
|
64
|
+
|
65
|
+
if attributes.key?(:'first_name')
|
66
|
+
self.first_name = attributes[:'first_name']
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes.key?(:'last_name')
|
70
|
+
self.last_name = attributes[:'last_name']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.key?(:'bank_name')
|
74
|
+
self.bank_name = attributes[:'bank_name']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.key?(:'bank_account')
|
78
|
+
self.bank_account = attributes[:'bank_account']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.key?(:'branch_code')
|
82
|
+
self.branch_code = attributes[:'branch_code']
|
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
|
+
if @first_name.nil?
|
91
|
+
invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
|
92
|
+
end
|
93
|
+
|
94
|
+
if @last_name.nil?
|
95
|
+
invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
|
96
|
+
end
|
97
|
+
|
98
|
+
if @bank_name.nil?
|
99
|
+
invalid_properties.push('invalid value for "bank_name", bank_name cannot be nil.')
|
100
|
+
end
|
101
|
+
|
102
|
+
if @bank_account.nil?
|
103
|
+
invalid_properties.push('invalid value for "bank_account", bank_account cannot be nil.')
|
104
|
+
end
|
105
|
+
|
106
|
+
if @branch_code.nil?
|
107
|
+
invalid_properties.push('invalid value for "branch_code", branch_code cannot be nil.')
|
108
|
+
end
|
109
|
+
|
110
|
+
invalid_properties
|
111
|
+
end
|
112
|
+
|
113
|
+
# Check to see if the all the properties in the model are valid
|
114
|
+
# @return true if the model is valid
|
115
|
+
def valid?
|
116
|
+
return false if @first_name.nil?
|
117
|
+
return false if @last_name.nil?
|
118
|
+
return false if @bank_name.nil?
|
119
|
+
return false if @bank_account.nil?
|
120
|
+
return false if @branch_code.nil?
|
121
|
+
true
|
122
|
+
end
|
123
|
+
|
124
|
+
# Checks equality by comparing each attribute.
|
125
|
+
# @param [Object] Object to be compared
|
126
|
+
def ==(o)
|
127
|
+
return true if self.equal?(o)
|
128
|
+
self.class == o.class &&
|
129
|
+
first_name == o.first_name &&
|
130
|
+
last_name == o.last_name &&
|
131
|
+
bank_name == o.bank_name &&
|
132
|
+
bank_account == o.bank_account &&
|
133
|
+
branch_code == o.branch_code
|
134
|
+
end
|
135
|
+
|
136
|
+
# @see the `==` method
|
137
|
+
# @param [Object] Object to be compared
|
138
|
+
def eql?(o)
|
139
|
+
self == o
|
140
|
+
end
|
141
|
+
|
142
|
+
# Calculates hash code according to all attributes.
|
143
|
+
# @return [Integer] Hash code
|
144
|
+
def hash
|
145
|
+
[first_name, last_name, bank_name, bank_account, branch_code].hash
|
146
|
+
end
|
147
|
+
|
148
|
+
require 'active_support/core_ext/hash'
|
149
|
+
require 'active_support/hash_with_indifferent_access.rb'
|
150
|
+
# Builds the object from hash
|
151
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
152
|
+
# @return [Object] Returns the model itself
|
153
|
+
def build_from_hash(attributes)
|
154
|
+
return nil unless attributes.is_a?(Hash)
|
155
|
+
self.class.openapi_types.each_pair do |key, type|
|
156
|
+
if type =~ /\AArray<(.*)>/i
|
157
|
+
# check to ensure the input is an array given that the the attribute
|
158
|
+
# is documented as an array but the input is not
|
159
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
160
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
161
|
+
end
|
162
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
163
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
164
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
165
|
+
end
|
166
|
+
|
167
|
+
self
|
168
|
+
end
|
169
|
+
|
170
|
+
# Deserializes the data based on type
|
171
|
+
# @param string type Data type
|
172
|
+
# @param string value Value to be deserialized
|
173
|
+
# @return [Object] Deserialized data
|
174
|
+
def _deserialize(type, value)
|
175
|
+
case type.to_sym
|
176
|
+
when :DateTime
|
177
|
+
DateTime.parse(value)
|
178
|
+
when :Date
|
179
|
+
Date.parse(value)
|
180
|
+
when :String
|
181
|
+
value.to_s
|
182
|
+
when :Integer
|
183
|
+
value.to_i
|
184
|
+
when :Float
|
185
|
+
value.to_f
|
186
|
+
when :Boolean
|
187
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
188
|
+
true
|
189
|
+
else
|
190
|
+
false
|
191
|
+
end
|
192
|
+
when :Object
|
193
|
+
# generic object (usually a Hash), return directly
|
194
|
+
value
|
195
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
196
|
+
inner_type = Regexp.last_match[:inner_type]
|
197
|
+
value.map { |v| _deserialize(inner_type, v) }
|
198
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
199
|
+
k_type = Regexp.last_match[:k_type]
|
200
|
+
v_type = Regexp.last_match[:v_type]
|
201
|
+
{}.tap do |hash|
|
202
|
+
value.each do |k, v|
|
203
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
else # model
|
207
|
+
temp_model = TransferZero.const_get(type).new
|
208
|
+
temp_model.build_from_hash(value)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns the string representation of the object
|
213
|
+
# @return [String] String presentation of the object
|
214
|
+
def to_s
|
215
|
+
to_hash.to_s
|
216
|
+
end
|
217
|
+
|
218
|
+
# to_body is an alias to to_hash (backward compatibility)
|
219
|
+
# @return [Hash] Returns the object in the form of hash
|
220
|
+
def to_body
|
221
|
+
to_hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Returns the object in the form of hash
|
225
|
+
# @return [Hash] Returns the object in the form of hash
|
226
|
+
def to_hash
|
227
|
+
hash = {}
|
228
|
+
self.class.attribute_map.each_pair do |attr, param|
|
229
|
+
value = self.send(attr)
|
230
|
+
next if value.nil?
|
231
|
+
hash[param] = _to_hash(value)
|
232
|
+
end
|
233
|
+
::ActiveSupport::HashWithIndifferentAccess.new(hash)
|
234
|
+
end
|
235
|
+
|
236
|
+
def [](key)
|
237
|
+
to_hash[key]
|
238
|
+
end
|
239
|
+
|
240
|
+
def dig(*args)
|
241
|
+
to_hash.dig(*args)
|
242
|
+
end
|
243
|
+
|
244
|
+
# Outputs non-array value in the form of hash
|
245
|
+
# For object, use to_hash. Otherwise, just return the value
|
246
|
+
# @param [Object] value Any valid value
|
247
|
+
# @return [Hash] Returns the value in the form of hash
|
248
|
+
def _to_hash(value)
|
249
|
+
if value.is_a?(Array)
|
250
|
+
value.compact.map { |v| _to_hash(v) }
|
251
|
+
elsif value.is_a?(Hash)
|
252
|
+
{}.tap do |hash|
|
253
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
254
|
+
end
|
255
|
+
elsif value.respond_to? :to_hash
|
256
|
+
value.to_hash
|
257
|
+
else
|
258
|
+
value
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
@@ -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\", \"city\": \"New Delhi\", \"street\": \"1, Akbar Road\", \"postal_code\": \"110016\", \"phone_number\": \"+919876543210\", \"bank_name\": \"Bank of India\" \"bank_account\": \"1234567890\", \"ifsc_code\": \"BKID0006005\" } ``` See [INR Bank](https://docs.transferzero.com/docs/payout-details/#inrbank) documentation for the bank_name list
|
17
|
+
class PayoutMethodDetailsINRBank
|
18
|
+
attr_accessor :first_name
|
19
|
+
|
20
|
+
attr_accessor :last_name
|
21
|
+
|
22
|
+
attr_accessor :city
|
23
|
+
|
24
|
+
attr_accessor :street
|
25
|
+
|
26
|
+
attr_accessor :postal_code
|
27
|
+
|
28
|
+
attr_accessor :phone_number
|
29
|
+
|
30
|
+
attr_accessor :bank_name
|
31
|
+
|
32
|
+
attr_accessor :bank_account
|
33
|
+
|
34
|
+
attr_accessor :ifsc_code
|
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
|
+
:'city' => :'city',
|
42
|
+
:'street' => :'street',
|
43
|
+
:'postal_code' => :'postal_code',
|
44
|
+
:'phone_number' => :'phone_number',
|
45
|
+
:'bank_name' => :'bank_name',
|
46
|
+
:'bank_account' => :'bank_account',
|
47
|
+
:'ifsc_code' => :'ifsc_code'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute type mapping.
|
52
|
+
def self.openapi_types
|
53
|
+
{
|
54
|
+
:'first_name' => :'String',
|
55
|
+
:'last_name' => :'String',
|
56
|
+
:'city' => :'String',
|
57
|
+
:'street' => :'String',
|
58
|
+
:'postal_code' => :'String',
|
59
|
+
:'phone_number' => :'String',
|
60
|
+
:'bank_name' => :'String',
|
61
|
+
:'bank_account' => :'String',
|
62
|
+
:'ifsc_code' => :'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::PayoutMethodDetailsINRBank` 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::PayoutMethodDetailsINRBank`. 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?(:'city')
|
90
|
+
self.city = attributes[:'city']
|
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?(:'phone_number')
|
102
|
+
self.phone_number = attributes[:'phone_number']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'bank_name')
|
106
|
+
self.bank_name = attributes[:'bank_name']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'bank_account')
|
110
|
+
self.bank_account = attributes[:'bank_account']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'ifsc_code')
|
114
|
+
self.ifsc_code = attributes[:'ifsc_code']
|
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 @city.nil?
|
131
|
+
invalid_properties.push('invalid value for "city", city cannot be nil.')
|
132
|
+
end
|
133
|
+
|
134
|
+
if @street.nil?
|
135
|
+
invalid_properties.push('invalid value for "street", street 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 @phone_number.nil?
|
143
|
+
invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
|
144
|
+
end
|
145
|
+
|
146
|
+
if @bank_name.nil?
|
147
|
+
invalid_properties.push('invalid value for "bank_name", bank_name cannot be nil.')
|
148
|
+
end
|
149
|
+
|
150
|
+
if @bank_account.nil?
|
151
|
+
invalid_properties.push('invalid value for "bank_account", bank_account cannot be nil.')
|
152
|
+
end
|
153
|
+
|
154
|
+
if @ifsc_code.nil?
|
155
|
+
invalid_properties.push('invalid value for "ifsc_code", ifsc_code 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 @city.nil?
|
167
|
+
return false if @street.nil?
|
168
|
+
return false if @postal_code.nil?
|
169
|
+
return false if @phone_number.nil?
|
170
|
+
return false if @bank_name.nil?
|
171
|
+
return false if @bank_account.nil?
|
172
|
+
return false if @ifsc_code.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
|
+
city == o.city &&
|
184
|
+
street == o.street &&
|
185
|
+
postal_code == o.postal_code &&
|
186
|
+
phone_number == o.phone_number &&
|
187
|
+
bank_name == o.bank_name &&
|
188
|
+
bank_account == o.bank_account &&
|
189
|
+
ifsc_code == o.ifsc_code
|
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, city, street, postal_code, phone_number, bank_name, bank_account, ifsc_code].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
|