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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +1 -1
  4. data/docs/ApiPublicTransactionsGetTransactionsResponse.md +24 -0
  5. data/docs/ApiPublicTransactionsLegacyGetTransactionsResponse.md +28 -0
  6. data/docs/BudCategory.md +20 -0
  7. data/docs/BudPrimaryCategory.md +15 -0
  8. data/docs/BudSubcategory.md +15 -0
  9. data/docs/CustomSandboxAccount.md +24 -0
  10. data/docs/CustomSandboxData.md +20 -0
  11. data/docs/GetLinksLink.md +20 -0
  12. data/docs/GetLinksResponse.md +20 -0
  13. data/docs/ImportTransactionsRequest.md +18 -0
  14. data/docs/ProductStateChangedWebhook.md +38 -0
  15. data/docs/Response401CorrectEnrichmentLinksIdTransactionsTxnIdEnrichmentPost.md +22 -0
  16. data/docs/Response401CreateLinkSessionLinkSessionPost.md +22 -0
  17. data/docs/Response401GetLinksLinksGet.md +22 -0
  18. data/docs/Response401ImportTransactionsLinksIdImportTransactionsPost.md +22 -0
  19. data/docs/Response401ResetLinkLinksIdResetPost.md +22 -0
  20. data/lib/moneykit/models/api_public_transactions_get_transactions_response.rb +321 -0
  21. data/lib/moneykit/models/api_public_transactions_legacy_get_transactions_response.rb +375 -0
  22. data/lib/moneykit/models/bud_category.rb +266 -0
  23. data/lib/moneykit/models/bud_primary_category.rb +61 -0
  24. data/lib/moneykit/models/bud_subcategory.rb +165 -0
  25. data/lib/moneykit/models/custom_sandbox_account.rb +300 -0
  26. data/lib/moneykit/models/custom_sandbox_data.rb +250 -0
  27. data/lib/moneykit/models/get_links_link.rb +261 -0
  28. data/lib/moneykit/models/get_links_response.rb +231 -0
  29. data/lib/moneykit/models/import_transactions_request.rb +238 -0
  30. data/lib/moneykit/models/product_state_changed_webhook.rb +493 -0
  31. data/lib/moneykit/models/response401_correct_enrichment_links_id_transactions_txn_id_enrichment_post.rb +104 -0
  32. data/lib/moneykit/models/response401_create_link_session_link_session_post.rb +103 -0
  33. data/lib/moneykit/models/response401_get_links_links_get.rb +103 -0
  34. data/lib/moneykit/models/response401_import_transactions_links_id_import_transactions_post.rb +103 -0
  35. data/lib/moneykit/models/response401_reset_link_links_id_reset_post.rb +104 -0
  36. data/lib/moneykit/version.rb +1 -1
  37. data/spec/models/api_public_transactions_get_transactions_response_spec.rb +54 -0
  38. data/spec/models/api_public_transactions_legacy_get_transactions_response_spec.rb +66 -0
  39. data/spec/models/bud_category_spec.rb +42 -0
  40. data/spec/models/bud_primary_category_spec.rb +30 -0
  41. data/spec/models/bud_subcategory_spec.rb +30 -0
  42. data/spec/models/custom_sandbox_account_spec.rb +54 -0
  43. data/spec/models/custom_sandbox_data_spec.rb +42 -0
  44. data/spec/models/get_links_link_spec.rb +42 -0
  45. data/spec/models/get_links_response_spec.rb +42 -0
  46. data/spec/models/import_transactions_request_spec.rb +36 -0
  47. data/spec/models/product_state_changed_webhook_spec.rb +108 -0
  48. data/spec/models/response401_correct_enrichment_links_id_transactions_txn_id_enrichment_post_spec.rb +21 -0
  49. data/spec/models/response401_create_link_session_link_session_post_spec.rb +21 -0
  50. data/spec/models/response401_get_links_links_get_spec.rb +21 -0
  51. data/spec/models/response401_import_transactions_links_id_import_transactions_post_spec.rb +21 -0
  52. data/spec/models/response401_reset_link_links_id_reset_post_spec.rb +21 -0
  53. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-12.0.0/gem_make.out +5 -5
  54. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/json-2.11.3/gem_make.out +5 -5
  55. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/prism-1.4.0/gem_make.out +5 -5
  56. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
  57. metadata +66 -2
