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 PutTransactionWrapper
@@ -23,22 +24,40 @@ module YNAB
23
24
  }
24
25
  end
25
26
 
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
26
32
  # Attribute type mapping.
27
- def self.swagger_types
33
+ def self.openapi_types
28
34
  {
29
35
  :'transaction' => :'SaveTransaction'
30
36
  }
31
37
  end
32
38
 
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
33
45
  # Initializes the object
34
46
  # @param [Hash] attributes Model attributes in the form of hash
35
47
  def initialize(attributes = {})
36
- return unless attributes.is_a?(Hash)
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::PutTransactionWrapper` initialize method"
50
+ end
37
51
 
38
- # convert string to symbol for hash key
39
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::PutTransactionWrapper`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
40
59
 
41
- if attributes.has_key?(:'transaction')
60
+ if attributes.key?(:'transaction')
42
61
  self.transaction = attributes[:'transaction']
43
62
  end
44
63
  end
@@ -76,17 +95,28 @@ module YNAB
76
95
  end
77
96
 
78
97
  # Calculates hash code according to all attributes.
79
- # @return [Fixnum] Hash code
98
+ # @return [Integer] Hash code
80
99
  def hash
81
100
  [transaction].hash
82
101
  end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
83
110
  # Builds the object from hash
84
111
  # @param [Hash] attributes Model attributes in the form of hash
85
112
  # @return [Object] Returns the model itself
86
113
  def build_from_hash(attributes)
87
114
  return nil unless attributes.is_a?(Hash)
88
- self.class.swagger_types.each_pair do |key, type|
89
- if type =~ /\AArray<(.*)>/i
115
+ attributes = attributes.transform_keys(&:to_sym)
116
+ self.class.openapi_types.each_pair do |key, type|
117
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
118
+ self.send("#{key}=", nil)
119
+ elsif type =~ /\AArray<(.*)>/i
90
120
  # check to ensure the input is an array given that the attribute
91
121
  # is documented as an array but the input is not
92
122
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -94,7 +124,7 @@ module YNAB
94
124
  end
95
125
  elsif !attributes[self.class.attribute_map[key]].nil?
96
126
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
97
- end # or else data not found in attributes(hash), not an issue as the data can be optional
127
+ end
98
128
  end
99
129
 
100
130
  self
@@ -106,8 +136,8 @@ module YNAB
106
136
  # @return [Object] Deserialized data
107
137
  def _deserialize(type, value)
108
138
  case type.to_sym
109
- when :DateTime
110
- DateTime.parse(value)
139
+ when :Time
140
+ Time.parse(value)
111
141
  when :Date
112
142
  Date.parse(value)
113
143
  when :String
@@ -116,7 +146,7 @@ module YNAB
116
146
  value.to_i
117
147
  when :Float
118
148
  value.to_f
119
- when :BOOLEAN
149
+ when :Boolean
120
150
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
121
151
  true
122
152
  else
@@ -137,8 +167,9 @@ module YNAB
137
167
  end
138
168
  end
139
169
  else # model
140
- temp_model = YNAB.const_get(type).new
141
- temp_model.build_from_hash(value)
170
+ # models (e.g. Pet) or oneOf
171
+ klass = YNAB.const_get(type)
172
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
142
173
  end
143
174
  end
144
175
 
@@ -160,7 +191,11 @@ module YNAB
160
191
  hash = {}
161
192
  self.class.attribute_map.each_pair do |attr, param|
162
193
  value = self.send(attr)
163
- next if value.nil?
194
+ if value.nil?
195
+ is_nullable = self.class.openapi_nullable.include?(attr)
196
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
197
+ end
198
+
164
199
  hash[param] = _to_hash(value)
165
200
  end
166
201
  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 SaveAccount
@@ -22,6 +23,28 @@ module YNAB
22
23
  # The current balance of the account in milliunits format
23
24
  attr_accessor :balance
24
25
 
