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 SaveMonthCategory
@@ -24,22 +25,40 @@ module YNAB
24
25
  }
25
26
  end
26
27
 
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
27
33
  # Attribute type mapping.
28
- def self.swagger_types
34
+ def self.openapi_types
29
35
  {
30
36
  :'budgeted' => :'Integer'
31
37
  }
32
38
  end
33
39
 
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
34
46
  # Initializes the object
35
47
  # @param [Hash] attributes Model attributes in the form of hash
36
48
  def initialize(attributes = {})
37
- return unless attributes.is_a?(Hash)
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SaveMonthCategory` initialize method"
51
+ end
38
52
 
39
- # convert string to symbol for hash key
40
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SaveMonthCategory`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
41
60
 
42
- if attributes.has_key?(:'budgeted')
61
+ if attributes.key?(:'budgeted')
43
62
  self.budgeted = attributes[:'budgeted']
44
63
  end
45
64
  end
@@ -77,17 +96,28 @@ module YNAB
77
96
  end
78
97
 
79
98
  # Calculates hash code according to all attributes.
80
- # @return [Fixnum] Hash code
99
+ # @return [Integer] Hash code
81
100
  def hash
82
101
  [budgeted].hash
83
102
  end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def self.build_from_hash(attributes)
108
+ new.build_from_hash(attributes)
109
+ end
110
+
84
111
  # Builds the object from hash
85
112
  # @param [Hash] attributes Model attributes in the form of hash
86
113
  # @return [Object] Returns the model itself
87
114
  def build_from_hash(attributes)
88
115
  return nil unless attributes.is_a?(Hash)
89
- self.class.swagger_types.each_pair do |key, type|
90
- if type =~ /\AArray<(.*)>/i
116
+ attributes = attributes.transform_keys(&:to_sym)
117
+ self.class.openapi_types.each_pair do |key, type|
118
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
119
+ self.send("#{key}=", nil)
120
+ elsif type =~ /\AArray<(.*)>/i
91
121
  # check to ensure the input is an array given that the attribute
92
122
  # is documented as an array but the input is not
93
123
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -95,7 +125,7 @@ module YNAB
95
125
  end
96
126
  elsif !attributes[self.class.attribute_map[key]].nil?
97
127
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
98
- end # or else data not found in attributes(hash), not an issue as the data can be optional
128
+ end
99
129
  end
100
130
 
101
131
  self
@@ -107,8 +137,8 @@ module YNAB
107
137
  # @return [Object] Deserialized data
108
138
  def _deserialize(type, value)
109
139
  case type.to_sym
110
- when :DateTime
111
- DateTime.parse(value)
140
+ when :Time
141
+ Time.parse(value)
112
142
  when :Date
113
143
  Date.parse(value)
114
144
  when :String
@@ -117,7 +147,7 @@ module YNAB
117
147
  value.to_i
118
148
  when :Float
119
149
  value.to_f
120
- when :BOOLEAN
150
+ when :Boolean
121
151
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
152
  true
123
153
  else
@@ -138,8 +168,9 @@ module YNAB
138
168
  end
139
169
  end
140
170
  else # model
141
- temp_model = YNAB.const_get(type).new
142
- temp_model.build_from_hash(value)
171
+ # models (e.g. Pet) or oneOf
172
+ klass = YNAB.const_get(type)
173
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
143
174
  end
144
175
  end
145
176
 
@@ -161,7 +192,11 @@ module YNAB
161
192
  hash = {}
162
193
  self.class.attribute_map.each_pair do |attr, param|
163
194
  value = self.send(attr)
164
- next if value.nil?
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
165
200
  hash[param] = _to_hash(value)
166
201
  end
167
202
  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 SaveSubTransaction
@@ -39,8 +40,13 @@ module YNAB
39
40
  }
40
41
  end
41
42
 
43
+ # Returns all the JSON keys this model knows about
44
+ def self.acceptable_attributes
45
+ attribute_map.values
46
+ end
47
+
42
48
  # Attribute type mapping.
43
- def self.swagger_types
49
+ def self.openapi_types
44
50
  {
45
51
  :'amount' => :'Integer',
46
52
  :'payee_id' => :'String',
@@ -50,31 +56,48 @@ module YNAB
50
56
  }
51
57
  end
52
58
 
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ :'payee_id',
63
+ :'payee_name',
64
+ :'category_id',
65
+ :'memo'
66
+ ])
67
+ end
68
+
53
69
  # Initializes the object
54
70
  # @param [Hash] attributes Model attributes in the form of hash
55
71
  def initialize(attributes = {})
