levelup 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/.rubocop.yml +427 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +58 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +113 -0
- data/Rakefile +1 -0
- data/levelup.gemspec +32 -0
- data/lib/levelup.rb +55 -0
- data/lib/levelup/api.rb +102 -0
- data/lib/levelup/configuration.rb +23 -0
- data/lib/levelup/endpoints/access_tokens.rb +40 -0
- data/lib/levelup/endpoints/app_users.rb +30 -0
- data/lib/levelup/endpoints/apps.rb +30 -0
- data/lib/levelup/endpoints/base.rb +25 -0
- data/lib/levelup/endpoints/credit_cards.rb +26 -0
- data/lib/levelup/endpoints/location_orders.rb +32 -0
- data/lib/levelup/endpoints/merchant_funded_credits.rb +19 -0
- data/lib/levelup/endpoints/merchant_locations.rb +32 -0
- data/lib/levelup/endpoints/merchant_orders.rb +28 -0
- data/lib/levelup/endpoints/orders.rb +19 -0
- data/lib/levelup/endpoints/permissions_requests.rb +28 -0
- data/lib/levelup/endpoints/qr_codes.rb +28 -0
- data/lib/levelup/endpoints/specific_location.rb +24 -0
- data/lib/levelup/endpoints/specific_merchant.rb +28 -0
- data/lib/levelup/endpoints/specific_order.rb +28 -0
- data/lib/levelup/endpoints/specific_permissions_request.rb +26 -0
- data/lib/levelup/endpoints/user_addresses.rb +25 -0
- data/lib/levelup/endpoints/user_orders.rb +18 -0
- data/lib/levelup/endpoints/users.rb +16 -0
- data/lib/levelup/errors/invalid_request.rb +8 -0
- data/lib/levelup/errors/unauthenticated.rb +8 -0
- data/lib/levelup/requests/authenticate_app.rb +19 -0
- data/lib/levelup/requests/authenticate_merchant.rb +26 -0
- data/lib/levelup/requests/base.rb +87 -0
- data/lib/levelup/requests/create_address.rb +19 -0
- data/lib/levelup/requests/create_card.rb +21 -0
- data/lib/levelup/requests/create_order.rb +33 -0
- data/lib/levelup/requests/create_user.rb +34 -0
- data/lib/levelup/requests/get_order.rb +17 -0
- data/lib/levelup/requests/get_qr_code.rb +16 -0
- data/lib/levelup/requests/get_user.rb +17 -0
- data/lib/levelup/requests/give_merchant_credit.rb +23 -0
- data/lib/levelup/requests/list_addresses.rb +20 -0
- data/lib/levelup/requests/list_locations.rb +24 -0
- data/lib/levelup/requests/list_orders.rb +23 -0
- data/lib/levelup/requests/list_user_orders.rb +20 -0
- data/lib/levelup/requests/refund_order.rb +21 -0
- data/lib/levelup/requests/request_permissions.rb +27 -0
- data/lib/levelup/requests/show_permissions_request.rb +21 -0
- data/lib/levelup/responses/error.rb +36 -0
- data/lib/levelup/responses/success.rb +11 -0
- data/lib/levelup/templates/data_parcel.rb +41 -0
- data/lib/levelup/templates/merchant_and_user_authenticated.rb +21 -0
- data/lib/levelup/templates/merchant_authenticated.rb +19 -0
- data/lib/levelup/templates/user_address_data.rb +20 -0
- data/lib/levelup/templates/user_authenticated.rb +17 -0
- data/spec/data_objects/requests/authenticate_app_spec.rb +13 -0
- data/spec/data_objects/requests/authenticate_merchant_spec.rb +14 -0
- data/spec/data_objects/requests/create_order_spec.rb +14 -0
- data/spec/data_objects/requests/get_order_spec.rb +13 -0
- data/spec/data_objects/requests/list_locations_spec.rb +13 -0
- data/spec/data_objects/requests/list_orders_spec.rb +13 -0
- data/spec/data_objects/requests/refund_order_spec.rb +19 -0
- data/spec/data_objects/requests/request_permissions_spec.rb +21 -0
- data/spec/data_objects/responses/error_spec.rb +67 -0
- data/spec/data_objects/responses/response_spec.rb +13 -0
- data/spec/endpoints/access_tokens_spec.rb +81 -0
- data/spec/endpoints/app_users_spec.rb +43 -0
- data/spec/endpoints/location_orders_spec.rb +34 -0
- data/spec/endpoints/merchant_funded_credits_spec.rb +16 -0
- data/spec/endpoints/merchant_locations_spec.rb +35 -0
- data/spec/endpoints/orders_spec.rb +37 -0
- data/spec/endpoints/permissions_requests_spec.rb +22 -0
- data/spec/endpoints/qr_codes_spec.rb +12 -0
- data/spec/endpoints/specific_order_spec.rb +33 -0
- data/spec/endpoints/specific_permissions_request_spec.rb +24 -0
- data/spec/endpoints/user_addresses_spec.rb +41 -0
- data/spec/endpoints/user_orders_spec.rb +12 -0
- data/spec/fixtures/keys.yml.example +15 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/vcr_filter_sensitive_data.rb +53 -0
- metadata +281 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Responses::Success' do
|
4
|
+
before do
|
5
|
+
@test_response = Levelup::Responses::Success.new({})
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#success?' do
|
9
|
+
it 'returns true' do
|
10
|
+
expect(@test_response.success?).to be_true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::AccessTokens', vcr: true do
|
4
|
+
describe '#create_for_app' do
|
5
|
+
context 'with no request object' do
|
6
|
+
context 'with no predefined API key/app secret' do
|
7
|
+
it 'fails to authenticate' do
|
8
|
+
expect(@test_client.access_tokens.create_for_app).to_not be_success
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'with a predefined API key/app secret' do
|
13
|
+
before do
|
14
|
+
@test_client.api_key = TestConfig.api_key_valid
|
15
|
+
@test_client.secret = TestConfig.secret_valid
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns a successful authentication response' do
|
19
|
+
response = @test_client.access_tokens.create_for_app
|
20
|
+
expect(response).to be_success
|
21
|
+
expect(response.token).to_not be_nil
|
22
|
+
expect(response.token).to_not be_empty
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with invalid keys' do
|
28
|
+
it 'returns an error response' do
|
29
|
+
auth_request = Levelup::Requests::AuthenticateApp.new(
|
30
|
+
api_key: 'wrong_api_key',
|
31
|
+
client_secret: 'wrong_client_secret'
|
32
|
+
)
|
33
|
+
response = @test_client.access_tokens.create_for_app(auth_request)
|
34
|
+
expect(response).to_not be_success
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with valid keys' do
|
39
|
+
it 'returns a successful authenticate response' do
|
40
|
+
auth_request = Levelup::Requests::AuthenticateApp.new(
|
41
|
+
api_key: TestConfig.api_key_valid,
|
42
|
+
client_secret: TestConfig.secret_valid
|
43
|
+
)
|
44
|
+
response = @test_client.access_tokens.create_for_app(auth_request)
|
45
|
+
expect(response).to be_success
|
46
|
+
expect(response.token).to_not be_nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#create_for_merchant' do
|
52
|
+
context 'with valid keys' do
|
53
|
+
it 'returns a successful authentication response' do
|
54
|
+
merchant_auth_request =
|
55
|
+
Levelup::Requests::AuthenticateMerchant.new(
|
56
|
+
api_key: TestConfig.merchant_api_key,
|
57
|
+
username: TestConfig.merchant_username,
|
58
|
+
password: TestConfig.merchant_password
|
59
|
+
)
|
60
|
+
|
61
|
+
response = @test_client.access_tokens.
|
62
|
+
create_for_merchant(merchant_auth_request)
|
63
|
+
expect(response).to be_success
|
64
|
+
expect(response.token).to_not be_nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with invalid keys' do
|
69
|
+
it 'fails to authenticate' do
|
70
|
+
merchant_auth_request = Levelup::Requests::AuthenticateMerchant.new(
|
71
|
+
api_key: 'abc123',
|
72
|
+
username: 'username_wrong',
|
73
|
+
password: 'password1'
|
74
|
+
)
|
75
|
+
response = @test_client.access_tokens.
|
76
|
+
create_for_merchant(merchant_auth_request)
|
77
|
+
expect(response).to_not be_success
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::AppUsers', vcr: true do
|
4
|
+
before do
|
5
|
+
@test_client.api_key = TestConfig.api_key_valid
|
6
|
+
@test_client.secret = TestConfig.secret_valid
|
7
|
+
auth = @test_client.access_tokens.create_for_app
|
8
|
+
@test_client.app_access_token = auth.token
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#create' do
|
12
|
+
it 'creates a user' do
|
13
|
+
response = @test_client.apps.users.create(
|
14
|
+
email: 'some@email.com',
|
15
|
+
first_name: 'firstname',
|
16
|
+
last_name: 'lastname',
|
17
|
+
permission_keynames: ['create_orders']
|
18
|
+
)
|
19
|
+
|
20
|
+
expect(response).to be_success
|
21
|
+
expect(response.user.last_name).to eq('lastname')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#get' do
|
26
|
+
context 'with an invalid access token' do
|
27
|
+
it 'returns an error response' do
|
28
|
+
response = @test_client.apps.users.get('invalid')
|
29
|
+
expect(response).to_not be_success
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with a valid access token' do
|
34
|
+
it 'returns the user\'s info' do
|
35
|
+
response = @test_client.apps.users.get(
|
36
|
+
TestConfig.user_token_with_read_info_perms)
|
37
|
+
|
38
|
+
expect(response).to be_success
|
39
|
+
expect(response.email).to_not be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::LocationOrders', vcr: true do
|
4
|
+
before :all do
|
5
|
+
VCR.use_cassette('merchant_auth') do
|
6
|
+
merchant_auth = Levelup::Api.new.access_tokens.create_for_merchant(
|
7
|
+
api_key: TestConfig.merchant_api_key,
|
8
|
+
username: TestConfig.merchant_username,
|
9
|
+
password: TestConfig.merchant_password
|
10
|
+
)
|
11
|
+
|
12
|
+
@test_merchant_auth_token = merchant_auth.token
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#list' do
|
17
|
+
context 'with a valid location' do
|
18
|
+
it 'returns a list of orders' do
|
19
|
+
response = @test_client.locations(TestConfig.location_id).
|
20
|
+
orders.list(@test_merchant_auth_token)
|
21
|
+
expect(response).to be_success
|
22
|
+
expect(response.orders).to_not be_nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with an invalid location' do
|
27
|
+
it 'returns an error response' do
|
28
|
+
response = @test_client.locations(-25).orders.
|
29
|
+
list(@test_merchant_auth_token)
|
30
|
+
expect(response).to_not be_success
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::MerchantFundedCredits', vcr: true do
|
4
|
+
describe '#give' do
|
5
|
+
it 'grants a user credit' do
|
6
|
+
response = @test_client.merchant_funded_credits.give(
|
7
|
+
email: 'pos@thelevelup.com',
|
8
|
+
value_amount: 5,
|
9
|
+
merchant_access_token: TestConfig.
|
10
|
+
merchant_token_with_grant_credit_perms
|
11
|
+
)
|
12
|
+
|
13
|
+
expect(response).to be_success
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::MerchantLocations', vcr: true do
|
4
|
+
before :all do
|
5
|
+
VCR.use_cassette('merchant_auth') do
|
6
|
+
merchant_auth = Levelup::Api.new.access_tokens.create_for_merchant(
|
7
|
+
api_key: TestConfig.merchant_api_key,
|
8
|
+
username: TestConfig.merchant_username,
|
9
|
+
password: TestConfig.merchant_password
|
10
|
+
)
|
11
|
+
|
12
|
+
@test_merchant_auth_token = merchant_auth.token
|
13
|
+
@test_merchant_id = merchant_auth.merchant_id
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#list' do
|
18
|
+
context 'with a valid merchant' do
|
19
|
+
it 'returns a successful list-locations response' do
|
20
|
+
response = @test_client.merchants(@test_merchant_id).locations.
|
21
|
+
list(@test_merchant_auth_token)
|
22
|
+
expect(response).to be_success
|
23
|
+
expect(response.locations).to_not be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with an invalid merchant' do
|
28
|
+
it 'returns an error response' do
|
29
|
+
response = @test_client.merchants(-25).locations.
|
30
|
+
list(@test_merchant_auth_token)
|
31
|
+
expect(response).to_not be_success
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::Orders', vcr: true do
|
4
|
+
describe '#create' do
|
5
|
+
context 'with an invalid user access token' do
|
6
|
+
it 'returns an error response' do
|
7
|
+
order_request = Levelup::Requests::CreateOrder.new(
|
8
|
+
items: [],
|
9
|
+
location_id: TestConfig.location_id,
|
10
|
+
spend_amount: 10,
|
11
|
+
merchant_access_token:
|
12
|
+
TestConfig.merchant_token_with_manage_orders_perms,
|
13
|
+
user_access_token: 'invalid'
|
14
|
+
)
|
15
|
+
expect(@test_client.orders.create(order_request)).to_not be_success
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with a valid user access token' do
|
20
|
+
it 'returns a successful order response' do
|
21
|
+
order_request = Levelup::Requests::CreateOrder.new(
|
22
|
+
items: [],
|
23
|
+
location_id: TestConfig.location_id,
|
24
|
+
spend_amount: 10,
|
25
|
+
merchant_access_token:
|
26
|
+
TestConfig.merchant_token_with_manage_orders_perms,
|
27
|
+
user_access_token:
|
28
|
+
TestConfig.user_token_with_create_orders_perms
|
29
|
+
)
|
30
|
+
|
31
|
+
response = @test_client.orders.create(order_request)
|
32
|
+
expect(response).to be_success
|
33
|
+
expect(response.spend_amount).to eq(order_request.spend_amount)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::PermissionsRequests', vcr: true do
|
4
|
+
before do
|
5
|
+
@test_client.api_key = TestConfig.api_key_valid
|
6
|
+
@test_client.secret = TestConfig.secret_valid
|
7
|
+
auth = @test_client.access_tokens.create_for_app
|
8
|
+
@test_client.app_access_token = auth.token
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#create' do
|
12
|
+
it 'submits a permissions request' do
|
13
|
+
response = @test_client.apps.permissions_requests.create(
|
14
|
+
email: TestConfig.user_email,
|
15
|
+
permission_keynames: ['create_orders']
|
16
|
+
)
|
17
|
+
|
18
|
+
expect(response).to be_success
|
19
|
+
expect(response.state).to eq('pending')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::QrCodes', vcr: true do
|
4
|
+
describe '#get' do
|
5
|
+
it 'retrieves a user\'s QR code' do
|
6
|
+
response = @test_client.qr_codes.get(TestConfig.
|
7
|
+
user_token_with_read_qr_perms)
|
8
|
+
expect(response).to be_success
|
9
|
+
expect(response.code).to_not be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::SpecificOrder', vcr: true do
|
4
|
+
describe '#refund' do
|
5
|
+
context 'with an invalid UUID' do
|
6
|
+
it 'returns an error response' do
|
7
|
+
response = @test_client.orders('0').
|
8
|
+
refund(@merchant_token_with_create_privs)
|
9
|
+
expect(response).to_not be_success
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'with a valid UUID' do
|
14
|
+
it 'refunds the specified order' do
|
15
|
+
order_response = @test_client.orders.create(
|
16
|
+
items: [],
|
17
|
+
location_id: TestConfig.location_id,
|
18
|
+
spend_amount: 10,
|
19
|
+
merchant_access_token:
|
20
|
+
TestConfig.merchant_token_with_manage_orders_perms,
|
21
|
+
user_access_token:
|
22
|
+
TestConfig.user_token_with_create_orders_perms
|
23
|
+
)
|
24
|
+
expect(order_response).to be_success
|
25
|
+
|
26
|
+
refund_response = @test_client.orders(order_response.uuid).
|
27
|
+
refund(TestConfig.merchant_token_with_manage_orders_perms)
|
28
|
+
expect(refund_response).to be_success
|
29
|
+
expect(refund_response.uuid).to eq(order_response.uuid)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::SpecificPermissionsRequest', vcr: true do
|
4
|
+
before do
|
5
|
+
@test_client.api_key = TestConfig.api_key_valid
|
6
|
+
@test_client.secret = TestConfig.secret_valid
|
7
|
+
auth = @test_client.access_tokens.create_for_app
|
8
|
+
@test_client.app_access_token = auth.token
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#show' do
|
12
|
+
it 'returns a permissions request' do
|
13
|
+
perms_request = @test_client.apps.permissions_requests.create(
|
14
|
+
email: TestConfig.user_email,
|
15
|
+
permission_keynames: ['read_user_basic_info']
|
16
|
+
)
|
17
|
+
|
18
|
+
response = @test_client.apps.permissions_requests(perms_request.id).
|
19
|
+
show
|
20
|
+
expect(response).to be_success
|
21
|
+
expect(response.permission_keynames).to eq(['read_user_basic_info'])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::UserAddresses', vcr: true do
|
4
|
+
describe '#create' do
|
5
|
+
before do
|
6
|
+
@test_address_hash = {
|
7
|
+
address_type: 'home',
|
8
|
+
street_address: '1 Levelup Lane',
|
9
|
+
extended_address: 'Suite 3',
|
10
|
+
locality: 'Boston',
|
11
|
+
region: 'MA',
|
12
|
+
postal_code: '02114'
|
13
|
+
}
|
14
|
+
@test_client.api_key = TestConfig.api_key_valid
|
15
|
+
@test_client.secret = TestConfig.secret_valid
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with an invalid user token' do
|
19
|
+
it 'returns an error response' do
|
20
|
+
test_request =
|
21
|
+
Levelup::Requests::CreateAddress.new(@test_address_hash)
|
22
|
+
test_request.user_access_token = 'invalid'
|
23
|
+
response = @test_client.user_addresses.create(test_request)
|
24
|
+
expect(response).to_not be_success
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with a valid user token' do
|
29
|
+
it 'returns a successful creation response' do
|
30
|
+
test_request =
|
31
|
+
Levelup::Requests::CreateAddress.new(@test_address_hash)
|
32
|
+
test_request.user_access_token =
|
33
|
+
TestConfig.user_token_with_manage_addresses_perms
|
34
|
+
response = @test_client.user_addresses.create(test_request)
|
35
|
+
expect(response).to be_success
|
36
|
+
expect(response.street_address).
|
37
|
+
to eq(@test_address_hash[:street_address])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Levelup::Endpoints::UserOrders', vcr: true do
|
4
|
+
describe '#list' do
|
5
|
+
it 'returns a user\'s order history' do
|
6
|
+
response = @test_client.users.orders.
|
7
|
+
list(TestConfig.user_token_with_read_orders_perms)
|
8
|
+
expect(response).to be_success
|
9
|
+
expect(response.orders).to_not be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#Rename this file to keys.yml once you've supplied the fields below
|
2
|
+
api_key_valid: key
|
3
|
+
secret_valid: secret
|
4
|
+
location_id: 123
|
5
|
+
merchant_token_with_grant_credit_perms: token
|
6
|
+
merchant_token_with_manage_orders_perms: token (can be same as other merchant token)
|
7
|
+
merchant_api_key: token_v14
|
8
|
+
merchant_username: merchant@email.tld
|
9
|
+
merchant_password: password
|
10
|
+
user_token_with_create_orders_perms: token
|
11
|
+
user_token_with_manage_addresses_perms: token (can be same as other user token)
|
12
|
+
user_token_with_read_info_perms: token (can be same as other user token)
|
13
|
+
user_token_with_read_orders_perms: token (can be same as other user token)
|
14
|
+
user_token_with_read_qr_perms: token (can be same as other user token)
|
15
|
+
user_email: user@email.tld
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'settingslogic'
|
2
|
+
require 'vcr'
|
3
|
+
require 'support/vcr_filter_sensitive_data'
|
4
|
+
|
5
|
+
$LOAD_PATH << File.expand_path('../lib', __FILE__)
|
6
|
+
require 'levelup'
|
7
|
+
|
8
|
+
Levelup::Configuration.base_api_url = 'https://api.staging-levelup.com/'
|
9
|
+
|
10
|
+
class TestConfig < Settingslogic
|
11
|
+
source 'spec/fixtures/keys.yml'
|
12
|
+
end
|
13
|
+
|
14
|
+
VCR.configure do |config|
|
15
|
+
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
16
|
+
config.hook_into :webmock
|
17
|
+
config.default_cassette_options = {
|
18
|
+
record: :new_episodes,
|
19
|
+
match_requests_on: [:method, :uri, :body]
|
20
|
+
}
|
21
|
+
config.configure_rspec_metadata!
|
22
|
+
end
|
23
|
+
|
24
|
+
RSpec.configure do |config|
|
25
|
+
config.before do
|
26
|
+
@test_client = Levelup::Api.new
|
27
|
+
end
|
28
|
+
end
|