26
+ class EnumAttributeValidator
27
+ attr_reader :datatype
28
+ attr_reader :allowable_values
29
+
30
+ def initialize(datatype, allowable_values)
31
+ @allowable_values = allowable_values.map do |value|
32
+ case datatype.to_s
33
+ when /Integer/i
34
+ value.to_i
35
+ when /Float/i
36
+ value.to_f
37
+ else
38
+ value
39
+ end
40
+ end
41
+ end
42
+
43
+ def valid?(value)
44
+ !value || allowable_values.include?(value)
45
+ end
46
+ end
47
+
25
48
  # Attribute mapping from ruby-style variable name to JSON key.
26
49
  def self.attribute_map
27
50
  {
@@ -31,8 +54,13 @@ module YNAB
31
54
  }
32
55
  end
33
56
 
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
34
62
  # Attribute type mapping.
35
- def self.swagger_types
63
+ def self.openapi_types
36
64
  {
37
65
  :'name' => :'String',
38
66
  :'type' => :'AccountType',
@@ -40,23 +68,36 @@ module YNAB
40
68
  }
41
69
  end
42
70
 
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
43
77
  # Initializes the object
44
78
  # @param [Hash] attributes Model attributes in the form of hash
45
79
  def initialize(attributes = {})
46
- return unless attributes.is_a?(Hash)
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SaveAccount` initialize method"
82
+ end
47
83
 
48
- # convert string to symbol for hash key
49
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!self.class.attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SaveAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
50
91
 
51
- if attributes.has_key?(:'name')
92
+ if attributes.key?(:'name')
52
93
  self.name = attributes[:'name']
53
94
  end
54
95
 
55
- if attributes.has_key?(:'type')
96
+ if attributes.key?(:'type')
56
97
  self.type = attributes[:'type']
57
98
  end
58
99
 
59
- if attributes.has_key?(:'balance')
100
+ if attributes.key?(:'balance')
60
101
  self.balance = attributes[:'balance']
61
102
  end
62
103
  end
@@ -106,17 +147,28 @@ module YNAB
106
147
  end
107
148
 
108
149
  # Calculates hash code according to all attributes.
109
- # @return [Fixnum] Hash code
150
+ # @return [Integer] Hash code
110
151
  def hash
111
152
  [name, type, balance].hash
112
153
  end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def self.build_from_hash(attributes)
159
+ new.build_from_hash(attributes)
160
+ end
161
+
113
162
  # Builds the object from hash
114
163
  # @param [Hash] attributes Model attributes in the form of hash
115
164
  # @return [Object] Returns the model itself
116
165
  def build_from_hash(attributes)
117
166
  return nil unless attributes.is_a?(Hash)
118
- self.class.swagger_types.each_pair do |key, type|
119
- if type =~ /\AArray<(.*)>/i
167
+ attributes = attributes.transform_keys(&:to_sym)
168
+ self.class.openapi_types.each_pair do |key, type|
169
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
170
+ self.send("#{key}=", nil)
171
+ elsif type =~ /\AArray<(.*)>/i
120
172
  # check to ensure the input is an array given that the attribute
121
173
  # is documented as an array but the input is not
122
174
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -124,7 +176,7 @@ module YNAB
124
176
  end
125
177
  elsif !attributes[self.class.attribute_map[key]].nil?
126
178
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
127
- end # or else data not found in attributes(hash), not an issue as the data can be optional
179
+ end
128
180
  end
129
181
 
130
182
  self
@@ -136,8 +188,8 @@ module YNAB
136
188
  # @return [Object] Deserialized data
137
189
  def _deserialize(type, value)
138
190
  case type.to_sym
139
- when :DateTime
140
- DateTime.parse(value)
191
+ when :Time
192
+ Time.parse(value)
141
193
  when :Date
142
194
  Date.parse(value)
143
195
  when :String
@@ -146,7 +198,7 @@ module YNAB
146
198
  value.to_i
147
199
  when :Float
148
200
  value.to_f
149
- when :BOOLEAN
201
+ when :Boolean
150
202
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
203
  true
152
204
  else
@@ -167,8 +219,9 @@ module YNAB
167
219
  end
168
220
  end
169
221
  else # model
170
- temp_model = YNAB.const_get(type).new
171
- temp_model.build_from_hash(value)
222
+ # models (e.g. Pet) or oneOf
223
+ klass = YNAB.const_get(type)
224
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
172
225
  end
173
226
  end
174
227
 
@@ -190,7 +243,11 @@ module YNAB
190
243
  hash = {}
191
244
  self.class.attribute_map.each_pair do |attr, param|
192
245
  value = self.send(attr)
193
- next if value.nil?
246
+ if value.nil?
247
+ is_nullable = self.class.openapi_nullable.include?(attr)
248
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
249
+ end
250
+
194
251
  hash[param] = _to_hash(value)
195
252
  end
196
253
  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 SaveCategoryResponse
@@ -23,22 +24,40 @@ module YNAB
23
24
  }
24
25
  end
25
26
 
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
26
32
  # Attribute type mapping.
27
- def self.swagger_types
33
+ def self.openapi_types
28
34
  {
29
35
  :'data' => :'SaveCategoryResponseData'
30
36
  }
31
37
  end
32
38
 
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
33
45
  # Initializes the object
34
46
  # @param [Hash] attributes Model attributes in the form of hash
35
47
  def initialize(attributes = {})
36
- return unless attributes.is_a?(Hash)
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SaveCategoryResponse` initialize method"
50
+ end
37
51
 
