ynab 1.29.0 → 2.0.0.rc1

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 +6 -6
  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 +79 -42
  146. data/lib/ynab/api/budgets_api.rb +69 -37
  147. data/lib/ynab/api/categories_api.rb +109 -61
  148. data/lib/ynab/api/deprecated_api.rb +33 -18
  149. data/lib/ynab/api/months_api.rb +50 -29
  150. data/lib/ynab/api/payee_locations_api.rb +74 -42
  151. data/lib/ynab/api/payees_api.rb +50 -29
  152. data/lib/ynab/api/scheduled_transactions_api.rb +50 -29
  153. data/lib/ynab/api/transactions_api.rb +269 -141
  154. data/lib/ynab/api/user_api.rb +23 -13
  155. data/lib/ynab/api_client.rb +98 -96
  156. data/lib/ynab/configuration.rb +103 -16
  157. data/lib/ynab/models/account.rb +118 -56
  158. data/lib/ynab/models/account_response.rb +54 -19
  159. data/lib/ynab/models/account_response_data.rb +54 -19
  160. data/lib/ynab/models/account_type.rb +31 -21
  161. data/lib/ynab/models/accounts_response.rb +54 -19
  162. data/lib/ynab/models/accounts_response_data.rb +55 -20
  163. data/lib/ynab/models/budget_detail.rb +81 -36
  164. data/lib/ynab/models/budget_detail_all_of.rb +320 -0
  165. data/lib/ynab/models/budget_detail_response.rb +54 -19
  166. data/lib/ynab/models/budget_detail_response_data.rb +55 -20
  167. data/lib/ynab/models/budget_settings.rb +57 -30
  168. data/lib/ynab/models/budget_settings_response.rb +54 -19
  169. data/lib/ynab/models/budget_settings_response_data.rb +54 -19
  170. data/lib/ynab/models/budget_summary.rb +64 -27
  171. data/lib/ynab/models/budget_summary_response.rb +54 -19
  172. data/lib/ynab/models/budget_summary_response_data.rb +55 -21
  173. data/lib/ynab/models/bulk_response.rb +54 -19
  174. data/lib/ynab/models/bulk_response_data.rb +54 -19
  175. data/lib/ynab/models/bulk_response_data_bulk.rb +55 -20
  176. data/lib/ynab/models/bulk_transactions.rb +54 -19
  177. data/lib/ynab/models/categories_response.rb +54 -19
  178. data/lib/ynab/models/categories_response_data.rb +55 -20
  179. data/lib/ynab/models/category.rb +111 -49
  180. data/lib/ynab/models/category_group.rb +59 -24
  181. data/lib/ynab/models/category_group_with_categories.rb +68 -25
  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 +54 -19
  184. data/lib/ynab/models/category_response_data.rb +54 -19
  185. data/lib/ynab/models/currency_format.rb +63 -28
  186. data/lib/ynab/models/date_format.rb +54 -19
  187. data/lib/ynab/models/error_detail.rb +56 -21
  188. data/lib/ynab/models/error_response.rb +54 -19
  189. data/lib/ynab/models/hybrid_transaction.rb +120 -47
  190. data/lib/ynab/models/hybrid_transaction_all_of.rb +304 -0
  191. data/lib/ynab/models/hybrid_transactions_response.rb +54 -19
  192. data/lib/ynab/models/hybrid_transactions_response_data.rb +55 -20
  193. data/lib/ynab/models/month_detail.rb +73 -28
  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 +54 -19
  196. data/lib/ynab/models/month_detail_response_data.rb +54 -19
  197. data/lib/ynab/models/month_summaries_response.rb +54 -19
  198. data/lib/ynab/models/month_summaries_response_data.rb +55 -20
  199. data/lib/ynab/models/month_summary.rb +64 -27
  200. data/lib/ynab/models/patch_month_category_wrapper.rb +54 -19
  201. data/lib/ynab/models/patch_transactions_wrapper.rb +54 -19
  202. data/lib/ynab/models/payee.rb +59 -23
  203. data/lib/ynab/models/payee_location.rb +59 -24
  204. data/lib/ynab/models/payee_location_response.rb +54 -19
  205. data/lib/ynab/models/payee_location_response_data.rb +54 -19
  206. data/lib/ynab/models/payee_locations_response.rb +54 -19
  207. data/lib/ynab/models/payee_locations_response_data.rb +54 -19
  208. data/lib/ynab/models/payee_response.rb +54 -19
  209. data/lib/ynab/models/payee_response_data.rb +54 -19
  210. data/lib/ynab/models/payees_response.rb +54 -19
  211. data/lib/ynab/models/payees_response_data.rb +55 -20
  212. data/lib/ynab/models/post_account_wrapper.rb +54 -19
  213. data/lib/ynab/models/post_transactions_wrapper.rb +55 -20
  214. data/lib/ynab/models/put_transaction_wrapper.rb +54 -19
  215. data/lib/ynab/models/save_account.rb +78 -21
  216. data/lib/ynab/models/save_category_response.rb +54 -19
  217. data/lib/ynab/models/save_category_response_data.rb +55 -20
  218. data/lib/ynab/models/save_month_category.rb +54 -19
  219. data/lib/ynab/models/save_sub_transaction.rb +62 -23
  220. data/lib/ynab/models/save_transaction.rb +89 -34
  221. data/lib/ynab/models/save_transaction_with_id.rb +103 -47
  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 +82 -34
  224. data/lib/ynab/models/save_transactions_response.rb +54 -19
  225. data/lib/ynab/models/save_transactions_response_data.rb +58 -24
  226. data/lib/ynab/models/scheduled_sub_transaction.rb +67 -28
  227. data/lib/ynab/models/scheduled_transaction_detail.rb +96 -37
  228. data/lib/ynab/models/scheduled_transaction_detail_all_of.rb +262 -0
  229. data/lib/ynab/models/scheduled_transaction_response.rb +54 -19
  230. data/lib/ynab/models/scheduled_transaction_response_data.rb +54 -19
  231. data/lib/ynab/models/scheduled_transaction_summary.rb +81 -33
  232. data/lib/ynab/models/scheduled_transactions_response.rb +54 -19
  233. data/lib/ynab/models/scheduled_transactions_response_data.rb +55 -20
  234. data/lib/ynab/models/sub_transaction.rb +72 -30
  235. data/lib/ynab/models/transaction_detail.rb +114 -45
  236. data/lib/ynab/models/{save_transaction_wrapper.rb → transaction_detail_all_of.rb} +102 -29
  237. data/lib/ynab/models/transaction_response.rb +54 -19
  238. data/lib/ynab/models/transaction_response_data.rb +54 -19
  239. data/lib/ynab/models/transaction_summary.rb +99 -41
  240. data/lib/ynab/models/transactions_import_response.rb +54 -19
  241. data/lib/ynab/models/transactions_import_response_data.rb +54 -19
  242. data/lib/ynab/models/transactions_response.rb +54 -19
  243. data/lib/ynab/models/transactions_response_data.rb +55 -20
  244. data/lib/ynab/models/user.rb +54 -19
  245. data/lib/ynab/models/user_response.rb +54 -19
  246. data/lib/ynab/models/user_response_data.rb +54 -19
  247. data/lib/ynab/version.rb +1 -1
  248. data/lib/ynab.rb +21 -16
  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 +197 -90
  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
