moneykit 0.1.10 → 0.1.12

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 (148) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +1 -1
  4. data/docs/AccessTokenApi.md +26 -21
  5. data/docs/AccountBalances.md +2 -2
  6. data/docs/AccountGroup.md +1 -1
  7. data/docs/AccountIdentity.md +2 -0
  8. data/docs/AccountImportData.md +26 -0
  9. data/docs/AccountResponse.md +28 -0
  10. data/docs/AccountWithAccountNumbersLegacy20230218.md +2 -0
  11. data/docs/Address.md +1 -1
  12. data/docs/AppClientResponse.md +2 -2
  13. data/docs/AppLinkStateChangedWebhook.md +36 -0
  14. data/docs/AppResponse.md +2 -2
  15. data/docs/Body.md +3 -3
  16. data/docs/CreateAccessTokenResponse.md +22 -0
  17. data/docs/CreateLinkSessionRequest.md +1 -1
  18. data/docs/CustomerUser.md +22 -0
  19. data/docs/CustomerUserEmail.md +20 -0
  20. data/docs/CustomerUserPhone.md +22 -0
  21. data/docs/Date.md +15 -0
  22. data/docs/Email.md +1 -1
  23. data/docs/GetAccountResponse.md +1 -1
  24. data/docs/GetAccountsResponse.md +1 -1
  25. data/docs/GetHoldingsResponse.md +1 -1
  26. data/docs/GetInvestmentTransactionsResponse.md +1 -1
  27. data/docs/GetTransactionsResponse.md +2 -2
  28. data/docs/GetUserTransactionsResponse.md +1 -1
  29. data/docs/ImportLinkRequest.md +26 -0
  30. data/docs/Institution.md +1 -1
  31. data/docs/LinkCommon.md +3 -3
  32. data/docs/LinkProductError.md +15 -0
  33. data/docs/LinkProductRefreshWebhook.md +2 -2
  34. data/docs/LinkProductResponse.md +28 -0
  35. data/docs/LinkProducts.md +7 -5
  36. data/docs/LinkResponse.md +3 -3
  37. data/docs/LinkSessionApi.md +1 -1
  38. data/docs/LinksApi.md +79 -9
  39. data/docs/PhoneNumber.md +1 -1
  40. data/docs/PublicLinkState.md +15 -0
  41. data/docs/Response401DeleteLinkLinksIdDelete.md +22 -0
  42. data/docs/Response401GetTransactionsSyncLinksIdTransactionsSyncGet.md +22 -0
  43. data/docs/Response401ImportLinkLinksImportPost.md +22 -0
  44. data/docs/ResponseHandleLinkWebhookEventRequestBodyWebhookPost.md +3 -3
  45. data/docs/TransactionCategoryResponse.md +20 -0
  46. data/docs/TransactionEnrichmentResponse.md +26 -0
  47. data/docs/TransactionImportData.md +28 -0
  48. data/docs/TransactionMerchantResponse.md +24 -0
  49. data/docs/TransactionProcessorResponse.md +24 -0
  50. data/docs/TransactionRecurrenceResponse.md +20 -0
  51. data/docs/TransactionResponse.md +42 -0
  52. data/docs/TransactionSubcategoryResponse.md +20 -0
  53. data/docs/TransactionSync.md +22 -0
  54. data/docs/TransactionSyncResponse.md +1 -1
  55. data/docs/TransactionUpdatesAvailableWebhook.md +4 -2
  56. data/docs/TransactionsApi.md +15 -15
  57. data/docs/TransactionsLinkProduct.md +1 -1
  58. data/lib/moneykit/api/access_token_api.rb +19 -16
  59. data/lib/moneykit/api/links_api.rb +75 -7
  60. data/lib/moneykit/api/transactions_api.rb +17 -17
  61. data/lib/moneykit/api_client.rb +1 -1
  62. data/lib/moneykit/models/account_balances.rb +2 -30
  63. data/lib/moneykit/models/account_group.rb +1 -1
  64. data/lib/moneykit/models/account_identity.rb +11 -1
  65. data/lib/moneykit/models/account_import_data.rb +280 -0
  66. data/lib/moneykit/models/account_response.rb +290 -0
  67. data/lib/moneykit/models/account_with_account_numbers_legacy20230218.rb +11 -1
  68. data/lib/moneykit/models/address.rb +0 -2
  69. data/lib/moneykit/models/app_client_response.rb +1 -1
  70. data/lib/moneykit/models/app_link_state_changed_webhook.rb +394 -0
  71. data/lib/moneykit/models/body.rb +1 -1
  72. data/lib/moneykit/models/create_access_token_response.rb +255 -0
  73. data/lib/moneykit/models/create_link_session_request.rb +1 -1
  74. data/lib/moneykit/models/customer_user.rb +266 -0
  75. data/lib/moneykit/models/customer_user_email.rb +258 -0
  76. data/lib/moneykit/models/customer_user_phone.rb +289 -0
  77. data/lib/moneykit/models/date.rb +104 -0
  78. data/lib/moneykit/models/email.rb +0 -2
  79. data/lib/moneykit/models/get_account_response.rb +1 -1
  80. data/lib/moneykit/models/get_accounts_response.rb +1 -1
  81. data/lib/moneykit/models/get_holdings_response.rb +1 -1
  82. data/lib/moneykit/models/get_investment_transactions_response.rb +1 -1
  83. data/lib/moneykit/models/get_transactions_response.rb +2 -2
  84. data/lib/moneykit/models/get_user_transactions_response.rb +1 -1
  85. data/lib/moneykit/models/import_link_request.rb +303 -0
  86. data/lib/moneykit/models/institution.rb +0 -7
  87. data/lib/moneykit/models/link_common.rb +3 -3
  88. data/lib/moneykit/models/link_product_error.rb +46 -0
  89. data/lib/moneykit/models/link_product_refresh_webhook.rb +24 -24
  90. data/lib/moneykit/models/link_product_response.rb +283 -0
  91. data/lib/moneykit/models/link_product_state.rb +3 -1
  92. data/lib/moneykit/models/link_products.rb +16 -7
  93. data/lib/moneykit/models/link_response.rb +3 -3
  94. data/lib/moneykit/models/phone_number.rb +0 -2
  95. data/lib/moneykit/models/product.rb +2 -1
  96. data/lib/moneykit/models/provider.rb +1 -2
  97. data/lib/moneykit/models/public_link_error.rb +1 -1
  98. data/lib/moneykit/models/public_link_state.rb +43 -0
  99. data/lib/moneykit/models/response401_delete_link_links_id_delete.rb +104 -0
  100. data/lib/moneykit/models/response401_get_transactions_sync_links_id_transactions_sync_get.rb +104 -0
  101. data/lib/moneykit/models/response401_import_link_links_import_post.rb +103 -0
  102. data/lib/moneykit/models/response_handle_link_webhook_event_request_body_webhook_post.rb +1 -1
  103. data/lib/moneykit/models/transaction_category_response.rb +230 -0
  104. data/lib/moneykit/models/transaction_enrichment_response.rb +255 -0
  105. data/lib/moneykit/models/transaction_import_data.rb +283 -0
  106. data/lib/moneykit/models/transaction_merchant_response.rb +243 -0
  107. data/lib/moneykit/models/transaction_processor_response.rb +243 -0
  108. data/lib/moneykit/models/transaction_recurrence_response.rb +223 -0
  109. data/lib/moneykit/models/transaction_response.rb +402 -0
  110. data/lib/moneykit/models/transaction_subcategory_response.rb +230 -0
  111. data/lib/moneykit/models/transaction_sync.rb +257 -0
  112. data/lib/moneykit/models/transaction_sync_response.rb +1 -1
  113. data/lib/moneykit/models/transaction_updates_available_webhook.rb +42 -24
  114. data/lib/moneykit/models/transactions_link_product.rb +1 -1
  115. data/lib/moneykit/version.rb +1 -1
  116. data/lib/moneykit.rb +25 -16
  117. data/spec/models/account_import_data_spec.rb +60 -0
  118. data/spec/models/account_response_spec.rb +66 -0
  119. data/spec/models/app_link_state_changed_webhook_spec.rb +102 -0
  120. data/spec/models/create_access_token_response_spec.rb +48 -0
  121. data/spec/models/customer_user_email_spec.rb +42 -0
  122. data/spec/models/customer_user_phone_spec.rb +48 -0
  123. data/spec/models/customer_user_spec.rb +48 -0
  124. data/spec/models/date_spec.rb +21 -0
  125. data/spec/models/import_link_request_spec.rb +60 -0
  126. data/spec/models/link_product_error_spec.rb +30 -0
  127. data/spec/models/link_product_response_spec.rb +66 -0
  128. data/spec/models/public_link_error_spec.rb +30 -0
  129. data/spec/models/public_link_state_spec.rb +30 -0
  130. data/spec/models/response401_delete_link_links_id_delete_spec.rb +21 -0
  131. data/spec/models/response401_get_transactions_sync_links_id_transactions_sync_get_spec.rb +21 -0
  132. data/spec/models/response401_import_link_links_import_post_spec.rb +21 -0
  133. data/spec/models/transaction_category_response_spec.rb +42 -0
  134. data/spec/models/transaction_enrichment_response_spec.rb +60 -0
  135. data/spec/models/transaction_import_data_spec.rb +66 -0
  136. data/spec/models/transaction_merchant_response_spec.rb +54 -0
  137. data/spec/models/transaction_processor_response_spec.rb +54 -0
  138. data/spec/models/transaction_recurrence_response_spec.rb +42 -0
  139. data/spec/models/transaction_response_spec.rb +108 -0
  140. data/spec/models/transaction_subcategory_response_spec.rb +42 -0
  141. data/spec/models/transaction_sync_spec.rb +48 -0
  142. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-11.1.3/gem_make.out +5 -5
  143. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  144. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.1.1.1/gem_make.out +5 -5
  145. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.1.1.1/mkmf.log +2 -2
  146. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.7.3/gem_make.out +5 -5
  147. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.1.0/gem_make.out +5 -5
  148. metadata +220 -122
