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 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
@@ -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 ScheduledTransactionDetail
@@ -48,6 +49,7 @@ module YNAB
48
49
 
49
50
  attr_accessor :payee_name
50
51
 
52
+ # The name of the category. If a split scheduled transaction, this will be 'Split'.
51
53
  attr_accessor :category_name
52
54
 
53
55
  # If a split scheduled transaction, the subtransactions.
@@ -97,8 +99,13 @@ module YNAB
97
99
  }
98
100
  end
99
101
 
102
+ # Returns all the JSON keys this model knows about
103
+ def self.acceptable_attributes
104
+ attribute_map.values
105
+ end
106
+
100
107
  # Attribute type mapping.
101
- def self.swagger_types
108
+ def self.openapi_types
102
109
  {
103
110
  :'id' => :'String',
104
111
  :'date_first' => :'Date',
@@ -111,7 +118,7 @@ module YNAB
111
118
  :'payee_id' => :'String',
112
119
  :'category_id' => :'String',
113
120
  :'transfer_account_id' => :'String',
114
- :'deleted' => :'BOOLEAN',
121
+ :'deleted' => :'Boolean',
115
122
  :'account_name' => :'String',
116
123
  :'payee_name' => :'String',
117
124
  :'category_name' => :'String',
@@ -119,75 +126,103 @@ module YNAB
119
126
  }
120
127
  end
121
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
+
122
150
  # Initializes the object
123
151
  # @param [Hash] attributes Model attributes in the form of hash
124
152
  def initialize(attributes = {})
125
- 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
126
156
 
127
- # convert string to symbol for hash key
128
- 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
+ }
129
164
 
130
- if attributes.has_key?(:'id')
165
+ if attributes.key?(:'id')
131
166
  self.id = attributes[:'id']
132
167
  end
133
168
 
134
- if attributes.has_key?(:'date_first')
169
+ if attributes.key?(:'date_first')
135
170
  self.date_first = attributes[:'date_first']
136
171
  end
137
172
 
138
- if attributes.has_key?(:'date_next')
173
+ if attributes.key?(:'date_next')
139
174
  self.date_next = attributes[:'date_next']
140
175
  end
141
176
 
142
- if attributes.has_key?(:'frequency')
177
+ if attributes.key?(:'frequency')
143
178
  self.frequency = attributes[:'frequency']
144
179
  end
145
180
 
146
- if attributes.has_key?(:'amount')
181
+ if attributes.key?(:'amount')
147
182
  self.amount = attributes[:'amount']
148
183
  end
149
184
 
150
- if attributes.has_key?(:'memo')
185
+ if attributes.key?(:'memo')
151
186
  self.memo = attributes[:'memo']
152
187
  end
153
188
 
154
- if attributes.has_key?(:'flag_color')
189
+ if attributes.key?(:'flag_color')
155
190
  self.flag_color = attributes[:'flag_color']
156
191
  end
157
192
 
158
- if attributes.has_key?(:'account_id')
193
+ if attributes.key?(:'account_id')
159
194
  self.account_id = attributes[:'account_id']
160
195
  end
161
196
 
162
- if attributes.has_key?(:'payee_id')
197
+ if attributes.key?(:'payee_id')
163
198
  self.payee_id = attributes[:'payee_id']
164
199
  end
165
200
 
166
- if attributes.has_key?(:'category_id')
201
+ if attributes.key?(:'category_id')
167
202
  self.category_id = attributes[:'category_id']
168
203
  end
169
204
 
170
- if attributes.has_key?(:'transfer_account_id')
205
+ if attributes.key?(:'transfer_account_id')
171
206
  self.transfer_account_id = attributes[:'transfer_account_id']
172
207
  end
173
208
 
174
- if attributes.has_key?(:'deleted')
209
+ if attributes.key?(:'deleted')
175
210
  self.deleted = attributes[:'deleted']
176
211
  end
177
212
 
