ynab 1.31.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/DEVELOPMENT.md +11 -0
  3. data/Gemfile +8 -0
  4. data/Gemfile.lock +42 -0
  5. data/README.md +3 -3
  6. data/Rakefile +58 -0
  7. data/config.json +9 -0
  8. data/docs/Account.md +25 -0
  9. data/docs/AccountResponse.md +8 -0
  10. data/docs/AccountResponseData.md +8 -0
  11. data/docs/AccountType.md +7 -0
  12. data/docs/AccountWrapper.md +8 -0
  13. data/docs/AccountsApi.md +70 -0
  14. data/docs/AccountsResponse.md +8 -0
  15. data/docs/AccountsResponseData.md +9 -0
  16. data/docs/AccountsWrapper.md +9 -0
  17. data/docs/BudgetDetail.md +24 -0
  18. data/docs/BudgetDetailAllOf.md +17 -0
  19. data/docs/BudgetDetailResponse.md +8 -0
  20. data/docs/BudgetDetailResponseData.md +9 -0
  21. data/docs/BudgetDetailWrapper.md +9 -0
  22. data/docs/BudgetSettings.md +9 -0
  23. data/docs/BudgetSettingsResponse.md +8 -0
  24. data/docs/BudgetSettingsResponseData.md +8 -0
  25. data/docs/BudgetSettingsWrapper.md +8 -0
  26. data/docs/BudgetSummary.md +15 -0
  27. data/docs/BudgetSummaryResponse.md +8 -0
  28. data/docs/BudgetSummaryResponseData.md +9 -0
  29. data/docs/BudgetSummaryWrapper.md +9 -0
  30. data/docs/BudgetsApi.md +68 -0
  31. data/docs/BulkIdWrapper.md +8 -0
  32. data/docs/BulkIds.md +9 -0
  33. data/docs/BulkResponse.md +8 -0
  34. data/docs/BulkResponseData.md +8 -0
  35. data/docs/BulkResponseDataBulk.md +9 -0
  36. data/docs/BulkTransactionCreateResponse.md +8 -0
  37. data/docs/BulkTransactionIds.md +8 -0
  38. data/docs/BulkTransactions.md +8 -0
  39. data/docs/CategoriesApi.md +94 -0
  40. data/docs/CategoriesResponse.md +8 -0
  41. data/docs/CategoriesResponseData.md +9 -0
  42. data/docs/Category.md +30 -0
  43. data/docs/CategoryGroup.md +11 -0
  44. data/docs/CategoryGroupWithCategories.md +12 -0
  45. data/docs/CategoryGroupWithCategoriesAllOf.md +8 -0
  46. data/docs/CategoryGroupsWrapper.md +9 -0
  47. data/docs/CategoryResponse.md +8 -0
  48. data/docs/CategoryResponseData.md +8 -0
  49. data/docs/CategoryWrapper.md +9 -0
  50. data/docs/CurrencyFormat.md +15 -0
  51. data/docs/DateFormat.md +8 -0
  52. data/docs/DeprecatedApi.md +28 -0
  53. data/docs/ErrorDetail.md +10 -0
  54. data/docs/ErrorResponse.md +8 -0
  55. data/docs/HybridTransaction.md +30 -0
  56. data/docs/HybridTransactionAllOf.md +12 -0
  57. data/docs/HybridTransactionsResponse.md +8 -0
  58. data/docs/HybridTransactionsResponseData.md +9 -0
  59. data/docs/HybridTransactionsWrapper.md +8 -0
  60. data/docs/LoanAccountPeriodicValue.md +7 -0
  61. data/docs/MonthDetail.md +16 -0
  62. data/docs/MonthDetailAllOf.md +8 -0
  63. data/docs/MonthDetailResponse.md +8 -0
  64. data/docs/MonthDetailResponseData.md +8 -0
  65. data/docs/MonthDetailWrapper.md +8 -0
  66. data/docs/MonthSummariesResponse.md +8 -0
  67. data/docs/MonthSummariesResponseData.md +9 -0
  68. data/docs/MonthSummariesWrapper.md +9 -0
  69. data/docs/MonthSummary.md +15 -0
  70. data/docs/MonthsApi.md +49 -0
  71. data/docs/PatchMonthCategoryWrapper.md +8 -0
  72. data/docs/PatchTransactionsWrapper.md +8 -0
  73. data/docs/Payee.md +11 -0
  74. data/docs/PayeeLocation.md +12 -0
  75. data/docs/PayeeLocationResponse.md +8 -0
  76. data/docs/PayeeLocationResponseData.md +8 -0
  77. data/docs/PayeeLocationWrapper.md +8 -0
  78. data/docs/PayeeLocationsApi.md +69 -0
  79. data/docs/PayeeLocationsResponse.md +8 -0
  80. data/docs/PayeeLocationsResponseData.md +8 -0
  81. data/docs/PayeeLocationsWrapper.md +8 -0
  82. data/docs/PayeeResponse.md +8 -0
  83. data/docs/PayeeResponseData.md +8 -0
  84. data/docs/PayeeWrapper.md +8 -0
  85. data/docs/PayeesApi.md +49 -0
  86. data/docs/PayeesResponse.md +8 -0
  87. data/docs/PayeesResponseData.md +9 -0
  88. data/docs/PayeesWrapper.md +9 -0
  89. data/docs/PostAccountWrapper.md +8 -0
  90. data/docs/PostTransactionsWrapper.md +9 -0
  91. data/docs/PutTransactionWrapper.md +8 -0
  92. data/docs/SaveAccount.md +10 -0
  93. data/docs/SaveAccountWrapper.md +8 -0
  94. data/docs/SaveCategoryResponse.md +8 -0
  95. data/docs/SaveCategoryResponseData.md +9 -0
  96. data/docs/SaveMonthCategory.md +8 -0
  97. data/docs/SaveMonthCategoryWrapper.md +8 -0
  98. data/docs/SaveSubTransaction.md +12 -0
  99. data/docs/SaveTransaction.md +19 -0
  100. data/docs/SaveTransactionWithId.md +20 -0
  101. data/docs/SaveTransactionWithIdAllOf.md +8 -0
  102. data/docs/SaveTransactionWithOptionalFields.md +19 -0
  103. data/docs/SaveTransactionWrapper.md +8 -0
  104. data/docs/SaveTransactionsResponse.md +8 -0
  105. data/docs/SaveTransactionsResponseData.md +12 -0
  106. data/docs/SaveTransactionsWrapper.md +9 -0
  107. data/docs/ScheduledSubTransaction.md +15 -0
  108. data/docs/ScheduledTransactionDetail.md +23 -0
  109. data/docs/ScheduledTransactionDetailAllOf.md +11 -0
  110. data/docs/ScheduledTransactionResponse.md +8 -0
  111. data/docs/ScheduledTransactionResponseData.md +8 -0
  112. data/docs/ScheduledTransactionSummary.md +19 -0
  113. data/docs/ScheduledTransactionWrapper.md +8 -0
  114. data/docs/ScheduledTransactionsApi.md +49 -0
  115. data/docs/ScheduledTransactionsResponse.md +8 -0
  116. data/docs/ScheduledTransactionsResponseData.md +9 -0
  117. data/docs/ScheduledTransactionsWrapper.md +8 -0
  118. data/docs/SubTransaction.md +18 -0
  119. data/docs/TransactionDetail.md +29 -0
  120. data/docs/TransactionDetailAllOf.md +11 -0
  121. data/docs/TransactionResponse.md +8 -0
  122. data/docs/TransactionResponseData.md +8 -0
  123. data/docs/TransactionSummary.md +25 -0
  124. data/docs/TransactionWrapper.md +8 -0
  125. data/docs/TransactionsApi.md +228 -0
  126. data/docs/TransactionsImportResponse.md +8 -0
  127. data/docs/TransactionsImportResponseData.md +8 -0
  128. data/docs/TransactionsResponse.md +8 -0
  129. data/docs/TransactionsResponseData.md +9 -0
  130. data/docs/TransactionsWrapper.md +9 -0
  131. data/docs/UpdateTransaction.md +20 -0
  132. data/docs/UpdateTransactionsWrapper.md +8 -0
  133. data/docs/User.md +8 -0
  134. data/docs/UserApi.md +25 -0
  135. data/docs/UserResponse.md +8 -0
  136. data/docs/UserResponseData.md +8 -0
  137. data/docs/UserWrapper.md +8 -0
  138. data/examples/budget-list.rb +21 -0
  139. data/examples/budget-month.rb +33 -0
  140. data/examples/category-balance.rb +23 -0
  141. data/examples/create-multiple-transactions.rb +42 -0
  142. data/examples/create-transaction.rb +30 -0
  143. data/examples/update-category-budgeted.rb +25 -0
  144. data/examples/update-multiple-transactions.rb +20 -0
  145. data/lib/ynab/api/accounts_api.rb +78 -41
  146. data/lib/ynab/api/budgets_api.rb +68 -36
  147. data/lib/ynab/api/categories_api.rb +108 -60
  148. data/lib/ynab/api/deprecated_api.rb +32 -17
  149. data/lib/ynab/api/months_api.rb +49 -28
  150. data/lib/ynab/api/payee_locations_api.rb +73 -41
  151. data/lib/ynab/api/payees_api.rb +49 -28
  152. data/lib/ynab/api/scheduled_transactions_api.rb +49 -28
  153. data/lib/ynab/api/transactions_api.rb +268 -140
  154. data/lib/ynab/api/user_api.rb +22 -12
  155. data/lib/ynab/api_client.rb +97 -95
  156. data/lib/ynab/configuration.rb +101 -14
  157. data/lib/ynab/models/account.rb +117 -55
  158. data/lib/ynab/models/account_response.rb +53 -18
  159. data/lib/ynab/models/account_response_data.rb +53 -18
  160. data/lib/ynab/models/account_type.rb +30 -20
  161. data/lib/ynab/models/accounts_response.rb +53 -18
  162. data/lib/ynab/models/accounts_response_data.rb +54 -19
  163. data/lib/ynab/models/budget_detail.rb +80 -35
  164. data/lib/ynab/models/budget_detail_all_of.rb +320 -0
  165. data/lib/ynab/models/budget_detail_response.rb +53 -18
  166. data/lib/ynab/models/budget_detail_response_data.rb +54 -19
  167. data/lib/ynab/models/budget_settings.rb +56 -29
  168. data/lib/ynab/models/budget_settings_response.rb +53 -18
  169. data/lib/ynab/models/budget_settings_response_data.rb +53 -18
  170. data/lib/ynab/models/budget_summary.rb +63 -26
  171. data/lib/ynab/models/budget_summary_response.rb +53 -18
  172. data/lib/ynab/models/budget_summary_response_data.rb +54 -20
  173. data/lib/ynab/models/bulk_response.rb +53 -18
  174. data/lib/ynab/models/bulk_response_data.rb +53 -18
  175. data/lib/ynab/models/bulk_response_data_bulk.rb +54 -19
  176. data/lib/ynab/models/bulk_transactions.rb +53 -18
  177. data/lib/ynab/models/categories_response.rb +53 -18
  178. data/lib/ynab/models/categories_response_data.rb +54 -19
  179. data/lib/ynab/models/category.rb +110 -48
  180. data/lib/ynab/models/category_group.rb +58 -23
  181. data/lib/ynab/models/category_group_with_categories.rb +67 -24
  182. data/lib/ynab/models/{save_month_category_wrapper.rb → category_group_with_categories_all_of.rb} +67 -29
  183. data/lib/ynab/models/category_response.rb +53 -18
  184. data/lib/ynab/models/category_response_data.rb +53 -18
  185. data/lib/ynab/models/currency_format.rb +62 -27
  186. data/lib/ynab/models/date_format.rb +53 -18
  187. data/lib/ynab/models/error_detail.rb +55 -20
  188. data/lib/ynab/models/error_response.rb +53 -18
  189. data/lib/ynab/models/hybrid_transaction.rb +118 -46
  190. data/lib/ynab/models/hybrid_transaction_all_of.rb +304 -0
  191. data/lib/ynab/models/hybrid_transactions_response.rb +53 -18
  192. data/lib/ynab/models/hybrid_transactions_response_data.rb +54 -19
  193. data/lib/ynab/models/month_detail.rb +72 -27
  194. data/lib/ynab/models/{update_transactions_wrapper.rb → month_detail_all_of.rb} +66 -30
  195. data/lib/ynab/models/month_detail_response.rb +53 -18
  196. data/lib/ynab/models/month_detail_response_data.rb +53 -18
  197. data/lib/ynab/models/month_summaries_response.rb +53 -18
  198. data/lib/ynab/models/month_summaries_response_data.rb +54 -19
  199. data/lib/ynab/models/month_summary.rb +63 -26
  200. data/lib/ynab/models/patch_month_category_wrapper.rb +53 -18
  201. data/lib/ynab/models/patch_transactions_wrapper.rb +53 -18
  202. data/lib/ynab/models/payee.rb +58 -22
  203. data/lib/ynab/models/payee_location.rb +58 -23
  204. data/lib/ynab/models/payee_location_response.rb +53 -18
  205. data/lib/ynab/models/payee_location_response_data.rb +53 -18
  206. data/lib/ynab/models/payee_locations_response.rb +53 -18
  207. data/lib/ynab/models/payee_locations_response_data.rb +53 -18
  208. data/lib/ynab/models/payee_response.rb +53 -18
  209. data/lib/ynab/models/payee_response_data.rb +53 -18
  210. data/lib/ynab/models/payees_response.rb +53 -18
  211. data/lib/ynab/models/payees_response_data.rb +54 -19
  212. data/lib/ynab/models/post_account_wrapper.rb +53 -18
  213. data/lib/ynab/models/post_transactions_wrapper.rb +54 -19
  214. data/lib/ynab/models/put_transaction_wrapper.rb +53 -18
  215. data/lib/ynab/models/save_account.rb +77 -20
  216. data/lib/ynab/models/save_category_response.rb +53 -18
  217. data/lib/ynab/models/save_category_response_data.rb +54 -19
  218. data/lib/ynab/models/save_month_category.rb +53 -18
  219. data/lib/ynab/models/save_sub_transaction.rb +61 -22
  220. data/lib/ynab/models/save_transaction.rb +88 -33
  221. data/lib/ynab/models/save_transaction_with_id.rb +102 -46
  222. data/lib/ynab/models/{save_transactions_wrapper.rb → save_transaction_with_id_all_of.rb} +60 -36
  223. data/lib/ynab/models/save_transaction_with_optional_fields.rb +81 -33
  224. data/lib/ynab/models/save_transactions_response.rb +53 -18
  225. data/lib/ynab/models/save_transactions_response_data.rb +57 -23
  226. data/lib/ynab/models/scheduled_sub_transaction.rb +66 -27
  227. data/lib/ynab/models/scheduled_transaction_detail.rb +94 -36
  228. data/lib/ynab/models/scheduled_transaction_detail_all_of.rb +262 -0
  229. data/lib/ynab/models/scheduled_transaction_response.rb +53 -18
  230. data/lib/ynab/models/scheduled_transaction_response_data.rb +53 -18
  231. data/lib/ynab/models/scheduled_transaction_summary.rb +80 -32
  232. data/lib/ynab/models/scheduled_transactions_response.rb +53 -18
  233. data/lib/ynab/models/scheduled_transactions_response_data.rb +54 -19
  234. data/lib/ynab/models/sub_transaction.rb +71 -29
  235. data/lib/ynab/models/transaction_detail.rb +112 -44
  236. data/lib/ynab/models/{save_transaction_wrapper.rb → transaction_detail_all_of.rb} +102 -29
  237. data/lib/ynab/models/transaction_response.rb +53 -18
  238. data/lib/ynab/models/transaction_response_data.rb +53 -18
  239. data/lib/ynab/models/transaction_summary.rb +98 -40
  240. data/lib/ynab/models/transactions_import_response.rb +53 -18
  241. data/lib/ynab/models/transactions_import_response_data.rb +53 -18
  242. data/lib/ynab/models/transactions_response.rb +53 -18
  243. data/lib/ynab/models/transactions_response_data.rb +54 -19
  244. data/lib/ynab/models/user.rb +53 -18
  245. data/lib/ynab/models/user_response.rb +53 -18
  246. data/lib/ynab/models/user_response_data.rb +53 -18
  247. data/lib/ynab/version.rb +1 -1
  248. data/lib/ynab.rb +19 -14
  249. data/open_api_spec.yaml +3012 -0
  250. data/templates/api_client.mustache +274 -0
  251. data/templates/api_client_typhoeus_partial.mustache +156 -0
  252. data/templates/api_doc.mustache +44 -0
  253. data/templates/gem.mustache +84 -0
  254. data/templates/partial_model_generic_doc.mustache +9 -0
  255. data/ynab.gemspec +38 -0
  256. metadata +192 -85
  257. data/lib/ynab/models/loan_account_periodic_value.rb +0 -175
  258. data/lib/ynab/models/save_account_wrapper.rb +0 -189
  259. data/lib/ynab/models/update_transaction.rb +0 -407
  260. data/spec/models/transaction_detail_spec.rb +0 -11
