ynab 1.31.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/DEVELOPMENT.md +11 -0
  3. data/Gemfile +8 -0
  4. data/Gemfile.lock +42 -0
  5. data/README.md +3 -3
  6. data/Rakefile +58 -0
  7. data/config.json +9 -0
  8. data/docs/Account.md +25 -0
  9. data/docs/AccountResponse.md +8 -0
  10. data/docs/AccountResponseData.md +8 -0
  11. data/docs/AccountType.md +7 -0
  12. data/docs/AccountWrapper.md +8 -0
  13. data/docs/AccountsApi.md +70 -0
  14. data/docs/AccountsResponse.md +8 -0
  15. data/docs/AccountsResponseData.md +9 -0
  16. data/docs/AccountsWrapper.md +9 -0
  17. data/docs/BudgetDetail.md +24 -0
  18. data/docs/BudgetDetailAllOf.md +17 -0
  19. data/docs/BudgetDetailResponse.md +8 -0
  20. data/docs/BudgetDetailResponseData.md +9 -0
  21. data/docs/BudgetDetailWrapper.md +9 -0
  22. data/docs/BudgetSettings.md +9 -0
  23. data/docs/BudgetSettingsResponse.md +8 -0
  24. data/docs/BudgetSettingsResponseData.md +8 -0
  25. data/docs/BudgetSettingsWrapper.md +8 -0
  26. data/docs/BudgetSummary.md +15 -0
  27. data/docs/BudgetSummaryResponse.md +8 -0
  28. data/docs/BudgetSummaryResponseData.md +9 -0
  29. data/docs/BudgetSummaryWrapper.md +9 -0
  30. data/docs/BudgetsApi.md +68 -0
  31. data/docs/BulkIdWrapper.md +8 -0
  32. data/docs/BulkIds.md +9 -0
  33. data/docs/BulkResponse.md +8 -0
  34. data/docs/BulkResponseData.md +8 -0
  35. data/docs/BulkResponseDataBulk.md +9 -0
  36. data/docs/BulkTransactionCreateResponse.md +8 -0
  37. data/docs/BulkTransactionIds.md +8 -0
  38. data/docs/BulkTransactions.md +8 -0
  39. data/docs/CategoriesApi.md +94 -0
  40. data/docs/CategoriesResponse.md +8 -0
  41. data/docs/CategoriesResponseData.md +9 -0
  42. data/docs/Category.md +30 -0
  43. data/docs/CategoryGroup.md +11 -0
  44. data/docs/CategoryGroupWithCategories.md +12 -0
  45. data/docs/CategoryGroupWithCategoriesAllOf.md +8 -0
  46. data/docs/CategoryGroupsWrapper.md +9 -0
  47. data/docs/CategoryResponse.md +8 -0
  48. data/docs/CategoryResponseData.md +8 -0
  49. data/docs/CategoryWrapper.md +9 -0
  50. data/docs/CurrencyFormat.md +15 -0
  51. data/docs/DateFormat.md +8 -0
  52. data/docs/DeprecatedApi.md +28 -0
  53. data/docs/ErrorDetail.md +10 -0
  54. data/docs/ErrorResponse.md +8 -0
  55. data/docs/HybridTransaction.md +30 -0
  56. data/docs/HybridTransactionAllOf.md +12 -0
  57. data/docs/HybridTransactionsResponse.md +8 -0
  58. data/docs/HybridTransactionsResponseData.md +9 -0
  59. data/docs/HybridTransactionsWrapper.md +8 -0
  60. data/docs/LoanAccountPeriodicValue.md +7 -0
  61. data/docs/MonthDetail.md +16 -0
  62. data/docs/MonthDetailAllOf.md +8 -0
  63. data/docs/MonthDetailResponse.md +8 -0
  64. data/docs/MonthDetailResponseData.md +8 -0
  65. data/docs/MonthDetailWrapper.md +8 -0
  66. data/docs/MonthSummariesResponse.md +8 -0
  67. data/docs/MonthSummariesResponseData.md +9 -0
  68. data/docs/MonthSummariesWrapper.md +9 -0
  69. data/docs/MonthSummary.md +15 -0
  70. data/docs/MonthsApi.md +49 -0
  71. data/docs/PatchMonthCategoryWrapper.md +8 -0
  72. data/docs/PatchTransactionsWrapper.md +8 -0
  73. data/docs/Payee.md +11 -0
  74. data/docs/PayeeLocation.md +12 -0
  75. data/docs/PayeeLocationResponse.md +8 -0
  76. data/docs/PayeeLocationResponseData.md +8 -0
  77. data/docs/PayeeLocationWrapper.md +8 -0
  78. data/docs/PayeeLocationsApi.md +69 -0
  79. data/docs/PayeeLocationsResponse.md +8 -0
  80. data/docs/PayeeLocationsResponseData.md +8 -0
  81. data/docs/PayeeLocationsWrapper.md +8 -0
  82. data/docs/PayeeResponse.md +8 -0
  83. data/docs/PayeeResponseData.md +8 -0
  84. data/docs/PayeeWrapper.md +8 -0
  85. data/docs/PayeesApi.md +49 -0
  86. data/docs/PayeesResponse.md +8 -0
  87. data/docs/PayeesResponseData.md +9 -0
  88. data/docs/PayeesWrapper.md +9 -0
  89. data/docs/PostAccountWrapper.md +8 -0
  90. data/docs/PostTransactionsWrapper.md +9 -0
  91. data/docs/PutTransactionWrapper.md +8 -0
  92. data/docs/SaveAccount.md +10 -0
  93. data/docs/SaveAccountWrapper.md +8 -0
  94. data/docs/SaveCategoryResponse.md +8 -0
  95. data/docs/SaveCategoryResponseData.md +9 -0
  96. data/docs/SaveMonthCategory.md +8 -0
  97. data/docs/SaveMonthCategoryWrapper.md +8 -0
  98. data/docs/SaveSubTransaction.md +12 -0
  99. data/docs/SaveTransaction.md +19 -0
  100. data/docs/SaveTransactionWithId.md +20 -0
  101. data/docs/SaveTransactionWithIdAllOf.md +8 -0
  102. data/docs/SaveTransactionWithOptionalFields.md +19 -0
  103. data/docs/SaveTransactionWrapper.md +8 -0
  104. data/docs/SaveTransactionsResponse.md +8 -0
  105. data/docs/SaveTransactionsResponseData.md +12 -0
  106. data/docs/SaveTransactionsWrapper.md +9 -0
  107. data/docs/ScheduledSubTransaction.md +15 -0
  108. data/docs/ScheduledTransactionDetail.md +23 -0
  109. data/docs/ScheduledTransactionDetailAllOf.md +11 -0
  110. data/docs/ScheduledTransactionResponse.md +8 -0
  111. data/docs/ScheduledTransactionResponseData.md +8 -0
  112. data/docs/ScheduledTransactionSummary.md +19 -0
  113. data/docs/ScheduledTransactionWrapper.md +8 -0
  114. data/docs/ScheduledTransactionsApi.md +49 -0
  115. data/docs/ScheduledTransactionsResponse.md +8 -0
  116. data/docs/ScheduledTransactionsResponseData.md +9 -0
  117. data/docs/ScheduledTransactionsWrapper.md +8 -0
  118. data/docs/SubTransaction.md +18 -0
  119. data/docs/TransactionDetail.md +29 -0
  120. data/docs/TransactionDetailAllOf.md +11 -0
  121. data/docs/TransactionResponse.md +8 -0
  122. data/docs/TransactionResponseData.md +8 -0
  123. data/docs/TransactionSummary.md +25 -0
  124. data/docs/TransactionWrapper.md +8 -0
  125. data/docs/TransactionsApi.md +228 -0
  126. data/docs/TransactionsImportResponse.md +8 -0
  127. data/docs/TransactionsImportResponseData.md +8 -0
  128. data/docs/TransactionsResponse.md +8 -0
  129. data/docs/TransactionsResponseData.md +9 -0
  130. data/docs/TransactionsWrapper.md +9 -0
  131. data/docs/UpdateTransaction.md +20 -0
  132. data/docs/UpdateTransactionsWrapper.md +8 -0
  133. data/docs/User.md +8 -0
  134. data/docs/UserApi.md +25 -0
  135. data/docs/UserResponse.md +8 -0
  136. data/docs/UserResponseData.md +8 -0
  137. data/docs/UserWrapper.md +8 -0
  138. data/examples/budget-list.rb +21 -0
  139. data/examples/budget-month.rb +33 -0
  140. data/examples/category-balance.rb +23 -0
  141. data/examples/create-multiple-transactions.rb +42 -0
  142. data/examples/create-transaction.rb +30 -0
  143. data/examples/update-category-budgeted.rb +25 -0
  144. data/examples/update-multiple-transactions.rb +20 -0
  145. data/lib/ynab/api/accounts_api.rb +78 -41
  146. data/lib/ynab/api/budgets_api.rb +68 -36
  147. data/lib/ynab/api/categories_api.rb +108 -60
  148. data/lib/ynab/api/deprecated_api.rb +32 -17
  149. data/lib/ynab/api/months_api.rb +49 -28
  150. data/lib/ynab/api/payee_locations_api.rb +73 -41
  151. data/lib/ynab/api/payees_api.rb +49 -28
  152. data/lib/ynab/api/scheduled_transactions_api.rb +49 -28
  153. data/lib/ynab/api/transactions_api.rb +268 -140
  154. data/lib/ynab/api/user_api.rb +22 -12
  155. data/lib/ynab/api_client.rb +97 -95
  156. data/lib/ynab/configuration.rb +101 -14
  157. data/lib/ynab/models/account.rb +117 -55
  158. data/lib/ynab/models/account_response.rb +53 -18
  159. data/lib/ynab/models/account_response_data.rb +53 -18
  160. data/lib/ynab/models/account_type.rb +30 -20
  161. data/lib/ynab/models/accounts_response.rb +53 -18
  162. data/lib/ynab/models/accounts_response_data.rb +54 -19
  163. data/lib/ynab/models/budget_detail.rb +80 -35
  164. data/lib/ynab/models/budget_detail_all_of.rb +320 -0
  165. data/lib/ynab/models/budget_detail_response.rb +53 -18
  166. data/lib/ynab/models/budget_detail_response_data.rb +54 -19
  167. data/lib/ynab/models/budget_settings.rb +56 -29
  168. data/lib/ynab/models/budget_settings_response.rb +53 -18
  169. data/lib/ynab/models/budget_settings_response_data.rb +53 -18
  170. data/lib/ynab/models/budget_summary.rb +63 -26
  171. data/lib/ynab/models/budget_summary_response.rb +53 -18
  172. data/lib/ynab/models/budget_summary_response_data.rb +54 -20
  173. data/lib/ynab/models/bulk_response.rb +53 -18
  174. data/lib/ynab/models/bulk_response_data.rb +53 -18
  175. data/lib/ynab/models/bulk_response_data_bulk.rb +54 -19
  176. data/lib/ynab/models/bulk_transactions.rb +53 -18
  177. data/lib/ynab/models/categories_response.rb +53 -18
  178. data/lib/ynab/models/categories_response_data.rb +54 -19
  179. data/lib/ynab/models/category.rb +110 -48
  180. data/lib/ynab/models/category_group.rb +58 -23
  181. data/lib/ynab/models/category_group_with_categories.rb +67 -24
  182. data/lib/ynab/models/{save_month_category_wrapper.rb → category_group_with_categories_all_of.rb} +67 -29
  183. data/lib/ynab/models/category_response.rb +53 -18
  184. data/lib/ynab/models/category_response_data.rb +53 -18
  185. data/lib/ynab/models/currency_format.rb +62 -27
  186. data/lib/ynab/models/date_format.rb +53 -18
  187. data/lib/ynab/models/error_detail.rb +55 -20
  188. data/lib/ynab/models/error_response.rb +53 -18
  189. data/lib/ynab/models/hybrid_transaction.rb +118 -46
  190. data/lib/ynab/models/hybrid_transaction_all_of.rb +304 -0
  191. data/lib/ynab/models/hybrid_transactions_response.rb +53 -18
  192. data/lib/ynab/models/hybrid_transactions_response_data.rb +54 -19
  193. data/lib/ynab/models/month_detail.rb +72 -27
  194. data/lib/ynab/models/{update_transactions_wrapper.rb → month_detail_all_of.rb} +66 -30
  195. data/lib/ynab/models/month_detail_response.rb +53 -18
  196. data/lib/ynab/models/month_detail_response_data.rb +53 -18
  197. data/lib/ynab/models/month_summaries_response.rb +53 -18
  198. data/lib/ynab/models/month_summaries_response_data.rb +54 -19
  199. data/lib/ynab/models/month_summary.rb +63 -26
  200. data/lib/ynab/models/patch_month_category_wrapper.rb +53 -18
  201. data/lib/ynab/models/patch_transactions_wrapper.rb +53 -18
  202. data/lib/ynab/models/payee.rb +58 -22
  203. data/lib/ynab/models/payee_location.rb +58 -23
  204. data/lib/ynab/models/payee_location_response.rb +53 -18
  205. data/lib/ynab/models/payee_location_response_data.rb +53 -18
  206. data/lib/ynab/models/payee_locations_response.rb +53 -18
  207. data/lib/ynab/models/payee_locations_response_data.rb +53 -18
  208. data/lib/ynab/models/payee_response.rb +53 -18
  209. data/lib/ynab/models/payee_response_data.rb +53 -18
  210. data/lib/ynab/models/payees_response.rb +53 -18
  211. data/lib/ynab/models/payees_response_data.rb +54 -19
  212. data/lib/ynab/models/post_account_wrapper.rb +53 -18
  213. data/lib/ynab/models/post_transactions_wrapper.rb +54 -19
  214. data/lib/ynab/models/put_transaction_wrapper.rb +53 -18
  215. data/lib/ynab/models/save_account.rb +77 -20
  216. data/lib/ynab/models/save_category_response.rb +53 -18
  217. data/lib/ynab/models/save_category_response_data.rb +54 -19
  218. data/lib/ynab/models/save_month_category.rb +53 -18
  219. data/lib/ynab/models/save_sub_transaction.rb +61 -22
  220. data/lib/ynab/models/save_transaction.rb +88 -33
  221. data/lib/ynab/models/save_transaction_with_id.rb +102 -46
  222. data/lib/ynab/models/{save_transactions_wrapper.rb → save_transaction_with_id_all_of.rb} +60 -36
  223. data/lib/ynab/models/save_transaction_with_optional_fields.rb +81 -33
  224. data/lib/ynab/models/save_transactions_response.rb +53 -18
  225. data/lib/ynab/models/save_transactions_response_data.rb +57 -23
  226. data/lib/ynab/models/scheduled_sub_transaction.rb +66 -27
  227. data/lib/ynab/models/scheduled_transaction_detail.rb +94 -36
  228. data/lib/ynab/models/scheduled_transaction_detail_all_of.rb +262 -0
  229. data/lib/ynab/models/scheduled_transaction_response.rb +53 -18
  230. data/lib/ynab/models/scheduled_transaction_response_data.rb +53 -18
  231. data/lib/ynab/models/scheduled_transaction_summary.rb +80 -32
  232. data/lib/ynab/models/scheduled_transactions_response.rb +53 -18
  233. data/lib/ynab/models/scheduled_transactions_response_data.rb +54 -19
  234. data/lib/ynab/models/sub_transaction.rb +71 -29
  235. data/lib/ynab/models/transaction_detail.rb +112 -44
  236. data/lib/ynab/models/{save_transaction_wrapper.rb → transaction_detail_all_of.rb} +102 -29
  237. data/lib/ynab/models/transaction_response.rb +53 -18
  238. data/lib/ynab/models/transaction_response_data.rb +53 -18
  239. data/lib/ynab/models/transaction_summary.rb +98 -40
  240. data/lib/ynab/models/transactions_import_response.rb +53 -18
  241. data/lib/ynab/models/transactions_import_response_data.rb +53 -18
  242. data/lib/ynab/models/transactions_response.rb +53 -18
  243. data/lib/ynab/models/transactions_response_data.rb +54 -19
  244. data/lib/ynab/models/user.rb +53 -18
  245. data/lib/ynab/models/user_response.rb +53 -18
  246. data/lib/ynab/models/user_response_data.rb +53 -18
  247. data/lib/ynab/version.rb +1 -1
  248. data/lib/ynab.rb +19 -14
  249. data/open_api_spec.yaml +3012 -0
  250. data/templates/api_client.mustache +274 -0
  251. data/templates/api_client_typhoeus_partial.mustache +156 -0
  252. data/templates/api_doc.mustache +44 -0
  253. data/templates/gem.mustache +84 -0
  254. data/templates/partial_model_generic_doc.mustache +9 -0
  255. data/ynab.gemspec +38 -0
  256. metadata +192 -85
  257. data/lib/ynab/models/loan_account_periodic_value.rb +0 -175
  258. data/lib/ynab/models/save_account_wrapper.rb +0 -189
  259. data/lib/ynab/models/update_transaction.rb +0 -407
  260. data/spec/models/transaction_detail_spec.rb +0 -11
