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 SubTransaction
@@ -57,8 +58,13 @@ module YNAB
57
58
  }
58
59
  end
59
60
 
61
+ # Returns all the JSON keys this model knows about
62
+ def self.acceptable_attributes
63
+ attribute_map.values
64
+ end
65
+
60
66
  # Attribute type mapping.
61
- def self.swagger_types
67
+ def self.openapi_types
62
68
  {
63
69
  :'id' => :'String',
64
70
  :'transaction_id' => :'String',
@@ -70,59 +76,79 @@ module YNAB
70
76
  :'category_name' => :'String',
71
77
  :'transfer_account_id' => :'String',
72
78
  :'transfer_transaction_id' => :'String',
73
- :'deleted' => :'BOOLEAN'
79
+ :'deleted' => :'Boolean'
74
80
  }
75
81
  end
76
82
 
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new([
86
+ :'memo',
87
+ :'payee_id',
88
+ :'payee_name',
89
+ :'category_id',
90
+ :'category_name',
91
+ :'transfer_account_id',
92
+ :'transfer_transaction_id',
93
+ ])
94
+ end
95
+
77
96
  # Initializes the object
78
97
  # @param [Hash] attributes Model attributes in the form of hash
79
98
  def initialize(attributes = {})
80
- return unless attributes.is_a?(Hash)
99
+ if (!attributes.is_a?(Hash))
100
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SubTransaction` initialize method"
101
+ end
81
102
 
82
- # convert string to symbol for hash key
83
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
103
+ # check to see if the attribute exists and convert string to symbol for hash key
104
+ attributes = attributes.each_with_object({}) { |(k, v), h|
105
+ if (!self.class.attribute_map.key?(k.to_sym))
106
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SubTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
107
+ end
108
+ h[k.to_sym] = v
109
+ }
84
110
 
85
- if attributes.has_key?(:'id')
111
+ if attributes.key?(:'id')
86
112
  self.id = attributes[:'id']
87
113
  end
88
114
 
89
- if attributes.has_key?(:'transaction_id')
115
+ if attributes.key?(:'transaction_id')
90
116
  self.transaction_id = attributes[:'transaction_id']
91
117
  end
92
118
 
93
- if attributes.has_key?(:'amount')
119
+ if attributes.key?(:'amount')
94
120
  self.amount = attributes[:'amount']
95
121
  end
96
122
 
97
- if attributes.has_key?(:'memo')
123
+ if attributes.key?(:'memo')
98
124
  self.memo = attributes[:'memo']
99
125
  end
100
126
 
101
- if attributes.has_key?(:'payee_id')
127
+ if attributes.key?(:'payee_id')
102
128
  self.payee_id = attributes[:'payee_id']
103
129
  end
104
130
 
105
- if attributes.has_key?(:'payee_name')
131
+ if attributes.key?(:'payee_name')
106
132
  self.payee_name = attributes[:'payee_name']
107
133
  end
108
134
 
109
- if attributes.has_key?(:'category_id')
135
+ if attributes.key?(:'category_id')
110
136
  self.category_id = attributes[:'category_id']
111
137
  end
112
138
 
113
- if attributes.has_key?(:'category_name')
139
+ if attributes.key?(:'category_name')
114
140
  self.category_name = attributes[:'category_name']
115
141
  end
116
142
 
117
- if attributes.has_key?(:'transfer_account_id')
143
+ if attributes.key?(:'transfer_account_id')
118
144
  self.transfer_account_id = attributes[:'transfer_account_id']
119
145
  end
120
146
 
121
- if attributes.has_key?(:'transfer_transaction_id')
147
+ if attributes.key?(:'transfer_transaction_id')
122
148
  self.transfer_transaction_id = attributes[:'transfer_transaction_id']
123
149
  end
124
150
 
125
- if attributes.has_key?(:'deleted')
151
+ if attributes.key?(:'deleted')
126
152
  self.deleted = attributes[:'deleted']
127
153
  end
128
154
  end
@@ -185,17 +211,28 @@ module YNAB
185
211
  end
186
212
 
187
213
  # Calculates hash code according to all attributes.
188
- # @return [Fixnum] Hash code
214
+ # @return [Integer] Hash code
189
215
  def hash
190
216
  [id, transaction_id, amount, memo, payee_id, payee_name, category_id, category_name, transfer_account_id, transfer_transaction_id, deleted].hash
191
217
  end
218
+
219
+ # Builds the object from hash
220
+ # @param [Hash] attributes Model attributes in the form of hash
221
+ # @return [Object] Returns the model itself
222
+ def self.build_from_hash(attributes)
223
+ new.build_from_hash(attributes)
224
+ end
225
+
192
226
  # Builds the object from hash
193
227
  # @param [Hash] attributes Model attributes in the form of hash
194
228
  # @return [Object] Returns the model itself
195
229
  def build_from_hash(attributes)
196
230
  return nil unless attributes.is_a?(Hash)
197
- self.class.swagger_types.each_pair do |key, type|
198
- if type =~ /\AArray<(.*)>/i
231
+ attributes = attributes.transform_keys(&:to_sym)
232
+ self.class.openapi_types.each_pair do |key, type|
233
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
234
+ self.send("#{key}=", nil)
235
+ elsif type =~ /\AArray<(.*)>/i
199
236
  # check to ensure the input is an array given that the attribute
200
237
  # is documented as an array but the input is not
201
238
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -203,7 +240,7 @@ module YNAB
203
240
  end
204
241
  elsif !attributes[self.class.attribute_map[key]].nil?
205
242
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
206
- end # or else data not found in attributes(hash), not an issue as the data can be optional
243
+ end
207
244
  end
208
245
 
209
246
  self
@@ -215,8 +252,8 @@ module YNAB
215
252
  # @return [Object] Deserialized data
216
253
  def _deserialize(type, value)
217
254
  case type.to_sym
218
- when :DateTime
219
- DateTime.parse(value)
255
+ when :Time
256
+ Time.parse(value)
220
257
  when :Date
221
258
  Date.parse(value)
222
259
  when :String
@@ -225,7 +262,7 @@ module YNAB
225
262
  value.to_i
226
263
  when :Float
227
264
  value.to_f
228
- when :BOOLEAN
265
+ when :Boolean
229
266
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
230
267
  true
231
268
  else
@@ -246,8 +283,9 @@ module YNAB
246
283
  end
247
284
  end
248
285
  else # model
249
- temp_model = YNAB.const_get(type).new
250
- temp_model.build_from_hash(value)
286
+ # models (e.g. Pet) or oneOf
287
+ klass = YNAB.const_get(type)
288
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
251
289
  end
252
290
  end
253
291
 
@@ -269,7 +307,11 @@ module YNAB
269
307
  hash = {}
270
308
  self.class.attribute_map.each_pair do |attr, param|
271
309
  value = self.send(attr)
272
- next if value.nil?
310
+ if value.nil?
311
+ is_nullable = self.class.openapi_nullable.include?(attr)
312
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
313
+ end
314
+
273
315
  hash[param] = _to_hash(value)
274
316
  end
275
317
  hash
@@ -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 TransactionDetail
@@ -67,6 +68,7 @@ module YNAB
67
68
 
68
69
  attr_accessor :payee_name
69
70
 
71
+ # The name of the category. If a split transaction, this will be 'Split'.
70
72
  attr_accessor :category_name
71
73
 
72
74
  # If a split transaction, the subtransactions.
@@ -122,15 +124,20 @@ module YNAB
122
124
  }
123
125
  end
124
126
 
127
+ # Returns all the JSON keys this model knows about
128
+ def self.acceptable_attributes
129
+ attribute_map.values
130
+ end
131
+
125
132
  # Attribute type mapping.
126
- def self.swagger_types
133
+ def self.openapi_types
127
134
  {
128
135
  :'id' => :'String',
129
136
  :'date' => :'Date',
130
137
  :'amount' => :'Integer',
131
138
  :'memo' => :'String',
132
139
  :'cleared' => :'String',
133
- :'approved' => :'BOOLEAN',
140
+ :'approved' => :'Boolean',
134
141
  :'flag_color' => :'String',
135
142
  :'account_id' => :'String',
136
143
  :'payee_id' => :'String',
@@ -142,7 +149,7 @@ module YNAB
142
149
  :'import_payee_name' => :'String',
143
150
  :'import_payee_name_original' => :'String',
144
151
  :'debt_transaction_type' => :'String',
145
- :'deleted' => :'BOOLEAN',
152
+ :'deleted' => :'Boolean',
146
153
  :'account_name' => :'String',
147
154
  :'payee_name' => :'String',
148
155
  :'category_name' => :'String',
@@ -150,99 +157,133 @@ module YNAB
150
157
  }
151
158
  end
152
159
 
160
+ # List of attributes with nullable: true
161
+ def self.openapi_nullable
162
+ Set.new([
163
+ :'memo',
164
+ :'flag_color',
165
+ :'payee_id',
166
+ :'category_id',
167
+ :'transfer_account_id',
168
+ :'transfer_transaction_id',
169
+ :'matched_transaction_id',
170
+ :'import_id',
171
+ :'import_payee_name',
172
+ :'import_payee_name_original',
173
+ :'debt_transaction_type',
174
+ :'payee_name',
175
+ :'category_name',
176
+ ])
177
+ end
178
+
179
+ # List of class defined in allOf (OpenAPI v3)
180
+ def self.openapi_all_of
181
+ [
182
+ :'TransactionDetailAllOf',
183
+ :'TransactionSummary'
184
+ ]
185
+ end
186
+
153
187
  # Initializes the object
154
188
  # @param [Hash] attributes Model attributes in the form of hash
155
189
  def initialize(attributes = {})
156
- return unless attributes.is_a?(Hash)
190
+ if (!attributes.is_a?(Hash))
191
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::TransactionDetail` initialize method"
192
+ end
157
193
 
