ynab 1.31.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 +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 +194 -87
  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 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
@@ -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 TransactionDetail
@@ -123,15 +124,20 @@ module YNAB
123
124
  }
124
125
  end
125
126
 
127
+ # Returns all the JSON keys this model knows about
128
+ def self.acceptable_attributes
129
+ attribute_map.values
130
+ end
131
+
126
132
  # Attribute type mapping.
127
- def self.swagger_types
133
+ def self.openapi_types
128
134
  {
129
135
  :'id' => :'String',
130
136
  :'date' => :'Date',
131
137
  :'amount' => :'Integer',
132
138
  :'memo' => :'String',
133
139
  :'cleared' => :'String',
134
- :'approved' => :'BOOLEAN',
140
+ :'approved' => :'Boolean',
135
141
  :'flag_color' => :'String',
136
142
  :'account_id' => :'String',
137
143
  :'payee_id' => :'String',
@@ -143,7 +149,7 @@ module YNAB
143
149
  :'import_payee_name' => :'String',
144
150
  :'import_payee_name_original' => :'String',
145
151
  :'debt_transaction_type' => :'String',
146
- :'deleted' => :'BOOLEAN',
152
+ :'deleted' => :'Boolean',
147
153
  :'account_name' => :'String',
148
154
  :'payee_name' => :'String',
149
155
  :'category_name' => :'String',
@@ -151,99 +157,133 @@ module YNAB
151
157
  }
152
158
  end
153
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
+
154
187
  # Initializes the object
155
188
  # @param [Hash] attributes Model attributes in the form of hash
156
189
  def initialize(attributes = {})
157
- 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
158
193
 
159
- # convert string to symbol for hash key
160
- 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
+ }
161
201
 
162
- if attributes.has_key?(:'id')
202
+ if attributes.key?(:'id')
163
203
  self.id = attributes[:'id']
164
204
  end
165
205
 
166
- if attributes.has_key?(:'date')
206
+ if attributes.key?(:'date')
167
207
  self.date = attributes[:'date']
168
208
  end
169
209
 
170
- if attributes.has_key?(:'amount')
210
+ if attributes.key?(:'amount')
171
211
  self.amount = attributes[:'amount']
172
212
  end
173
213
 
174
- if attributes.has_key?(:'memo')
214
+ if attributes.key?(:'memo')
175
215
  self.memo = attributes[:'memo']
176
216
  end
177
217
 
178
- if attributes.has_key?(:'cleared')
218
+ if attributes.key?(:'cleared')
179
219
  self.cleared = attributes[:'cleared']
180
220
  end
181
221
 
182
- if attributes.has_key?(:'approved')
222
+ if attributes.key?(:'approved')
183
223
  self.approved = attributes[:'approved']
184
224
  end
185
225
 
186
- if attributes.has_key?(:'flag_color')
226
+ if attributes.key?(:'flag_color')
187
227
  self.flag_color = attributes[:'flag_color']
188
228
  end
189
229
 
190
- if attributes.has_key?(:'account_id')
230
+ if attributes.key?(:'account_id')
191
231
  self.account_id = attributes[:'account_id']
192
232
  end
193
233
 
194
- if attributes.has_key?(:'payee_id')
234
+ if attributes.key?(:'payee_id')
195
235
  self.payee_id = attributes[:'payee_id']
196
236
  end
197
237
 
198
- if attributes.has_key?(:'category_id')
238
+ if attributes.key?(:'category_id')
199
239
  self.category_id = attributes[:'category_id']
200
240
  end
201
241
 
202
- if attributes.has_key?(:'transfer_account_id')
242
+ if attributes.key?(:'transfer_account_id')
203
243
  self.transfer_account_id = attributes[:'transfer_account_id']
204
244
  end
205
245
 
206
- if attributes.has_key?(:'transfer_transaction_id')
246
+ if attributes.key?(:'transfer_transaction_id')
207
247
  self.transfer_transaction_id = attributes[:'transfer_transaction_id']
208
248
  end
209
249
 
210
- if attributes.has_key?(:'matched_transaction_id')
250
+ if attributes.key?(:'matched_transaction_id')
211
251
  self.matched_transaction_id = attributes[:'matched_transaction_id']
212
252
  end
213
253
 
214
- if attributes.has_key?(:'import_id')
254
+ if attributes.key?(:'import_id')
215
255
  self.import_id = attributes[:'import_id']
216
256
  end
217
257
 
218
- if attributes.has_key?(:'import_payee_name')
258
+ if attributes.key?(:'import_payee_name')
219
259
  self.import_payee_name = attributes[:'import_payee_name']
220
260
  end
221
261
 
222
- if attributes.has_key?(:'import_payee_name_original')
262
+ if attributes.key?(:'import_payee_name_original')
223
263
  self.import_payee_name_original = attributes[:'import_payee_name_original']