@@ -3,14 +3,15 @@
3
3
 
4
4
  #Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.ynab.com
5
5
 
6
- OpenAPI spec version: 1.0.0
6
+ The version of the OpenAPI document: 1.0.0
7
7
 
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.14
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module YNAB
16
17
  class ScheduledSubTransaction
@@ -30,7 +31,7 @@ module YNAB
30
31
  # If a transfer, the account_id which the scheduled subtransaction transfers to
31
32
  attr_accessor :transfer_account_id
32
33
 
33
- # Whether or not the scheduled subtransaction has been deleted. Deleted scheduled subtransactions will only be included in delta requests.
34
+ # Whether or not the scheduled subtransaction has been deleted. Deleted scheduled subtransactions will only be included in delta requests.
34
35
  attr_accessor :deleted
35
36
 
36
37
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -47,8 +48,13 @@ module YNAB
47
48
  }
48
49
  end
49
50
 
51
+ # Returns all the JSON keys this model knows about
52
+ def self.acceptable_attributes
53
+ attribute_map.values
54
+ end
55
+
50
56
  # Attribute type mapping.
51
- def self.swagger_types
57
+ def self.openapi_types
52
58
  {
53
59
  :'id' => :'String',
54
60
  :'scheduled_transaction_id' => :'String',
@@ -57,47 +63,64 @@ module YNAB
57
63
  :'payee_id' => :'String',
58
64
  :'category_id' => :'String',
59
65
  :'transfer_account_id' => :'String',
60
- :'deleted' => :'BOOLEAN'
66
+ :'deleted' => :'Boolean'
61
67
  }
