ynab 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.md +201 -0
- data/README.md +57 -0
- data/Rakefile +31 -0
- data/config.json +10 -0
- data/docs/Account.md +16 -0
- data/docs/AccountResponse.md +8 -0
- data/docs/AccountWrapper.md +8 -0
- data/docs/AccountsApi.md +121 -0
- data/docs/AccountsResponse.md +8 -0
- data/docs/AccountsWrapper.md +8 -0
- data/docs/BudgetDetail.md +22 -0
- data/docs/BudgetDetailResponse.md +8 -0
- data/docs/BudgetDetailWrapper.md +9 -0
- data/docs/BudgetSummary.md +12 -0
- data/docs/BudgetSummaryResponse.md +8 -0
- data/docs/BudgetSummaryWrapper.md +8 -0
- data/docs/BudgetsApi.md +116 -0
- data/docs/BulkIdWrapper.md +8 -0
- data/docs/BulkIds.md +9 -0
- data/docs/BulkResponse.md +8 -0
- data/docs/BulkTransactionCreateResponse.md +8 -0
- data/docs/BulkTransactionIds.md +8 -0
- data/docs/BulkTransactions.md +8 -0
- data/docs/CategoriesApi.md +121 -0
- data/docs/CategoriesResponse.md +8 -0
- data/docs/Category.md +15 -0
- data/docs/CategoryGroup.md +10 -0
- data/docs/CategoryGroupWithCategories.md +11 -0
- data/docs/CategoryGroupsWrapper.md +8 -0
- data/docs/CategoryResponse.md +8 -0
- data/docs/CategoryWrapper.md +8 -0
- data/docs/CurrencyFormat.md +8 -0
- data/docs/DateFormat.md +8 -0
- data/docs/ErrorDetail.md +10 -0
- data/docs/ErrorResponse.md +8 -0
- data/docs/MonthDetail.md +12 -0
- data/docs/MonthDetailResponse.md +8 -0
- data/docs/MonthDetailWrapper.md +8 -0
- data/docs/MonthSummariesResponse.md +8 -0
- data/docs/MonthSummariesWrapper.md +8 -0
- data/docs/MonthSummary.md +11 -0
- data/docs/MonthsApi.md +121 -0
- data/docs/Payee.md +10 -0
- data/docs/PayeeLocation.md +11 -0
- data/docs/PayeeLocationResponse.md +8 -0
- data/docs/PayeeLocationWrapper.md +8 -0
- data/docs/PayeeLocationsApi.md +179 -0
- data/docs/PayeeLocationsResponse.md +8 -0
- data/docs/PayeeLocationsWrapper.md +8 -0
- data/docs/PayeeResponse.md +8 -0
- data/docs/PayeeWrapper.md +8 -0
- data/docs/PayeesApi.md +121 -0
- data/docs/PayeesResponse.md +8 -0
- data/docs/PayeesWrapper.md +8 -0
- data/docs/SaveTransaction.md +18 -0
- data/docs/SaveTransactionWrapper.md +8 -0
- data/docs/ScheduledSubTransaction.md +14 -0
- data/docs/ScheduledTransactionDetail.md +19 -0
- data/docs/ScheduledTransactionResponse.md +8 -0
- data/docs/ScheduledTransactionSummary.md +18 -0
- data/docs/ScheduledTransactionWrapper.md +8 -0
- data/docs/ScheduledTransactionsApi.md +121 -0
- data/docs/ScheduledTransactionsResponse.md +8 -0
- data/docs/ScheduledTransactionsWrapper.md +8 -0
- data/docs/SubTransaction.md +14 -0
- data/docs/TransactionDetail.md +20 -0
- data/docs/TransactionResponse.md +8 -0
- data/docs/TransactionSummary.md +19 -0
- data/docs/TransactionWrapper.md +8 -0
- data/docs/TransactionsApi.md +428 -0
- data/docs/TransactionsResponse.md +8 -0
- data/docs/TransactionsWrapper.md +8 -0
- data/examples/budget-list.rb +25 -0
- data/examples/budget-month.rb +36 -0
- data/examples/category-balance.rb +27 -0
- data/lib/ynab.rb +136 -0
- data/lib/ynab/api/accounts_api.rb +135 -0
- data/lib/ynab/api/budgets_api.rb +126 -0
- data/lib/ynab/api/categories_api.rb +135 -0
- data/lib/ynab/api/months_api.rb +135 -0
- data/lib/ynab/api/payee_locations_api.rb +194 -0
- data/lib/ynab/api/payees_api.rb +135 -0
- data/lib/ynab/api/scheduled_transactions_api.rb +135 -0
- data/lib/ynab/api/transactions_api.rb +451 -0
- data/lib/ynab/api_client.rb +392 -0
- data/lib/ynab/api_error.rb +38 -0
- data/lib/ynab/configuration.rb +209 -0
- data/lib/ynab/models/account.rb +343 -0
- data/lib/ynab/models/account_response.rb +193 -0
- data/lib/ynab/models/account_wrapper.rb +193 -0
- data/lib/ynab/models/accounts_response.rb +193 -0
- data/lib/ynab/models/accounts_wrapper.rb +195 -0
- data/lib/ynab/models/budget_detail.rb +345 -0
- data/lib/ynab/models/budget_detail_response.rb +193 -0
- data/lib/ynab/models/budget_detail_wrapper.rb +208 -0
- data/lib/ynab/models/budget_summary.rb +235 -0
- data/lib/ynab/models/budget_summary_response.rb +193 -0
- data/lib/ynab/models/budget_summary_wrapper.rb +195 -0
- data/lib/ynab/models/bulk_id_wrapper.rb +193 -0
- data/lib/ynab/models/bulk_ids.rb +213 -0
- data/lib/ynab/models/bulk_response.rb +193 -0
- data/lib/ynab/models/bulk_transaction_create_response.rb +193 -0
- data/lib/ynab/models/bulk_transaction_ids.rb +195 -0
- data/lib/ynab/models/bulk_transactions.rb +195 -0
- data/lib/ynab/models/categories_response.rb +193 -0
- data/lib/ynab/models/category.rb +295 -0
- data/lib/ynab/models/category_group.rb +222 -0
- data/lib/ynab/models/category_group_with_categories.rb +239 -0
- data/lib/ynab/models/category_groups_wrapper.rb +195 -0
- data/lib/ynab/models/category_response.rb +193 -0
- data/lib/ynab/models/category_wrapper.rb +193 -0
- data/lib/ynab/models/currency_format.rb +193 -0
- data/lib/ynab/models/date_format.rb +193 -0
- data/lib/ynab/models/error_detail.rb +221 -0
- data/lib/ynab/models/error_response.rb +193 -0
- data/lib/ynab/models/month_detail.rb +253 -0
- data/lib/ynab/models/month_detail_response.rb +193 -0
- data/lib/ynab/models/month_detail_wrapper.rb +193 -0
- data/lib/ynab/models/month_summaries_response.rb +193 -0
- data/lib/ynab/models/month_summaries_wrapper.rb +195 -0
- data/lib/ynab/models/month_summary.rb +236 -0
- data/lib/ynab/models/payee.rb +222 -0
- data/lib/ynab/models/payee_location.rb +235 -0
- data/lib/ynab/models/payee_location_response.rb +193 -0
- data/lib/ynab/models/payee_location_wrapper.rb +193 -0
- data/lib/ynab/models/payee_locations_response.rb +193 -0
- data/lib/ynab/models/payee_locations_wrapper.rb +195 -0
- data/lib/ynab/models/payee_response.rb +193 -0
- data/lib/ynab/models/payee_wrapper.rb +193 -0
- data/lib/ynab/models/payees_response.rb +193 -0
- data/lib/ynab/models/payees_wrapper.rb +195 -0
- data/lib/ynab/models/save_transaction.rb +346 -0
- data/lib/ynab/models/save_transaction_wrapper.rb +193 -0
- data/lib/ynab/models/scheduled_sub_transaction.rb +279 -0
- data/lib/ynab/models/scheduled_transaction_detail.rb +387 -0
- data/lib/ynab/models/scheduled_transaction_response.rb +193 -0
- data/lib/ynab/models/scheduled_transaction_summary.rb +370 -0
- data/lib/ynab/models/scheduled_transaction_wrapper.rb +193 -0
- data/lib/ynab/models/scheduled_transactions_response.rb +193 -0
- data/lib/ynab/models/scheduled_transactions_wrapper.rb +195 -0
- data/lib/ynab/models/sub_transaction.rb +279 -0
- data/lib/ynab/models/transaction_detail.rb +401 -0
- data/lib/ynab/models/transaction_response.rb +193 -0
- data/lib/ynab/models/transaction_summary.rb +384 -0
- data/lib/ynab/models/transaction_wrapper.rb +193 -0
- data/lib/ynab/models/transactions_response.rb +193 -0
- data/lib/ynab/models/transactions_wrapper.rb +195 -0
- data/lib/ynab/version.rb +15 -0
- data/pkg/ynab-0.1.0.gem +0 -0
- data/spec-v1-swagger.json +2121 -0
- data/spec/api/accounts_spec.rb +56 -0
- data/spec/api/budgets_spec.rb +55 -0
- data/spec/api/categories_spec.rb +57 -0
- data/spec/api/months_spec.rb +57 -0
- data/spec/api/payee_locations_spec.rb +57 -0
- data/spec/api/payees_spec.rb +56 -0
- data/spec/api/scheduled_transactions_spec.rb +56 -0
- data/spec/api/transactions_spec.rb +122 -0
- data/spec/fixtures/.DS_Store +0 -0
- data/spec/fixtures/vcr_cassettes/account.yml +46 -0
- data/spec/fixtures/vcr_cassettes/accounts.yml +46 -0
- data/spec/fixtures/vcr_cassettes/accounts_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/budget.yml +1413 -0
- data/spec/fixtures/vcr_cassettes/budgets.yml +49 -0
- data/spec/fixtures/vcr_cassettes/budgets_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/bulk_transactions.yml +46 -0
- data/spec/fixtures/vcr_cassettes/categories.yml +67 -0
- data/spec/fixtures/vcr_cassettes/categories_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/category.yml +46 -0
- data/spec/fixtures/vcr_cassettes/create_transaction.yml +46 -0
- data/spec/fixtures/vcr_cassettes/month.yml +59 -0
- data/spec/fixtures/vcr_cassettes/months.yml +47 -0
- data/spec/fixtures/vcr_cassettes/months_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/payee.yml +47 -0
- data/spec/fixtures/vcr_cassettes/payee_location.yml +46 -0
- data/spec/fixtures/vcr_cassettes/payee_locations.yml +46 -0
- data/spec/fixtures/vcr_cassettes/payee_locations_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/payees.yml +51 -0
- data/spec/fixtures/vcr_cassettes/payees_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/scheduled_transaction.yml +46 -0
- data/spec/fixtures/vcr_cassettes/scheduled_transactions.yml +46 -0
- data/spec/fixtures/vcr_cassettes/scheduled_transactions_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/transaction.yml +46 -0
- data/spec/fixtures/vcr_cassettes/transactions.yml +46 -0
- data/spec/fixtures/vcr_cassettes/transactions_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/update_transaction.yml +46 -0
- data/spec/spec_helper.rb +18 -0
- data/swagger-templates/api_client.mustache +386 -0
- data/swagger-templates/gemspec.mustache +37 -0
- data/ynab.gemspec +40 -0
- metadata +353 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'accounts' do
|
4
|
+
let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
|
5
|
+
let(:budget_id) { 'f419ac25-6217-4175-88dc-c3136ff5f6fd' }
|
6
|
+
let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
|
7
|
+
let (:instance) { client.accounts }
|
8
|
+
|
9
|
+
describe 'test an instance of AccountsApi' do
|
10
|
+
it 'should create an instance of AccountsApi' do
|
11
|
+
expect(instance).to be_instance_of(YnabApi::AccountsApi)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'authorization' do
|
16
|
+
it "sets the Bearer Auth header correctly" do
|
17
|
+
VCR.use_cassette("accounts") do
|
18
|
+
response = instance.get_accounts(budget_id)
|
19
|
+
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "throws when unauthorized" do
|
25
|
+
VCR.use_cassette("accounts_unauthorized") do
|
26
|
+
client = YnabApi::Client.new('not_valid_access_token', 'api.localhost:3000', false)
|
27
|
+
begin
|
28
|
+
response = client.accounts.get_accounts(budget_id)
|
29
|
+
rescue YnabApi::ApiError => e
|
30
|
+
expect(e.code).to be 401
|
31
|
+
expect(client.last_request.response.options[:code]).to be 401
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'GET /budgets/{budget_id}/accounts' do
|
38
|
+
it "returns a list of accounts" do
|
39
|
+
VCR.use_cassette("accounts") do
|
40
|
+
response = instance.get_accounts(budget_id)
|
41
|
+
expect(client.last_request.response.options[:code]).to be 200
|
42
|
+
expect(response.data.accounts.length).to be 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'GET /budgets/{budget_id}/accounts/{account_id}' do
|
48
|
+
it "returns an account" do
|
49
|
+
VCR.use_cassette("account") do
|
50
|
+
response = instance.get_account_by_id(budget_id, '5982e895-98e5-41ca-9681-0b6de1036a1c')
|
51
|
+
expect(response.data.account).to be
|
52
|
+
expect(response.data.account.name).to eq "Checking"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'budgets' do
|
4
|
+
let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
|
5
|
+
let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
|
6
|
+
let (:instance) { client.budgets }
|
7
|
+
|
8
|
+
describe 'test an instance of BudgetsApi' do
|
9
|
+
it 'should create an instance of BudgetsApi' do
|
10
|
+
expect(instance).to be_instance_of(YnabApi::BudgetsApi)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'authorization' do
|
15
|
+
it "sets the Bearer Auth header correctly" do
|
16
|
+
VCR.use_cassette("budgets") do
|
17
|
+
response = instance.get_budgets
|
18
|
+
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "throws when unauthorized" do
|
24
|
+
VCR.use_cassette("budgets_unauthorized") do
|
25
|
+
client = YnabApi::Client.new('not_valid_access_token', 'api.localhost:3000', false)
|
26
|
+
begin
|
27
|
+
response = client.budgets.get_budgets
|
28
|
+
rescue YnabApi::ApiError => e
|
29
|
+
expect(e.code).to be 401
|
30
|
+
expect(client.last_request.response.options[:code]).to be 401
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'GET /budgets' do
|
37
|
+
it "returns a list of budgets" do
|
38
|
+
VCR.use_cassette("budgets") do
|
39
|
+
response = instance.get_budgets
|
40
|
+
expect(client.last_request.response.options[:code]).to be 200
|
41
|
+
expect(response.data.budgets.length).to be 4
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'GET /budgets/{budget_id}' do
|
47
|
+
it "returns a budget" do
|
48
|
+
VCR.use_cassette("budget") do
|
49
|
+
response = instance.get_budget_by_id('f419ac25-6217-4175-88dc-c3136ff5f6fd')
|
50
|
+
expect(response.data.budget).to be
|
51
|
+
expect(response.data.budget.name).to eq "ABC"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'categories' do
|
4
|
+
let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
|
5
|
+
let(:budget_id) { 'f419ac25-6217-4175-88dc-c3136ff5f6fd' }
|
6
|
+
let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
|
7
|
+
let (:instance) { client.categories }
|
8
|
+
|
9
|
+
describe 'test an instance of CategoriesApi' do
|
10
|
+
it 'should create an instance of CategoriesApi' do
|
11
|
+
expect(instance).to be_instance_of(YnabApi::CategoriesApi)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'authorization' do
|
16
|
+
it "sets the Bearer Auth header correctly" do
|
17
|
+
VCR.use_cassette("categories") do
|
18
|
+
response = instance.get_categories(budget_id)
|
19
|
+
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "throws when unauthorized" do
|
25
|
+
VCR.use_cassette("categories_unauthorized") do
|
26
|
+
client = YnabApi::Client.new('not_valid_access_token', 'api.localhost:3000', false)
|
27
|
+
begin
|
28
|
+
response = client.categories.get_categories(budget_id)
|
29
|
+
rescue YnabApi::ApiError => e
|
30
|
+
expect(e.code).to be 401
|
31
|
+
expect(client.last_request.response.options[:code]).to be 401
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'GET /budgets/{budget_id}/categories' do
|
38
|
+
it "returns a list of categories" do
|
39
|
+
VCR.use_cassette("categories") do
|
40
|
+
response = instance.get_categories(budget_id)
|
41
|
+
expect(client.last_request.response.options[:code]).to be 200
|
42
|
+
expect(response.data.category_groups.length).to be 8
|
43
|
+
expect(response.data.category_groups[0].categories.length).to be 3
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'GET /budgets/{budget_id}/category/{category_id}' do
|
49
|
+
it "returns a category" do
|
50
|
+
VCR.use_cassette("category") do
|
51
|
+
response = instance.get_category_by_id(budget_id, '574fac19-537d-46a8-be2b-d2f875691165')
|
52
|
+
expect(response.data.category).to be
|
53
|
+
expect(response.data.category.name).to eq 'Groceries'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'months' do
|
4
|
+
let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
|
5
|
+
let(:budget_id) { 'f419ac25-6217-4175-88dc-c3136ff5f6fd' }
|
6
|
+
let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
|
7
|
+
let (:instance) { client.months }
|
8
|
+
|
9
|
+
describe 'test an instance of MonthsApi' do
|
10
|
+
it 'should create an instance of MonthsApi' do
|
11
|
+
expect(instance).to be_instance_of(YnabApi::MonthsApi)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'authorization' do
|
16
|
+
it "sets the Bearer Auth header correctly" do
|
17
|
+
VCR.use_cassette("months") do
|
18
|
+
response = instance.get_budget_months(budget_id)
|
19
|
+
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "throws when unauthorized" do
|
25
|
+
VCR.use_cassette("months_unauthorized") do
|
26
|
+
client = YnabApi::Client.new('not_valid_access_token', 'api.localhost:3000', false)
|
27
|
+
begin
|
28
|
+
response = client.months.get_budget_months(budget_id)
|
29
|
+
rescue YnabApi::ApiError => e
|
30
|
+
expect(e.code).to be 401
|
31
|
+
expect(client.last_request.response.options[:code]).to be 401
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'GET /budgets/{budget_id}/months' do
|
38
|
+
it "returns a list of months" do
|
39
|
+
VCR.use_cassette("months") do
|
40
|
+
response = instance.get_budget_months(budget_id)
|
41
|
+
expect(client.last_request.response.options[:code]).to be 200
|
42
|
+
expect(response.data.months.length).to be 3
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'GET /budgets/{budget_id}/months/{month}' do
|
48
|
+
it "returns a month" do
|
49
|
+
VCR.use_cassette("month") do
|
50
|
+
response = instance.get_budget_month(budget_id, '2018-02-01')
|
51
|
+
expect(response.data.month).to be
|
52
|
+
expect(response.data.month.to_be_budgeted).to eq 1000000
|
53
|
+
expect(response.data.month.note).to eq "Test Note"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'payee locations' do
|
4
|
+
let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
|
5
|
+
let(:budget_id) { 'f419ac25-6217-4175-88dc-c3136ff5f6fd' }
|
6
|
+
let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
|
7
|
+
let (:instance) { client.payee_locations }
|
8
|
+
|
9
|
+
describe 'test an instance of PayeeLocationsApi' do
|
10
|
+
it 'should create an instance of PayeeLocationsApi' do
|
11
|
+
expect(instance).to be_instance_of(YnabApi::PayeeLocationsApi)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'authorization' do
|
16
|
+
it "sets the Bearer Auth header correctly" do
|
17
|
+
VCR.use_cassette("payee_locations") do
|
18
|
+
response = instance.get_payee_locations(budget_id)
|
19
|
+
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "throws when unauthorized" do
|
25
|
+
VCR.use_cassette("payee_locations_unauthorized") do
|
26
|
+
client = YnabApi::Client.new('not_valid_access_token', 'api.localhost:3000', false)
|
27
|
+
begin
|
28
|
+
response = client.payee_locations.get_payee_locations(budget_id)
|
29
|
+
rescue YnabApi::ApiError => e
|
30
|
+
expect(e.code).to be 401
|
31
|
+
expect(client.last_request.response.options[:code]).to be 401
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'GET /budgets/{budget_id}/payee_location' do
|
38
|
+
it "returns a list of payee locations" do
|
39
|
+
VCR.use_cassette("payee_locations") do
|
40
|
+
response = instance.get_payee_locations(budget_id)
|
41
|
+
expect(client.last_request.response.options[:code]).to be 200
|
42
|
+
expect(response.data.payee_locations.length).to be 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'GET /budgets/{budget_id}/payee_locations/{payee_id}' do
|
48
|
+
it "returns a payee location" do
|
49
|
+
VCR.use_cassette("payee_location") do
|
50
|
+
response = instance.get_payee_location_by_id(budget_id, '052c7814-1797-44ce-9519-020e864e4928')
|
51
|
+
expect(response.data.payee_location).to be
|
52
|
+
expect(response.data.payee_location.latitude).to eq "40.7128"
|
53
|
+
expect(response.data.payee_location.longitude).to eq "74.006"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'payees' do
|
4
|
+
let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
|
5
|
+
let(:budget_id) { 'f419ac25-6217-4175-88dc-c3136ff5f6fd' }
|
6
|
+
let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
|
7
|
+
let (:instance) { client.payees }
|
8
|
+
|
9
|
+
describe 'test an instance of PayeesApi' do
|
10
|
+
it 'should create an instance of PayeesApi' do
|
11
|
+
expect(instance).to be_instance_of(YnabApi::PayeesApi)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'authorization' do
|
16
|
+
it "sets the Bearer Auth header correctly" do
|
17
|
+
VCR.use_cassette("payees") do
|
18
|
+
response = instance.get_payees(budget_id)
|
19
|
+
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "throws when unauthorized" do
|
25
|
+
VCR.use_cassette("payees_unauthorized") do
|
26
|
+
client = YnabApi::Client.new('not_valid_access_token', 'api.localhost:3000', false)
|
27
|
+
begin
|
28
|
+
response = client.payees.get_payees(budget_id)
|
29
|
+
rescue YnabApi::ApiError => e
|
30
|
+
expect(e.code).to be 401
|
31
|
+
expect(client.last_request.response.options[:code]).to be 401
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'GET /budgets/{budget_id}/payees' do
|
38
|
+
it "returns a list of payees" do
|
39
|
+
VCR.use_cassette("payees") do
|
40
|
+
response = instance.get_payees(budget_id)
|
41
|
+
expect(client.last_request.response.options[:code]).to be 200
|
42
|
+
expect(response.data.payees.length).to be 5
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'GET /budgets/{budget_id}/payees/{payee_id}' do
|
48
|
+
it "returns a payee" do
|
49
|
+
VCR.use_cassette("payee") do
|
50
|
+
response = instance.get_payee_by_id(budget_id, '200e6eb1-02fc-4af6-be26-27c5740bb949')
|
51
|
+
expect(response.data.payee).to be
|
52
|
+
expect(response.data.payee.name).to eq 'Test Payee'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'scheduled transactions' do
|
4
|
+
let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
|
5
|
+
let(:budget_id) { 'f419ac25-6217-4175-88dc-c3136ff5f6fd' }
|
6
|
+
let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
|
7
|
+
let (:instance) { client.scheduled_transactions }
|
8
|
+
|
9
|
+
describe 'test an instance of ScheduledTransactionsApi' do
|
10
|
+
it 'should create an instance of ScheduledTransactionApi' do
|
11
|
+
expect(instance).to be_instance_of(YnabApi::ScheduledTransactionsApi)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'authorization' do
|
16
|
+
it "sets the Bearer Auth header correctly" do
|
17
|
+
VCR.use_cassette("scheduled_transactions") do
|
18
|
+
response = instance.get_scheduled_transactions(budget_id)
|
19
|
+
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "throws when unauthorized" do
|
25
|
+
VCR.use_cassette("scheduled_transactions_unauthorized") do
|
26
|
+
client = YnabApi::Client.new('not_valid_access_token', 'api.localhost:3000', false)
|
27
|
+
begin
|
28
|
+
response = client.scheduled_transactions.get_scheduled_transactions(budget_id)
|
29
|
+
rescue YnabApi::ApiError => e
|
30
|
+
expect(e.code).to be 401
|
31
|
+
expect(client.last_request.response.options[:code]).to be 401
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'GET /budgets/{budget_id}/transactions' do
|
38
|
+
it "returns a list of transactions" do
|
39
|
+
VCR.use_cassette("scheduled_transactions") do
|
40
|
+
response = instance.get_scheduled_transactions(budget_id)
|
41
|
+
expect(client.last_request.response.options[:code]).to be 200
|
42
|
+
expect(response.data.scheduled_transactions.length).to be 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'GET /budgets/{budget_id}/transaction/{payee_id}' do
|
48
|
+
it "returns a payee" do
|
49
|
+
VCR.use_cassette("scheduled_transaction") do
|
50
|
+
response = instance.get_scheduled_transaction_by_id(budget_id, '1a8e4929-3ad1-4859-8443-2aeeab0684ab')
|
51
|
+
expect(response.data.scheduled_transaction).to be
|
52
|
+
expect(response.data.scheduled_transaction.amount).to eq -10000
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
describe 'transactions' do
|
5
|
+
let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
|
6
|
+
let(:budget_id) { 'f419ac25-6217-4175-88dc-c3136ff5f6fd' }
|
7
|
+
let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
|
8
|
+
let (:instance) { client.transactions }
|
9
|
+
|
10
|
+
describe 'test an instance of TransactionsApi' do
|
11
|
+
it 'should create an instance of TransactionApi' do
|
12
|
+
expect(instance).to be_instance_of(YnabApi::TransactionsApi)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'authorization' do
|
17
|
+
it "sets the Bearer Auth header correctly" do
|
18
|
+
VCR.use_cassette("transactions") do
|
19
|
+
response = instance.get_transactions(budget_id)
|
20
|
+
expect(client.last_request.options[:headers]["Authorization"]).to eq "Bearer #{access_token}"
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "throws when unauthorized" do
|
26
|
+
VCR.use_cassette("transactions_unauthorized") do
|
27
|
+
client = YnabApi::Client.new('not_valid_access_token', 'api.localhost:3000', false)
|
28
|
+
begin
|
29
|
+
response = client.transactions.get_transactions(budget_id)
|
30
|
+
rescue YnabApi::ApiError => e
|
31
|
+
expect(e.code).to be 401
|
32
|
+
expect(client.last_request.response.options[:code]).to be 401
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'GET /budgets/{budget_id}/transactions' do
|
39
|
+
it "returns a list of transactions" do
|
40
|
+
VCR.use_cassette("transactions") do
|
41
|
+
response = instance.get_transactions(budget_id)
|
42
|
+
expect(client.last_request.response.options[:code]).to be 200
|
43
|
+
expect(response.data.transactions.length).to be 2
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'GET /budgets/{budget_id}/transaction/{payee_id}' do
|
49
|
+
it "returns a payee" do
|
50
|
+
VCR.use_cassette("transaction") do
|
51
|
+
response = instance.get_transactions_by_id(budget_id, '81c374ff-74ab-4d6d-8d5a-ba3ad3fa68e4')
|
52
|
+
expect(response.data.transaction).to be
|
53
|
+
expect(response.data.transaction.amount).to eq -2000
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'POST /budgets/{budget_id}/transactions' do
|
59
|
+
it "creates a transaction" do
|
60
|
+
VCR.use_cassette("create_transaction") do
|
61
|
+
response = instance.create_transaction(budget_id, {
|
62
|
+
transaction: {
|
63
|
+
date: '2018-01-01',
|
64
|
+
account_id: '5982e895-98e5-41ca-9681-0b6de1036a1c',
|
65
|
+
amount: 20000
|
66
|
+
}
|
67
|
+
})
|
68
|
+
expect(client.last_request.response.options[:code]).to be 201
|
69
|
+
expect(response.data.transaction).to be
|
70
|
+
expect(response.data.transaction.amount).to eq 20000
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'PUT /budgets/{budget_id}/transactions/{transaction_id}' do
|
76
|
+
it "updates a transaction" do
|
77
|
+
VCR.use_cassette("update_transaction") do
|
78
|
+
response = instance.update_transaction(budget_id, '4cd63d34-3814-4f50-abd0-59ce05b40d91', {
|
79
|
+
transaction: {
|
80
|
+
date: '2018-01-02',
|
81
|
+
account_id: '5982e895-98e5-41ca-9681-0b6de1036a1c',
|
82
|
+
amount: 30000
|
83
|
+
}
|
84
|
+
})
|
85
|
+
expect(client.last_request.response.options[:code]).to be 200
|
86
|
+
expect(response.data.transaction).to be
|
87
|
+
expect(response.data.transaction.amount).to eq 30000
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'POST /budgets/{budget_id}/transactions/bulk' do
|
93
|
+
it "bulk creations transactions" do
|
94
|
+
VCR.use_cassette("bulk_transactions") do
|
95
|
+
response = instance.bulk_create_transactions(budget_id, {
|
96
|
+
transactions: [
|
97
|
+
{
|
98
|
+
date: '2018-01-01',
|
99
|
+
account_id: '5982e895-98e5-41ca-9681-0b6de1036a1c',
|
100
|
+
amount: 10000
|
101
|
+
},
|
102
|
+
{
|
103
|
+
date: '2018-01-02',
|
104
|
+
account_id: '5982e895-98e5-41ca-9681-0b6de1036a1c',
|
105
|
+
amount: 20000
|
106
|
+
},
|
107
|
+
{
|
108
|
+
date: '2018-01-03',
|
109
|
+
account_id: '5982e895-98e5-41ca-9681-0b6de1036a1c',
|
110
|
+
amount: 30000,
|
111
|
+
import_id: '123456'
|
112
|
+
}
|
113
|
+
]
|
114
|
+
})
|
115
|
+
expect(client.last_request.response.options[:code]).to be 201
|
116
|
+
expect(response.data.bulk).to be
|
117
|
+
expect(response.data.bulk.transaction_ids.length).to eq 3
|
118
|
+
expect(response.data.bulk.duplicate_import_ids.length).to eq 0
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|