56
- return unless attributes.is_a?(Hash)
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SaveSubTransaction` initialize method"
74
+ end
57
75
 
58
- # convert string to symbol for hash key
59
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h|
78
+ if (!self.class.attribute_map.key?(k.to_sym))
79
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SaveSubTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
+ end
81
+ h[k.to_sym] = v
82
+ }
60
83
 
61
- if attributes.has_key?(:'amount')
84
+ if attributes.key?(:'amount')
62
85
  self.amount = attributes[:'amount']
63
86
  end
64
87
 
65
- if attributes.has_key?(:'payee_id')
88
+ if attributes.key?(:'payee_id')
66
89
  self.payee_id = attributes[:'payee_id']
67
90
  end
68
91
 
69
- if attributes.has_key?(:'payee_name')
92
+ if attributes.key?(:'payee_name')
70
93
  self.payee_name = attributes[:'payee_name']
71
94
  end
72
95
 
73
- if attributes.has_key?(:'category_id')
96
+ if attributes.key?(:'category_id')
74
97
  self.category_id = attributes[:'category_id']
75
98
  end
76
99
 
77
- if attributes.has_key?(:'memo')
100
+ if attributes.key?(:'memo')
78
101
  self.memo = attributes[:'memo']
79
102
  end
80
103
  end
@@ -146,17 +169,28 @@ module YNAB
146
169
  end
147
170
 
148
171
  # Calculates hash code according to all attributes.
149
- # @return [Fixnum] Hash code
172
+ # @return [Integer] Hash code
150
173
  def hash
151
174
  [amount, payee_id, payee_name, category_id, memo].hash
152
175
  end
176
+
177
+ # Builds the object from hash
178
+ # @param [Hash] attributes Model attributes in the form of hash
179
+ # @return [Object] Returns the model itself
180
+ def self.build_from_hash(attributes)
181
+ new.build_from_hash(attributes)
182
+ end
183
+
153
184
  # Builds the object from hash
154
185
  # @param [Hash] attributes Model attributes in the form of hash
155
186
  # @return [Object] Returns the model itself
156
187
  def build_from_hash(attributes)
157
188
  return nil unless attributes.is_a?(Hash)
158
- self.class.swagger_types.each_pair do |key, type|
159
- if type =~ /\AArray<(.*)>/i
189
+ attributes = attributes.transform_keys(&:to_sym)
190
+ self.class.openapi_types.each_pair do |key, type|
191
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
192
+ self.send("#{key}=", nil)
193
+ elsif type =~ /\AArray<(.*)>/i
160
194
  # check to ensure the input is an array given that the attribute
161
195
  # is documented as an array but the input is not
162
196
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -164,7 +198,7 @@ module YNAB
164
198
  end
165
199
  elsif !attributes[self.class.attribute_map[key]].nil?
166
200
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
167
- end # or else data not found in attributes(hash), not an issue as the data can be optional
201
+ end
168
202
  end
169
203
 
170
204
  self
@@ -176,8 +210,8 @@ module YNAB
176
210
  # @return [Object] Deserialized data
177
211
  def _deserialize(type, value)
178
212
  case type.to_sym
179
- when :DateTime
180
- DateTime.parse(value)
213
+ when :Time
214
+ Time.parse(value)
181
215
  when :Date
182
216
  Date.parse(value)
183
217
  when :String
@@ -186,7 +220,7 @@ module YNAB
186
220
  value.to_i
187
221
  when :Float
188
222
  value.to_f
189
- when :BOOLEAN
223
+ when :Boolean
190
224
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
191
225
  true
192
226
  else
@@ -207,8 +241,9 @@ module YNAB
207
241
  end
208
242
  end
209
243
  else # model
210
- temp_model = YNAB.const_get(type).new
211
- temp_model.build_from_hash(value)
244
+ # models (e.g. Pet) or oneOf
245
+ klass = YNAB.const_get(type)
246
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
212
247
  end
213
248
  end
214
249
 
@@ -230,7 +265,11 @@ module YNAB
230
265
  hash = {}
231
266
  self.class.attribute_map.each_pair do |attr, param|
232
267
  value = self.send(attr)
233
- next if value.nil?
268
+ if value.nil?
269
+ is_nullable = self.class.openapi_nullable.include?(attr)
270
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
271
+ end
272
+
234
273
  hash[param] = _to_hash(value)
235
274
  end
236
275
  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 SaveTransaction
@@ -45,7 +46,7 @@ module YNAB
45
46
  # If specified, the new transaction will be assigned this `import_id` and considered \"imported\". We will also attempt to match this imported transaction to an existing \"user-entered\" transation on the same account, with the same amount, and with a date +/-10 days from the imported transaction date.<br><br>Transactions imported through File Based Import or Direct Import (not through the API) are assigned an import_id in the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. Using a consistent format will prevent duplicates through Direct Import and File Based Import.<br><br>If import_id is omitted or specified as null, the transaction will be treated as a \"user-entered\" transaction. As such, it will be eligible to be matched against transactions later being imported (via DI, FBI, or API).
46
47
  attr_accessor :import_id
47
48
 
48
- # An array of subtransactions to configure a transaction as a split. Updating `subtransactions` on an existing split transaction is not supported.
49
+ # An array of subtransactions to configure a transaction as a split. Updating `subtransactions` on an existing split transaction is not supported.
49
50
  attr_accessor :subtransactions
50
51
 
51
52
  class EnumAttributeValidator
@@ -88,8 +89,13 @@ module YNAB
88
89
  }
89
90
  end
90
91
 
92
+ # Returns all the JSON keys this model knows about
93
+ def self.acceptable_attributes
94
+ attribute_map.values
95
+ end
96
+
91
97
  # Attribute type mapping.
92
- def self.swagger_types
98
+ def self.openapi_types
93
99
  {
94
100
  :'account_id' => :'String',
95
101
  :'date' => :'Date',
@@ -99,66 +105,91 @@ module YNAB
99
105
  :'category_id' => :'String',
100
106
  :'memo' => :'String',
101
107
  :'cleared' => :'String',
102
- :'approved' => :'BOOLEAN',
108
+ :'approved' => :'Boolean',
103
109
  :'flag_color' => :'String',
104
110
  :'import_id' => :'String',
105
111
  :'subtransactions' => :'Array<SaveSubTransaction>'
106
112
  }
107
113
  end
108
114
 
115
+ # List of attributes with nullable: true
116
+ def self.openapi_nullable
117
+ Set.new([
118
+ :'payee_id',
119
+ :'payee_name',
120
+ :'category_id',
121
+ :'memo',
122
+ :'import_id',
123
+ ])
124
+ end
125
+
126
+ # List of class defined in allOf (OpenAPI v3)
127
+ def self.openapi_all_of
128
+ [
129
+ :'SaveTransactionWithOptionalFields'
130
+ ]
131
+ end
132
+
109
133
  # Initializes the object
110
134
  # @param [Hash] attributes Model attributes in the form of hash
111
135
  def initialize(attributes = {})
112
- return unless attributes.is_a?(Hash)
136
+ if (!attributes.is_a?(Hash))
137
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SaveTransaction` initialize method"
138
+ end
113
139
 