@@ -1,16 +1,17 @@
1
1
  =begin
2
2
  #YNAB API Endpoints
3
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.youneedabudget.com
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
@@ -73,6 +74,7 @@ module YNAB
73
74
 
74
75
  attr_accessor :payee_name
75
76
 
77
+ # The name of the category. If a split transaction, this will be 'Split'.
76
78
  attr_accessor :category_name
77
79
 
78
80
  class EnumAttributeValidator
@@ -126,15 +128,20 @@ module YNAB
126
128
  }
127
129
  end
128
130
 
131
+ # Returns all the JSON keys this model knows about
132
+ def self.acceptable_attributes
133
+ attribute_map.values
134
+ end
135
+
129
136
  # Attribute type mapping.
130
- def self.swagger_types
137
+ def self.openapi_types
131
138
  {
132
139
  :'id' => :'String',
133
140
  :'date' => :'Date',
134
141
  :'amount' => :'Integer',
135
142
  :'memo' => :'String',
136
143
  :'cleared' => :'String',
137
- :'approved' => :'BOOLEAN',
144
+ :'approved' => :'Boolean',
138
145
  :'flag_color' => :'String',
139
146
  :'account_id' => :'String',
140
147
  :'payee_id' => :'String',
@@ -146,7 +153,7 @@ module YNAB
146
153
  :'import_payee_name' => :'String',
147
154
  :'import_payee_name_original' => :'String',
148
155
  :'debt_transaction_type' => :'String',
149
- :'deleted' => :'BOOLEAN',
156
+ :'deleted' => :'Boolean',
150
157
  :'type' => :'String',
151
158
  :'parent_transaction_id' => :'String',
152
159
  :'account_name' => :'String',
@@ -155,103 +162,137 @@ module YNAB
155
162
  }