62
68
  end
63
69
 
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ :'memo',
74
+ :'payee_id',
75
+ :'category_id',
76
+ :'transfer_account_id',
77
+ ])
78
+ end
79
+
64
80
  # Initializes the object
65
81
  # @param [Hash] attributes Model attributes in the form of hash
66
82
  def initialize(attributes = {})
67
- return unless attributes.is_a?(Hash)
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::ScheduledSubTransaction` initialize method"
85
+ end
68
86
 
69
- # convert string to symbol for hash key
70
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::ScheduledSubTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
71
94
 
72
- if attributes.has_key?(:'id')
95
+ if attributes.key?(:'id')
73
96
  self.id = attributes[:'id']
74
97
  end
75
98
 
76
- if attributes.has_key?(:'scheduled_transaction_id')
99
+ if attributes.key?(:'scheduled_transaction_id')
77
100
  self.scheduled_transaction_id = attributes[:'scheduled_transaction_id']
78
101
  end
79
102
 
80
- if attributes.has_key?(:'amount')
103
+ if attributes.key?(:'amount')
81
104
  self.amount = attributes[:'amount']
82
105
  end
83
106
 
84
- if attributes.has_key?(:'memo')
107
+ if attributes.key?(:'memo')
85
108
  self.memo = attributes[:'memo']
86
109
  end
87
110
 
88
- if attributes.has_key?(:'payee_id')
111
+ if attributes.key?(:'payee_id')
89
112
  self.payee_id = attributes[:'payee_id']
90
113
  end
91
114
 
92
- if attributes.has_key?(:'category_id')
115
+ if attributes.key?(:'category_id')
93
116
  self.category_id = attributes[:'category_id']
94
117
  end
95
118
 
96
- if attributes.has_key?(:'transfer_account_id')
119
+ if attributes.key?(:'transfer_account_id')
97
120
  self.transfer_account_id = attributes[:'transfer_account_id']
98
121
  end
99
122
 
100
- if attributes.has_key?(:'deleted')
123
+ if attributes.key?(:'deleted')
101
124
  self.deleted = attributes[:'deleted']
102
125
  end
103
126
  end
@@ -157,17 +180,28 @@ module YNAB
157
180
  end
158
181
 
159
182
  # Calculates hash code according to all attributes.
160
- # @return [Fixnum] Hash code
183
+ # @return [Integer] Hash code
161
184
  def hash
162
185
  [id, scheduled_transaction_id, amount, memo, payee_id, category_id, transfer_account_id, deleted].hash
163
186
  end
187
+
188
+ # Builds the object from hash
189
+ # @param [Hash] attributes Model attributes in the form of hash
190
+ # @return [Object] Returns the model itself
191
+ def self.build_from_hash(attributes)
192
+ new.build_from_hash(attributes)
193
+ end
194
+
164
195
  # Builds the object from hash
165
196
  # @param [Hash] attributes Model attributes in the form of hash
166
197
  # @return [Object] Returns the model itself
167
198
  def build_from_hash(attributes)
168
199
  return nil unless attributes.is_a?(Hash)
169
- self.class.swagger_types.each_pair do |key, type|
170
- if type =~ /\AArray<(.*)>/i
200
+ attributes = attributes.transform_keys(&:to_sym)
201
+ self.class.openapi_types.each_pair do |key, type|
202
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
203
+ self.send("#{key}=", nil)
204
+ elsif type =~ /\AArray<(.*)>/i
171
205
  # check to ensure the input is an array given that the attribute
172
206
  # is documented as an array but the input is not
173
207
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -175,7 +209,7 @@ module YNAB
175
209
  end
176
210
  elsif !attributes[self.class.attribute_map[key]].nil?
177
211
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
178
- end # or else data not found in attributes(hash), not an issue as the data can be optional
212
+ end
179
213
  end
180
214
 
181
215
  self
@@ -187,8 +221,8 @@ module YNAB
187
221
  # @return [Object] Deserialized data
188
222
  def _deserialize(type, value)
189
223
  case type.to_sym
190
- when :DateTime
191
- DateTime.parse(value)
224
+ when :Time
225
+ Time.parse(value)
192
226
  when :Date
193
227
  Date.parse(value)
194
228
  when :String
@@ -197,7 +231,7 @@ module YNAB
197
231
  value.to_i
198
232
  when :Float
199
233
  value.to_f
200
- when :BOOLEAN
234
+ when :Boolean
201
235
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
202
236
  true
203
237
  else
@@ -218,8 +252,9 @@ module YNAB
218
252
  end
219
253
  end
220
254
  else # model
221
- temp_model = YNAB.const_get(type).new
222
- temp_model.build_from_hash(value)
255
+ # models (e.g. Pet) or oneOf
256
+ klass = YNAB.const_get(type)
257
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
223
258
  end
224
259
  end
225
260
 
@@ -241,7 +276,11 @@ module YNAB
241
276
  hash = {}
242
277
  self.class.attribute_map.each_pair do |attr, param|
243
278
  value = self.send(attr)
244
- next if value.nil?
279
+ if value.nil?
280
+ is_nullable = self.class.openapi_nullable.include?(attr)
281
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
282
+ end
283
+
245
284
  hash[param] = _to_hash(value)
246
285
  end
247
286
  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 ScheduledTransactionDetail
@@ -98,8 +99,13 @@ module YNAB
98
99
  }
99
100
  end
100
101
 
102
+ # Returns all the JSON keys this model knows about
103
+ def self.acceptable_attributes
104
+ attribute_map.values
105
+ end
106
+
101
107
  # Attribute type mapping.
102
- def self.swagger_types
108
+ def self.openapi_types
103
109
  {
104
110
  :'id' => :'String',
105
111
  :'date_first' => :'Date',
@@ -112,7 +118,7 @@ module YNAB
112
118
  :'payee_id' => :'String',
113
119
  :'category_id' => :'String',
114
120
  :'transfer_account_id' => :'String',
115
- :'deleted' => :'BOOLEAN',
121
+ :'deleted' => :'Boolean',
116
122
  :'account_name' => :'String',
117
123
  :'payee_name' => :'String',
118
124
  :'category_name' => :'String',
@@ -120,75 +126,103 @@ module YNAB
120
126
  }
121
127
  end
122
128
 
129
+ # List of attributes with nullable: true
130
+ def self.openapi_nullable
131
+ Set.new([
132
+ :'memo',
133
+ :'flag_color',
134
+ :'payee_id',
135
+ :'category_id',
136
+ :'transfer_account_id',
137
+ :'payee_name',
138
+ :'category_name',
139
+ ])
140
+ end
141
+
142
+ # List of class defined in allOf (OpenAPI v3)
143
+ def self.openapi_all_of
144
+ [
145
+ :'ScheduledTransactionDetailAllOf',
146
+ :'ScheduledTransactionSummary'
147
+ ]
148
+ end
149
+
123
150
  # Initializes the object
124
151
  # @param [Hash] attributes Model attributes in the form of hash
125
152
  def initialize(attributes = {})
126
- return unless attributes.is_a?(Hash)
153
+ if (!attributes.is_a?(Hash))
154
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::ScheduledTransactionDetail` initialize method"
155
+ end
127
156
 
