ynab 1.16.0 → 1.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/ynab.rb +12 -8
- data/lib/ynab/api/accounts_api.rb +63 -5
- data/lib/ynab/api/budgets_api.rb +5 -5
- data/lib/ynab/api/categories_api.rb +9 -9
- data/lib/ynab/api/deprecated_api.rb +3 -3
- data/lib/ynab/api/months_api.rb +5 -5
- data/lib/ynab/api/payee_locations_api.rb +9 -9
- data/lib/ynab/api/payees_api.rb +7 -7
- data/lib/ynab/api/scheduled_transactions_api.rb +5 -5
- data/lib/ynab/api/transactions_api.rb +71 -19
- data/lib/ynab/api/user_api.rb +1 -1
- data/lib/ynab/api_client.rb +3 -2
- data/lib/ynab/configuration.rb +2 -3
- data/lib/ynab/models/account.rb +25 -8
- data/lib/ynab/models/account_response.rb +4 -3
- data/lib/ynab/models/account_response_data.rb +4 -3
- data/lib/ynab/models/accounts_response.rb +4 -3
- data/lib/ynab/models/accounts_response_data.rb +4 -3
- data/lib/ynab/models/budget_detail.rb +4 -3
- data/lib/ynab/models/budget_detail_response.rb +4 -3
- data/lib/ynab/models/budget_detail_response_data.rb +4 -3
- data/lib/ynab/models/budget_settings.rb +4 -3
- data/lib/ynab/models/budget_settings_response.rb +4 -3
- data/lib/ynab/models/budget_settings_response_data.rb +4 -3
- data/lib/ynab/models/budget_summary.rb +4 -3
- data/lib/ynab/models/budget_summary_response.rb +4 -3
- data/lib/ynab/models/budget_summary_response_data.rb +4 -3
- data/lib/ynab/models/bulk_response.rb +4 -3
- data/lib/ynab/models/bulk_response_data.rb +4 -3
- data/lib/ynab/models/bulk_response_data_bulk.rb +4 -3
- data/lib/ynab/models/bulk_transactions.rb +4 -3
- data/lib/ynab/models/categories_response.rb +4 -3
- data/lib/ynab/models/categories_response_data.rb +4 -3
- data/lib/ynab/models/category.rb +46 -9
- data/lib/ynab/models/category_group.rb +4 -3
- data/lib/ynab/models/category_group_with_categories.rb +4 -3
- data/lib/ynab/models/category_response.rb +4 -3
- data/lib/ynab/models/category_response_data.rb +4 -3
- data/lib/ynab/models/currency_format.rb +4 -3
- data/lib/ynab/models/date_format.rb +4 -3
- data/lib/ynab/models/error_detail.rb +4 -3
- data/lib/ynab/models/error_response.rb +4 -3
- data/lib/ynab/models/hybrid_transaction.rb +4 -15
- data/lib/ynab/models/hybrid_transactions_response.rb +4 -3
- data/lib/ynab/models/hybrid_transactions_response_data.rb +4 -3
- data/lib/ynab/models/month_detail.rb +4 -3
- data/lib/ynab/models/month_detail_response.rb +4 -3
- data/lib/ynab/models/month_detail_response_data.rb +4 -3
- data/lib/ynab/models/month_summaries_response.rb +4 -3
- data/lib/ynab/models/month_summaries_response_data.rb +4 -3
- data/lib/ynab/models/month_summary.rb +4 -3
- data/lib/ynab/models/payee.rb +4 -3
- data/lib/ynab/models/payee_location.rb +4 -3
- data/lib/ynab/models/payee_location_response.rb +4 -3
- data/lib/ynab/models/payee_location_response_data.rb +4 -3
- data/lib/ynab/models/payee_locations_response.rb +4 -3
- data/lib/ynab/models/payee_locations_response_data.rb +4 -3
- data/lib/ynab/models/payee_response.rb +4 -3
- data/lib/ynab/models/payee_response_data.rb +4 -3
- data/lib/ynab/models/payees_response.rb +4 -3
- data/lib/ynab/models/payees_response_data.rb +4 -3
- data/lib/ynab/models/save_account.rb +250 -0
- data/lib/ynab/models/save_account_wrapper.rb +189 -0
- data/lib/ynab/models/save_category_response.rb +4 -3
- data/lib/ynab/models/save_category_response_data.rb +4 -3
- data/lib/ynab/models/save_month_category.rb +4 -3
- data/lib/ynab/models/save_month_category_wrapper.rb +4 -3
- data/lib/ynab/models/save_sub_transaction.rb +5 -4
- data/lib/ynab/models/save_transaction.rb +4 -11
- data/lib/ynab/models/save_transaction_wrapper.rb +4 -3
- data/lib/ynab/models/save_transactions_response.rb +4 -3
- data/lib/ynab/models/save_transactions_response_data.rb +4 -3
- data/lib/ynab/models/save_transactions_wrapper.rb +4 -3
- data/lib/ynab/models/scheduled_sub_transaction.rb +4 -3
- data/lib/ynab/models/scheduled_transaction_detail.rb +4 -11
- data/lib/ynab/models/scheduled_transaction_response.rb +4 -3
- data/lib/ynab/models/scheduled_transaction_response_data.rb +4 -3
- data/lib/ynab/models/scheduled_transaction_summary.rb +4 -11
- data/lib/ynab/models/scheduled_transactions_response.rb +4 -3
- data/lib/ynab/models/scheduled_transactions_response_data.rb +4 -3
- data/lib/ynab/models/sub_transaction.rb +15 -4
- data/lib/ynab/models/transaction_detail.rb +4 -11
- data/lib/ynab/models/transaction_response.rb +4 -3
- data/lib/ynab/models/transaction_response_data.rb +4 -3
- data/lib/ynab/models/transaction_summary.rb +4 -11
- data/lib/ynab/models/transactions_import_response.rb +189 -0
- data/lib/ynab/models/transactions_import_response_data.rb +192 -0
- data/lib/ynab/models/transactions_response.rb +4 -3
- data/lib/ynab/models/transactions_response_data.rb +4 -3
- data/lib/ynab/models/update_transaction.rb +8 -29
- data/lib/ynab/models/update_transactions_wrapper.rb +4 -3
- data/lib/ynab/models/user.rb +4 -3
- data/lib/ynab/models/user_response.rb +4 -3
- data/lib/ynab/models/user_response_data.rb +4 -3
- data/lib/ynab/version.rb +1 -1
- data/spec/api/accounts_spec.rb +19 -10
- data/spec/api/budgets_spec.rb +4 -4
- data/spec/api/categories_spec.rb +5 -5
- data/spec/api/months_spec.rb +4 -4
- data/spec/api/payee_locations_spec.rb +4 -4
- data/spec/api/payees_spec.rb +4 -4
- data/spec/api/scheduled_transactions_spec.rb +4 -4
- data/spec/api/transactions_spec.rb +23 -13
- data/spec/fixtures/vcr_cassettes/create_account.yml +51 -0
- data/spec/fixtures/vcr_cassettes/import_transactions.yml +50 -0
- data/spec/models/transaction_detail_spec.rb +11 -0
- metadata +12 -2
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.0.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -80,7 +80,6 @@ module YNAB
|
|
80
80
|
def hash
|
81
81
|
[data].hash
|
82
82
|
end
|
83
|
-
|
84
83
|
# Builds the object from hash
|
85
84
|
# @param [Hash] attributes Model attributes in the form of hash
|
86
85
|
# @return [Object] Returns the model itself
|
@@ -88,7 +87,7 @@ module YNAB
|
|
88
87
|
return nil unless attributes.is_a?(Hash)
|
89
88
|
self.class.swagger_types.each_pair do |key, type|
|
90
89
|
if type =~ /\AArray<(.*)>/i
|
91
|
-
# check to ensure the input is an array given that the
|
90
|
+
# check to ensure the input is an array given that the attribute
|
92
91
|
# is documented as an array but the input is not
|
93
92
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
94
93
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -184,5 +183,7 @@ module YNAB
|
|
184
183
|
value
|
185
184
|
end
|
186
185
|
end
|
186
|
+
|
187
187
|
end
|
188
|
+
|
188
189
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.0.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -97,7 +97,6 @@ module YNAB
|
|
97
97
|
def hash
|
98
98
|
[transactions, server_knowledge].hash
|
99
99
|
end
|
100
|
-
|
101
100
|
# Builds the object from hash
|
102
101
|
# @param [Hash] attributes Model attributes in the form of hash
|
103
102
|
# @return [Object] Returns the model itself
|
@@ -105,7 +104,7 @@ module YNAB
|
|
105
104
|
return nil unless attributes.is_a?(Hash)
|
106
105
|
self.class.swagger_types.each_pair do |key, type|
|
107
106
|
if type =~ /\AArray<(.*)>/i
|
108
|
-
# check to ensure the input is an array given that the
|
107
|
+
# check to ensure the input is an array given that the attribute
|
109
108
|
# is documented as an array but the input is not
|
110
109
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
111
110
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -201,5 +200,7 @@ module YNAB
|
|
201
200
|
value
|
202
201
|
end
|
203
202
|
end
|
203
|
+
|
204
204
|
end
|
205
|
+
|
205
206
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.0.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -48,8 +48,6 @@ module YNAB
|
|
48
48
|
# An array of subtransactions to configure a transaction as a split. Updating `subtransactions` on an existing split transaction is not supported.
|
49
49
|
attr_accessor :subtransactions
|
50
50
|
|
51
|
-
attr_accessor :id
|
52
|
-
|
53
51
|
class EnumAttributeValidator
|
54
52
|
attr_reader :datatype
|
55
53
|
attr_reader :allowable_values
|
@@ -86,8 +84,7 @@ module YNAB
|
|
86
84
|
:'approved' => :'approved',
|
87
85
|
:'flag_color' => :'flag_color',
|
88
86
|
:'import_id' => :'import_id',
|
89
|
-
:'subtransactions' => :'subtransactions'
|
90
|
-
:'id' => :'id'
|
87
|
+
:'subtransactions' => :'subtransactions'
|
91
88
|
}
|
92
89
|
end
|
93
90
|
|
@@ -105,8 +102,7 @@ module YNAB
|
|
105
102
|
:'approved' => :'BOOLEAN',
|
106
103
|
:'flag_color' => :'String',
|
107
104
|
:'import_id' => :'String',
|
108
|
-
:'subtransactions' => :'Array<SaveSubTransaction>'
|
109
|
-
:'id' => :'String'
|
105
|
+
:'subtransactions' => :'Array<SaveSubTransaction>'
|
110
106
|
}
|
111
107
|
end
|
112
108
|
|
@@ -167,10 +163,6 @@ module YNAB
|
|
167
163
|
self.subtransactions = value
|
168
164
|
end
|
169
165
|
end
|
170
|
-
|
171
|
-
if attributes.has_key?(:'id')
|
172
|
-
self.id = attributes[:'id']
|
173
|
-
end
|
174
166
|
end
|
175
167
|
|
176
168
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -201,10 +193,6 @@ module YNAB
|
|
201
193
|
invalid_properties.push('invalid value for "import_id", the character length must be smaller than or equal to 36.')
|
202
194
|
end
|
203
195
|
|
204
|
-
if @id.nil?
|
205
|
-
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
206
|
-
end
|
207
|
-
|
208
196
|
invalid_properties
|
209
197
|
end
|
210
198
|
|
@@ -221,7 +209,6 @@ module YNAB
|
|
221
209
|
flag_color_validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
|
222
210
|
return false unless flag_color_validator.valid?(@flag_color)
|
223
211
|
return false if !@import_id.nil? && @import_id.to_s.length > 36
|
224
|
-
return false if @id.nil?
|
225
212
|
true
|
226
213
|
end
|
227
214
|
|
@@ -248,20 +235,12 @@ module YNAB
|
|
248
235
|
# Custom attribute writer method checking allowed values (enum).
|
249
236
|
# @param [Object] cleared Object to be assigned
|
250
237
|
def cleared=(cleared)
|
251
|
-
validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
|
252
|
-
unless validator.valid?(cleared)
|
253
|
-
fail ArgumentError, 'invalid value for "cleared", must be one of #{validator.allowable_values}.'
|
254
|
-
end
|
255
238
|
@cleared = cleared
|
256
239
|
end
|
257
240
|
|
258
241
|
# Custom attribute writer method checking allowed values (enum).
|
259
242
|
# @param [Object] flag_color Object to be assigned
|
260
243
|
def flag_color=(flag_color)
|
261
|
-
validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
|
262
|
-
unless validator.valid?(flag_color)
|
263
|
-
fail ArgumentError, 'invalid value for "flag_color", must be one of #{validator.allowable_values}.'
|
264
|
-
end
|
265
244
|
@flag_color = flag_color
|
266
245
|
end
|
267
246
|
|
@@ -291,8 +270,7 @@ module YNAB
|
|
291
270
|
approved == o.approved &&
|
292
271
|
flag_color == o.flag_color &&
|
293
272
|
import_id == o.import_id &&
|
294
|
-
subtransactions == o.subtransactions
|
295
|
-
id == o.id
|
273
|
+
subtransactions == o.subtransactions
|
296
274
|
end
|
297
275
|
|
298
276
|
# @see the `==` method
|
@@ -304,9 +282,8 @@ module YNAB
|
|
304
282
|
# Calculates hash code according to all attributes.
|
305
283
|
# @return [Fixnum] Hash code
|
306
284
|
def hash
|
307
|
-
[account_id, date, amount, payee_id, payee_name, category_id, memo, cleared, approved, flag_color, import_id, subtransactions
|
285
|
+
[account_id, date, amount, payee_id, payee_name, category_id, memo, cleared, approved, flag_color, import_id, subtransactions].hash
|
308
286
|
end
|
309
|
-
|
310
287
|
# Builds the object from hash
|
311
288
|
# @param [Hash] attributes Model attributes in the form of hash
|
312
289
|
# @return [Object] Returns the model itself
|
@@ -314,7 +291,7 @@ module YNAB
|
|
314
291
|
return nil unless attributes.is_a?(Hash)
|
315
292
|
self.class.swagger_types.each_pair do |key, type|
|
316
293
|
if type =~ /\AArray<(.*)>/i
|
317
|
-
# check to ensure the input is an array given that the
|
294
|
+
# check to ensure the input is an array given that the attribute
|
318
295
|
# is documented as an array but the input is not
|
319
296
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
320
297
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -410,5 +387,7 @@ module YNAB
|
|
410
387
|
value
|
411
388
|
end
|
412
389
|
end
|
390
|
+
|
413
391
|
end
|
392
|
+
|
414
393
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.0.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -82,7 +82,6 @@ module YNAB
|
|
82
82
|
def hash
|
83
83
|
[transactions].hash
|
84
84
|
end
|
85
|
-
|
86
85
|
# Builds the object from hash
|
87
86
|
# @param [Hash] attributes Model attributes in the form of hash
|
88
87
|
# @return [Object] Returns the model itself
|
@@ -90,7 +89,7 @@ module YNAB
|
|
90
89
|
return nil unless attributes.is_a?(Hash)
|
91
90
|
self.class.swagger_types.each_pair do |key, type|
|
92
91
|
if type =~ /\AArray<(.*)>/i
|
93
|
-
# check to ensure the input is an array given that the
|
92
|
+
# check to ensure the input is an array given that the attribute
|
94
93
|
# is documented as an array but the input is not
|
95
94
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
96
95
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -186,5 +185,7 @@ module YNAB
|
|
186
185
|
value
|
187
186
|
end
|
188
187
|
end
|
188
|
+
|
189
189
|
end
|
190
|
+
|
190
191
|
end
|
data/lib/ynab/models/user.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.0.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -80,7 +80,6 @@ module YNAB
|
|
80
80
|
def hash
|
81
81
|
[id].hash
|
82
82
|
end
|
83
|
-
|
84
83
|
# Builds the object from hash
|
85
84
|
# @param [Hash] attributes Model attributes in the form of hash
|
86
85
|
# @return [Object] Returns the model itself
|
@@ -88,7 +87,7 @@ module YNAB
|
|
88
87
|
return nil unless attributes.is_a?(Hash)
|
89
88
|
self.class.swagger_types.each_pair do |key, type|
|
90
89
|
if type =~ /\AArray<(.*)>/i
|
91
|
-
# check to ensure the input is an array given that the
|
90
|
+
# check to ensure the input is an array given that the attribute
|
92
91
|
# is documented as an array but the input is not
|
93
92
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
94
93
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -184,5 +183,7 @@ module YNAB
|
|
184
183
|
value
|
185
184
|
end
|
186
185
|
end
|
186
|
+
|
187
187
|
end
|
188
|
+
|
188
189
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.0.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -80,7 +80,6 @@ module YNAB
|
|
80
80
|
def hash
|
81
81
|
[data].hash
|
82
82
|
end
|
83
|
-
|
84
83
|
# Builds the object from hash
|
85
84
|
# @param [Hash] attributes Model attributes in the form of hash
|
86
85
|
# @return [Object] Returns the model itself
|
@@ -88,7 +87,7 @@ module YNAB
|
|
88
87
|
return nil unless attributes.is_a?(Hash)
|
89
88
|
self.class.swagger_types.each_pair do |key, type|
|
90
89
|
if type =~ /\AArray<(.*)>/i
|
91
|
-
# check to ensure the input is an array given that the
|
90
|
+
# check to ensure the input is an array given that the attribute
|
92
91
|
# is documented as an array but the input is not
|
93
92
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
94
93
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -184,5 +183,7 @@ module YNAB
|
|
184
183
|
value
|
185
184
|
end
|
186
185
|
end
|
186
|
+
|
187
187
|
end
|
188
|
+
|
188
189
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.0.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -80,7 +80,6 @@ module YNAB
|
|
80
80
|
def hash
|
81
81
|
[user].hash
|
82
82
|
end
|
83
|
-
|
84
83
|
# Builds the object from hash
|
85
84
|
# @param [Hash] attributes Model attributes in the form of hash
|
86
85
|
# @return [Object] Returns the model itself
|
@@ -88,7 +87,7 @@ module YNAB
|
|
88
87
|
return nil unless attributes.is_a?(Hash)
|
89
88
|
self.class.swagger_types.each_pair do |key, type|
|
90
89
|
if type =~ /\AArray<(.*)>/i
|
91
|
-
# check to ensure the input is an array given that the
|
90
|
+
# check to ensure the input is an array given that the attribute
|
92
91
|
# is documented as an array but the input is not
|
93
92
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
94
93
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -184,5 +183,7 @@ module YNAB
|
|
184
183
|
value
|
185
184
|
end
|
186
185
|
end
|
186
|
+
|
187
187
|
end
|
188
|
+
|
188
189
|
end
|
data/lib/ynab/version.rb
CHANGED
data/spec/api/accounts_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe 'accounts' do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'authorization' do
|
16
|
-
it
|
16
|
+
it 'sets the Bearer Auth header correctly' do
|
17
17
|
VCR.use_cassette("accounts") do
|
18
18
|
response = instance.get_accounts(budget_id)
|
19
19
|
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
@@ -21,7 +21,7 @@ describe 'accounts' do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'throws when unauthorized' do
|
25
25
|
VCR.use_cassette("accounts_unauthorized") do
|
26
26
|
client = YNAB::API.new('not_valid_access_token', 'api.localhost:3000', false)
|
27
27
|
begin
|
@@ -35,7 +35,7 @@ describe 'accounts' do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe 'GET /budgets/{budget_id}/accounts' do
|
38
|
-
it
|
38
|
+
it 'returns a list of accounts' do
|
39
39
|
VCR.use_cassette("accounts") do
|
40
40
|
response = instance.get_accounts(budget_id)
|
41
41
|
expect(client.last_request.response.options[:code]).to be 200
|
@@ -45,7 +45,7 @@ describe 'accounts' do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
describe 'GET /budgets/{budget_id}/accounts/{account_id}' do
|
48
|
-
it
|
48
|
+
it 'returns an account' do
|
49
49
|
VCR.use_cassette("account") do
|
50
50
|
response = instance.get_account_by_id(budget_id, '5982e895-98e5-41ca-9681-0b6de1036a1c')
|
51
51
|
expect(response.data.account).to be
|
@@ -54,12 +54,21 @@ describe 'accounts' do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
describe 'POST /budgets/{budget_id}/accounts' do
|
58
|
+
it 'creates an account' do
|
59
|
+
VCR.use_cassette("create_account") do
|
60
|
+
response = instance.create_account(budget_id, {
|
61
|
+
account: {
|
62
|
+
name: 'New Checking Account',
|
63
|
+
type: 'checking',
|
64
|
+
balance: 215000
|
65
|
+
}
|
66
|
+
})
|
67
|
+
|
68
|
+
expect(client.last_request.response.options[:code]).to be 201
|
69
|
+
expect(response.data.account).to be
|
70
|
+
expect(response.data.account.balance).to eq 215000
|
71
|
+
end
|
63
72
|
end
|
64
73
|
end
|
65
74
|
end
|
data/spec/api/budgets_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe 'budgets' do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe 'authorization' do
|
15
|
-
it
|
15
|
+
it 'sets the Bearer Auth header correctly' do
|
16
16
|
VCR.use_cassette("budgets") do
|
17
17
|
response = instance.get_budgets
|
18
18
|
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
@@ -20,7 +20,7 @@ describe 'budgets' do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'throws when unauthorized' do
|
24
24
|
VCR.use_cassette("budgets_unauthorized") do
|
25
25
|
client = YNAB::API.new('not_valid_access_token', 'api.localhost:3000', false)
|
26
26
|
begin
|
@@ -34,7 +34,7 @@ describe 'budgets' do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
describe 'GET /budgets' do
|
37
|
-
it
|
37
|
+
it 'returns a list of budgets' do
|
38
38
|
VCR.use_cassette("budgets") do
|
39
39
|
response = instance.get_budgets
|
40
40
|
expect(client.last_request.response.options[:code]).to be 200
|
@@ -44,7 +44,7 @@ describe 'budgets' do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe 'GET /budgets/{budget_id}' do
|
47
|
-
it
|
47
|
+
it 'returns a budget' do
|
48
48
|
VCR.use_cassette("budget") do
|
49
49
|
response = instance.get_budget_by_id('f419ac25-6217-4175-88dc-c3136ff5f6fd')
|
50
50
|
expect(response.data.budget).to be
|
data/spec/api/categories_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe 'categories' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe 'authorization' do
|
17
|
-
it
|
17
|
+
it 'sets the Bearer Auth header correctly' do
|
18
18
|
VCR.use_cassette("categories") do
|
19
19
|
response = instance.get_categories(budget_id)
|
20
20
|
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
@@ -22,7 +22,7 @@ describe 'categories' do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it 'throws when unauthorized' do
|
26
26
|
VCR.use_cassette("categories_unauthorized") do
|
27
27
|
client = YNAB::API.new('not_valid_access_token', 'api.localhost:3000', false)
|
28
28
|
begin
|
@@ -36,7 +36,7 @@ describe 'categories' do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
describe 'GET /budgets/{budget_id}/categories' do
|
39
|
-
it
|
39
|
+
it 'returns a list of categories' do
|
40
40
|
VCR.use_cassette("categories") do
|
41
41
|
response = instance.get_categories(budget_id)
|
42
42
|
expect(client.last_request.response.options[:code]).to be 200
|
@@ -47,7 +47,7 @@ describe 'categories' do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe 'GET /budgets/{budget_id}/categories/{category_id}' do
|
50
|
-
it
|
50
|
+
it 'returns a category' do
|
51
51
|
VCR.use_cassette("category") do
|
52
52
|
response = instance.get_category_by_id(budget_id, category_id)
|
53
53
|
expect(response.data.category).to be
|
@@ -57,7 +57,7 @@ describe 'categories' do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe 'PATCH /budgets/{budget_id}/months/{month}/categories/{category_id}' do
|
60
|
-
it
|
60
|
+
it 'returns a category' do
|
61
61
|
VCR.use_cassette("patch_month_category") do
|
62
62
|
response = instance.update_month_category(budget_id, '2018-02-01', category_id, month_category: { budgeted: 20382 })
|
63
63
|
expect(response.data.category).to be
|