114
- # convert string to symbol for hash key
115
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
140
+ # check to see if the attribute exists and convert string to symbol for hash key
141
+ attributes = attributes.each_with_object({}) { |(k, v), h|
142
+ if (!self.class.attribute_map.key?(k.to_sym))
143
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SaveTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
144
+ end
145
+ h[k.to_sym] = v
146
+ }
116
147
 
117
- if attributes.has_key?(:'account_id')
148
+ if attributes.key?(:'account_id')
118
149
  self.account_id = attributes[:'account_id']
119
150
  end
120
151
 
121
- if attributes.has_key?(:'date')
152
+ if attributes.key?(:'date')
122
153
  self.date = attributes[:'date']
123
154
  end
124
155
 
125
- if attributes.has_key?(:'amount')
156
+ if attributes.key?(:'amount')
126
157
  self.amount = attributes[:'amount']
127
158
  end
128
159
 
129
- if attributes.has_key?(:'payee_id')
160
+ if attributes.key?(:'payee_id')
130
161
  self.payee_id = attributes[:'payee_id']
131
162
  end
132
163
 
133
- if attributes.has_key?(:'payee_name')
164
+ if attributes.key?(:'payee_name')
134
165
  self.payee_name = attributes[:'payee_name']
135
166
  end
136
167
 
137
- if attributes.has_key?(:'category_id')
168
+ if attributes.key?(:'category_id')
138
169
  self.category_id = attributes[:'category_id']
139
170
  end
140
171
 
141
- if attributes.has_key?(:'memo')
172
+ if attributes.key?(:'memo')
142
173
  self.memo = attributes[:'memo']
143
174
  end
144
175
 
145
- if attributes.has_key?(:'cleared')
176
+ if attributes.key?(:'cleared')
146
177
  self.cleared = attributes[:'cleared']
147
178
  end
148
179
 
149
- if attributes.has_key?(:'approved')
180
+ if attributes.key?(:'approved')
150
181
  self.approved = attributes[:'approved']
151
182
  end
152
183
 
153
- if attributes.has_key?(:'flag_color')
184
+ if attributes.key?(:'flag_color')
154
185
  self.flag_color = attributes[:'flag_color']
155
186
  end
156
187
 
157
- if attributes.has_key?(:'import_id')
188
+ if attributes.key?(:'import_id')
158
189
  self.import_id = attributes[:'import_id']
159
190
  end
160
191
 
161
- if attributes.has_key?(:'subtransactions')
192
+ if attributes.key?(:'subtransactions')
162
193
  if (value = attributes[:'subtransactions']).is_a?(Array)