128
- # convert string to symbol for hash key
129
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
157
+ # check to see if the attribute exists and convert string to symbol for hash key
158
+ attributes = attributes.each_with_object({}) { |(k, v), h|
159
+ if (!self.class.attribute_map.key?(k.to_sym))
160
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::ScheduledTransactionDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
161
+ end
162
+ h[k.to_sym] = v
163
+ }
130
164
 
131
- if attributes.has_key?(:'id')
165
+ if attributes.key?(:'id')
132
166
  self.id = attributes[:'id']
133
167
  end
134
168
 
135
- if attributes.has_key?(:'date_first')
169
+ if attributes.key?(:'date_first')
136
170
  self.date_first = attributes[:'date_first']
137
171
  end
138
172
 
139
- if attributes.has_key?(:'date_next')
173
+ if attributes.key?(:'date_next')
140
174
  self.date_next = attributes[:'date_next']
141
175
  end
142
176
 
143
- if attributes.has_key?(:'frequency')
177
+ if attributes.key?(:'frequency')
144
178
  self.frequency = attributes[:'frequency']
145
179
  end
146
180
 
147
- if attributes.has_key?(:'amount')
181
+ if attributes.key?(:'amount')
148
182
  self.amount = attributes[:'amount']
149
183
  end
150
184
 