158
- # convert string to symbol for hash key
159
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
194
+ # check to see if the attribute exists and convert string to symbol for hash key
195
+ attributes = attributes.each_with_object({}) { |(k, v), h|
196
+ if (!self.class.attribute_map.key?(k.to_sym))
197
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::TransactionDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
198
+ end
199
+ h[k.to_sym] = v
200
+ }
160
201
 
161
- if attributes.has_key?(:'id')
202
+ if attributes.key?(:'id')
162
203
  self.id = attributes[:'id']
163
204
  end
164
205
 
165
- if attributes.has_key?(:'date')
206
+ if attributes.key?(:'date')
166
207
  self.date = attributes[:'date']
167
208
  end
168
209
 
169
- if attributes.has_key?(:'amount')
210
+ if attributes.key?(:'amount')
170
211
  self.amount = attributes[:'amount']
171
212
  end
172
213
 
173
- if attributes.has_key?(:'memo')
214
+ if attributes.key?(:'memo')
174
215
  self.memo = attributes[:'memo']
175
216
  end
176
217
 
177
- if attributes.has_key?(:'cleared')
218
+ if attributes.key?(:'cleared')
178
219
  self.cleared = attributes[:'cleared']
179
220
  end
180
221
 
181
- if attributes.has_key?(:'approved')
222
+ if attributes.key?(:'approved')
182
223
  self.approved = attributes[:'approved']
