moneykit 0.2.1 → 0.2.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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/docs/ApiPublicTransactionsGetTransactionsResponse.md +24 -0
- data/docs/ApiPublicTransactionsLegacyGetTransactionsResponse.md +28 -0
- data/docs/BudCategory.md +20 -0
- data/docs/BudPrimaryCategory.md +15 -0
- data/docs/BudSubcategory.md +15 -0
- data/docs/CustomSandboxAccount.md +24 -0
- data/docs/CustomSandboxData.md +20 -0
- data/docs/GetLinksLink.md +20 -0
- data/docs/GetLinksResponse.md +20 -0
- data/docs/ImportTransactionsRequest.md +18 -0
- data/docs/ProductStateChangedWebhook.md +38 -0
- data/docs/Response401CorrectEnrichmentLinksIdTransactionsTxnIdEnrichmentPost.md +22 -0
- data/docs/Response401CreateLinkSessionLinkSessionPost.md +22 -0
- data/docs/Response401GetLinksLinksGet.md +22 -0
- data/docs/Response401ImportTransactionsLinksIdImportTransactionsPost.md +22 -0
- data/docs/Response401ResetLinkLinksIdResetPost.md +22 -0
- data/lib/moneykit/models/api_public_transactions_get_transactions_response.rb +321 -0
- data/lib/moneykit/models/api_public_transactions_legacy_get_transactions_response.rb +375 -0
- data/lib/moneykit/models/bud_category.rb +266 -0
- data/lib/moneykit/models/bud_primary_category.rb +61 -0
- data/lib/moneykit/models/bud_subcategory.rb +165 -0
- data/lib/moneykit/models/custom_sandbox_account.rb +300 -0
- data/lib/moneykit/models/custom_sandbox_data.rb +250 -0
- data/lib/moneykit/models/get_links_link.rb +261 -0
- data/lib/moneykit/models/get_links_response.rb +231 -0
- data/lib/moneykit/models/import_transactions_request.rb +238 -0
- data/lib/moneykit/models/product_state_changed_webhook.rb +493 -0
- data/lib/moneykit/models/response401_correct_enrichment_links_id_transactions_txn_id_enrichment_post.rb +104 -0
- data/lib/moneykit/models/response401_create_link_session_link_session_post.rb +103 -0
- data/lib/moneykit/models/response401_get_links_links_get.rb +103 -0
- data/lib/moneykit/models/response401_import_transactions_links_id_import_transactions_post.rb +103 -0
- data/lib/moneykit/models/response401_reset_link_links_id_reset_post.rb +104 -0
- data/lib/moneykit/version.rb +1 -1
- data/spec/models/api_public_transactions_get_transactions_response_spec.rb +54 -0
- data/spec/models/api_public_transactions_legacy_get_transactions_response_spec.rb +66 -0
- data/spec/models/bud_category_spec.rb +42 -0
- data/spec/models/bud_primary_category_spec.rb +30 -0
- data/spec/models/bud_subcategory_spec.rb +30 -0
- data/spec/models/custom_sandbox_account_spec.rb +54 -0
- data/spec/models/custom_sandbox_data_spec.rb +42 -0
- data/spec/models/get_links_link_spec.rb +42 -0
- data/spec/models/get_links_response_spec.rb +42 -0
- data/spec/models/import_transactions_request_spec.rb +36 -0
- data/spec/models/product_state_changed_webhook_spec.rb +108 -0
- data/spec/models/response401_correct_enrichment_links_id_transactions_txn_id_enrichment_post_spec.rb +21 -0
- data/spec/models/response401_create_link_session_link_session_post_spec.rb +21 -0
- data/spec/models/response401_get_links_links_get_spec.rb +21 -0
- data/spec/models/response401_import_transactions_links_id_import_transactions_post_spec.rb +21 -0
- data/spec/models/response401_reset_link_links_id_reset_post_spec.rb +21 -0
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-12.0.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/json-2.11.3/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/prism-1.4.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
- metadata +66 -2
@@ -0,0 +1,300 @@
|
|
1
|
+
=begin
|
2
|
+
#MoneyKit API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2023-02-18
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.12.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module MoneyKit
|
17
|
+
class CustomSandboxAccount
|
18
|
+
# Account type applied to the sandbox account. See <a href=/pages/account_types>Account Types</a> for a full listing.
|
19
|
+
attr_accessor :account_type
|
20
|
+
|
21
|
+
# Account name used for the sandbox account.
|
22
|
+
attr_accessor :name
|
23
|
+
|
24
|
+
# Account number used for the sandbox account.
|
25
|
+
attr_accessor :account_number
|
26
|
+
|
27
|
+
# Routing number used for the sandbox account (if applicable). Must follow the standard ABA routing transit number format with a valid check digit, but does not need to be a real bank's routing number.
|
28
|
+
attr_accessor :routing_number
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
31
|
+
def self.attribute_map
|
32
|
+
{
|
33
|
+
:'account_type' => :'account_type',
|
34
|
+
:'name' => :'name',
|
35
|
+
:'account_number' => :'account_number',
|
36
|
+
:'routing_number' => :'routing_number'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns attribute mapping this model knows about
|
41
|
+
def self.acceptable_attribute_map
|
42
|
+
attribute_map
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns all the JSON keys this model knows about
|
46
|
+
def self.acceptable_attributes
|
47
|
+
acceptable_attribute_map.values
|
48
|
+
end
|
49
|
+
|
50
|
+
# Attribute type mapping.
|
51
|
+
def self.openapi_types
|
52
|
+
{
|
53
|
+
:'account_type' => :'String',
|
54
|
+
:'name' => :'String',
|
55
|
+
:'account_number' => :'String',
|
56
|
+
:'routing_number' => :'String'
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
# List of attributes with nullable: true
|
61
|
+
def self.openapi_nullable
|
62
|
+
Set.new([
|
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 `MoneyKit::CustomSandboxAccount` initialize method"
|
71
|
+
end
|
72
|
+
|
73
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
74
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
75
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
76
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
77
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MoneyKit::CustomSandboxAccount`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
78
|
+
end
|
79
|
+
h[k.to_sym] = v
|
80
|
+
}
|
81
|
+
|
82
|
+
if attributes.key?(:'account_type')
|
83
|
+
self.account_type = attributes[:'account_type']
|
84
|
+
else
|
85
|
+
self.account_type = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.key?(:'name')
|
89
|
+
self.name = attributes[:'name']
|
90
|
+
else
|
91
|
+
self.name = nil
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'account_number')
|
95
|
+
self.account_number = attributes[:'account_number']
|
96
|
+
else
|
97
|
+
self.account_number = nil
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.key?(:'routing_number')
|
101
|
+
self.routing_number = attributes[:'routing_number']
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
106
|
+
# @return Array for valid properties with the reasons
|
107
|
+
def list_invalid_properties
|
108
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
109
|
+
invalid_properties = Array.new
|
110
|
+
if @account_type.nil?
|
111
|
+
invalid_properties.push('invalid value for "account_type", account_type cannot be nil.')
|
112
|
+
end
|
113
|
+
|
114
|
+
if @name.nil?
|
115
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
116
|
+
end
|
117
|
+
|
118
|
+
if @account_number.nil?
|
119
|
+
invalid_properties.push('invalid value for "account_number", account_number cannot be nil.')
|
120
|
+
end
|
121
|
+
|
122
|
+
invalid_properties
|
123
|
+
end
|
124
|
+
|
125
|
+
# Check to see if the all the properties in the model are valid
|
126
|
+
# @return true if the model is valid
|
127
|
+
def valid?
|
128
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
129
|
+
return false if @account_type.nil?
|
130
|
+
return false if @name.nil?
|
131
|
+
return false if @account_number.nil?
|
132
|
+
true
|
133
|
+
end
|
134
|
+
|
135
|
+
# Custom attribute writer method with validation
|
136
|
+
# @param [Object] account_type Value to be assigned
|
137
|
+
def account_type=(account_type)
|
138
|
+
if account_type.nil?
|
139
|
+
fail ArgumentError, 'account_type cannot be nil'
|
140
|
+
end
|
141
|
+
|
142
|
+
@account_type = account_type
|
143
|
+
end
|
144
|
+
|
145
|
+
# Custom attribute writer method with validation
|
146
|
+
# @param [Object] name Value to be assigned
|
147
|
+
def name=(name)
|
148
|
+
if name.nil?
|
149
|
+
fail ArgumentError, 'name cannot be nil'
|
150
|
+
end
|
151
|
+
|
152
|
+
@name = name
|
153
|
+
end
|
154
|
+
|
155
|
+
# Custom attribute writer method with validation
|
156
|
+
# @param [Object] account_number Value to be assigned
|
157
|
+
def account_number=(account_number)
|
158
|
+
if account_number.nil?
|
159
|
+
fail ArgumentError, 'account_number cannot be nil'
|
160
|
+
end
|
161
|
+
|
162
|
+
@account_number = account_number
|
163
|
+
end
|
164
|
+
|
165
|
+
# Checks equality by comparing each attribute.
|
166
|
+
# @param [Object] Object to be compared
|
167
|
+
def ==(o)
|
168
|
+
return true if self.equal?(o)
|
169
|
+
self.class == o.class &&
|
170
|
+
account_type == o.account_type &&
|
171
|
+
name == o.name &&
|
172
|
+
account_number == o.account_number &&
|
173
|
+
routing_number == o.routing_number
|
174
|
+
end
|
175
|
+
|
176
|
+
# @see the `==` method
|
177
|
+
# @param [Object] Object to be compared
|
178
|
+
def eql?(o)
|
179
|
+
self == o
|
180
|
+
end
|
181
|
+
|
182
|
+
# Calculates hash code according to all attributes.
|
183
|
+
# @return [Integer] Hash code
|
184
|
+
def hash
|
185
|
+
[account_type, name, account_number, routing_number].hash
|
186
|
+
end
|
187
|
+
|
188
|
+
# Builds the object from hash
|
189
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
190
|
+
# @return [Object] Returns the model itself
|
191
|
+
def self.build_from_hash(attributes)
|
192
|
+
return nil unless attributes.is_a?(Hash)
|
193
|
+
attributes = attributes.transform_keys(&:to_sym)
|
194
|
+
transformed_hash = {}
|
195
|
+
openapi_types.each_pair do |key, type|
|
196
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
197
|
+
transformed_hash["#{key}"] = nil
|
198
|
+
elsif type =~ /\AArray<(.*)>/i
|
199
|
+
# check to ensure the input is an array given that the attribute
|
200
|
+
# is documented as an array but the input is not
|
201
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
202
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
203
|
+
end
|
204
|
+
elsif !attributes[attribute_map[key]].nil?
|
205
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
206
|
+
end
|
207
|
+
end
|
208
|
+
new(transformed_hash)
|
209
|
+
end
|
210
|
+
|
211
|
+
# Deserializes the data based on type
|
212
|
+
# @param string type Data type
|
213
|
+
# @param string value Value to be deserialized
|
214
|
+
# @return [Object] Deserialized data
|
215
|
+
def self._deserialize(type, value)
|
216
|
+
case type.to_sym
|
217
|
+
when :Time
|
218
|
+
Time.parse(value)
|
219
|
+
when :Date
|
220
|
+
::Date.parse(value)
|
221
|
+
when :String
|
222
|
+
value.to_s
|
223
|
+
when :Integer
|
224
|
+
value.to_i
|
225
|
+
when :Float
|
226
|
+
value.to_f
|
227
|
+
when :Boolean
|
228
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
229
|
+
true
|
230
|
+
else
|
231
|
+
false
|
232
|
+
end
|
233
|
+
when :Object
|
234
|
+
# generic object (usually a Hash), return directly
|
235
|
+
value
|
236
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
237
|
+
inner_type = Regexp.last_match[:inner_type]
|
238
|
+
value.map { |v| _deserialize(inner_type, v) }
|
239
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
240
|
+
k_type = Regexp.last_match[:k_type]
|
241
|
+
v_type = Regexp.last_match[:v_type]
|
242
|
+
{}.tap do |hash|
|
243
|
+
value.each do |k, v|
|
244
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
else # model
|
248
|
+
# models (e.g. Pet) or oneOf
|
249
|
+
klass = MoneyKit.const_get(type)
|
250
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
# Returns the string representation of the object
|
255
|
+
# @return [String] String presentation of the object
|
256
|
+
def to_s
|
257
|
+
to_hash.to_s
|
258
|
+
end
|
259
|
+
|
260
|
+
# to_body is an alias to to_hash (backward compatibility)
|
261
|
+
# @return [Hash] Returns the object in the form of hash
|
262
|
+
def to_body
|
263
|
+
to_hash
|
264
|
+
end
|
265
|
+
|
266
|
+
# Returns the object in the form of hash
|
267
|
+
# @return [Hash] Returns the object in the form of hash
|
268
|
+
def to_hash
|
269
|
+
hash = {}
|
270
|
+
self.class.attribute_map.each_pair do |attr, param|
|
271
|
+
value = self.send(attr)
|
272
|
+
if value.nil?
|
273
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
274
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
275
|
+
end
|
276
|
+
|
277
|
+
hash[param] = _to_hash(value)
|
278
|
+
end
|
279
|
+
hash
|
280
|
+
end
|
281
|
+
|
282
|
+
# Outputs non-array value in the form of hash
|
283
|
+
# For object, use to_hash. Otherwise, just return the value
|
284
|
+
# @param [Object] value Any valid value
|
285
|
+
# @return [Hash] Returns the value in the form of hash
|
286
|
+
def _to_hash(value)
|
287
|
+
if value.is_a?(Array)
|
288
|
+
value.compact.map { |v| _to_hash(v) }
|
289
|
+
elsif value.is_a?(Hash)
|
290
|
+
{}.tap do |hash|
|
291
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
292
|
+
end
|
293
|
+
elsif value.respond_to? :to_hash
|
294
|
+
value.to_hash
|
295
|
+
else
|
296
|
+
value
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
@@ -0,0 +1,250 @@
|
|
1
|
+
=begin
|
2
|
+
#MoneyKit API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2023-02-18
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.12.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module MoneyKit
|
17
|
+
class CustomSandboxData
|
18
|
+
# An array of static accounts to be returned from Sandbox via `user_custom`.
|
19
|
+
attr_accessor :accounts
|
20
|
+
|
21
|
+
# An array of owners to attach to the identity response of every account on `user_custom`. Owners will otherwise be randomly generated.
|
22
|
+
attr_accessor :owners
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'accounts' => :'accounts',
|
28
|
+
:'owners' => :'owners'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns attribute mapping this model knows about
|
33
|
+
def self.acceptable_attribute_map
|
34
|
+
attribute_map
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns all the JSON keys this model knows about
|
38
|
+
def self.acceptable_attributes
|
39
|
+
acceptable_attribute_map.values
|
40
|
+
end
|
41
|
+
|
42
|
+
# Attribute type mapping.
|
43
|
+
def self.openapi_types
|
44
|
+
{
|
45
|
+
:'accounts' => :'Array<CustomSandboxAccount>',
|
46
|
+
:'owners' => :'Array<Owner>'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# List of attributes with nullable: true
|
51
|
+
def self.openapi_nullable
|
52
|
+
Set.new([
|
53
|
+
])
|
54
|
+
end
|
55
|
+
|
56
|
+
# Initializes the object
|
57
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
58
|
+
def initialize(attributes = {})
|
59
|
+
if (!attributes.is_a?(Hash))
|
60
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `MoneyKit::CustomSandboxData` initialize method"
|
61
|
+
end
|
62
|
+
|
63
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
64
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
66
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `MoneyKit::CustomSandboxData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
68
|
+
end
|
69
|
+
h[k.to_sym] = v
|
70
|
+
}
|
71
|
+
|
72
|
+
if attributes.key?(:'accounts')
|
73
|
+
if (value = attributes[:'accounts']).is_a?(Array)
|
74
|
+
self.accounts = value
|
75
|
+
end
|
76
|
+
else
|
77
|
+
self.accounts = nil
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.key?(:'owners')
|
81
|
+
if (value = attributes[:'owners']).is_a?(Array)
|
82
|
+
self.owners = value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
88
|
+
# @return Array for valid properties with the reasons
|
89
|
+
def list_invalid_properties
|
90
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
91
|
+
invalid_properties = Array.new
|
92
|
+
if @accounts.nil?
|
93
|
+
invalid_properties.push('invalid value for "accounts", accounts cannot be nil.')
|
94
|
+
end
|
95
|
+
|
96
|
+
invalid_properties
|
97
|
+
end
|
98
|
+
|
99
|
+
# Check to see if the all the properties in the model are valid
|
100
|
+
# @return true if the model is valid
|
101
|
+
def valid?
|
102
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
103
|
+
return false if @accounts.nil?
|
104
|
+
true
|
105
|
+
end
|
106
|
+
|
107
|
+
# Custom attribute writer method with validation
|
108
|
+
# @param [Object] accounts Value to be assigned
|
109
|
+
def accounts=(accounts)
|
110
|
+
if accounts.nil?
|
111
|
+
fail ArgumentError, 'accounts cannot be nil'
|
112
|
+
end
|
113
|
+
|
114
|
+
@accounts = accounts
|
115
|
+
end
|
116
|
+
|
117
|
+
# Checks equality by comparing each attribute.
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def ==(o)
|
120
|
+
return true if self.equal?(o)
|
121
|
+
self.class == o.class &&
|
122
|
+
accounts == o.accounts &&
|
123
|
+
owners == o.owners
|
124
|
+
end
|
125
|
+
|
126
|
+
# @see the `==` method
|
127
|
+
# @param [Object] Object to be compared
|
128
|
+
def eql?(o)
|
129
|
+
self == o
|
130
|
+
end
|
131
|
+
|
132
|
+
# Calculates hash code according to all attributes.
|
133
|
+
# @return [Integer] Hash code
|
134
|
+
def hash
|
135
|
+
[accounts, owners].hash
|
136
|
+
end
|
137
|
+
|
138
|
+
# Builds the object from hash
|
139
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
140
|
+
# @return [Object] Returns the model itself
|
141
|
+
def self.build_from_hash(attributes)
|
142
|
+
return nil unless attributes.is_a?(Hash)
|
143
|
+
attributes = attributes.transform_keys(&:to_sym)
|
144
|
+
transformed_hash = {}
|
145
|
+
openapi_types.each_pair do |key, type|
|
146
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
147
|
+
transformed_hash["#{key}"] = nil
|
148
|
+
elsif type =~ /\AArray<(.*)>/i
|
149
|
+
# check to ensure the input is an array given that the attribute
|
150
|
+
# is documented as an array but the input is not
|
151
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
152
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
153
|
+
end
|
154
|
+
elsif !attributes[attribute_map[key]].nil?
|
155
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
156
|
+
end
|
157
|
+
end
|
158
|
+
new(transformed_hash)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Deserializes the data based on type
|
162
|
+
# @param string type Data type
|
163
|
+
# @param string value Value to be deserialized
|
164
|
+
# @return [Object] Deserialized data
|
165
|
+
def self._deserialize(type, value)
|
166
|
+
case type.to_sym
|
167
|
+
when :Time
|
168
|
+
Time.parse(value)
|
169
|
+
when :Date
|
170
|
+
::Date.parse(value)
|
171
|
+
when :String
|
172
|
+
value.to_s
|
173
|
+
when :Integer
|
174
|
+
value.to_i
|
175
|
+
when :Float
|
176
|
+
value.to_f
|
177
|
+
when :Boolean
|
178
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
179
|
+
true
|
180
|
+
else
|
181
|
+
false
|
182
|
+
end
|
183
|
+
when :Object
|
184
|
+
# generic object (usually a Hash), return directly
|
185
|
+
value
|
186
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
187
|
+
inner_type = Regexp.last_match[:inner_type]
|
188
|
+
value.map { |v| _deserialize(inner_type, v) }
|
189
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
190
|
+
k_type = Regexp.last_match[:k_type]
|
191
|
+
v_type = Regexp.last_match[:v_type]
|
192
|
+
{}.tap do |hash|
|
193
|
+
value.each do |k, v|
|
194
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
else # model
|
198
|
+
# models (e.g. Pet) or oneOf
|
199
|
+
klass = MoneyKit.const_get(type)
|
200
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns the string representation of the object
|
205
|
+
# @return [String] String presentation of the object
|
206
|
+
def to_s
|
207
|
+
to_hash.to_s
|
208
|
+
end
|
209
|
+
|
210
|
+
# to_body is an alias to to_hash (backward compatibility)
|
211
|
+
# @return [Hash] Returns the object in the form of hash
|
212
|
+
def to_body
|
213
|
+
to_hash
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns the object in the form of hash
|
217
|
+
# @return [Hash] Returns the object in the form of hash
|
218
|
+
def to_hash
|
219
|
+
hash = {}
|
220
|
+
self.class.attribute_map.each_pair do |attr, param|
|
221
|
+
value = self.send(attr)
|
222
|
+
if value.nil?
|
223
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
224
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
225
|
+
end
|
226
|
+
|
227
|
+
hash[param] = _to_hash(value)
|
228
|
+
end
|
229
|
+
hash
|
230
|
+
end
|
231
|
+
|
232
|
+
# Outputs non-array value in the form of hash
|
233
|
+
# For object, use to_hash. Otherwise, just return the value
|
234
|
+
# @param [Object] value Any valid value
|
235
|
+
# @return [Hash] Returns the value in the form of hash
|
236
|
+
def _to_hash(value)
|
237
|
+
if value.is_a?(Array)
|
238
|
+
value.compact.map { |v| _to_hash(v) }
|
239
|
+
elsif value.is_a?(Hash)
|
240
|
+
{}.tap do |hash|
|
241
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
242
|
+
end
|
243
|
+
elsif value.respond_to? :to_hash
|
244
|
+
value.to_hash
|
245
|
+
else
|
246
|
+
value
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|