@@ -0,0 +1,402 @@
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
+ OpenAPI Generator version: 7.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MoneyKit
17
+ class TransactionResponse
18
+ # The unique ID for this transaction.
19
+ attr_accessor :transaction_id
20
+
21
+ # The ID of the account in which this transaction occurred.
22
+ attr_accessor :account_id
23
+
24
+ # The amount of this transaction, denominated in account currency. This amount is always non-negative. The `type` field indicates whether it is entering or leaving the account.
25
+ attr_accessor :amount
26
+
27
+ attr_accessor :type
28
+
29
+ # The ISO-4217 currency code of the transaction.
30
+ attr_accessor :currency
31
+
32
+ # The effective (posted) date of the transaction, in ISO-8601 format. For pending transactions, this date is when the transaction was initiated.
33
+ attr_accessor :date
34
+
35
+ # If the institution has provided the actual time of the transaction, this field contains the full date and time of the transaction, in ISO-8601 format. If the time is not available, this field will be null. <p>Note that the time is generally reported in the timezone of the institution or the account holder.
36
+ attr_accessor :datetime
37
+
38
+ # A normalized, cleaned transaction description suitable for presentation to the end user. Commonly this will be the merchant or counterparty name.
39
+ attr_accessor :description
40
+
41
+ # The raw transaction description as provided by the institution, where available.
42
+ attr_accessor :raw_description
43
+
44
+ # If true, this transaction is pending or unsettled and has not yet affected the account. Commonly these are credit card transactions, particularly approvals (holds) such as for hotel or restaurant reservations placed in advance where the final amount is still to be determined.
45
+ attr_accessor :pending
46
+
47
+ # (deprecated) Refer to enrichment.category.
48
+ attr_accessor :category
49
+
50
+ attr_accessor :enrichment
51
+
52
+ # The original ID of this transaction, if supplied (by you) during an import.
53
+ attr_accessor :original_id
54
+
55
+ class EnumAttributeValidator
56
+ attr_reader :datatype
57
+ attr_reader :allowable_values
58
+
59
+ def initialize(datatype, allowable_values)
60
+ @allowable_values = allowable_values.map do |value|
61
+ case datatype.to_s
62
+ when /Integer/i
63
+ value.to_i
64
+ when /Float/i
65
+ value.to_f
66
+ else
67
+ value
68
+ end
69
+ end
70
+ end
71
+
72
+ def valid?(value)
73
+ !value || allowable_values.include?(value)
74
+ end
75
+ end
76
+
77
+ # Attribute mapping from ruby-style variable name to JSON key.
78
+ def self.attribute_map
79
+ {
80
+ :'transaction_id' => :'transaction_id',
81
+ :'account_id' => :'account_id',
82
+ :'amount' => :'amount',
83
+ :'type' => :'type',
84
+ :'currency' => :'currency',
85
+ :'date' => :'date',
86
+ :'datetime' => :'datetime',
87
+ :'description' => :'description',
88
+ :'raw_description' => :'raw_description',
89
+ :'pending' => :'pending',
90
+ :'category' => :'category',
91
+ :'enrichment' => :'enrichment',
92
+ :'original_id' => :'original_id'
93
+ }
94
+ end
95
+
96
+ # Returns all the JSON keys this model knows about
97
+ def self.acceptable_attributes
98
+ attribute_map.values
99
+ end
100
+
101
+ # Attribute type mapping.
102
+ def self.openapi_types
103
+ {
104
+ :'transaction_id' => :'String',
105
+ :'account_id' => :'String',
106
+ :'amount' => :'String',
107
+ :'type' => :'TransactionType',
108
+ :'currency' => :'String',
109
+ :'date' => :'Date',
110
+ :'datetime' => :'Time',
111
+ :'description' => :'String',
112
+ :'raw_description' => :'String',
113
+ :'pending' => :'Boolean',
114
+ :'category' => :'String',
115
+ :'enrichment' => :'TransactionEnrichmentResponse',
116
+ :'original_id' => :'String'
117
+ }
118
+ end
119
+
120
+ # List of attributes with nullable: true
121
+ def self.openapi_nullable
122
+ Set.new([
123
+ ])
124
+ end
125
+
126
+ # Initializes the object
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ def initialize(attributes = {})
129
+ if (!attributes.is_a?(Hash))
130
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MoneyKit::TransactionResponse` initialize method"
131
+ end
132
+
133
+ # check to see if the attribute exists and convert string to symbol for hash key
134
+ attributes = attributes.each_with_object({}) { |(k, v), h|
135
+ if (!self.class.attribute_map.key?(k.to_sym))
136
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MoneyKit::TransactionResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
137
+ end
138
+ h[k.to_sym] = v
139
+ }
140
+
141
+ if attributes.key?(:'transaction_id')
142
+ self.transaction_id = attributes[:'transaction_id']
143
+ else
144
+ self.transaction_id = nil
145
+ end
146
+
147
+ if attributes.key?(:'account_id')
148
+ self.account_id = attributes[:'account_id']
149
+ else
150
+ self.account_id = nil
151
+ end
152
+
153
+ if attributes.key?(:'amount')
154
+ self.amount = attributes[:'amount']
155
+ else
156
+ self.amount = nil
157
+ end
158
+
159
+ if attributes.key?(:'type')
160
+ self.type = attributes[:'type']
161
+ else
162
+ self.type = nil
163
+ end
164
+
165
+ if attributes.key?(:'currency')
166
+ self.currency = attributes[:'currency']
167
+ else
168
+ self.currency = nil
169
+ end
170
+
171
+ if attributes.key?(:'date')
172
+ self.date = attributes[:'date']
173
+ else
174
+ self.date = nil
175
+ end
176
+
177
+ if attributes.key?(:'datetime')
178
+ self.datetime = attributes[:'datetime']
179
+ end
180
+
181
+ if attributes.key?(:'description')
182
+ self.description = attributes[:'description']
183
+ end
184
+
185
+ if attributes.key?(:'raw_description')
186
+ self.raw_description = attributes[:'raw_description']
187
+ end
188
+
189
+ if attributes.key?(:'pending')
190
+ self.pending = attributes[:'pending']
191
+ else
192
+ self.pending = nil
193
+ end
194
+
195
+ if attributes.key?(:'category')
196
+ self.category = attributes[:'category']
197
+ end
198
+
199
+ if attributes.key?(:'enrichment')
200
+ self.enrichment = attributes[:'enrichment']
201
+ end
202
+
203
+ if attributes.key?(:'original_id')
204
+ self.original_id = attributes[:'original_id']
205
+ end
206
+ end
207
+
208
+ # Show invalid properties with the reasons. Usually used together with valid?
209
+ # @return Array for valid properties with the reasons
210
+ def list_invalid_properties
211
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
212
+ invalid_properties = Array.new
213
+ if @transaction_id.nil?
214
+ invalid_properties.push('invalid value for "transaction_id", transaction_id cannot be nil.')
215
+ end
216
+
217
+ if @account_id.nil?
218
+ invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
219
+ end
220
+
221
+ if @amount.nil?
222
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
223
+ end
224
+
225
+ if @type.nil?
226
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
227
+ end
228
+
229
+ if @currency.nil?
230
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
231
+ end
232
+
233
+ if @date.nil?
234
+ invalid_properties.push('invalid value for "date", date cannot be nil.')
235
+ end
236
+
237
+ if @pending.nil?
238
+ invalid_properties.push('invalid value for "pending", pending cannot be nil.')
239
+ end
240
+
241
+ invalid_properties
242
+ end
243
+
244
+ # Check to see if the all the properties in the model are valid
245
+ # @return true if the model is valid
246
+ def valid?
247
+ warn '[DEPRECATED] the `valid?` method is obsolete'
248
+ return false if @transaction_id.nil?
249
+ return false if @account_id.nil?
250
+ return false if @amount.nil?
251
+ return false if @type.nil?
252
+ return false if @currency.nil?
253
+ return false if @date.nil?
254
+ return false if @pending.nil?
255
+ true
256
+ end
257
+
258
+ # Checks equality by comparing each attribute.
259
+ # @param [Object] Object to be compared
260
+ def ==(o)
261
+ return true if self.equal?(o)
262
+ self.class == o.class &&
263
+ transaction_id == o.transaction_id &&
264
+ account_id == o.account_id &&
265
+ amount == o.amount &&
266
+ type == o.type &&
267
+ currency == o.currency &&
268
+ date == o.date &&
269
+ datetime == o.datetime &&
270
+ description == o.description &&
271
+ raw_description == o.raw_description &&
272
+ pending == o.pending &&
273
+ category == o.category &&
274
+ enrichment == o.enrichment &&
275
+ original_id == o.original_id
276
+ end
277
+
278
+ # @see the `==` method
279
+ # @param [Object] Object to be compared
280
+ def eql?(o)
281
+ self == o
282
+ end
283
+
284
+ # Calculates hash code according to all attributes.
285
+ # @return [Integer] Hash code
286
+ def hash
287
+ [transaction_id, account_id, amount, type, currency, date, datetime, description, raw_description, pending, category, enrichment, original_id].hash
288
+ end
289
+
290
+ # Builds the object from hash
291
+ # @param [Hash] attributes Model attributes in the form of hash
292
+ # @return [Object] Returns the model itself
293
+ def self.build_from_hash(attributes)
294
+ return nil unless attributes.is_a?(Hash)
295
+ attributes = attributes.transform_keys(&:to_sym)
296
+ transformed_hash = {}
297
+ openapi_types.each_pair do |key, type|
298
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
299
+ transformed_hash["#{key}"] = nil
300
+ elsif type =~ /\AArray<(.*)>/i
301
+ # check to ensure the input is an array given that the attribute
302
+ # is documented as an array but the input is not
303
+ if attributes[attribute_map[key]].is_a?(Array)
304
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
305
+ end
306
+ elsif !attributes[attribute_map[key]].nil?
307
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
308
+ end
309
+ end
310
+ new(transformed_hash)
311
+ end
312
+
313
+ # Deserializes the data based on type
314
+ # @param string type Data type
315
+ # @param string value Value to be deserialized
316
+ # @return [Object] Deserialized data
317
+ def self._deserialize(type, value)
318
+ case type.to_sym
319
+ when :Time
320
+ Time.parse(value)
321
+ when :Date
322
+ Date.parse(value)
323
+ when :String
324
+ value.to_s
325
+ when :Integer
326
+ value.to_i
327
+ when :Float
328
+ value.to_f
329
+ when :Boolean
330
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
331
+ true
332
+ else
333
+ false
334
+ end
335
+ when :Object
336
+ # generic object (usually a Hash), return directly
337
+ value
338
+ when /\AArray<(?<inner_type>.+)>\z/
339
+ inner_type = Regexp.last_match[:inner_type]
340
+ value.map { |v| _deserialize(inner_type, v) }
341
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
342
+ k_type = Regexp.last_match[:k_type]
343
+ v_type = Regexp.last_match[:v_type]
344
+ {}.tap do |hash|
345
+ value.each do |k, v|
346
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
347
+ end
348
+ end
349
+ else # model
350
+ # models (e.g. Pet) or oneOf
351
+ klass = MoneyKit.const_get(type)
352
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
353
+ end
354
+ end
355
+
356
+ # Returns the string representation of the object
357
+ # @return [String] String presentation of the object
358
+ def to_s
359
+ to_hash.to_s
360
+ end
361
+
362
+ # to_body is an alias to to_hash (backward compatibility)
363
+ # @return [Hash] Returns the object in the form of hash
364
+ def to_body
365
+ to_hash
366
+ end
367
+
368
+ # Returns the object in the form of hash
369
+ # @return [Hash] Returns the object in the form of hash
370
+ def to_hash
371
+ hash = {}
372
+ self.class.attribute_map.each_pair do |attr, param|
373
+ value = self.send(attr)
374
+ if value.nil?
375
+ is_nullable = self.class.openapi_nullable.include?(attr)
376
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
377
+ end
378
+
379
+ hash[param] = _to_hash(value)
380
+ end
381
+ hash
382
+ end
383
+
384
+ # Outputs non-array value in the form of hash
385
+ # For object, use to_hash. Otherwise, just return the value
386
+ # @param [Object] value Any valid value
387
+ # @return [Hash] Returns the value in the form of hash
388
+ def _to_hash(value)
389
+ if value.is_a?(Array)
390
+ value.compact.map { |v| _to_hash(v) }
391
+ elsif value.is_a?(Hash)
392
+ {}.tap do |hash|
393
+ value.each { |k, v| hash[k] = _to_hash(v) }
394
+ end
395
+ elsif value.respond_to? :to_hash
396
+ value.to_hash
397
+ else
398
+ value
399
+ end
400
+ end
401
+ end
402
+ end
@@ -0,0 +1,230 @@
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
+ OpenAPI Generator version: 7.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MoneyKit
17
+ class TransactionSubcategoryResponse
18
+ # Transaction subcategory
19
+ attr_accessor :value
20
+
21
+ # Confidence score. Estimated accuracy of this data point (as a percentage).
22
+ attr_accessor :confidence
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'value' => :'value',
28
+ :'confidence' => :'confidence'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'value' => :'String',
41
+ :'confidence' => :'Integer'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MoneyKit::TransactionSubcategoryResponse` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MoneyKit::TransactionSubcategoryResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'value')
67
+ self.value = attributes[:'value']
68
+ else
69
+ self.value = nil
70
+ end
71
+
72
+ if attributes.key?(:'confidence')
73
+ self.confidence = attributes[:'confidence']
74
+ end
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
81
+ invalid_properties = Array.new
82
+ if @value.nil?
83
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
84
+ end
85
+
86
+ invalid_properties
87
+ end
88
+
89
+ # Check to see if the all the properties in the model are valid
90
+ # @return true if the model is valid
91
+ def valid?
92
+ warn '[DEPRECATED] the `valid?` method is obsolete'
93
+ return false if @value.nil?
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(o)
100
+ return true if self.equal?(o)
101
+ self.class == o.class &&
102
+ value == o.value &&
103
+ confidence == o.confidence
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(o)
109
+ self == o
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Integer] Hash code
114
+ def hash
115
+ [value, confidence].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def self.build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ attributes = attributes.transform_keys(&:to_sym)
124
+ transformed_hash = {}
125
+ openapi_types.each_pair do |key, type|
126
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
127
+ transformed_hash["#{key}"] = nil
128
+ elsif type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[attribute_map[key]].is_a?(Array)
132
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
133
+ end
134
+ elsif !attributes[attribute_map[key]].nil?
135
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
136
+ end
137
+ end
138
+ new(transformed_hash)
139
+ end
140
+
141
+ # Deserializes the data based on type
142
+ # @param string type Data type
143
+ # @param string value Value to be deserialized
144
+ # @return [Object] Deserialized data
145
+ def self._deserialize(type, value)
146
+ case type.to_sym
147
+ when :Time
148
+ Time.parse(value)
149
+ when :Date
150
+ Date.parse(value)
151
+ when :String
152
+ value.to_s
153
+ when :Integer
154
+ value.to_i
155
+ when :Float
156
+ value.to_f
157
+ when :Boolean
158
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
159
+ true
160
+ else
161
+ false
162
+ end
163
+ when :Object
164
+ # generic object (usually a Hash), return directly
165
+ value
166
+ when /\AArray<(?<inner_type>.+)>\z/
167
+ inner_type = Regexp.last_match[:inner_type]
168
+ value.map { |v| _deserialize(inner_type, v) }
169
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
170
+ k_type = Regexp.last_match[:k_type]
171
+ v_type = Regexp.last_match[:v_type]
172
+ {}.tap do |hash|
173
+ value.each do |k, v|
174
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
175
+ end
176
+ end
177
+ else # model
178
+ # models (e.g. Pet) or oneOf
179
+ klass = MoneyKit.const_get(type)
180
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ # Returns the string representation of the object
185
+ # @return [String] String presentation of the object
186
+ def to_s
187
+ to_hash.to_s
188
+ end
189
+
190
+ # to_body is an alias to to_hash (backward compatibility)
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_body
193
+ to_hash
194
+ end
195
+
196
+ # Returns the object in the form of hash
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_hash
199
+ hash = {}
200
+ self.class.attribute_map.each_pair do |attr, param|
201
+ value = self.send(attr)
202
+ if value.nil?
203
+ is_nullable = self.class.openapi_nullable.include?(attr)
204
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
205
+ end
206
+
207
+ hash[param] = _to_hash(value)
208
+ end
209
+ hash
210
+ end
211
+
212
+ # Outputs non-array value in the form of hash
213
+ # For object, use to_hash. Otherwise, just return the value
214
+ # @param [Object] value Any valid value
215
+ # @return [Hash] Returns the value in the form of hash
216
+ def _to_hash(value)
217
+ if value.is_a?(Array)
218
+ value.compact.map { |v| _to_hash(v) }
219
+ elsif value.is_a?(Hash)
220
+ {}.tap do |hash|
221
+ value.each { |k, v| hash[k] = _to_hash(v) }
222
+ end
223
+ elsif value.respond_to? :to_hash
224
+ value.to_hash
225
+ else
226
+ value
227
+ end
228
+ end
229
+ end
230
+ end