mx-platform-ruby 0.42.0 → 0.43.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/docs/MicrodepositRequest.md +30 -0
- data/docs/MicrodepositRequestBody.md +18 -0
- data/docs/MicrodepositResponse.md +44 -0
- data/docs/MicrodepositResponseBody.md +18 -0
- data/docs/MicrodepositVerifyRequest.md +20 -0
- data/docs/MicrodepositVerifyRequestBody.md +18 -0
- data/docs/MicrodepositsApi.md +371 -0
- data/docs/MicrodepositsResponseBody.md +20 -0
- data/docs/TransactionCreateRequest.md +40 -0
- data/docs/TransactionCreateRequestBody.md +18 -0
- data/docs/TransactionCreateResponseBody.md +104 -0
- data/docs/TransactionsApi.md +82 -0
- data/lib/mx-platform-ruby/api/microdeposits_api.rb +365 -0
- data/lib/mx-platform-ruby/api/transactions_api.rb +102 -0
- data/lib/mx-platform-ruby/models/microdeposit_request.rb +289 -0
- data/lib/mx-platform-ruby/models/microdeposit_request_body.rb +214 -0
- data/lib/mx-platform-ruby/models/microdeposit_response.rb +331 -0
- data/lib/mx-platform-ruby/models/microdeposit_response_body.rb +214 -0
- data/lib/mx-platform-ruby/models/microdeposit_verify_request.rb +223 -0
- data/lib/mx-platform-ruby/models/microdeposit_verify_request_body.rb +214 -0
- data/lib/mx-platform-ruby/models/microdeposits_response_body.rb +225 -0
- data/lib/mx-platform-ruby/models/transaction_create_request.rb +344 -0
- data/lib/mx-platform-ruby/models/transaction_create_request_body.rb +214 -0
- data/lib/mx-platform-ruby/models/transaction_create_response_body.rb +642 -0
- data/lib/mx-platform-ruby/version.rb +1 -1
- data/lib/mx-platform-ruby.rb +12 -0
- data/openapi/config.yml +1 -1
- data/spec/api/microdeposits_api_spec.rb +99 -0
- data/spec/api/transactions_api_spec.rb +49 -0
- data/spec/models/microdeposit_request_body_spec.rb +34 -0
- data/spec/models/microdeposit_request_spec.rb +70 -0
- data/spec/models/microdeposit_response_body_spec.rb +34 -0
- data/spec/models/microdeposit_response_spec.rb +112 -0
- data/spec/models/microdeposit_verify_request_body_spec.rb +34 -0
- data/spec/models/microdeposit_verify_request_spec.rb +40 -0
- data/spec/models/microdeposits_response_body_spec.rb +40 -0
- data/spec/models/transaction_create_request_body_spec.rb +34 -0
- data/spec/models/transaction_create_request_spec.rb +100 -0
- data/spec/models/transaction_create_response_body_spec.rb +292 -0
- metadata +195 -147
@@ -0,0 +1,344 @@
|
|
1
|
+
=begin
|
2
|
+
#MX Platform API
|
3
|
+
|
4
|
+
#The MX Platform API is a powerful, fully-featured API designed to make aggregating and enhancing financial data easy and reliable. It can seamlessly connect your app or website to tens of thousands of financial institutions.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 0.1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module MxPlatformRuby
|
17
|
+
class TransactionCreateRequest
|
18
|
+
attr_accessor :amount
|
19
|
+
|
20
|
+
attr_accessor :date
|
21
|
+
|
22
|
+
attr_accessor :description
|
23
|
+
|
24
|
+
# The type of transaction, which must be CREDIT or DEBIT. See Transaction Fields for more information.
|
25
|
+
attr_accessor :type
|
26
|
+
|
27
|
+
# Unique identifier of the category.
|
28
|
+
attr_accessor :category_guid
|
29
|
+
|
30
|
+
attr_accessor :currency_code
|
31
|
+
|
32
|
+
attr_accessor :has_been_viewed
|
33
|
+
|
34
|
+
attr_accessor :is_hidden
|
35
|
+
|
36
|
+
attr_accessor :is_international
|
37
|
+
|
38
|
+
attr_accessor :memo
|
39
|
+
|
40
|
+
attr_accessor :metadata
|
41
|
+
|
42
|
+
# When set to true, this parameter will prevent a webhook from being triggered by the request.
|
43
|
+
attr_accessor :skip_webhook
|
44
|
+
|
45
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
46
|
+
def self.attribute_map
|
47
|
+
{
|
48
|
+
:'amount' => :'amount',
|
49
|
+
:'date' => :'date',
|
50
|
+
:'description' => :'description',
|
51
|
+
:'type' => :'type',
|
52
|
+
:'category_guid' => :'category_guid',
|
53
|
+
:'currency_code' => :'currency_code',
|
54
|
+
:'has_been_viewed' => :'has_been_viewed',
|
55
|
+
:'is_hidden' => :'is_hidden',
|
56
|
+
:'is_international' => :'is_international',
|
57
|
+
:'memo' => :'memo',
|
58
|
+
:'metadata' => :'metadata',
|
59
|
+
:'skip_webhook' => :'skip_webhook'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns all the JSON keys this model knows about
|
64
|
+
def self.acceptable_attributes
|
65
|
+
attribute_map.values
|
66
|
+
end
|
67
|
+
|
68
|
+
# Attribute type mapping.
|
69
|
+
def self.openapi_types
|
70
|
+
{
|
71
|
+
:'amount' => :'Float',
|
72
|
+
:'date' => :'String',
|
73
|
+
:'description' => :'String',
|
74
|
+
:'type' => :'String',
|
75
|
+
:'category_guid' => :'String',
|
76
|
+
:'currency_code' => :'String',
|
77
|
+
:'has_been_viewed' => :'Boolean',
|
78
|
+
:'is_hidden' => :'Boolean',
|
79
|
+
:'is_international' => :'Boolean',
|
80
|
+
:'memo' => :'String',
|
81
|
+
:'metadata' => :'String',
|
82
|
+
:'skip_webhook' => :'Boolean'
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
# List of attributes with nullable: true
|
87
|
+
def self.openapi_nullable
|
88
|
+
Set.new([
|
89
|
+
])
|
90
|
+
end
|
91
|
+
|
92
|
+
# Initializes the object
|
93
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
94
|
+
def initialize(attributes = {})
|
95
|
+
if (!attributes.is_a?(Hash))
|
96
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MxPlatformRuby::TransactionCreateRequest` initialize method"
|
97
|
+
end
|
98
|
+
|
99
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
100
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
101
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
102
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MxPlatformRuby::TransactionCreateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
103
|
+
end
|
104
|
+
h[k.to_sym] = v
|
105
|
+
}
|
106
|
+
|
107
|
+
if attributes.key?(:'amount')
|
108
|
+
self.amount = attributes[:'amount']
|
109
|
+
else
|
110
|
+
self.amount = nil
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'date')
|
114
|
+
self.date = attributes[:'date']
|
115
|
+
else
|
116
|
+
self.date = nil
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'description')
|
120
|
+
self.description = attributes[:'description']
|
121
|
+
else
|
122
|
+
self.description = nil
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:'type')
|
126
|
+
self.type = attributes[:'type']
|
127
|
+
else
|
128
|
+
self.type = nil
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:'category_guid')
|
132
|
+
self.category_guid = attributes[:'category_guid']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.key?(:'currency_code')
|
136
|
+
self.currency_code = attributes[:'currency_code']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'has_been_viewed')
|
140
|
+
self.has_been_viewed = attributes[:'has_been_viewed']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.key?(:'is_hidden')
|
144
|
+
self.is_hidden = attributes[:'is_hidden']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.key?(:'is_international')
|
148
|
+
self.is_international = attributes[:'is_international']
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.key?(:'memo')
|
152
|
+
self.memo = attributes[:'memo']
|
153
|
+
end
|
154
|
+
|
155
|
+
if attributes.key?(:'metadata')
|
156
|
+
self.metadata = attributes[:'metadata']
|
157
|
+
end
|
158
|
+
|
159
|
+
if attributes.key?(:'skip_webhook')
|
160
|
+
self.skip_webhook = attributes[:'skip_webhook']
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
165
|
+
# @return Array for valid properties with the reasons
|
166
|
+
def list_invalid_properties
|
167
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
168
|
+
invalid_properties = Array.new
|
169
|
+
if @amount.nil?
|
170
|
+
invalid_properties.push('invalid value for "amount", amount cannot be nil.')
|
171
|
+
end
|
172
|
+
|
173
|
+
if @date.nil?
|
174
|
+
invalid_properties.push('invalid value for "date", date cannot be nil.')
|
175
|
+
end
|
176
|
+
|
177
|
+
if @description.nil?
|
178
|
+
invalid_properties.push('invalid value for "description", description cannot be nil.')
|
179
|
+
end
|
180
|
+
|
181
|
+
if @type.nil?
|
182
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
183
|
+
end
|
184
|
+
|
185
|
+
invalid_properties
|
186
|
+
end
|
187
|
+
|
188
|
+
# Check to see if the all the properties in the model are valid
|
189
|
+
# @return true if the model is valid
|
190
|
+
def valid?
|
191
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
192
|
+
return false if @amount.nil?
|
193
|
+
return false if @date.nil?
|
194
|
+
return false if @description.nil?
|
195
|
+
return false if @type.nil?
|
196
|
+
true
|
197
|
+
end
|
198
|
+
|
199
|
+
# Checks equality by comparing each attribute.
|
200
|
+
# @param [Object] Object to be compared
|
201
|
+
def ==(o)
|
202
|
+
return true if self.equal?(o)
|
203
|
+
self.class == o.class &&
|
204
|
+
amount == o.amount &&
|
205
|
+
date == o.date &&
|
206
|
+
description == o.description &&
|
207
|
+
type == o.type &&
|
208
|
+
category_guid == o.category_guid &&
|
209
|
+
currency_code == o.currency_code &&
|
210
|
+
has_been_viewed == o.has_been_viewed &&
|
211
|
+
is_hidden == o.is_hidden &&
|
212
|
+
is_international == o.is_international &&
|
213
|
+
memo == o.memo &&
|
214
|
+
metadata == o.metadata &&
|
215
|
+
skip_webhook == o.skip_webhook
|
216
|
+
end
|
217
|
+
|
218
|
+
# @see the `==` method
|
219
|
+
# @param [Object] Object to be compared
|
220
|
+
def eql?(o)
|
221
|
+
self == o
|
222
|
+
end
|
223
|
+
|
224
|
+
# Calculates hash code according to all attributes.
|
225
|
+
# @return [Integer] Hash code
|
226
|
+
def hash
|
227
|
+
[amount, date, description, type, category_guid, currency_code, has_been_viewed, is_hidden, is_international, memo, metadata, skip_webhook].hash
|
228
|
+
end
|
229
|
+
|
230
|
+
# Builds the object from hash
|
231
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
232
|
+
# @return [Object] Returns the model itself
|
233
|
+
def self.build_from_hash(attributes)
|
234
|
+
return nil unless attributes.is_a?(Hash)
|
235
|
+
attributes = attributes.transform_keys(&:to_sym)
|
236
|
+
transformed_hash = {}
|
237
|
+
openapi_types.each_pair do |key, type|
|
238
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
239
|
+
transformed_hash["#{key}"] = nil
|
240
|
+
elsif type =~ /\AArray<(.*)>/i
|
241
|
+
# check to ensure the input is an array given that the attribute
|
242
|
+
# is documented as an array but the input is not
|
243
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
244
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
245
|
+
end
|
246
|
+
elsif !attributes[attribute_map[key]].nil?
|
247
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
248
|
+
end
|
249
|
+
end
|
250
|
+
new(transformed_hash)
|
251
|
+
end
|
252
|
+
|
253
|
+
# Deserializes the data based on type
|
254
|
+
# @param string type Data type
|
255
|
+
# @param string value Value to be deserialized
|
256
|
+
# @return [Object] Deserialized data
|
257
|
+
def self._deserialize(type, value)
|
258
|
+
case type.to_sym
|
259
|
+
when :Time
|
260
|
+
Time.parse(value)
|
261
|
+
when :Date
|
262
|
+
Date.parse(value)
|
263
|
+
when :String
|
264
|
+
value.to_s
|
265
|
+
when :Integer
|
266
|
+
value.to_i
|
267
|
+
when :Float
|
268
|
+
value.to_f
|
269
|
+
when :Boolean
|
270
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
271
|
+
true
|
272
|
+
else
|
273
|
+
false
|
274
|
+
end
|
275
|
+
when :Object
|
276
|
+
# generic object (usually a Hash), return directly
|
277
|
+
value
|
278
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
279
|
+
inner_type = Regexp.last_match[:inner_type]
|
280
|
+
value.map { |v| _deserialize(inner_type, v) }
|
281
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
282
|
+
k_type = Regexp.last_match[:k_type]
|
283
|
+
v_type = Regexp.last_match[:v_type]
|
284
|
+
{}.tap do |hash|
|
285
|
+
value.each do |k, v|
|
286
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
else # model
|
290
|
+
# models (e.g. Pet) or oneOf
|
291
|
+
klass = MxPlatformRuby.const_get(type)
|
292
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
# Returns the string representation of the object
|
297
|
+
# @return [String] String presentation of the object
|
298
|
+
def to_s
|
299
|
+
to_hash.to_s
|
300
|
+
end
|
301
|
+
|
302
|
+
# to_body is an alias to to_hash (backward compatibility)
|
303
|
+
# @return [Hash] Returns the object in the form of hash
|
304
|
+
def to_body
|
305
|
+
to_hash
|
306
|
+
end
|
307
|
+
|
308
|
+
# Returns the object in the form of hash
|
309
|
+
# @return [Hash] Returns the object in the form of hash
|
310
|
+
def to_hash
|
311
|
+
hash = {}
|
312
|
+
self.class.attribute_map.each_pair do |attr, param|
|
313
|
+
value = self.send(attr)
|
314
|
+
if value.nil?
|
315
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
316
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
317
|
+
end
|
318
|
+
|
319
|
+
hash[param] = _to_hash(value)
|
320
|
+
end
|
321
|
+
hash
|
322
|
+
end
|
323
|
+
|
324
|
+
# Outputs non-array value in the form of hash
|
325
|
+
# For object, use to_hash. Otherwise, just return the value
|
326
|
+
# @param [Object] value Any valid value
|
327
|
+
# @return [Hash] Returns the value in the form of hash
|
328
|
+
def _to_hash(value)
|
329
|
+
if value.is_a?(Array)
|
330
|
+
value.compact.map { |v| _to_hash(v) }
|
331
|
+
elsif value.is_a?(Hash)
|
332
|
+
{}.tap do |hash|
|
333
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
334
|
+
end
|
335
|
+
elsif value.respond_to? :to_hash
|
336
|
+
value.to_hash
|
337
|
+
else
|
338
|
+
value
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
=begin
|
2
|
+
#MX Platform API
|
3
|
+
|
4
|
+
#The MX Platform API is a powerful, fully-featured API designed to make aggregating and enhancing financial data easy and reliable. It can seamlessly connect your app or website to tens of thousands of financial institutions.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 0.1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module MxPlatformRuby
|
17
|
+
class TransactionCreateRequestBody
|
18
|
+
attr_accessor :transaction
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'transaction' => :'transaction'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns all the JSON keys this model knows about
|
28
|
+
def self.acceptable_attributes
|
29
|
+
attribute_map.values
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.openapi_types
|
34
|
+
{
|
35
|
+
:'transaction' => :'TransactionCreateRequest'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# List of attributes with nullable: true
|
40
|
+
def self.openapi_nullable
|
41
|
+
Set.new([
|
42
|
+
])
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes the object
|
46
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
+
def initialize(attributes = {})
|
48
|
+
if (!attributes.is_a?(Hash))
|
49
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MxPlatformRuby::TransactionCreateRequestBody` initialize method"
|
50
|
+
end
|
51
|
+
|
52
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
53
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
54
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
55
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MxPlatformRuby::TransactionCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
56
|
+
end
|
57
|
+
h[k.to_sym] = v
|
58
|
+
}
|
59
|
+
|
60
|
+
if attributes.key?(:'transaction')
|
61
|
+
self.transaction = attributes[:'transaction']
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
66
|
+
# @return Array for valid properties with the reasons
|
67
|
+
def list_invalid_properties
|
68
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
69
|
+
invalid_properties = Array.new
|
70
|
+
invalid_properties
|
71
|
+
end
|
72
|
+
|
73
|
+
# Check to see if the all the properties in the model are valid
|
74
|
+
# @return true if the model is valid
|
75
|
+
def valid?
|
76
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
# Checks equality by comparing each attribute.
|
81
|
+
# @param [Object] Object to be compared
|
82
|
+
def ==(o)
|
83
|
+
return true if self.equal?(o)
|
84
|
+
self.class == o.class &&
|
85
|
+
transaction == o.transaction
|
86
|
+
end
|
87
|
+
|
88
|
+
# @see the `==` method
|
89
|
+
# @param [Object] Object to be compared
|
90
|
+
def eql?(o)
|
91
|
+
self == o
|
92
|
+
end
|
93
|
+
|
94
|
+
# Calculates hash code according to all attributes.
|
95
|
+
# @return [Integer] Hash code
|
96
|
+
def hash
|
97
|
+
[transaction].hash
|
98
|
+
end
|
99
|
+
|
100
|
+
# Builds the object from hash
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
# @return [Object] Returns the model itself
|
103
|
+
def self.build_from_hash(attributes)
|
104
|
+
return nil unless attributes.is_a?(Hash)
|
105
|
+
attributes = attributes.transform_keys(&:to_sym)
|
106
|
+
transformed_hash = {}
|
107
|
+
openapi_types.each_pair do |key, type|
|
108
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
109
|
+
transformed_hash["#{key}"] = nil
|
110
|
+
elsif type =~ /\AArray<(.*)>/i
|
111
|
+
# check to ensure the input is an array given that the attribute
|
112
|
+
# is documented as an array but the input is not
|
113
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
114
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
115
|
+
end
|
116
|
+
elsif !attributes[attribute_map[key]].nil?
|
117
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
118
|
+
end
|
119
|
+
end
|
120
|
+
new(transformed_hash)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Deserializes the data based on type
|
124
|
+
# @param string type Data type
|
125
|
+
# @param string value Value to be deserialized
|
126
|
+
# @return [Object] Deserialized data
|
127
|
+
def self._deserialize(type, value)
|
128
|
+
case type.to_sym
|
129
|
+
when :Time
|
130
|
+
Time.parse(value)
|
131
|
+
when :Date
|
132
|
+
Date.parse(value)
|
133
|
+
when :String
|
134
|
+
value.to_s
|
135
|
+
when :Integer
|
136
|
+
value.to_i
|
137
|
+
when :Float
|
138
|
+
value.to_f
|
139
|
+
when :Boolean
|
140
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
141
|
+
true
|
142
|
+
else
|
143
|
+
false
|
144
|
+
end
|
145
|
+
when :Object
|
146
|
+
# generic object (usually a Hash), return directly
|
147
|
+
value
|
148
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
149
|
+
inner_type = Regexp.last_match[:inner_type]
|
150
|
+
value.map { |v| _deserialize(inner_type, v) }
|
151
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
152
|
+
k_type = Regexp.last_match[:k_type]
|
153
|
+
v_type = Regexp.last_match[:v_type]
|
154
|
+
{}.tap do |hash|
|
155
|
+
value.each do |k, v|
|
156
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
else # model
|
160
|
+
# models (e.g. Pet) or oneOf
|
161
|
+
klass = MxPlatformRuby.const_get(type)
|
162
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Returns the string representation of the object
|
167
|
+
# @return [String] String presentation of the object
|
168
|
+
def to_s
|
169
|
+
to_hash.to_s
|
170
|
+
end
|
171
|
+
|
172
|
+
# to_body is an alias to to_hash (backward compatibility)
|
173
|
+
# @return [Hash] Returns the object in the form of hash
|
174
|
+
def to_body
|
175
|
+
to_hash
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns the object in the form of hash
|
179
|
+
# @return [Hash] Returns the object in the form of hash
|
180
|
+
def to_hash
|
181
|
+
hash = {}
|
182
|
+
self.class.attribute_map.each_pair do |attr, param|
|
183
|
+
value = self.send(attr)
|
184
|
+
if value.nil?
|
185
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
186
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
187
|
+
end
|
188
|
+
|
189
|
+
hash[param] = _to_hash(value)
|
190
|
+
end
|
191
|
+
hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# Outputs non-array value in the form of hash
|
195
|
+
# For object, use to_hash. Otherwise, just return the value
|
196
|
+
# @param [Object] value Any valid value
|
197
|
+
# @return [Hash] Returns the value in the form of hash
|
198
|
+
def _to_hash(value)
|
199
|
+
if value.is_a?(Array)
|
200
|
+
value.compact.map { |v| _to_hash(v) }
|
201
|
+
elsif value.is_a?(Hash)
|
202
|
+
{}.tap do |hash|
|
203
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
204
|
+
end
|
205
|
+
elsif value.respond_to? :to_hash
|
206
|
+
value.to_hash
|
207
|
+
else
|
208
|
+
value
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|