@@ -0,0 +1,321 @@
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 ApiPublicTransactionsGetTransactionsResponse
18
+ # A list of transactions.
19
+ attr_accessor :transactions
20
+
21
+ # A list of accounts for which transactions are being returned.
22
+ attr_accessor :accounts
23
+
24
+ # The link that these accounts belong to.
25
+ attr_accessor :link
26
+
27
+ # Pagination information
28
+ attr_accessor :cursor
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'transactions' => :'transactions',
34
+ :'accounts' => :'accounts',
35
+ :'link' => :'link',
36
+ :'cursor' => :'cursor'
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
+ :'transactions' => :'Array<TransactionResponse>',
54
+ :'accounts' => :'Array<AccountResponse>',
55
+ :'link' => :'LinkCommon',
56
+ :'cursor' => :'CursorPagination'
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::ApiPublicTransactionsGetTransactionsResponse` 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::ApiPublicTransactionsGetTransactionsResponse`. 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?(:'transactions')
83
+ if (value = attributes[:'transactions']).is_a?(Array)
84
+ self.transactions = value
85
+ end
86
+ else
87
+ self.transactions = nil
88
+ end
89
+
90
+ if attributes.key?(:'accounts')
91
+ if (value = attributes[:'accounts']).is_a?(Array)
92
+ self.accounts = value
93
+ end
94
+ else
95
+ self.accounts = nil
96
+ end
97
+
98
+ if attributes.key?(:'link')
99
+ self.link = attributes[:'link']
100
+ else
101
+ self.link = nil
102
+ end
103
+
104
+ if attributes.key?(:'cursor')
105
+ self.cursor = attributes[:'cursor']
106
+ else
107
+ self.cursor = nil
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
115
+ invalid_properties = Array.new
116
+ if @transactions.nil?
117
+ invalid_properties.push('invalid value for "transactions", transactions cannot be nil.')
118
+ end
119
+
120
+ if @accounts.nil?
121
+ invalid_properties.push('invalid value for "accounts", accounts cannot be nil.')
122
+ end
123
+
124
+ if @link.nil?
125
+ invalid_properties.push('invalid value for "link", link cannot be nil.')
126
+ end
127
+
128
+ if @cursor.nil?
129
+ invalid_properties.push('invalid value for "cursor", cursor cannot be nil.')
130
+ end
131
+
132
+ invalid_properties
133
+ end
134
+
135
+ # Check to see if the all the properties in the model are valid
136
+ # @return true if the model is valid
137
+ def valid?
138
+ warn '[DEPRECATED] the `valid?` method is obsolete'
139
+ return false if @transactions.nil?
140
+ return false if @accounts.nil?
141
+ return false if @link.nil?
142
+ return false if @cursor.nil?
143
+ true
144
+ end
145
+
146
+ # Custom attribute writer method with validation
147
+ # @param [Object] transactions Value to be assigned
148
+ def transactions=(transactions)
149
+ if transactions.nil?
150
+ fail ArgumentError, 'transactions cannot be nil'
151
+ end
152
+
153
+ @transactions = transactions
154
+ end
155
+
156
+ # Custom attribute writer method with validation
157
+ # @param [Object] accounts Value to be assigned
158
+ def accounts=(accounts)
159
+ if accounts.nil?
160
+ fail ArgumentError, 'accounts cannot be nil'
161
+ end
162
+
163
+ @accounts = accounts
164
+ end
165
+
166
+ # Custom attribute writer method with validation
167
+ # @param [Object] link Value to be assigned
168
+ def link=(link)
169
+ if link.nil?
170
+ fail ArgumentError, 'link cannot be nil'
171
+ end
172
+
173
+ @link = link
174
+ end
175
+
176
+ # Custom attribute writer method with validation
177
+ # @param [Object] cursor Value to be assigned
178
+ def cursor=(cursor)
179
+ if cursor.nil?
180
+ fail ArgumentError, 'cursor cannot be nil'
181
+ end
182
+
183
+ @cursor = cursor
184
+ end
185
+
186
+ # Checks equality by comparing each attribute.
187
+ # @param [Object] Object to be compared
188
+ def ==(o)
189
+ return true if self.equal?(o)
190
+ self.class == o.class &&
191
+ transactions == o.transactions &&
192
+ accounts == o.accounts &&
193
+ link == o.link &&
194
+ cursor == o.cursor
195
+ end
196
+
197
+ # @see the `==` method
198
+ # @param [Object] Object to be compared
199
+ def eql?(o)
200
+ self == o
201
+ end
202
+
203
+ # Calculates hash code according to all attributes.
204
+ # @return [Integer] Hash code
205
+ def hash
206
+ [transactions, accounts, link, cursor].hash
207
+ end
208
+
209
+ # Builds the object from hash
210
+ # @param [Hash] attributes Model attributes in the form of hash
211
+ # @return [Object] Returns the model itself
212
+ def self.build_from_hash(attributes)
213
+ return nil unless attributes.is_a?(Hash)
214
+ attributes = attributes.transform_keys(&:to_sym)
215
+ transformed_hash = {}
216
+ openapi_types.each_pair do |key, type|
217
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
218
+ transformed_hash["#{key}"] = nil
219
+ elsif type =~ /\AArray<(.*)>/i
220
+ # check to ensure the input is an array given that the attribute
221
+ # is documented as an array but the input is not
222
+ if attributes[attribute_map[key]].is_a?(Array)
223
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
224
+ end
225
+ elsif !attributes[attribute_map[key]].nil?
226
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
227
+ end
228
+ end
229
+ new(transformed_hash)
230
+ end
231
+
232
+ # Deserializes the data based on type
233
+ # @param string type Data type
234
+ # @param string value Value to be deserialized
235
+ # @return [Object] Deserialized data
236
+ def self._deserialize(type, value)
237
+ case type.to_sym
238
+ when :Time
239
+ Time.parse(value)
240
+ when :Date
241
+ ::Date.parse(value)
242
+ when :String
243
+ value.to_s
244
+ when :Integer
245
+ value.to_i
246
+ when :Float
247
+ value.to_f
248
+ when :Boolean
249
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
250
+ true
251
+ else
252
+ false
253
+ end
254
+ when :Object
255
+ # generic object (usually a Hash), return directly
256
+ value
257
+ when /\AArray<(?<inner_type>.+)>\z/
258
+ inner_type = Regexp.last_match[:inner_type]
259
+ value.map { |v| _deserialize(inner_type, v) }
260
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
261
+ k_type = Regexp.last_match[:k_type]
262
+ v_type = Regexp.last_match[:v_type]
263
+ {}.tap do |hash|
264
+ value.each do |k, v|
265
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
266
+ end
267
+ end
268
+ else # model
269
+ # models (e.g. Pet) or oneOf
270
+ klass = MoneyKit.const_get(type)
271
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
272
+ end
273
+ end
274
+
275
+ # Returns the string representation of the object
276
+ # @return [String] String presentation of the object
277
+ def to_s
278
+ to_hash.to_s
279
+ end
280
+
281
+ # to_body is an alias to to_hash (backward compatibility)
282
+ # @return [Hash] Returns the object in the form of hash
283
+ def to_body
284
+ to_hash
285
+ end
286
+
287
+ # Returns the object in the form of hash
288
+ # @return [Hash] Returns the object in the form of hash
289
+ def to_hash
290
+ hash = {}
291
+ self.class.attribute_map.each_pair do |attr, param|
292
+ value = self.send(attr)
293
+ if value.nil?
294
+ is_nullable = self.class.openapi_nullable.include?(attr)
295
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
296
+ end
297
+
298
+ hash[param] = _to_hash(value)
299
+ end
300
+ hash
301
+ end
302
+
303
+ # Outputs non-array value in the form of hash
304
+ # For object, use to_hash. Otherwise, just return the value
305
+ # @param [Object] value Any valid value
306
+ # @return [Hash] Returns the value in the form of hash
307
+ def _to_hash(value)
308
+ if value.is_a?(Array)
309
+ value.compact.map { |v| _to_hash(v) }
310
+ elsif value.is_a?(Hash)
311
+ {}.tap do |hash|
312
+ value.each { |k, v| hash[k] = _to_hash(v) }
313
+ end
314
+ elsif value.respond_to? :to_hash
315
+ value.to_hash
316
+ else
317
+ value
318
+ end
319
+ end
320
+ end
321
+ end
@@ -0,0 +1,375 @@
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 ApiPublicTransactionsLegacyGetTransactionsResponse
18
+ # The total number of results for this query.
19
+ attr_accessor :total
20
+
21
+ # The page number corresponding to this batch of results.
22
+ attr_accessor :page
23
+
24
+ # The number of results in this batch.
25
+ attr_accessor :size
26
+
27
+ # A list of transactions.
28
+ attr_accessor :transactions
29
+
30
+ # A list of accounts for which transactions are being returned.
31
+ attr_accessor :accounts
32
+
33
+ # The link that these accounts belong to.
34
+ attr_accessor :link
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'total' => :'total',
40
+ :'page' => :'page',
41
+ :'size' => :'size',
42
+ :'transactions' => :'transactions',
43
+ :'accounts' => :'accounts',
44
+ :'link' => :'link'
45
+ }
46
+ end
47
+
48
+ # Returns attribute mapping this model knows about
49
+ def self.acceptable_attribute_map
50
+ attribute_map
51
+ end
52
+
53
+ # Returns all the JSON keys this model knows about
54
+ def self.acceptable_attributes
55
+ acceptable_attribute_map.values
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'total' => :'Integer',
62
+ :'page' => :'Integer',
63
+ :'size' => :'Integer',
64
+ :'transactions' => :'Array<TransactionResponse>',
65
+ :'accounts' => :'Array<AccountResponse>',
66
+ :'link' => :'LinkCommon'
67
+ }
68
+ end
69
+
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MoneyKit::ApiPublicTransactionsLegacyGetTransactionsResponse` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ acceptable_attribute_map = self.class.acceptable_attribute_map
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!acceptable_attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MoneyKit::ApiPublicTransactionsLegacyGetTransactionsResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'total')
93
+ self.total = attributes[:'total']
94
+ else
95
+ self.total = nil
96
+ end
97
+
98
+ if attributes.key?(:'page')
99
+ self.page = attributes[:'page']
100
+ else
101
+ self.page = nil
102
+ end
103
+
104
+ if attributes.key?(:'size')
105
+ self.size = attributes[:'size']
106
+ else
107
+ self.size = nil
108
+ end
109
+
110
+ if attributes.key?(:'transactions')
111
+ if (value = attributes[:'transactions']).is_a?(Array)
112
+ self.transactions = value
113
+ end
114
+ else
115
+ self.transactions = nil
116
+ end
117
+
118
+ if attributes.key?(:'accounts')
119
+ if (value = attributes[:'accounts']).is_a?(Array)
120
+ self.accounts = value
121
+ end
122
+ else
123
+ self.accounts = nil
124
+ end
125
+
126
+ if attributes.key?(:'link')
127
+ self.link = attributes[:'link']
128
+ else
129
+ self.link = nil
130
+ end
131
+ end
132
+
133
+ # Show invalid properties with the reasons. Usually used together with valid?
134
+ # @return Array for valid properties with the reasons
135
+ def list_invalid_properties
136
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
137
+ invalid_properties = Array.new
138
+ if @total.nil?
139
+ invalid_properties.push('invalid value for "total", total cannot be nil.')
140
+ end
141
+
142
+ if @page.nil?
143
+ invalid_properties.push('invalid value for "page", page cannot be nil.')
144
+ end
145
+
146
+ if @size.nil?
147
+ invalid_properties.push('invalid value for "size", size cannot be nil.')
148
+ end
149
+
150
+ if @transactions.nil?
151
+ invalid_properties.push('invalid value for "transactions", transactions cannot be nil.')
152
+ end
153
+
154
+ if @accounts.nil?
155
+ invalid_properties.push('invalid value for "accounts", accounts cannot be nil.')
156
+ end
157
+
158
+ if @link.nil?
159
+ invalid_properties.push('invalid value for "link", link 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
+ warn '[DEPRECATED] the `valid?` method is obsolete'
169
+ return false if @total.nil?
170
+ return false if @page.nil?
171
+ return false if @size.nil?
172
+ return false if @transactions.nil?
173
+ return false if @accounts.nil?
174
+ return false if @link.nil?
175
+ true
176
+ end
177
+
178
+ # Custom attribute writer method with validation
179
+ # @param [Object] total Value to be assigned
180
+ def total=(total)
181
+ if total.nil?
182
+ fail ArgumentError, 'total cannot be nil'
183
+ end
184
+
185
+ @total = total
186
+ end
187
+
188
+ # Custom attribute writer method with validation
189
+ # @param [Object] page Value to be assigned
190
+ def page=(page)
191
+ if page.nil?
192
+ fail ArgumentError, 'page cannot be nil'
193
+ end
194
+
195
+ @page = page
196
+ end
197
+
198
+ # Custom attribute writer method with validation
199
+ # @param [Object] size Value to be assigned
200
+ def size=(size)
201
+ if size.nil?
202
+ fail ArgumentError, 'size cannot be nil'
203
+ end
204
+
205
+ @size = size
206
+ end
207
+
208
+ # Custom attribute writer method with validation
209
+ # @param [Object] transactions Value to be assigned
210
+ def transactions=(transactions)
211
+ if transactions.nil?
212
+ fail ArgumentError, 'transactions cannot be nil'
213
+ end
214
+
215
+ @transactions = transactions
216
+ end
217
+
218
+ # Custom attribute writer method with validation
219
+ # @param [Object] accounts Value to be assigned
220
+ def accounts=(accounts)
221
+ if accounts.nil?
222
+ fail ArgumentError, 'accounts cannot be nil'
223
+ end
224
+
225
+ @accounts = accounts
226
+ end
227
+
228
+ # Custom attribute writer method with validation
229
+ # @param [Object] link Value to be assigned
230
+ def link=(link)
231
+ if link.nil?
232
+ fail ArgumentError, 'link cannot be nil'
233
+ end
234
+
235
+ @link = link
236
+ end
237
+
238
+ # Checks equality by comparing each attribute.
239
+ # @param [Object] Object to be compared
240
+ def ==(o)
241
+ return true if self.equal?(o)
242
+ self.class == o.class &&
243
+ total == o.total &&
244
+ page == o.page &&
245
+ size == o.size &&
246
+ transactions == o.transactions &&
247
+ accounts == o.accounts &&
248
+ link == o.link
249
+ end
250
+
251
+ # @see the `==` method
252
+ # @param [Object] Object to be compared
253
+ def eql?(o)
254
+ self == o
255
+ end
256
+
257
+ # Calculates hash code according to all attributes.
258
+ # @return [Integer] Hash code
259
+ def hash
260
+ [total, page, size, transactions, accounts, link].hash
261
+ end
262
+
263
+ # Builds the object from hash
264
+ # @param [Hash] attributes Model attributes in the form of hash
265
+ # @return [Object] Returns the model itself
266
+ def self.build_from_hash(attributes)
267
+ return nil unless attributes.is_a?(Hash)
268
+ attributes = attributes.transform_keys(&:to_sym)
269
+ transformed_hash = {}
270
+ openapi_types.each_pair do |key, type|
271
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
272
+ transformed_hash["#{key}"] = nil
273
+ elsif type =~ /\AArray<(.*)>/i
274
+ # check to ensure the input is an array given that the attribute
275
+ # is documented as an array but the input is not
276
+ if attributes[attribute_map[key]].is_a?(Array)
277
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
278
+ end
279
+ elsif !attributes[attribute_map[key]].nil?
280
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
281
+ end
282
+ end
283
+ new(transformed_hash)
284
+ end
285
+
286
+ # Deserializes the data based on type
287
+ # @param string type Data type
288
+ # @param string value Value to be deserialized
289
+ # @return [Object] Deserialized data
290
+ def self._deserialize(type, value)
291
+ case type.to_sym
292
+ when :Time
293
+ Time.parse(value)
294
+ when :Date
295
+ ::Date.parse(value)
296
+ when :String
297
+ value.to_s
298
+ when :Integer
299
+ value.to_i
300
+ when :Float
301
+ value.to_f
302
+ when :Boolean
303
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
304
+ true
305
+ else
306
+ false
307
+ end
308
+ when :Object
309
+ # generic object (usually a Hash), return directly
310
+ value
311
+ when /\AArray<(?<inner_type>.+)>\z/
312
+ inner_type = Regexp.last_match[:inner_type]
313
+ value.map { |v| _deserialize(inner_type, v) }
314
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
315
+ k_type = Regexp.last_match[:k_type]
316
+ v_type = Regexp.last_match[:v_type]
317
+ {}.tap do |hash|
318
+ value.each do |k, v|
319
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
320
+ end
321
+ end
322
+ else # model
323
+ # models (e.g. Pet) or oneOf
324
+ klass = MoneyKit.const_get(type)
325
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
326
+ end
327
+ end
328
+
329
+ # Returns the string representation of the object
330
+ # @return [String] String presentation of the object
331
+ def to_s
332
+ to_hash.to_s
333
+ end
334
+
335
+ # to_body is an alias to to_hash (backward compatibility)
336
+ # @return [Hash] Returns the object in the form of hash
337
+ def to_body
338
+ to_hash
339
+ end
340
+
341
+ # Returns the object in the form of hash
342
+ # @return [Hash] Returns the object in the form of hash
343
+ def to_hash
344
+ hash = {}
345
+ self.class.attribute_map.each_pair do |attr, param|
346
+ value = self.send(attr)
347
+ if value.nil?
348
+ is_nullable = self.class.openapi_nullable.include?(attr)
349
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
350
+ end
351
+
352
+ hash[param] = _to_hash(value)
353
+ end
354
+ hash
355
+ end
356
+
357
+ # Outputs non-array value in the form of hash
358
+ # For object, use to_hash. Otherwise, just return the value
359
+ # @param [Object] value Any valid value
360
+ # @return [Hash] Returns the value in the form of hash
361
+ def _to_hash(value)
362
+ if value.is_a?(Array)
363
+ value.compact.map { |v| _to_hash(v) }
364
+ elsif value.is_a?(Hash)
365
+ {}.tap do |hash|
366
+ value.each { |k, v| hash[k] = _to_hash(v) }
367
+ end
368
+ elsif value.respond_to? :to_hash
369
+ value.to_hash
370
+ else
371
+ value
372
+ end
373
+ end
374
+ end
375
+ end