163
194
  self.subtransactions = value
164
195
  end
@@ -189,9 +220,9 @@ module YNAB
189
220
  def valid?
190
221
  return false if !@payee_name.nil? && @payee_name.to_s.length > 50
191
222
  return false if !@memo.nil? && @memo.to_s.length > 200
192
- cleared_validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
223
+ cleared_validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
193
224
  return false unless cleared_validator.valid?(@cleared)
194
- flag_color_validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
225
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple", "null"])
195
226
  return false unless flag_color_validator.valid?(@flag_color)
196
227
  return false if !@import_id.nil? && @import_id.to_s.length > 36
197
228
  true
@@ -220,12 +251,20 @@ module YNAB
220
251
  # Custom attribute writer method checking allowed values (enum).
221
252
  # @param [Object] cleared Object to be assigned
222
253
  def cleared=(cleared)
254
+ validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
255
+ unless validator.valid?(cleared)
256
+ fail ArgumentError, "invalid value for \"cleared\", must be one of #{validator.allowable_values}."
257
+ end
223
258
  @cleared = cleared
224
259
  end
225
260
 
226
261
  # Custom attribute writer method checking allowed values (enum).
227
262
  # @param [Object] flag_color Object to be assigned
228
263
  def flag_color=(flag_color)
264
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple", "null"])
265
+ unless validator.valid?(flag_color)
266
+ fail ArgumentError, "invalid value for \"flag_color\", must be one of #{validator.allowable_values}."
267
+ end
229
268
  @flag_color = flag_color
230
269
  end
231
270
 
@@ -265,17 +304,28 @@ module YNAB
265
304
  end
266
305
 
267
306
  # Calculates hash code according to all attributes.
268
- # @return [Fixnum] Hash code
307
+ # @return [Integer] Hash code
269
308
  def hash
270
309
  [account_id, date, amount, payee_id, payee_name, category_id, memo, cleared, approved, flag_color, import_id, subtransactions].hash
271
310
  end
311
+
312
+ # Builds the object from hash
313
+ # @param [Hash] attributes Model attributes in the form of hash
314
+ # @return [Object] Returns the model itself
315
+ def self.build_from_hash(attributes)
316
+ new.build_from_hash(attributes)
317
+ end
318
+
272
319
  # Builds the object from hash
273
320
  # @param [Hash] attributes Model attributes in the form of hash
274
321
  # @return [Object] Returns the model itself
275
322
  def build_from_hash(attributes)
276
323
  return nil unless attributes.is_a?(Hash)
277
- self.class.swagger_types.each_pair do |key, type|
278
- if type =~ /\AArray<(.*)>/i
324
+ attributes = attributes.transform_keys(&:to_sym)
325
+ self.class.openapi_types.each_pair do |key, type|
326
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
327
+ self.send("#{key}=", nil)
328
+ elsif type =~ /\AArray<(.*)>/i
279
329
  # check to ensure the input is an array given that the attribute
280
330
  # is documented as an array but the input is not
281
331
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -283,7 +333,7 @@ module YNAB
283
333
  end
284
334
  elsif !attributes[self.class.attribute_map[key]].nil?
285
335
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
286
- end # or else data not found in attributes(hash), not an issue as the data can be optional
336
+ end
287
337
  end
288
338
 
289
339
  self
@@ -295,8 +345,8 @@ module YNAB
295
345
  # @return [Object] Deserialized data
296
346
  def _deserialize(type, value)
297
347
  case type.to_sym
298
- when :DateTime
299
- DateTime.parse(value)
348
+ when :Time
349
+ Time.parse(value)
300
350
  when :Date
301
351
  Date.parse(value)
302
352
  when :String
@@ -305,7 +355,7 @@ module YNAB
305
355
  value.to_i
306
356
  when :Float
307
357
  value.to_f
308
- when :BOOLEAN
358
+ when :Boolean
309
359
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
310
360
  true
311
361
  else
@@ -326,8 +376,9 @@ module YNAB
326
376
  end
327
377
  end
328
378
  else # model
329
- temp_model = YNAB.const_get(type).new
330
- temp_model.build_from_hash(value)
379
+ # models (e.g. Pet) or oneOf
380
+ klass = YNAB.const_get(type)
381
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
331
382
  end
332
383
  end
333
384
 
@@ -349,7 +400,11 @@ module YNAB
349
400
  hash = {}
350
401
  self.class.attribute_map.each_pair do |attr, param|
351
402
  value = self.send(attr)
352
- next if value.nil?
403
+ if value.nil?
404
+ is_nullable = self.class.openapi_nullable.include?(attr)
405
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
406
+ end
407
+
353
408
  hash[param] = _to_hash(value)
354
409
  end
355
410
  hash