ynab 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/DEVELOPMENT.md +6 -2
  3. data/Gemfile.lock +1 -1
  4. data/README.md +3 -1
  5. data/docs/BulkTransactions.md +1 -1
  6. data/docs/CategoriesApi.md +22 -0
  7. data/docs/ExistingTransaction.md +18 -0
  8. data/docs/HybridTransaction.md +3 -2
  9. data/docs/NewTransaction.md +19 -0
  10. data/docs/PatchCategoryWrapper.md +8 -0
  11. data/docs/PatchPayeeWrapper.md +8 -0
  12. data/docs/PatchTransactionsWrapper.md +1 -1
  13. data/docs/PayeesApi.md +22 -0
  14. data/docs/PostTransactionsWrapper.md +2 -2
  15. data/docs/PutTransactionWrapper.md +1 -1
  16. data/docs/SaveCategory.md +10 -0
  17. data/docs/SavePayee.md +8 -0
  18. data/docs/SavePayeeResponse.md +8 -0
  19. data/docs/SavePayeeResponseData.md +9 -0
  20. data/docs/SaveTransactionWithIdOrImportId.md +20 -0
  21. data/docs/SaveTransactionWithOptionalFields.md +2 -3
  22. data/docs/ScheduledTransactionDetail.md +2 -1
  23. data/docs/ScheduledTransactionSummary.md +2 -1
  24. data/docs/TransactionClearedStatus.md +7 -0
  25. data/docs/TransactionDetail.md +3 -2
  26. data/docs/TransactionFlagColor.md +7 -0
  27. data/docs/TransactionSummary.md +3 -2
  28. data/docs/TransactionsApi.md +7 -7
  29. data/lib/ynab/api/accounts_api.rb +2 -2
  30. data/lib/ynab/api/budgets_api.rb +2 -2
  31. data/lib/ynab/api/categories_api.rb +82 -2
  32. data/lib/ynab/api/months_api.rb +2 -2
  33. data/lib/ynab/api/payee_locations_api.rb +2 -2
  34. data/lib/ynab/api/payees_api.rb +82 -2
  35. data/lib/ynab/api/scheduled_transactions_api.rb +2 -2
  36. data/lib/ynab/api/transactions_api.rb +12 -12
  37. data/lib/ynab/api/user_api.rb +2 -2
  38. data/lib/ynab/api_client.rb +2 -2
  39. data/lib/ynab/configuration.rb +14 -11
  40. data/lib/ynab/models/account.rb +13 -20
  41. data/lib/ynab/models/account_response.rb +13 -20
  42. data/lib/ynab/models/account_response_data.rb +13 -20
  43. data/lib/ynab/models/account_type.rb +2 -2
  44. data/lib/ynab/models/accounts_response.rb +13 -20
  45. data/lib/ynab/models/accounts_response_data.rb +13 -20
  46. data/lib/ynab/models/budget_detail.rb +13 -21
  47. data/lib/ynab/models/budget_detail_response.rb +13 -20
  48. data/lib/ynab/models/budget_detail_response_data.rb +13 -20
  49. data/lib/ynab/models/budget_settings.rb +13 -20
  50. data/lib/ynab/models/budget_settings_response.rb +13 -20
  51. data/lib/ynab/models/budget_settings_response_data.rb +13 -20
  52. data/lib/ynab/models/budget_summary.rb +13 -20
  53. data/lib/ynab/models/budget_summary_response.rb +13 -20
  54. data/lib/ynab/models/budget_summary_response_data.rb +13 -20
  55. data/lib/ynab/models/bulk_response.rb +13 -20
  56. data/lib/ynab/models/bulk_response_data.rb +13 -20
  57. data/lib/ynab/models/bulk_response_data_bulk.rb +13 -20
  58. data/lib/ynab/models/bulk_transactions.rb +14 -21
  59. data/lib/ynab/models/categories_response.rb +13 -20
  60. data/lib/ynab/models/categories_response_data.rb +13 -20
  61. data/lib/ynab/models/category.rb +13 -20
  62. data/lib/ynab/models/category_group.rb +13 -20
  63. data/lib/ynab/models/category_group_with_categories.rb +14 -22
  64. data/lib/ynab/models/category_response.rb +13 -20
  65. data/lib/ynab/models/category_response_data.rb +13 -20
  66. data/lib/ynab/models/currency_format.rb +13 -20
  67. data/lib/ynab/models/date_format.rb +13 -20
  68. data/lib/ynab/models/error_detail.rb +13 -20
  69. data/lib/ynab/models/error_response.rb +13 -20
  70. data/lib/ynab/models/existing_transaction.rb +359 -0
  71. data/lib/ynab/models/hybrid_transaction.rb +28 -43
  72. data/lib/ynab/models/hybrid_transactions_response.rb +13 -20
  73. data/lib/ynab/models/hybrid_transactions_response_data.rb +13 -20
  74. data/lib/ynab/models/month_detail.rb +13 -21
  75. data/lib/ynab/models/month_detail_response.rb +13 -20
  76. data/lib/ynab/models/month_detail_response_data.rb +13 -20
  77. data/lib/ynab/models/month_summaries_response.rb +13 -20
  78. data/lib/ynab/models/month_summaries_response_data.rb +13 -20
  79. data/lib/ynab/models/month_summary.rb +13 -20
  80. data/lib/ynab/models/new_transaction.rb +377 -0
  81. data/lib/ynab/models/patch_category_wrapper.rb +213 -0
  82. data/lib/ynab/models/patch_month_category_wrapper.rb +13 -20
  83. data/lib/ynab/models/patch_payee_wrapper.rb +213 -0
  84. data/lib/ynab/models/patch_transactions_wrapper.rb +14 -21
  85. data/lib/ynab/models/payee.rb +13 -20
  86. data/lib/ynab/models/payee_location.rb +13 -20
  87. data/lib/ynab/models/payee_location_response.rb +13 -20
  88. data/lib/ynab/models/payee_location_response_data.rb +13 -20
  89. data/lib/ynab/models/payee_locations_response.rb +13 -20
  90. data/lib/ynab/models/payee_locations_response_data.rb +13 -20
  91. data/lib/ynab/models/payee_response.rb +13 -20
  92. data/lib/ynab/models/payee_response_data.rb +13 -20
  93. data/lib/ynab/models/payees_response.rb +13 -20
  94. data/lib/ynab/models/payees_response_data.rb +13 -20
  95. data/lib/ynab/models/post_account_wrapper.rb +13 -20
  96. data/lib/ynab/models/post_transactions_wrapper.rb +15 -22
  97. data/lib/ynab/models/put_transaction_wrapper.rb +14 -21
  98. data/lib/ynab/models/save_account.rb +13 -20
  99. data/lib/ynab/models/save_category.rb +232 -0
  100. data/lib/ynab/models/save_category_response.rb +13 -20
  101. data/lib/ynab/models/save_category_response_data.rb +13 -20
  102. data/lib/ynab/models/save_month_category.rb +13 -20
  103. data/lib/ynab/models/save_payee.rb +220 -0
  104. data/lib/ynab/models/save_payee_response.rb +213 -0
  105. data/lib/ynab/models/save_payee_response_data.rb +224 -0
  106. data/lib/ynab/models/save_sub_transaction.rb +13 -20
  107. data/lib/ynab/models/save_transaction_with_id_or_import_id.rb +388 -0
  108. data/lib/ynab/models/save_transaction_with_optional_fields.rb +17 -59
  109. data/lib/ynab/models/save_transactions_response.rb +13 -20
  110. data/lib/ynab/models/save_transactions_response_data.rb +13 -20
  111. data/lib/ynab/models/scheduled_sub_transaction.rb +13 -20
  112. data/lib/ynab/models/scheduled_transaction_detail.rb +26 -32
  113. data/lib/ynab/models/scheduled_transaction_response.rb +13 -20
  114. data/lib/ynab/models/scheduled_transaction_response_data.rb +13 -20
  115. data/lib/ynab/models/scheduled_transaction_summary.rb +26 -31
  116. data/lib/ynab/models/scheduled_transactions_response.rb +13 -20
  117. data/lib/ynab/models/scheduled_transactions_response_data.rb +13 -20
  118. data/lib/ynab/models/sub_transaction.rb +13 -20
  119. data/lib/ynab/models/transaction_cleared_status.rb +41 -0
  120. data/lib/ynab/models/transaction_detail.rb +28 -43
  121. data/lib/ynab/models/transaction_flag_color.rb +45 -0
  122. data/lib/ynab/models/transaction_response.rb +13 -20
  123. data/lib/ynab/models/transaction_response_data.rb +13 -20
  124. data/lib/ynab/models/transaction_summary.rb +28 -42
  125. data/lib/ynab/models/transactions_import_response.rb +13 -20
  126. data/lib/ynab/models/transactions_import_response_data.rb +13 -20
  127. data/lib/ynab/models/transactions_response.rb +13 -20
  128. data/lib/ynab/models/transactions_response_data.rb +13 -20
  129. data/lib/ynab/models/user.rb +13 -20
  130. data/lib/ynab/models/user_response.rb +13 -20
  131. data/lib/ynab/models/user_response_data.rb +13 -20
  132. data/lib/ynab/version.rb +1 -1
  133. data/lib/ynab.rb +13 -12
  134. data/open_api_spec.yaml +455 -343
  135. data/ynab.gemspec +4 -3
  136. metadata +29 -7