183
224
  end
184
225
 
185
- if attributes.has_key?(:'flag_color')
226
+ if attributes.key?(:'flag_color')
186
227
  self.flag_color = attributes[:'flag_color']
187
228
  end
188
229
 
189
- if attributes.has_key?(:'account_id')
230
+ if attributes.key?(:'account_id')
190
231
  self.account_id = attributes[:'account_id']
191
232
  end
192
233
 
193
- if attributes.has_key?(:'payee_id')
234
+ if attributes.key?(:'payee_id')
194
235
  self.payee_id = attributes[:'payee_id']
195
236
  end
196
237
 
197
- if attributes.has_key?(:'category_id')
238
+ if attributes.key?(:'category_id')
198
239
  self.category_id = attributes[:'category_id']
199
240
  end
200
241
 
201
- if attributes.has_key?(:'transfer_account_id')
242
+ if attributes.key?(:'transfer_account_id')
202
243
  self.transfer_account_id = attributes[:'transfer_account_id']
203
244
  end
204
245
 
205
- if attributes.has_key?(:'transfer_transaction_id')
246
+ if attributes.key?(:'transfer_transaction_id')
206
247
  self.transfer_transaction_id = attributes[:'transfer_transaction_id']
207
248
  end
208
249
 
209
- if attributes.has_key?(:'matched_transaction_id')
250
+ if attributes.key?(:'matched_transaction_id')
210
251
  self.matched_transaction_id = attributes[:'matched_transaction_id']