178
- if attributes.has_key?(:'account_name')
213
+ if attributes.key?(:'account_name')
179
214
  self.account_name = attributes[:'account_name']
180
215
  end
181
216
 
182
- if attributes.has_key?(:'payee_name')
217
+ if attributes.key?(:'payee_name')
183
218
  self.payee_name = attributes[:'payee_name']
184
219
  end
185
220
 
186
- if attributes.has_key?(:'category_name')
221
+ if attributes.key?(:'category_name')
187
222
  self.category_name = attributes[:'category_name']
188
223
  end
189
224
 
190
- if attributes.has_key?(:'subtransactions')
225
+ if attributes.key?(:'subtransactions')
191
226
  if (value = attributes[:'subtransactions']).is_a?(Array)
192
227
  self.subtransactions = value
193
228
  end
@@ -244,10 +279,10 @@ module YNAB
244
279
  return false if @date_first.nil?
245
280
  return false if @date_next.nil?
246
281
  return false if @frequency.nil?
247
- 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"])
248
283
  return false unless frequency_validator.valid?(@frequency)
249
284
  return false if @amount.nil?
250
- 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"])
251
286
  return false unless flag_color_validator.valid?(@flag_color)
252
287
  return false if @account_id.nil?
253
288
  return false if @deleted.nil?
@@ -259,12 +294,20 @@ module YNAB
259
294
  # Custom attribute writer method checking allowed values (enum).
260
295
  # @param [Object] frequency Object to be assigned
261
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
262
301
  @frequency = frequency
263
302
  end
264
303
 
265
304
  # Custom attribute writer method checking allowed values (enum).
266
305
  # @param [Object] flag_color Object to be assigned
267
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
268
311
  @flag_color = flag_color
269
312
  end
270
313
 
@@ -298,17 +341,28 @@ module YNAB
298
341
  end
299
342
 
300
343
  # Calculates hash code according to all attributes.
301
- # @return [Fixnum] Hash code
344
+ # @return [Integer] Hash code
302
345
  def hash
303
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
304
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
+
305
356
  # Builds the object from hash
306
357
  # @param [Hash] attributes Model attributes in the form of hash
307
358
  # @return [Object] Returns the model itself
308
359
  def build_from_hash(attributes)
309
360
  return nil unless attributes.is_a?(Hash)
310
- self.class.swagger_types.each_pair do |key, type|
311
- 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
312
366
  # check to ensure the input is an array given that the attribute
313
367
  # is documented as an array but the input is not
314
368
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -316,7 +370,7 @@ module YNAB
316
370
  end
317
371
  elsif !attributes[self.class.attribute_map[key]].nil?
318
372
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
319
- end # or else data not found in attributes(hash), not an issue as the data can be optional
373
+ end
320
374
  end
321
375
 
322
376
  self
@@ -328,8 +382,8 @@ module YNAB
328
382
  # @return [Object] Deserialized data
329
383
  def _deserialize(type, value)
330
384
  case type.to_sym
331
- when :DateTime
332
- DateTime.parse(value)
385
+ when :Time
386
+ Time.parse(value)
333
387
  when :Date
334
388
  Date.parse(value)
335
389
  when :String
@@ -338,7 +392,7 @@ module YNAB
338
392
  value.to_i
339
393
  when :Float
340
394
  value.to_f
341
- when :BOOLEAN
395
+ when :Boolean
342
396
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
343
397
  true
344
398
  else
@@ -359,8 +413,9 @@ module YNAB
359
413
  end
360
414
  end
361
415
  else # model
362
- temp_model = YNAB.const_get(type).new
363
- 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)
364
419
  end
365
420
  end
366
421
 
@@ -382,7 +437,11 @@ module YNAB
382
437
  hash = {}
383
438
  self.class.attribute_map.each_pair do |attr, param|
384
439
  value = self.send(attr)
385
- 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
+
386
445
  hash[param] = _to_hash(value)
387
446
  end
388
447
  hash