38
- # convert string to symbol for hash key
39
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SaveCategoryResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
40
59
 
41
- if attributes.has_key?(:'data')
60
+ if attributes.key?(:'data')
42
61
  self.data = attributes[:'data']
43
62
  end
44
63
  end
@@ -76,17 +95,28 @@ module YNAB
76
95
  end
77
96
 
78
97
  # Calculates hash code according to all attributes.
79
- # @return [Fixnum] Hash code
98
+ # @return [Integer] Hash code
80
99
  def hash
81
100
  [data].hash
82
101
  end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
83
110
  # Builds the object from hash
84
111
  # @param [Hash] attributes Model attributes in the form of hash
85
112
  # @return [Object] Returns the model itself
86
113
  def build_from_hash(attributes)
87
114
  return nil unless attributes.is_a?(Hash)
88
- self.class.swagger_types.each_pair do |key, type|
89
- if type =~ /\AArray<(.*)>/i
115
+ attributes = attributes.transform_keys(&:to_sym)
116
+ self.class.openapi_types.each_pair do |key, type|
117
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
118
+ self.send("#{key}=", nil)
119
+ elsif type =~ /\AArray<(.*)>/i
90
120
  # check to ensure the input is an array given that the attribute
91
121
  # is documented as an array but the input is not
92
122
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -94,7 +124,7 @@ module YNAB
94
124
  end
95
125
  elsif !attributes[self.class.attribute_map[key]].nil?
96
126
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
97
- end # or else data not found in attributes(hash), not an issue as the data can be optional
127
+ end
98
128
  end
99
129
 
100
130
  self
@@ -106,8 +136,8 @@ module YNAB
106
136
  # @return [Object] Deserialized data
107
137
  def _deserialize(type, value)
108
138
  case type.to_sym
109
- when :DateTime
110
- DateTime.parse(value)
139
+ when :Time
140
+ Time.parse(value)
111
141
  when :Date
112
142
  Date.parse(value)
113
143
  when :String
@@ -116,7 +146,7 @@ module YNAB
116
146
  value.to_i
117
147
  when :Float
118
148
  value.to_f
119
- when :BOOLEAN
149
+ when :Boolean
120
150
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
121
151
  true
122
152
  else
@@ -137,8 +167,9 @@ module YNAB
137
167
  end
138
168
  end
139
169
  else # model
140
- temp_model = YNAB.const_get(type).new
141
- temp_model.build_from_hash(value)
170
+ # models (e.g. Pet) or oneOf
171
+ klass = YNAB.const_get(type)
172
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
142
173
  end
143
174
  end
144
175
 
@@ -160,7 +191,11 @@ module YNAB
160
191
  hash = {}
161
192
  self.class.attribute_map.each_pair do |attr, param|
162
193
  value = self.send(attr)