151
- if attributes.has_key?(:'memo')
185
+ if attributes.key?(:'memo')
152
186
  self.memo = attributes[:'memo']
153
187
  end
154
188
 
155
- if attributes.has_key?(:'flag_color')
189
+ if attributes.key?(:'flag_color')
156
190
  self.flag_color = attributes[:'flag_color']
157
191
  end
158
192
 
159
- if attributes.has_key?(:'account_id')
193
+ if attributes.key?(:'account_id')
160
194
  self.account_id = attributes[:'account_id']
161
195
  end
162
196
 
163
- if attributes.has_key?(:'payee_id')
197
+ if attributes.key?(:'payee_id')
164
198
  self.payee_id = attributes[:'payee_id']
165
199
  end
166
200
 
167
- if attributes.has_key?(:'category_id')
201
+ if attributes.key?(:'category_id')
168
202
  self.category_id = attributes[:'category_id']
169
203
  end
170
204
 
171
- if attributes.has_key?(:'transfer_account_id')
205
+ if attributes.key?(:'transfer_account_id')
172
206
  self.transfer_account_id = attributes[:'transfer_account_id']
173
207
  end
174
208
 
175
- if attributes.has_key?(:'deleted')
209
+ if attributes.key?(:'deleted')
176
210
  self.deleted = attributes[:'deleted']