211
252
  end
212
253
 
213
- if attributes.has_key?(:'import_id')
254
+ if attributes.key?(:'import_id')
214
255
  self.import_id = attributes[:'import_id']
215
256
  end
216
257
 
217
- if attributes.has_key?(:'import_payee_name')
258
+ if attributes.key?(:'import_payee_name')
218
259
  self.import_payee_name = attributes[:'import_payee_name']
219
260
  end
220
261
 
221
- if attributes.has_key?(:'import_payee_name_original')
262
+ if attributes.key?(:'import_payee_name_original')
222
263
  self.import_payee_name_original = attributes[:'import_payee_name_original']
223
264
  end
224
265
 
225
- if attributes.has_key?(:'debt_transaction_type')
266
+ if attributes.key?(:'debt_transaction_type')
226
267
  self.debt_transaction_type = attributes[:'debt_transaction_type']
227
268
  end
228
269
 
229
- if attributes.has_key?(:'deleted')
270
+ if attributes.key?(:'deleted')
230
271
  self.deleted = attributes[:'deleted']
231
272
  end
232
273
 
233
- if attributes.has_key?(:'account_name')
274
+ if attributes.key?(:'account_name')
234
275
  self.account_name = attributes[:'account_name']
235
276
  end
236
277
 
237
- if attributes.has_key?(:'payee_name')
278
+ if attributes.key?(:'payee_name')
238
279
  self.payee_name = attributes[:'payee_name']
239
280
  end
240
281
 
241
- if attributes.has_key?(:'category_name')
282
+ if attributes.key?(:'category_name')
242
283
  self.category_name = attributes[:'category_name']
243
284
  end
244
285
 
245
- if attributes.has_key?(:'subtransactions')
286
+ if attributes.key?(:'subtransactions')
246
287
  if (value = attributes[:'subtransactions']).is_a?(Array)
247
288
  self.subtransactions = value
248
289
  end
@@ -299,13 +340,13 @@ module YNAB
299
340
  return false if @date.nil?
300
341
  return false if @amount.nil?
301
342
  return false if @cleared.nil?
302
- cleared_validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
343
+ cleared_validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
303
344
  return false unless cleared_validator.valid?(@cleared)
304
345
  return false if @approved.nil?
305
- flag_color_validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
346
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple", "null"])
306
347
  return false unless flag_color_validator.valid?(@flag_color)
307
348
  return false if @account_id.nil?
308
- debt_transaction_type_validator = EnumAttributeValidator.new('String', ['payment', 'refund', 'fee', 'interest', 'escrow', 'balancedAdjustment', 'credit', 'charge'])
349
+ debt_transaction_type_validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balancedAdjustment", "credit", "charge", "null"])
309
350
  return false unless debt_transaction_type_validator.valid?(@debt_transaction_type)
310
351
  return false if @deleted.nil?
311
352
  return false if @account_name.nil?
@@ -316,18 +357,30 @@ module YNAB
316
357
  # Custom attribute writer method checking allowed values (enum).
317
358
  # @param [Object] cleared Object to be assigned
318
359
  def cleared=(cleared)
360
+ validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
361
+ unless validator.valid?(cleared)
362
+ fail ArgumentError, "invalid value for \"cleared\", must be one of #{validator.allowable_values}."
363
+ end
319
364
  @cleared = cleared
320
365
  end
321
366
 
322
367
  # Custom attribute writer method checking allowed values (enum).