163
- next if value.nil?
194
+ if value.nil?
195
+ is_nullable = self.class.openapi_nullable.include?(attr)
196
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
197
+ end
198
+
164
199
  hash[param] = _to_hash(value)
165
200
  end
166
201
  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 SaveCategoryResponseData
@@ -27,27 +28,45 @@ module YNAB
27
28
  }
28
29
  end
29
30
 
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
30
36
  # Attribute type mapping.
31
- def self.swagger_types
37
+ def self.openapi_types
32
38
  {
33
39
  :'category' => :'Category',
34
40
  :'server_knowledge' => :'Integer'
35
41
  }
36
42
  end
37
43
 
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
38
50
  # Initializes the object
39
51
  # @param [Hash] attributes Model attributes in the form of hash
40
52
  def initialize(attributes = {})
41
- return unless attributes.is_a?(Hash)
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SaveCategoryResponseData` initialize method"
55
+ end
42
56
 
43
- # convert string to symbol for hash key
44
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SaveCategoryResponseData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
45
64
 
46
- if attributes.has_key?(:'category')
65
+ if attributes.key?(:'category')
47
66
  self.category = attributes[:'category']
48
67
  end
49
68
 
50
- if attributes.has_key?(:'server_knowledge')
69
+ if attributes.key?(:'server_knowledge')
51
70
  self.server_knowledge = attributes[:'server_knowledge']
52
71
  end
53
72
  end
@@ -91,17 +110,28 @@ module YNAB
91
110
  end
92
111
 
93
112
  # Calculates hash code according to all attributes.
94
- # @return [Fixnum] Hash code
113
+ # @return [Integer] Hash code
95
114
  def hash
96
115
  [category, server_knowledge].hash
97
116
  end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def self.build_from_hash(attributes)
122
+ new.build_from_hash(attributes)
123
+ end
124
+
98
125
  # Builds the object from hash
99
126
  # @param [Hash] attributes Model attributes in the form of hash
100
127
  # @return [Object] Returns the model itself
101
128
  def build_from_hash(attributes)
102
129
  return nil unless attributes.is_a?(Hash)
103
- self.class.swagger_types.each_pair do |key, type|
104
- if type =~ /\AArray<(.*)>/i
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ self.class.openapi_types.each_pair do |key, type|
132
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
133
+ self.send("#{key}=", nil)
134
+ elsif type =~ /\AArray<(.*)>/i
105
135
  # check to ensure the input is an array given that the attribute
106
136
  # is documented as an array but the input is not
107
137
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -109,7 +139,7 @@ module YNAB
109
139
  end
110
140
  elsif !attributes[self.class.attribute_map[key]].nil?
111
141
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
112
- end # or else data not found in attributes(hash), not an issue as the data can be optional
142
+ end
113
143
  end
114
144
 
115
145
  self
@@ -121,8 +151,8 @@ module YNAB
121
151
  # @return [Object] Deserialized data
122
152
  def _deserialize(type, value)
123
153
  case type.to_sym
124
- when :DateTime
125
- DateTime.parse(value)
154
+ when :Time
155
+ Time.parse(value)
126
156
  when :Date
127
157
  Date.parse(value)
128
158
  when :String
@@ -131,7 +161,7 @@ module YNAB
131
161
  value.to_i
132
162
  when :Float
133
163
  value.to_f
134
- when :BOOLEAN
164
+ when :Boolean
135
165
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
136
166
  true
137
167
  else
@@ -152,8 +182,9 @@ module YNAB
152
182
  end
153
183
  end
154
184
  else # model
155
- temp_model = YNAB.const_get(type).new
156
- temp_model.build_from_hash(value)
185
+ # models (e.g. Pet) or oneOf
186
+ klass = YNAB.const_get(type)
187
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
157
188
  end
158
189
  end
159
190
 
@@ -175,7 +206,11 @@ module YNAB
175
206
  hash = {}
176
207
  self.class.attribute_map.each_pair do |attr, param|
177
208
  value = self.send(attr)
178
- next if value.nil?
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
179
214
  hash[param] = _to_hash(value)
180
215
  end
181
216
  hash