156
163
  end
157
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
+
158
192
  # Initializes the object
159
193
  # @param [Hash] attributes Model attributes in the form of hash
160
194
  def initialize(attributes = {})
161
- 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
162
198
 
163
- # convert string to symbol for hash key
164
- 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
+ }
165
206
 
166
- if attributes.has_key?(:'id')
207
+ if attributes.key?(:'id')
167
208
  self.id = attributes[:'id']
168
209
  end
169
210
 
170
- if attributes.has_key?(:'date')
211
+ if attributes.key?(:'date')
171
212
  self.date = attributes[:'date']
172
213
  end
173
214
 
174
- if attributes.has_key?(:'amount')
215
+ if attributes.key?(:'amount')
175
216
  self.amount = attributes[:'amount']
176
217
  end
177
218
 
178
- if attributes.has_key?(:'memo')
219
+ if attributes.key?(:'memo')
179
220
  self.memo = attributes[:'memo']
180
221
  end
181
222
 
182
- if attributes.has_key?(:'cleared')
223
+ if attributes.key?(:'cleared')
183
224
  self.cleared = attributes[:'cleared']
184
225
  end
185
226
 
186
- if attributes.has_key?(:'approved')
227
+ if attributes.key?(:'approved')
187
228
  self.approved = attributes[:'approved']
188
229
  end
189
230
 
190
- if attributes.has_key?(:'flag_color')
231
+ if attributes.key?(:'flag_color')
191
232
  self.flag_color = attributes[:'flag_color']
192
233
  end
193
234
 
194
- if attributes.has_key?(:'account_id')
235
+ if attributes.key?(:'account_id')
195
236
  self.account_id = attributes[:'account_id']
196
237
  end
197
238
 
198
- if attributes.has_key?(:'payee_id')
239
+ if attributes.key?(:'payee_id')
199
240
  self.payee_id = attributes[:'payee_id']
200
241
  end
201
242
 
202
- if attributes.has_key?(:'category_id')
243
+ if attributes.key?(:'category_id')
203
244
  self.category_id = attributes[:'category_id']
204
245
  end
205
246
 
206
- if attributes.has_key?(:'transfer_account_id')
247
+ if attributes.key?(:'transfer_account_id')
207
248
  self.transfer_account_id = attributes[:'transfer_account_id']
208
249
  end
209
250
 
210
- if attributes.has_key?(:'transfer_transaction_id')
251
+ if attributes.key?(:'transfer_transaction_id')
211
252
  self.transfer_transaction_id = attributes[:'transfer_transaction_id']
212
253
  end
213
254
 
214
- if attributes.has_key?(:'matched_transaction_id')
255
+ if attributes.key?(:'matched_transaction_id')
215
256
  self.matched_transaction_id = attributes[:'matched_transaction_id']
216
257
  end
217
258
 
218
- if attributes.has_key?(:'import_id')
259
+ if attributes.key?(:'import_id')
219
260
  self.import_id = attributes[:'import_id']
220
261
  end
221
262
 
222
- if attributes.has_key?(:'import_payee_name')
263
+ if attributes.key?(:'import_payee_name')
223
264
  self.import_payee_name = attributes[:'import_payee_name']
224
265
  end
225
266
 
226
- if attributes.has_key?(:'import_payee_name_original')
267
+ if attributes.key?(:'import_payee_name_original')
227
268
  self.import_payee_name_original = attributes[:'import_payee_name_original']
228
269
  end
229
270
 
230
- if attributes.has_key?(:'debt_transaction_type')
271
+ if attributes.key?(:'debt_transaction_type')
231
272
  self.debt_transaction_type = attributes[:'debt_transaction_type']
232
273
  end
233
274
 
234
- if attributes.has_key?(:'deleted')
275
+ if attributes.key?(:'deleted')
235
276
  self.deleted = attributes[:'deleted']
236
277
  end
237
278
 
238
- if attributes.has_key?(:'type')
279
+ if attributes.key?(:'type')
239
280
  self.type = attributes[:'type']
240
281
  end
241
282
 
242
- if attributes.has_key?(:'parent_transaction_id')
283
+ if attributes.key?(:'parent_transaction_id')
243
284
  self.parent_transaction_id = attributes[:'parent_transaction_id']
244
285
  end
245
286
 
246
- if attributes.has_key?(:'account_name')
287
+ if attributes.key?(:'account_name')
247
288
  self.account_name = attributes[:'account_name']