@@ -0,0 +1,377 @@
1
+ =begin
2
+ #YNAB API Endpoints
3
+
4
+ #Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.ynab.com
5
+
6
+ The version of the OpenAPI document: 1.69.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module YNAB
17
+ class NewTransaction
18
+ attr_accessor :account_id
19
+
20
+ # The transaction date in ISO format (e.g. 2016-12-01). Future dates (scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date is supplied it will be ignored.
21
+ attr_accessor :date
22
+
23
+ # The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored.
24
+ attr_accessor :amount
25
+
26
+ # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource.
27
+ attr_accessor :payee_id
28
+
29
+ # The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee.
30
+ attr_accessor :payee_name
31
+
32
+ # The category for the transaction. To configure a split transaction, you can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object. If an existing transaction is a split, the `category_id` cannot be changed. Credit Card Payment categories are not permitted and will be ignored if supplied.
33
+ attr_accessor :category_id
34
+
35
+ attr_accessor :memo
36
+
37
+ attr_accessor :cleared
38
+
39
+ # Whether or not the transaction is approved. If not supplied, transaction will be unapproved by default.
40
+ attr_accessor :approved
41
+
42
+ attr_accessor :flag_color
43
+
44
+ # An array of subtransactions to configure a transaction as a split. Updating `subtransactions` on an existing split transaction is not supported.
45
+ attr_accessor :subtransactions
46
+
47
+ # If specified, a new transaction will be assigned this `import_id` and considered \"imported\". We will also attempt to match this imported transaction to an existing \"user-entered\" transaction on the same account, with the same amount, and with a date +/-10 days from the imported transaction date.<br><br>Transactions imported through File Based Import or Direct Import (not through the API) are assigned an import_id in the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. Using a consistent format will prevent duplicates through Direct Import and File Based Import.<br><br>If import_id is omitted or specified as null, the transaction will be treated as a \"user-entered\" transaction. As such, it will be eligible to be matched against transactions later being imported (via DI, FBI, or API).
48
+ attr_accessor :import_id
49
+
50
+ class EnumAttributeValidator
51
+ attr_reader :datatype
52
+ attr_reader :allowable_values
53
+
54
+ def initialize(datatype, allowable_values)
55
+ @allowable_values = allowable_values.map do |value|
56
+ case datatype.to_s
57
+ when /Integer/i
58
+ value.to_i
59
+ when /Float/i
60
+ value.to_f
61
+ else
62
+ value
63
+ end
64
+ end
65
+ end
66
+
67
+ def valid?(value)
68
+ !value || allowable_values.include?(value)
69
+ end
70
+ end
71
+
72
+ # Attribute mapping from ruby-style variable name to JSON key.
73
+ def self.attribute_map
74
+ {
75
+ :'account_id' => :'account_id',
76
+ :'date' => :'date',
77
+ :'amount' => :'amount',
78
+ :'payee_id' => :'payee_id',
79
+ :'payee_name' => :'payee_name',
80
+ :'category_id' => :'category_id',
81
+ :'memo' => :'memo',
82
+ :'cleared' => :'cleared',
83
+ :'approved' => :'approved',
84
+ :'flag_color' => :'flag_color',
85
+ :'subtransactions' => :'subtransactions',
86
+ :'import_id' => :'import_id'
87
+ }
88
+ end
89
+
90
+ # Returns all the JSON keys this model knows about
91
+ def self.acceptable_attributes
92
+ attribute_map.values
93
+ end
94
+
95
+ # Attribute type mapping.
96
+ def self.openapi_types
97
+ {
98
+ :'account_id' => :'String',
99
+ :'date' => :'Date',
100
+ :'amount' => :'Integer',
101
+ :'payee_id' => :'String',
102
+ :'payee_name' => :'String',
103
+ :'category_id' => :'String',
104
+ :'memo' => :'String',
105
+ :'cleared' => :'TransactionClearedStatus',
106
+ :'approved' => :'Boolean',
107
+ :'flag_color' => :'TransactionFlagColor',
108
+ :'subtransactions' => :'Array<SaveSubTransaction>',
109
+ :'import_id' => :'String'
110
+ }
111
+ end
112
+
113
+ # List of attributes with nullable: true
114
+ def self.openapi_nullable
115
+ Set.new([
116
+ :'payee_id',
117
+ :'payee_name',
118
+ :'category_id',
119
+ :'memo',
120
+ :'flag_color',
121
+ :'import_id'
122
+ ])
123
+ end
124
+
125
+ # List of class defined in allOf (OpenAPI v3)
126
+ def self.openapi_all_of
127
+ [
128
+ :'SaveTransactionWithOptionalFields'
129
+ ]
130
+ end
131
+
132
+ # Initializes the object
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ def initialize(attributes = {})
135
+ if (!attributes.is_a?(Hash))
136
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::NewTransaction` initialize method"
137
+ end
138
+
139
+ # check to see if the attribute exists and convert string to symbol for hash key
140
+ attributes = attributes.each_with_object({}) { |(k, v), h|
141
+ if (!self.class.attribute_map.key?(k.to_sym))
142
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::NewTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
143
+ end
144
+ h[k.to_sym] = v
145
+ }
146
+
147
+ if attributes.key?(:'account_id')
148
+ self.account_id = attributes[:'account_id']
149
+ end
150
+
151
+ if attributes.key?(:'date')
152
+ self.date = attributes[:'date']
153
+ end
154
+
155
+ if attributes.key?(:'amount')
156
+ self.amount = attributes[:'amount']
157
+ end
158
+
159
+ if attributes.key?(:'payee_id')
160
+ self.payee_id = attributes[:'payee_id']
161
+ end
162
+
163
+ if attributes.key?(:'payee_name')
164
+ self.payee_name = attributes[:'payee_name']
165
+ end
166
+
167
+ if attributes.key?(:'category_id')
168
+ self.category_id = attributes[:'category_id']
169
+ end
170
+
171
+ if attributes.key?(:'memo')
172
+ self.memo = attributes[:'memo']
173
+ end
174
+
175
+ if attributes.key?(:'cleared')
176
+ self.cleared = attributes[:'cleared']
177
+ end
178
+
179
+ if attributes.key?(:'approved')
180
+ self.approved = attributes[:'approved']
181
+ end
182
+
183
+ if attributes.key?(:'flag_color')
184
+ self.flag_color = attributes[:'flag_color']
185
+ end
186
+
187
+ if attributes.key?(:'subtransactions')
188
+ if (value = attributes[:'subtransactions']).is_a?(Array)
189
+ self.subtransactions = value
190
+ end
191
+ end
192
+
193
+ if attributes.key?(:'import_id')
194
+ self.import_id = attributes[:'import_id']
195
+ end
196
+ end
197
+
198
+ # Show invalid properties with the reasons. Usually used together with valid?
199
+ # @return Array for valid properties with the reasons
200
+ def list_invalid_properties
201
+ invalid_properties = Array.new
202
+ invalid_properties
203
+ end
204
+
205
+ # Check to see if the all the properties in the model are valid
206
+ # @return true if the model is valid
207
+ def valid?
208
+ return false if !@payee_name.nil? && @payee_name.to_s.length > 50
209
+ return false if !@memo.nil? && @memo.to_s.length > 200
210
+ return false if !@import_id.nil? && @import_id.to_s.length > 36
211
+ true
212
+ end
213
+
214
+ # Custom attribute writer method with validation
215
+ # @param [Object] payee_name Value to be assigned
216
+ def payee_name=(payee_name)
217
+ @payee_name = payee_name
218
+ end
219
+
220
+ # Custom attribute writer method with validation
221
+ # @param [Object] memo Value to be assigned
222
+ def memo=(memo)
223
+ @memo = memo
224
+ end
225
+
226
+ # Custom attribute writer method with validation
227
+ # @param [Object] import_id Value to be assigned
228
+ def import_id=(import_id)
229
+ @import_id = import_id
230
+ end
231
+
232
+ # Checks equality by comparing each attribute.
233
+ # @param [Object] Object to be compared
234
+ def ==(o)
235
+ return true if self.equal?(o)
236
+ self.class == o.class &&
237
+ account_id == o.account_id &&
238
+ date == o.date &&
239
+ amount == o.amount &&
240
+ payee_id == o.payee_id &&
241
+ payee_name == o.payee_name &&
242
+ category_id == o.category_id &&
243
+ memo == o.memo &&
244
+ cleared == o.cleared &&
245
+ approved == o.approved &&
246
+ flag_color == o.flag_color &&
247
+ subtransactions == o.subtransactions &&
248
+ import_id == o.import_id
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
+ [account_id, date, amount, payee_id, payee_name, category_id, memo, cleared, approved, flag_color, subtransactions, import_id].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 = YNAB.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
+
375
+ end
376
+
377
+ end
@@ -0,0 +1,213 @@
1
+ =begin
2
+ #YNAB API Endpoints
3
+
4
+ #Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.ynab.com
5
+
6
+ The version of the OpenAPI document: 1.69.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module YNAB
17
+ class PatchCategoryWrapper
18
+ attr_accessor :category
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'category' => :'category'
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
+ :'category' => :'SaveCategory'
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 `YNAB::PatchCategoryWrapper` 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 `YNAB::PatchCategoryWrapper`. 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?(:'category')
61
+ self.category = attributes[:'category']
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
+ invalid_properties = Array.new
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ return false if @category.nil?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ category == o.category
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [category].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ return nil unless attributes.is_a?(Hash)
104
+ attributes = attributes.transform_keys(&:to_sym)
105
+ transformed_hash = {}
106
+ openapi_types.each_pair do |key, type|
107
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
108
+ transformed_hash["#{key}"] = nil
109
+ elsif type =~ /\AArray<(.*)>/i
110
+ # check to ensure the input is an array given that the attribute
111
+ # is documented as an array but the input is not
112
+ if attributes[attribute_map[key]].is_a?(Array)
113
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
114
+ end
115
+ elsif !attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
117
+ end
118
+ end
119
+ new(transformed_hash)
120
+ end
121
+
122
+ # Deserializes the data based on type
123
+ # @param string type Data type
124
+ # @param string value Value to be deserialized
125
+ # @return [Object] Deserialized data
126
+ def self._deserialize(type, value)
127
+ case type.to_sym
128
+ when :Time
129
+ Time.parse(value)
130
+ when :Date
131
+ Date.parse(value)
132
+ when :String
133
+ value.to_s
134
+ when :Integer
135
+ value.to_i
136
+ when :Float
137
+ value.to_f
138
+ when :Boolean
139
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
140
+ true
141
+ else
142
+ false
143
+ end
144
+ when :Object
145
+ # generic object (usually a Hash), return directly
146
+ value
147
+ when /\AArray<(?<inner_type>.+)>\z/
148
+ inner_type = Regexp.last_match[:inner_type]
149
+ value.map { |v| _deserialize(inner_type, v) }
150
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
151
+ k_type = Regexp.last_match[:k_type]
152
+ v_type = Regexp.last_match[:v_type]
153
+ {}.tap do |hash|
154
+ value.each do |k, v|
155
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
156
+ end
157
+ end
158
+ else # model
159
+ # models (e.g. Pet) or oneOf
160
+ klass = YNAB.const_get(type)
161
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
162
+ end
163
+ end
164
+
165
+ # Returns the string representation of the object
166
+ # @return [String] String presentation of the object
167
+ def to_s
168
+ to_hash.to_s
169
+ end
170
+
171
+ # to_body is an alias to to_hash (backward compatibility)
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_body
174
+ to_hash
175
+ end
176
+
177
+ # Returns the object in the form of hash
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_hash
180
+ hash = {}
181
+ self.class.attribute_map.each_pair do |attr, param|
182
+ value = self.send(attr)
183
+ if value.nil?
184
+ is_nullable = self.class.openapi_nullable.include?(attr)
185
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
186
+ end
187
+
188
+ hash[param] = _to_hash(value)
189
+ end
190
+ hash
191
+ end
192
+
193
+ # Outputs non-array value in the form of hash
194
+ # For object, use to_hash. Otherwise, just return the value
195
+ # @param [Object] value Any valid value
196
+ # @return [Hash] Returns the value in the form of hash
197
+ def _to_hash(value)
198
+ if value.is_a?(Array)
199
+ value.compact.map { |v| _to_hash(v) }
200
+ elsif value.is_a?(Hash)
201
+ {}.tap do |hash|
202
+ value.each { |k, v| hash[k] = _to_hash(v) }
203
+ end
204
+ elsif value.respond_to? :to_hash
205
+ value.to_hash
206
+ else
207
+ value
208
+ end
209
+ end
210
+
211
+ end
212
+
213
+ end
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.ynab.com
5
5
 
6
- The version of the OpenAPI document: 1.0.0
6
+ The version of the OpenAPI document: 1.69.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -100,37 +100,30 @@ module YNAB
100
100
  # @param [Hash] attributes Model attributes in the form of hash
101
101
  # @return [Object] Returns the model itself
102
102
  def self.build_from_hash(attributes)
103
- new.build_from_hash(attributes)
104
- end
105
-
106
- # Builds the object from hash
107
- # @param [Hash] attributes Model attributes in the form of hash
108
- # @return [Object] Returns the model itself
109
- def build_from_hash(attributes)
110
103
  return nil unless attributes.is_a?(Hash)
111
104
  attributes = attributes.transform_keys(&:to_sym)
112
- self.class.openapi_types.each_pair do |key, type|
113
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
114
- self.send("#{key}=", nil)
105
+ transformed_hash = {}
106
+ openapi_types.each_pair do |key, type|
107
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
108
+ transformed_hash["#{key}"] = nil
115
109
  elsif type =~ /\AArray<(.*)>/i
116
110
  # check to ensure the input is an array given that the attribute
117
111
  # is documented as an array but the input is not
118
- if attributes[self.class.attribute_map[key]].is_a?(Array)
119
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
112
+ if attributes[attribute_map[key]].is_a?(Array)
113
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
120
114
  end
121
- elsif !attributes[self.class.attribute_map[key]].nil?
122
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
115
+ elsif !attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
123
117
  end
124
118
  end
125
-
126
- self
119
+ new(transformed_hash)
127
120
  end
128
121
 
129
122
  # Deserializes the data based on type
130
123
  # @param string type Data type
131
124
  # @param string value Value to be deserialized
132
125
  # @return [Object] Deserialized data
133
- def _deserialize(type, value)
126
+ def self._deserialize(type, value)
134
127
  case type.to_sym
135
128
  when :Time
136
129
  Time.parse(value)
@@ -165,7 +158,7 @@ module YNAB
165
158
  else # model
166
159
  # models (e.g. Pet) or oneOf
167
160
  klass = YNAB.const_get(type)
168
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
161
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
162
  end
170
163
  end
171
164