323
368
  # @param [Object] flag_color Object to be assigned
324
369
  def flag_color=(flag_color)
370
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple", "null"])
371
+ unless validator.valid?(flag_color)
372
+ fail ArgumentError, "invalid value for \"flag_color\", must be one of #{validator.allowable_values}."
373
+ end
325
374
  @flag_color = flag_color
326
375
  end
327
376
 
328
377
  # Custom attribute writer method checking allowed values (enum).
329
378
  # @param [Object] debt_transaction_type Object to be assigned
330
379
  def debt_transaction_type=(debt_transaction_type)
380
+ validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balancedAdjustment", "credit", "charge", "null"])
381
+ unless validator.valid?(debt_transaction_type)
382
+ fail ArgumentError, "invalid value for \"debt_transaction_type\", must be one of #{validator.allowable_values}."
383
+ end
331
384
  @debt_transaction_type = debt_transaction_type
332
385
  end
333
386
 
@@ -367,17 +420,28 @@ module YNAB
367
420
  end
368
421
 
369
422
  # Calculates hash code according to all attributes.
370
- # @return [Fixnum] Hash code
423
+ # @return [Integer] Hash code
371
424
  def hash
372
425
  [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, account_name, payee_name, category_name, subtransactions].hash
373
426
  end
427
+
428
+ # Builds the object from hash
429
+ # @param [Hash] attributes Model attributes in the form of hash
430
+ # @return [Object] Returns the model itself
431
+ def self.build_from_hash(attributes)
432
+ new.build_from_hash(attributes)
433
+ end
434
+
374
435
  # Builds the object from hash
375
436
  # @param [Hash] attributes Model attributes in the form of hash
376
437
  # @return [Object] Returns the model itself
377
438
  def build_from_hash(attributes)
378
439
  return nil unless attributes.is_a?(Hash)
379
- self.class.swagger_types.each_pair do |key, type|
380
- if type =~ /\AArray<(.*)>/i
440
+ attributes = attributes.transform_keys(&:to_sym)
441
+ self.class.openapi_types.each_pair do |key, type|
442
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
443
+ self.send("#{key}=", nil)
444
+ elsif type =~ /\AArray<(.*)>/i
381
445
  # check to ensure the input is an array given that the attribute
382
446
  # is documented as an array but the input is not
383
447
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -385,7 +449,7 @@ module YNAB
385
449
  end
386
450
  elsif !attributes[self.class.attribute_map[key]].nil?
387
451
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
388
- end # or else data not found in attributes(hash), not an issue as the data can be optional
452
+ end
389
453
  end
390
454
 
391
455
  self
@@ -397,8 +461,8 @@ module YNAB
397
461
  # @return [Object] Deserialized data
398
462
  def _deserialize(type, value)
399
463
  case type.to_sym
400
- when :DateTime
401
- DateTime.parse(value)
464
+ when :Time
465
+ Time.parse(value)
402
466
  when :Date
403
467
  Date.parse(value)
404
468
  when :String
@@ -407,7 +471,7 @@ module YNAB
407
471
  value.to_i
408
472
  when :Float
409
473
  value.to_f
410
- when :BOOLEAN
474
+ when :Boolean
411
475
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
412
476
  true
413
477
  else
@@ -428,8 +492,9 @@ module YNAB
428
492
  end
429
493
  end
430
494
  else # model
431
- temp_model = YNAB.const_get(type).new
432
- temp_model.build_from_hash(value)
495
+ # models (e.g. Pet) or oneOf
496
+ klass = YNAB.const_get(type)
497
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
433
498
  end
434
499
  end
435
500
 
@@ -451,7 +516,11 @@ module YNAB
451
516
  hash = {}
452
517
  self.class.attribute_map.each_pair do |attr, param|
453
518
  value = self.send(attr)
454
- next if value.nil?
519
+ if value.nil?
520
+ is_nullable = self.class.openapi_nullable.include?(attr)
521
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
522
+ end
523
+
455
524
  hash[param] = _to_hash(value)
456
525
  end
457
526
  hash