248
289
  end
249
290
 
250
- if attributes.has_key?(:'payee_name')
291
+ if attributes.key?(:'payee_name')
251
292
  self.payee_name = attributes[:'payee_name']
252
293
  end
253
294
 
254
- if attributes.has_key?(:'category_name')
295
+ if attributes.key?(:'category_name')
255
296
  self.category_name = attributes[:'category_name']
256
297
  end
257
298
  end
@@ -306,17 +347,17 @@ module YNAB
306
347
  return false if @date.nil?
307
348
  return false if @amount.nil?
308
349
  return false if @cleared.nil?
309
- cleared_validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
350
+ cleared_validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
310
351
  return false unless cleared_validator.valid?(@cleared)
311
352
  return false if @approved.nil?
312
- 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"])
313
354
  return false unless flag_color_validator.valid?(@flag_color)
314
355
  return false if @account_id.nil?
315
- 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"])
316
357
  return false unless debt_transaction_type_validator.valid?(@debt_transaction_type)
317
358
  return false if @deleted.nil?
318
359
  return false if @type.nil?
319
- type_validator = EnumAttributeValidator.new('String', ['transaction', 'subtransaction'])
360
+ type_validator = EnumAttributeValidator.new('String', ["transaction", "subtransaction"])
320
361
  return false unless type_validator.valid?(@type)
321
362
  return false if @account_name.nil?
322
363
  true
@@ -325,24 +366,40 @@ module YNAB
325
366
  # Custom attribute writer method checking allowed values (enum).
326
367
  # @param [Object] cleared Object to be assigned
327
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
328
373
  @cleared = cleared
329
374
  end
330
375
 
331
376
  # Custom attribute writer method checking allowed values (enum).
332
377
  # @param [Object] flag_color Object to be assigned
333
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
334
383
  @flag_color = flag_color
335
384
  end
336
385
 
337
386
  # Custom attribute writer method checking allowed values (enum).
338
387
  # @param [Object] debt_transaction_type Object to be assigned
339
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
340
393
  @debt_transaction_type = debt_transaction_type
341
394
  end
342
395
 
343
396
  # Custom attribute writer method checking allowed values (enum).
344
397
  # @param [Object] type Object to be assigned
345
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
346
403
  @type = type
347
404
  end
348
405
 
@@ -383,17 +440,28 @@ module YNAB
383
440
  end
384
441
 
385
442
  # Calculates hash code according to all attributes.
386
- # @return [Fixnum] Hash code
443
+ # @return [Integer] Hash code
387
444
  def hash
388
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
389
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
+
390
455
  # Builds the object from hash
391
456
  # @param [Hash] attributes Model attributes in the form of hash
392
457
  # @return [Object] Returns the model itself
393
458
  def build_from_hash(attributes)
394
459
  return nil unless attributes.is_a?(Hash)
395
- self.class.swagger_types.each_pair do |key, type|
396
- 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
397
465
  # check to ensure the input is an array given that the attribute
398
466
  # is documented as an array but the input is not
399
467
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -401,7 +469,7 @@ module YNAB
401
469
  end
402
470
  elsif !attributes[self.class.attribute_map[key]].nil?
403
471
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
404
- end # or else data not found in attributes(hash), not an issue as the data can be optional
472
+ end
405
473
  end
406
474
 
407
475
  self
@@ -413,8 +481,8 @@ module YNAB
413
481
  # @return [Object] Deserialized data
414
482
  def _deserialize(type, value)
415
483
  case type.to_sym
416
- when :DateTime
417
- DateTime.parse(value)
484
+ when :Time
485
+ Time.parse(value)
418
486
  when :Date
419
487
  Date.parse(value)
420
488
  when :String
@@ -423,7 +491,7 @@ module YNAB
423
491
  value.to_i
424
492
  when :Float
425
493
  value.to_f
426
- when :BOOLEAN
494
+ when :Boolean
427
495
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
428
496
  true
429
497
  else
@@ -444,8 +512,9 @@ module YNAB
444
512
  end
445
513
  end
446
514
  else # model
447
- temp_model = YNAB.const_get(type).new
448
- 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)
449
518
  end
450
519
  end
451
520
 
@@ -467,7 +536,11 @@ module YNAB
467
536
  hash = {}
468
537
  self.class.attribute_map.each_pair do |attr, param|
469
538
  value = self.send(attr)
470
- 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
+
471
544
  hash[param] = _to_hash(value)
472
545
  end
473
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