@@ -3,14 +3,15 @@
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
- OpenAPI spec version: 1.0.0
6
+ The version of the OpenAPI document: 1.0.0
7
7
 
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.14
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module YNAB
16
17
  class HybridTransaction
@@ -127,15 +128,20 @@ module YNAB
127
128
  }
128
129
  end
129
130
 
131
+ # Returns all the JSON keys this model knows about
132
+ def self.acceptable_attributes
133
+ attribute_map.values
134
+ end
135
+
130
136
  # Attribute type mapping.
131
- def self.swagger_types
137
+ def self.openapi_types
132
138
  {
133
139
  :'id' => :'String',
134
140
  :'date' => :'Date',
135
141
  :'amount' => :'Integer',
136
142
  :'memo' => :'String',
137
143
  :'cleared' => :'String',
138
- :'approved' => :'BOOLEAN',
144
+ :'approved' => :'Boolean',
139
145
  :'flag_color' => :'String',
140
146
  :'account_id' => :'String',
141
147
  :'payee_id' => :'String',
@@ -147,7 +153,7 @@ module YNAB
147
153
  :'import_payee_name' => :'String',
148
154
  :'import_payee_name_original' => :'String',
149
155
  :'debt_transaction_type' => :'String',
150
- :'deleted' => :'BOOLEAN',
156
+ :'deleted' => :'Boolean',
151
157
  :'type' => :'String',
152
158
  :'parent_transaction_id' => :'String',
153
159
  :'account_name' => :'String',
@@ -156,103 +162,137 @@ module YNAB
156
162
  }