177
211
  end
178
212
 
179
- if attributes.has_key?(:'account_name')
213
+ if attributes.key?(:'account_name')
180
214
  self.account_name = attributes[:'account_name']
181
215
  end
182
216
 
183
- if attributes.has_key?(:'payee_name')
217
+ if attributes.key?(:'payee_name')
184
218
  self.payee_name = attributes[:'payee_name']
185
219
  end
186
220
 
187
- if attributes.has_key?(:'category_name')
221
+ if attributes.key?(:'category_name')
188
222
  self.category_name = attributes[:'category_name']
189
223
  end
190
224
 
191
- if attributes.has_key?(:'subtransactions')
225
+ if attributes.key?(:'subtransactions')
192
226
  if (value = attributes[:'subtransactions']).is_a?(Array)
193
227
  self.subtransactions = value
194
228
  end
@@ -245,10 +279,10 @@ module YNAB
245
279
  return false if @date_first.nil?
246
280
  return false if @date_next.nil?
247
281
  return false if @frequency.nil?
248
- frequency_validator = EnumAttributeValidator.new('String', ['never', 'daily', 'weekly', 'everyOtherWeek', 'twiceAMonth', 'every4Weeks', 'monthly', 'everyOtherMonth', 'every3Months', 'every4Months', 'twiceAYear', 'yearly', 'everyOtherYear'])
282
+ frequency_validator = EnumAttributeValidator.new('String', ["never", "daily", "weekly", "everyOtherWeek", "twiceAMonth", "every4Weeks", "monthly", "everyOtherMonth", "every3Months", "every4Months", "twiceAYear", "yearly", "everyOtherYear"])
249
283
  return false unless frequency_validator.valid?(@frequency)