224
264
  end
225
265
 
226
- if attributes.has_key?(:'debt_transaction_type')
266
+ if attributes.key?(:'debt_transaction_type')
227
267
  self.debt_transaction_type = attributes[:'debt_transaction_type']
228
268
  end
229
269
 
230
- if attributes.has_key?(:'deleted')
270
+ if attributes.key?(:'deleted')
231
271
  self.deleted = attributes[:'deleted']
232
272
  end
233
273
 
234
- if attributes.has_key?(:'account_name')
274
+ if attributes.key?(:'account_name')
235
275
  self.account_name = attributes[:'account_name']
236
276
  end
237
277
 
238
- if attributes.has_key?(:'payee_name')
278
+ if attributes.key?(:'payee_name')
239
279
  self.payee_name = attributes[:'payee_name']
240
280
  end
241
281
 
242
- if attributes.has_key?(:'category_name')
282
+ if attributes.key?(:'category_name')
243
283
  self.category_name = attributes[:'category_name']
244
284
  end
245
285
 
246
- if attributes.has_key?(:'subtransactions')
286
+ if attributes.key?(:'subtransactions')
247
287
  if (value = attributes[:'subtransactions']).is_a?(Array)
248
288
  self.subtransactions = value
249
289
  end
@@ -300,13 +340,13 @@ module YNAB
300
340
  return false if @date.nil?
301
341
  return false if @amount.nil?
302
342
  return false if @cleared.nil?
303
- cleared_validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
343
+ cleared_validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
304
344
  return false unless cleared_validator.valid?(@cleared)
305
345
  return false if @approved.nil?
306
- 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"])
307
347
  return false unless flag_color_validator.valid?(@flag_color)
308
348
  return false if @account_id.nil?
309
- 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"])
310
350
  return false unless debt_transaction_type_validator.valid?(@debt_transaction_type)
311
351
  return false if @deleted.nil?
312
352
  return false if @account_name.nil?
@@ -317,18 +357,30 @@ module YNAB
317
357
  # Custom attribute writer method checking allowed values (enum).
318
358
  # @param [Object] cleared Object to be assigned
319
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
320
364
  @cleared = cleared
321
365
  end
322
366
 
323
367
  # Custom attribute writer method checking allowed values (enum).
324
368
  # @param [Object] flag_color Object to be assigned
325
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
326
374
  @flag_color = flag_color
327
375
  end
328
376
 
329
377
  # Custom attribute writer method checking allowed values (enum).
330
378
  # @param [Object] debt_transaction_type Object to be assigned
331
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
332
384
  @debt_transaction_type = debt_transaction_type
333
385
  end
334
386
 
@@ -368,17 +420,28 @@ module YNAB
368
420
  end
369
421
 
370
422
  # Calculates hash code according to all attributes.
371
- # @return [Fixnum] Hash code
423
+ # @return [Integer] Hash code
372
424
  def hash
373
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
374
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
+
375
435
  # Builds the object from hash
376
436
  # @param [Hash] attributes Model attributes in the form of hash
377
437
  # @return [Object] Returns the model itself
378
438
  def build_from_hash(attributes)
379
439
  return nil unless attributes.is_a?(Hash)
380
- self.class.swagger_types.each_pair do |key, type|
381
- 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
382
445
  # check to ensure the input is an array given that the attribute
383
446
  # is documented as an array but the input is not
384
447
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -386,7 +449,7 @@ module YNAB
386
449
  end
387
450
  elsif !attributes[self.class.attribute_map[key]].nil?
388
451
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
389
- end # or else data not found in attributes(hash), not an issue as the data can be optional
452
+ end
390
453
  end
391
454
 
392
455
  self
@@ -398,8 +461,8 @@ module YNAB
398
461
  # @return [Object] Deserialized data
399
462
  def _deserialize(type, value)
400
463
  case type.to_sym
401
- when :DateTime
402
- DateTime.parse(value)
464
+ when :Time
465
+ Time.parse(value)
403
466
  when :Date
404
467
  Date.parse(value)
405
468
  when :String
@@ -408,7 +471,7 @@ module YNAB
408
471
  value.to_i
409
472
  when :Float
410
473
  value.to_f
411
- when :BOOLEAN
474
+ when :Boolean
412
475
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
413
476
  true
414
477
  else
@@ -429,8 +492,9 @@ module YNAB
429
492
  end
430
493
  end
431
494
  else # model
432
- temp_model = YNAB.const_get(type).new
433
- 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)
434
498
  end
435
499
  end
436
500
 
@@ -452,7 +516,11 @@ module YNAB
452
516
  hash = {}
453
517
  self.class.attribute_map.each_pair do |attr, param|
454
518
  value = self.send(attr)
455
- 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
+
456
524
  hash[param] = _to_hash(value)
457
525
  end
458
526
  hash