157
163
  end
158
164
 
165
+ # List of attributes with nullable: true
166
+ def self.openapi_nullable
167
+ Set.new([
168
+ :'memo',
169
+ :'flag_color',
170
+ :'payee_id',
171
+ :'category_id',
172
+ :'transfer_account_id',
173
+ :'transfer_transaction_id',
174
+ :'matched_transaction_id',
175
+ :'import_id',
176
+ :'import_payee_name',
177
+ :'import_payee_name_original',
178
+ :'debt_transaction_type',
179
+ :'parent_transaction_id',
180
+ :'payee_name',
181
+ ])
182
+ end
183
+
184
+ # List of class defined in allOf (OpenAPI v3)
185
+ def self.openapi_all_of
186
+ [
187
+ :'HybridTransactionAllOf',
188
+ :'TransactionSummary'
189
+ ]
190
+ end
191
+
159
192
  # Initializes the object
160
193
  # @param [Hash] attributes Model attributes in the form of hash
161
194
  def initialize(attributes = {})
162
- return unless attributes.is_a?(Hash)
195
+ if (!attributes.is_a?(Hash))
196
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::HybridTransaction` initialize method"
197
+ end
163
198
 
164
- # convert string to symbol for hash key
165
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
199
+ # check to see if the attribute exists and convert string to symbol for hash key
200
+ attributes = attributes.each_with_object({}) { |(k, v), h|
201
+ if (!self.class.attribute_map.key?(k.to_sym))
202
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::HybridTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
203
+ end
204
+ h[k.to_sym] = v
205
+ }
166
206
 
167
- if attributes.has_key?(:'id')
207
+ if attributes.key?(:'id')
168
208
  self.id = attributes[:'id']
169
209
  end
170
210
 
171
- if attributes.has_key?(:'date')
211
+ if attributes.key?(:'date')
172
212
  self.date = attributes[:'date']
173
213
  end
174
214
 
175
- if attributes.has_key?(:'amount')
215
+ if attributes.key?(:'amount')
176
216
  self.amount = attributes[:'amount']
177
217
  end
178
218
 
179
- if attributes.has_key?(:'memo')
219
+ if attributes.key?(:'memo')
180
220
  self.memo = attributes[:'memo']
181
221
  end
182
222
 
183
- if attributes.has_key?(:'cleared')
223
+ if attributes.key?(:'cleared')
184
224
  self.cleared = attributes[:'cleared']
185
225
  end
186
226
 
187
- if attributes.has_key?(:'approved')
227
+ if attributes.key?(:'approved')
188
228
  self.approved = attributes[:'approved']
189
229
  end
190
230
 
191
- if attributes.has_key?(:'flag_color')
231
+ if attributes.key?(:'flag_color')
192
232
  self.flag_color = attributes[:'flag_color']
193
233
  end
194
234
 
195
- if attributes.has_key?(:'account_id')
235
+ if attributes.key?(:'account_id')
196
236
  self.account_id = attributes[:'account_id']
197
237
  end
198
238
 
199
- if attributes.has_key?(:'payee_id')
239
+ if attributes.key?(:'payee_id')
200
240
  self.payee_id = attributes[:'payee_id']
201
241
  end
202
242
 
203
- if attributes.has_key?(:'category_id')
243
+ if attributes.key?(:'category_id')
204
244
  self.category_id = attributes[:'category_id']
205
245
  end
206
246
 
207
- if attributes.has_key?(:'transfer_account_id')
247
+ if attributes.key?(:'transfer_account_id')
208
248
  self.transfer_account_id = attributes[:'transfer_account_id']
209
249
  end
210
250
 
211
- if attributes.has_key?(:'transfer_transaction_id')
251
+ if attributes.key?(:'transfer_transaction_id')
212
252
  self.transfer_transaction_id = attributes[:'transfer_transaction_id']
213
253
  end
214
254
 
215
- if attributes.has_key?(:'matched_transaction_id')
255
+ if attributes.key?(:'matched_transaction_id')
216
256
  self.matched_transaction_id = attributes[:'matched_transaction_id']
217
257
  end
218
258
 
219
- if attributes.has_key?(:'import_id')
259
+ if attributes.key?(:'import_id')
220
260
  self.import_id = attributes[:'import_id']
221
261
  end
222
262
 
223
- if attributes.has_key?(:'import_payee_name')
263
+ if attributes.key?(:'import_payee_name')
224
264
  self.import_payee_name = attributes[:'import_payee_name']
225
265
  end
226
266
 
227
- if attributes.has_key?(:'import_payee_name_original')
267
+ if attributes.key?(:'import_payee_name_original')
228
268
  self.import_payee_name_original = attributes[:'import_payee_name_original']
229
269
  end
230
270
 
231
- if attributes.has_key?(:'debt_transaction_type')
271
+ if attributes.key?(:'debt_transaction_type')
232
272
  self.debt_transaction_type = attributes[:'debt_transaction_type']
233
273
  end
234
274
 
235
- if attributes.has_key?(:'deleted')
275
+ if attributes.key?(:'deleted')
236
276
  self.deleted = attributes[:'deleted']
237
277
  end
238
278
 
239
- if attributes.has_key?(:'type')
279
+ if attributes.key?(:'type')
240
280
  self.type = attributes[:'type']
241
281
  end
242
282
 
243
- if attributes.has_key?(:'parent_transaction_id')
283
+ if attributes.key?(:'parent_transaction_id')
244
284
  self.parent_transaction_id = attributes[:'parent_transaction_id']
245
285
  end
246
286
 
247
- if attributes.has_key?(:'account_name')
287
+ if attributes.key?(:'account_name')
248
288
  self.account_name = attributes[:'account_name']
249
289
  end
250
290
 
251
- if attributes.has_key?(:'payee_name')
291
+ if attributes.key?(:'payee_name')
252
292
  self.payee_name = attributes[:'payee_name']
253
293
  end
254
294
 
255
- if attributes.has_key?(:'category_name')
295
+ if attributes.key?(:'category_name')
256
296
  self.category_name = attributes[:'category_name']
257
297
  end
258
298
  end
@@ -307,17 +347,17 @@ module YNAB
307
347
  return false if @date.nil?
308
348
  return false if @amount.nil?
309
349
  return false if @cleared.nil?
310
- cleared_validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
350
+ cleared_validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
311
351
  return false unless cleared_validator.valid?(@cleared)
312
352
  return false if @approved.nil?
313
- flag_color_validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
353
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple", "null"])
314
354
  return false unless flag_color_validator.valid?(@flag_color)
315
355
  return false if @account_id.nil?
316
- debt_transaction_type_validator = EnumAttributeValidator.new('String', ['payment', 'refund', 'fee', 'interest', 'escrow', 'balancedAdjustment', 'credit', 'charge'])
356
+ debt_transaction_type_validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balancedAdjustment", "credit", "charge", "null"])
317
357
  return false unless debt_transaction_type_validator.valid?(@debt_transaction_type)
318
358
  return false if @deleted.nil?
319
359
  return false if @type.nil?
320
- type_validator = EnumAttributeValidator.new('String', ['transaction', 'subtransaction'])
360
+ type_validator = EnumAttributeValidator.new('String', ["transaction", "subtransaction"])
321
361
  return false unless type_validator.valid?(@type)
322
362
  return false if @account_name.nil?
323
363
  true
@@ -326,24 +366,40 @@ module YNAB
326
366
  # Custom attribute writer method checking allowed values (enum).
327
367
  # @param [Object] cleared Object to be assigned
328
368
  def cleared=(cleared)
369
+ validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
370
+ unless validator.valid?(cleared)
371
+ fail ArgumentError, "invalid value for \"cleared\", must be one of #{validator.allowable_values}."
372
+ end
329
373
  @cleared = cleared
330
374
  end
331
375
 
332
376
  # Custom attribute writer method checking allowed values (enum).
333
377
  # @param [Object] flag_color Object to be assigned
334
378
  def flag_color=(flag_color)
379
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple", "null"])
380
+ unless validator.valid?(flag_color)
381
+ fail ArgumentError, "invalid value for \"flag_color\", must be one of #{validator.allowable_values}."
382
+ end
335
383
  @flag_color = flag_color
336
384
  end
337
385
 
338
386
  # Custom attribute writer method checking allowed values (enum).
339
387
  # @param [Object] debt_transaction_type Object to be assigned
340
388
  def debt_transaction_type=(debt_transaction_type)
389
+ validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balancedAdjustment", "credit", "charge", "null"])
390
+ unless validator.valid?(debt_transaction_type)
391
+ fail ArgumentError, "invalid value for \"debt_transaction_type\", must be one of #{validator.allowable_values}."
392
+ end
341
393
  @debt_transaction_type = debt_transaction_type
342
394
  end
343
395
 
344
396
  # Custom attribute writer method checking allowed values (enum).
345
397
  # @param [Object] type Object to be assigned
346
398
  def type=(type)
399
+ validator = EnumAttributeValidator.new('String', ["transaction", "subtransaction"])
400
+ unless validator.valid?(type)
401
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
402
+ end
347
403
  @type = type
348
404
  end
349
405
 
@@ -384,17 +440,28 @@ module YNAB
384
440
  end
385
441
 
386
442
  # Calculates hash code according to all attributes.
387
- # @return [Fixnum] Hash code
443
+ # @return [Integer] Hash code
388
444
  def hash
389
445
  [id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, transfer_transaction_id, matched_transaction_id, import_id, import_payee_name, import_payee_name_original, debt_transaction_type, deleted, type, parent_transaction_id, account_name, payee_name, category_name].hash
390
446
  end
447
+
448
+ # Builds the object from hash
449
+ # @param [Hash] attributes Model attributes in the form of hash
450
+ # @return [Object] Returns the model itself
451
+ def self.build_from_hash(attributes)
452
+ new.build_from_hash(attributes)
453
+ end
454
+
391
455
  # Builds the object from hash
392
456
  # @param [Hash] attributes Model attributes in the form of hash
393
457
  # @return [Object] Returns the model itself
394
458
  def build_from_hash(attributes)
395
459
  return nil unless attributes.is_a?(Hash)
396
- self.class.swagger_types.each_pair do |key, type|
397
- if type =~ /\AArray<(.*)>/i
460
+ attributes = attributes.transform_keys(&:to_sym)
461
+ self.class.openapi_types.each_pair do |key, type|
462
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
463
+ self.send("#{key}=", nil)
464
+ elsif type =~ /\AArray<(.*)>/i
398
465
  # check to ensure the input is an array given that the attribute
399
466
  # is documented as an array but the input is not
400
467
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -402,7 +469,7 @@ module YNAB
402
469
  end
403
470
  elsif !attributes[self.class.attribute_map[key]].nil?
404
471
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
405
- end # or else data not found in attributes(hash), not an issue as the data can be optional
472
+ end
406
473
  end
407
474
 
408
475
  self
@@ -414,8 +481,8 @@ module YNAB
414
481
  # @return [Object] Deserialized data
415
482
  def _deserialize(type, value)
416
483
  case type.to_sym
417
- when :DateTime
418
- DateTime.parse(value)
484
+ when :Time
485
+ Time.parse(value)
419
486
  when :Date
420
487
  Date.parse(value)
421
488
  when :String
@@ -424,7 +491,7 @@ module YNAB
424
491
  value.to_i
425
492
  when :Float
426
493
  value.to_f
427
- when :BOOLEAN
494
+ when :Boolean
428
495
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
429
496
  true
430
497
  else
@@ -445,8 +512,9 @@ module YNAB
445
512
  end
446
513
  end
447
514
  else # model
448
- temp_model = YNAB.const_get(type).new
449
- temp_model.build_from_hash(value)
515
+ # models (e.g. Pet) or oneOf
516
+ klass = YNAB.const_get(type)
517
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
450
518
  end
451
519
  end
452
520
 
@@ -468,7 +536,11 @@ module YNAB
468
536
  hash = {}
469
537
  self.class.attribute_map.each_pair do |attr, param|
470
538
  value = self.send(attr)
471
- next if value.nil?
539
+ if value.nil?
540
+ is_nullable = self.class.openapi_nullable.include?(attr)
541
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
542
+ end
543
+
472
544
  hash[param] = _to_hash(value)
473
545
  end
474
546
  hash
@@ -0,0 +1,304 @@
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.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module YNAB
17
+ class HybridTransactionAllOf
18
+ # Whether the hybrid transaction represents a regular transaction or a subtransaction
19
+ attr_accessor :type
20
+
21
+ # For subtransaction types, this is the id of the parent transaction. For transaction types, this id will be always be null.
22
+ attr_accessor :parent_transaction_id
23
+
24
+ attr_accessor :account_name
25
+
26
+ attr_accessor :payee_name
27
+
28
+ # The name of the category. If a split transaction, this will be 'Split'.
29
+ attr_accessor :category_name
30
+
31
+ class EnumAttributeValidator
32
+ attr_reader :datatype
33
+ attr_reader :allowable_values
34
+
35
+ def initialize(datatype, allowable_values)
36
+ @allowable_values = allowable_values.map do |value|
37
+ case datatype.to_s
38
+ when /Integer/i
39
+ value.to_i
40
+ when /Float/i
41
+ value.to_f
42
+ else
43
+ value
44
+ end
45
+ end
46
+ end
47
+
48
+ def valid?(value)
49
+ !value || allowable_values.include?(value)
50
+ end
51
+ end
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'type' => :'type',
57
+ :'parent_transaction_id' => :'parent_transaction_id',
58
+ :'account_name' => :'account_name',
59
+ :'payee_name' => :'payee_name',
60
+ :'category_name' => :'category_name'
61
+ }
62
+ end
63
+
64
+ # Returns all the JSON keys this model knows about
65
+ def self.acceptable_attributes
66
+ attribute_map.values
67
+ end
68
+
69
+ # Attribute type mapping.
70
+ def self.openapi_types
71
+ {
72
+ :'type' => :'String',
73
+ :'parent_transaction_id' => :'String',
74
+ :'account_name' => :'String',
75
+ :'payee_name' => :'String',
76
+ :'category_name' => :'String'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([
83
+ :'parent_transaction_id',
84
+ :'payee_name',
85
+ ])
86
+ end
87
+
88
+ # Initializes the object
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ def initialize(attributes = {})
91
+ if (!attributes.is_a?(Hash))
92
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::HybridTransactionAllOf` initialize method"
93
+ end
94
+
95
+ # check to see if the attribute exists and convert string to symbol for hash key
96
+ attributes = attributes.each_with_object({}) { |(k, v), h|
97
+ if (!self.class.attribute_map.key?(k.to_sym))
98
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::HybridTransactionAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
99
+ end
100
+ h[k.to_sym] = v
101
+ }
102
+
103
+ if attributes.key?(:'type')
104
+ self.type = attributes[:'type']
105
+ end
106
+
107
+ if attributes.key?(:'parent_transaction_id')
108
+ self.parent_transaction_id = attributes[:'parent_transaction_id']
109
+ end
110
+
111
+ if attributes.key?(:'account_name')
112
+ self.account_name = attributes[:'account_name']
113
+ end
114
+
115
+ if attributes.key?(:'payee_name')
116
+ self.payee_name = attributes[:'payee_name']
117
+ end
118
+
119
+ if attributes.key?(:'category_name')
120
+ self.category_name = attributes[:'category_name']
121
+ end
122
+ end
123
+
124
+ # Show invalid properties with the reasons. Usually used together with valid?
125
+ # @return Array for valid properties with the reasons
126
+ def list_invalid_properties
127
+ invalid_properties = Array.new
128
+ if @type.nil?
129
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
130
+ end
131
+
132
+ if @account_name.nil?
133
+ invalid_properties.push('invalid value for "account_name", account_name cannot be nil.')
134
+ end
135
+
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ return false if @type.nil?
143
+ type_validator = EnumAttributeValidator.new('String', ["transaction", "subtransaction"])
144
+ return false unless type_validator.valid?(@type)
145
+ return false if @account_name.nil?
146
+ true
147
+ end
148
+
149
+ # Custom attribute writer method checking allowed values (enum).
150
+ # @param [Object] type Object to be assigned
151
+ def type=(type)
152
+ validator = EnumAttributeValidator.new('String', ["transaction", "subtransaction"])
153
+ unless validator.valid?(type)
154
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
155
+ end
156
+ @type = type
157
+ end
158
+
159
+ # Checks equality by comparing each attribute.
160
+ # @param [Object] Object to be compared
161
+ def ==(o)
162
+ return true if self.equal?(o)
163
+ self.class == o.class &&
164
+ type == o.type &&
165
+ parent_transaction_id == o.parent_transaction_id &&
166
+ account_name == o.account_name &&
167
+ payee_name == o.payee_name &&
168
+ category_name == o.category_name
169
+ end
170
+
171
+ # @see the `==` method
172
+ # @param [Object] Object to be compared
173
+ def eql?(o)
174
+ self == o
175
+ end
176
+
177
+ # Calculates hash code according to all attributes.
178
+ # @return [Integer] Hash code
179
+ def hash
180
+ [type, parent_transaction_id, account_name, payee_name, category_name].hash
181
+ end
182
+
183
+ # Builds the object from hash
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ # @return [Object] Returns the model itself
186
+ def self.build_from_hash(attributes)
187
+ new.build_from_hash(attributes)
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def build_from_hash(attributes)
194
+ return nil unless attributes.is_a?(Hash)
195
+ attributes = attributes.transform_keys(&:to_sym)
196
+ self.class.openapi_types.each_pair do |key, type|
197
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
198
+ self.send("#{key}=", nil)
199
+ elsif type =~ /\AArray<(.*)>/i
200
+ # check to ensure the input is an array given that the attribute
201
+ # is documented as an array but the input is not
202
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
203
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
204
+ end
205
+ elsif !attributes[self.class.attribute_map[key]].nil?
206
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
207
+ end
208
+ end
209
+
210
+ self
211
+ end
212
+
213
+ # Deserializes the data based on type
214
+ # @param string type Data type
215
+ # @param string value Value to be deserialized
216
+ # @return [Object] Deserialized data
217
+ def _deserialize(type, value)
218
+ case type.to_sym
219
+ when :Time
220
+ Time.parse(value)
221
+ when :Date
222
+ Date.parse(value)
223
+ when :String
224
+ value.to_s
225
+ when :Integer
226
+ value.to_i
227
+ when :Float
228
+ value.to_f
229
+ when :Boolean
230
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
231
+ true
232
+ else
233
+ false
234
+ end
235
+ when :Object
236
+ # generic object (usually a Hash), return directly
237
+ value
238
+ when /\AArray<(?<inner_type>.+)>\z/
239
+ inner_type = Regexp.last_match[:inner_type]
240
+ value.map { |v| _deserialize(inner_type, v) }
241
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
242
+ k_type = Regexp.last_match[:k_type]
243
+ v_type = Regexp.last_match[:v_type]
244
+ {}.tap do |hash|
245
+ value.each do |k, v|
246
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
247
+ end
248
+ end
249
+ else # model
250
+ # models (e.g. Pet) or oneOf
251
+ klass = YNAB.const_get(type)
252
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ # Returns the object in the form of hash
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_hash
271
+ hash = {}
272
+ self.class.attribute_map.each_pair do |attr, param|
273
+ value = self.send(attr)
274
+ if value.nil?
275
+ is_nullable = self.class.openapi_nullable.include?(attr)
276
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
277
+ end
278
+
279
+ hash[param] = _to_hash(value)
280
+ end
281
+ hash
282
+ end
283
+
284
+ # Outputs non-array value in the form of hash
285
+ # For object, use to_hash. Otherwise, just return the value
286
+ # @param [Object] value Any valid value
287
+ # @return [Hash] Returns the value in the form of hash
288
+ def _to_hash(value)
289
+ if value.is_a?(Array)
290
+ value.compact.map { |v| _to_hash(v) }
291
+ elsif value.is_a?(Hash)
292
+ {}.tap do |hash|
293
+ value.each { |k, v| hash[k] = _to_hash(v) }
294
+ end
295
+ elsif value.respond_to? :to_hash
296
+ value.to_hash
297
+ else
298
+ value
299
+ end
300
+ end
301
+
302
+ end
303
+
304
+ end