250
284
  return false if @amount.nil?
251
- flag_color_validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
285
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple", "null"])
252
286
  return false unless flag_color_validator.valid?(@flag_color)
253
287
  return false if @account_id.nil?
254
288
  return false if @deleted.nil?
@@ -260,12 +294,20 @@ module YNAB
260
294
  # Custom attribute writer method checking allowed values (enum).
261
295
  # @param [Object] frequency Object to be assigned
262
296
  def frequency=(frequency)
297
+ validator = EnumAttributeValidator.new('String', ["never", "daily", "weekly", "everyOtherWeek", "twiceAMonth", "every4Weeks", "monthly", "everyOtherMonth", "every3Months", "every4Months", "twiceAYear", "yearly", "everyOtherYear"])
298
+ unless validator.valid?(frequency)
299
+ fail ArgumentError, "invalid value for \"frequency\", must be one of #{validator.allowable_values}."
300
+ end
263
301
  @frequency = frequency
264
302
  end
265
303
 
266
304
  # Custom attribute writer method checking allowed values (enum).
267
305
  # @param [Object] flag_color Object to be assigned
268
306
  def flag_color=(flag_color)
307
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple", "null"])
308
+ unless validator.valid?(flag_color)
309
+ fail ArgumentError, "invalid value for \"flag_color\", must be one of #{validator.allowable_values}."
310
+ end
269
311
  @flag_color = flag_color
270
312
  end
271
313
 
@@ -299,17 +341,28 @@ module YNAB
299
341
  end
300
342
 
301
343
  # Calculates hash code according to all attributes.
302
- # @return [Fixnum] Hash code
344
+ # @return [Integer] Hash code
303
345
  def hash
304
346
  [id, date_first, date_next, frequency, amount, memo, flag_color, account_id, payee_id, category_id, transfer_account_id, deleted, account_name, payee_name, category_name, subtransactions].hash
305
347
  end
348
+
349
+ # Builds the object from hash
350
+ # @param [Hash] attributes Model attributes in the form of hash
351
+ # @return [Object] Returns the model itself
352
+ def self.build_from_hash(attributes)
353
+ new.build_from_hash(attributes)
354
+ end
355
+
306
356
  # Builds the object from hash
307
357
  # @param [Hash] attributes Model attributes in the form of hash
308
358
  # @return [Object] Returns the model itself
309
359
  def build_from_hash(attributes)
310
360
  return nil unless attributes.is_a?(Hash)
311
- self.class.swagger_types.each_pair do |key, type|
312
- if type =~ /\AArray<(.*)>/i
361
+ attributes = attributes.transform_keys(&:to_sym)
362
+ self.class.openapi_types.each_pair do |key, type|
363
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
364
+ self.send("#{key}=", nil)
365
+ elsif type =~ /\AArray<(.*)>/i
313
366
  # check to ensure the input is an array given that the attribute
314
367
  # is documented as an array but the input is not
315
368
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -317,7 +370,7 @@ module YNAB
317
370
  end
318
371
  elsif !attributes[self.class.attribute_map[key]].nil?
319
372
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
320
- end # or else data not found in attributes(hash), not an issue as the data can be optional
373
+ end
321
374
  end
322
375
 
323
376
  self
@@ -329,8 +382,8 @@ module YNAB
329
382
  # @return [Object] Deserialized data
330
383
  def _deserialize(type, value)
331
384
  case type.to_sym
332
- when :DateTime
333
- DateTime.parse(value)
385
+ when :Time
386
+ Time.parse(value)
334
387
  when :Date
335
388
  Date.parse(value)
336
389
  when :String
@@ -339,7 +392,7 @@ module YNAB
339
392
  value.to_i
340
393
  when :Float
341
394
  value.to_f
342
- when :BOOLEAN
395
+ when :Boolean
343
396
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
344
397
  true
345
398
  else
@@ -360,8 +413,9 @@ module YNAB
360
413
  end
361
414
  end
362
415
  else # model
363
- temp_model = YNAB.const_get(type).new
364
- temp_model.build_from_hash(value)
416
+ # models (e.g. Pet) or oneOf
417
+ klass = YNAB.const_get(type)
418
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
365
419
  end
366
420
  end
367
421
 
@@ -383,7 +437,11 @@ module YNAB
383
437
  hash = {}
384
438
  self.class.attribute_map.each_pair do |attr, param|
385
439
  value = self.send(attr)
386
- next if value.nil?
440
+ if value.nil?
441
+ is_nullable = self.class.openapi_nullable.include?(attr)
442
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
443
+ end
444
+
387
445
  hash[param] = _to_hash(value)
388
446
  end
389
447
  hash