adyen-ruby-api-library 7.0.0 → 7.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/release.yml +18 -0
- data/.github/workflows/gh_release.yml +16 -0
- data/.github/workflows/release_request.yml +15 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/services.yml +28 -0
- data/.rubocop.yml +8 -0
- data/Gemfile +7 -7
- data/Makefile +14 -10
- data/README.md +13 -10
- data/Rakefile +3 -3
- data/adyen-ruby-api-library.gemspec +6 -3
- data/bin/console +2 -2
- data/lib/adyen/client.rb +96 -76
- data/lib/adyen/errors.rb +23 -18
- data/lib/adyen/hash_with_accessors.rb +12 -7
- data/lib/adyen/services/balanceControlService.rb +7 -14
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +22 -38
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +48 -79
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +6 -13
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +6 -13
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +12 -22
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +16 -29
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +26 -45
- data/lib/adyen/services/balancePlatform/platform_api.rb +12 -22
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +21 -37
- data/lib/adyen/services/balancePlatform.rb +38 -40
- data/lib/adyen/services/binLookup.rb +12 -22
- data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +11 -21
- data/lib/adyen/services/checkout/modifications_api.rb +31 -53
- data/lib/adyen/services/checkout/orders_api.rb +16 -29
- data/lib/adyen/services/checkout/payment_links_api.rb +16 -29
- data/lib/adyen/services/checkout/payments_api.rb +40 -53
- data/lib/adyen/services/checkout/recurring_api.rb +13 -23
- data/lib/adyen/services/checkout/utility_api.rb +11 -21
- data/lib/adyen/services/checkout.rb +32 -34
- data/lib/adyen/services/dataProtection.rb +7 -14
- data/lib/adyen/services/dispute.rb +6 -5
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +16 -29
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +26 -45
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +25 -29
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement.rb +32 -34
- data/lib/adyen/services/management/account_company_level_api.rb +18 -31
- data/lib/adyen/services/management/account_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/account_store_level_api.rb +43 -71
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +21 -37
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +21 -37
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +22 -38
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/api_key_company_level_api.rb +6 -13
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +6 -13
- data/lib/adyen/services/management/client_key_company_level_api.rb +6 -13
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +6 -13
- data/lib/adyen/services/management/my_api_credential_api.rb +26 -45
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +32 -54
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +26 -45
- data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +92 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +24 -40
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +6 -13
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +55 -89
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +55 -89
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +23 -39
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +23 -39
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +45 -73
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +21 -37
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +7 -14
- data/lib/adyen/services/management/users_company_level_api.rb +22 -38
- data/lib/adyen/services/management/users_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/webhooks_company_level_api.rb +37 -62
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +37 -62
- data/lib/adyen/services/management.rb +99 -96
- data/lib/adyen/services/marketpay.rb +42 -36
- data/lib/adyen/services/payment/general_api.rb +56 -0
- data/lib/adyen/services/payment/modifications_api.rb +83 -0
- data/lib/adyen/services/payment.rb +10 -158
- data/lib/adyen/services/payout/initialization_api.rb +16 -29
- data/lib/adyen/services/payout/instant_payouts_api.rb +6 -13
- data/lib/adyen/services/payout/reviewing_api.rb +11 -21
- data/lib/adyen/services/payout.rb +19 -21
- data/lib/adyen/services/posTerminalManagement.rb +27 -46
- data/lib/adyen/services/recurring.rb +32 -54
- data/lib/adyen/services/service.rb +5 -4
- data/lib/adyen/services/storedValue.rb +32 -54
- data/lib/adyen/services/transfers/capital_api.rb +38 -0
- data/lib/adyen/services/transfers/transactions_api.rb +12 -22
- data/lib/adyen/services/transfers/transfers_api.rb +6 -13
- data/lib/adyen/services/transfers.rb +20 -17
- data/lib/adyen/utils/hmac_validator.rb +9 -9
- data/lib/adyen/version.rb +3 -3
- data/lib/adyen-ruby-api-library.rb +21 -21
- data/spec/account_spec.rb +20 -20
- data/spec/balance_control_spec.rb +28 -29
- data/spec/balance_platform_spec.rb +108 -102
- data/spec/bin_lookup_spec.rb +50 -50
- data/spec/checkout_spec.rb +581 -515
- data/spec/client_spec.rb +118 -71
- data/spec/data_protection_spec.rb +4 -4
- data/spec/dispute_spec.rb +7 -7
- data/spec/errors_spec.rb +37 -17
- data/spec/fund_spec.rb +10 -10
- data/spec/hash_with_accessors_spec.rb +18 -8
- data/spec/hop_spec.rb +4 -4
- data/spec/lem_spec.rb +44 -49
- data/spec/management_spec.rb +46 -48
- data/spec/notification_spec.rb +9 -9
- data/spec/payments_spec.rb +31 -32
- data/spec/payouts_spec.rb +29 -32
- data/spec/pos_terminal_management_spec.rb +30 -32
- data/spec/recurring_spec.rb +8 -8
- data/spec/service_spec.rb +4 -0
- data/spec/spec_helper.rb +37 -35
- data/spec/stored_value_spec.rb +28 -27
- data/spec/transfers_spec.rb +48 -47
- data/spec/utils/hmac_validator_spec.rb +15 -14
- data/templates/api-single.mustache +13 -15
- data/templates/api-small.mustache +8 -15
- data/templates/api.mustache +7 -14
- metadata +27 -18
- data/.github/dependabot.yml +0 -8
- /data/spec/mocks/responses/Webhooks/{backslash_notification.json → backslash_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{colon_notification.json → colon_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{forwardslash_notification.json → forwardslash_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{mixed_notification.json → mixed_webhook.json} +0 -0
data/spec/management_spec.rb
CHANGED
@@ -1,68 +1,66 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
RSpec.describe Adyen::Management, service: "Management" do
|
4
|
+
RSpec.describe Adyen::Management, service: 'Management' do
|
7
5
|
before(:all) do
|
8
6
|
@shared_values = {
|
9
7
|
client: create_client(:api_key),
|
10
|
-
service:
|
8
|
+
service: 'Management'
|
11
9
|
}
|
12
10
|
end
|
13
11
|
|
14
12
|
# must be created manually because every field in the response is an array
|
15
|
-
it
|
16
|
-
response_body = json_from_file(
|
13
|
+
it 'makes a companies GET call' do
|
14
|
+
response_body = json_from_file('mocks/responses/Management/get_companies.json')
|
17
15
|
|
18
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'companies',
|
17
|
+
@shared_values[:client].management.version)
|
18
|
+
WebMock.stub_request(:get, url)
|
19
|
+
.with(
|
20
|
+
headers: {
|
21
|
+
'x-api-key' => @shared_values[:client].api_key
|
22
|
+
}
|
23
|
+
)
|
24
|
+
.to_return(
|
25
|
+
body: response_body
|
26
|
+
)
|
28
27
|
|
29
|
-
result = @shared_values[:client].management.account_company_level_api.list_company_accounts
|
28
|
+
result = @shared_values[:client].management.account_company_level_api.list_company_accounts
|
30
29
|
response_hash = result.response
|
31
30
|
|
32
|
-
expect(result.status)
|
33
|
-
to eq(200)
|
34
|
-
expect(response_hash)
|
35
|
-
to eq(JSON.parse(response_body))
|
36
|
-
expect(response_hash)
|
37
|
-
to be_a Adyen::HashWithAccessors
|
38
|
-
expect(response_hash)
|
39
|
-
to be_a_kind_of Hash
|
31
|
+
expect(result.status)
|
32
|
+
.to eq(200)
|
33
|
+
expect(response_hash)
|
34
|
+
.to eq(JSON.parse(response_body))
|
35
|
+
expect(response_hash)
|
36
|
+
.to be_a Adyen::HashWithAccessors
|
37
|
+
expect(response_hash)
|
38
|
+
.to be_a_kind_of Hash
|
40
39
|
end
|
41
40
|
|
42
|
-
it
|
43
|
-
request_body = JSON.parse(json_from_file(
|
41
|
+
it 'makes a create_store POST call' do
|
42
|
+
request_body = JSON.parse(json_from_file('mocks/responses/LegalEntityManagement/create_business_line.json'))
|
44
43
|
|
45
|
-
response_body = json_from_file(
|
44
|
+
response_body = json_from_file('mocks/responses/LegalEntityManagement/create_business_line.json')
|
46
45
|
|
47
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
46
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'merchants/merchantID/stores',
|
47
|
+
@shared_values[:client].management.version)
|
48
|
+
WebMock.stub_request(:post, url)
|
49
|
+
.with(
|
50
|
+
body: request_body,
|
51
|
+
headers: {
|
52
|
+
'x-api-key' => @shared_values[:client].api_key
|
53
|
+
}
|
54
|
+
)
|
55
|
+
.to_return(
|
56
|
+
body: response_body
|
57
|
+
)
|
58
58
|
|
59
|
-
result = @shared_values[:client].management.account_store_level_api.create_store_by_merchant_id(request_body,
|
60
|
-
|
59
|
+
result = @shared_values[:client].management.account_store_level_api.create_store_by_merchant_id(request_body,
|
60
|
+
'merchantID')
|
61
|
+
result.response
|
61
62
|
|
62
|
-
|
63
|
-
to eq(200)
|
63
|
+
expect(result.status)
|
64
|
+
.to eq(200)
|
64
65
|
end
|
65
|
-
|
66
|
-
|
67
66
|
end
|
68
|
-
|
data/spec/notification_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe Adyen::Payment, service:
|
3
|
+
RSpec.describe Adyen::Payment, service: 'marketpay fund service' do
|
4
4
|
# client instance to be used in dynamically generated tests
|
5
5
|
client = create_client(:basic)
|
6
6
|
|
7
7
|
# methods / values to test for
|
8
8
|
# format is defined in spec_helper
|
9
9
|
test_sets = [
|
10
|
-
[
|
11
|
-
[
|
12
|
-
[
|
13
|
-
[
|
14
|
-
[
|
15
|
-
[
|
10
|
+
%w[create_notification_configuration pspReference 8515077331535427],
|
11
|
+
%w[delete_notification_configurations pspReference 8515078085249090],
|
12
|
+
%w[get_notification_configuration pspReference 8815078078131377],
|
13
|
+
%w[get_notification_configuration_list pspReference 8515078078661665],
|
14
|
+
%w[test_notification_configuration pspReference 8515078087759211],
|
15
|
+
%w[update_notification_configuration pspReference 8515078084389038]
|
16
16
|
]
|
17
17
|
|
18
|
-
generate_tests(client,
|
18
|
+
generate_tests(client, 'Notification', test_sets, client.marketpay.notification)
|
19
19
|
end
|
data/spec/payments_spec.rb
CHANGED
@@ -1,44 +1,43 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
3
|
|
4
|
-
RSpec.describe Adyen::Payment, service:
|
4
|
+
RSpec.describe Adyen::Payment, service: 'Payment' do
|
5
5
|
before(:all) do
|
6
6
|
@shared_values = {
|
7
7
|
client: create_client(:api_key),
|
8
|
-
service:
|
8
|
+
service: 'Payment'
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
12
12
|
# must be created manually because every field in the response is an array
|
13
|
-
it
|
14
|
-
request_body = JSON.parse(json_from_file(
|
15
|
-
|
16
|
-
response_body = json_from_file(
|
17
|
-
|
18
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
it 'makes an adjust_authorisation POST call' do
|
14
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Payment/adjust_authorisation.json'))
|
15
|
+
|
16
|
+
response_body = json_from_file('mocks/responses/Payment/adjust_authorisation.json')
|
17
|
+
|
18
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'adjustAuthorisation',
|
19
|
+
@shared_values[:client].payment.version)
|
20
|
+
WebMock.stub_request(:post, url)
|
21
|
+
.with(
|
22
|
+
body: request_body,
|
23
|
+
headers: {
|
24
|
+
'x-api-key' => @shared_values[:client].api_key
|
25
|
+
}
|
26
|
+
)
|
27
|
+
.to_return(
|
28
|
+
body: response_body
|
29
|
+
)
|
30
|
+
|
31
|
+
result = @shared_values[:client].payment.modifications_api.adjust_authorisation(request_body)
|
31
32
|
response_hash = result.response
|
32
33
|
|
33
|
-
expect(result.status)
|
34
|
-
to eq(200)
|
35
|
-
expect(response_hash)
|
36
|
-
to eq(JSON.parse(response_body))
|
37
|
-
expect(response_hash)
|
38
|
-
to be_a Adyen::HashWithAccessors
|
39
|
-
expect(response_hash)
|
40
|
-
to be_a_kind_of Hash
|
34
|
+
expect(result.status)
|
35
|
+
.to eq(200)
|
36
|
+
expect(response_hash)
|
37
|
+
.to eq(JSON.parse(response_body))
|
38
|
+
expect(response_hash)
|
39
|
+
.to be_a Adyen::HashWithAccessors
|
40
|
+
expect(response_hash)
|
41
|
+
.to be_a_kind_of Hash
|
41
42
|
end
|
42
|
-
|
43
43
|
end
|
44
|
-
|
data/spec/payouts_spec.rb
CHANGED
@@ -1,46 +1,43 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
RSpec.describe Adyen::Payout, service: "Payout" do
|
4
|
+
RSpec.describe Adyen::Payout, service: 'Payout' do
|
7
5
|
before(:all) do
|
8
6
|
@shared_values = {
|
9
7
|
client: create_client(:api_key),
|
10
|
-
service:
|
8
|
+
service: 'Payout'
|
11
9
|
}
|
12
10
|
end
|
13
11
|
|
14
12
|
# must be created manually because every field in the response is an array
|
15
|
-
it
|
16
|
-
request_body = JSON.parse(json_from_file(
|
17
|
-
|
18
|
-
response_body = json_from_file(
|
19
|
-
|
20
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
it 'makes a business_lines POST call' do
|
14
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Payout/confirm_third_party.json'))
|
15
|
+
|
16
|
+
response_body = json_from_file('mocks/responses/Payout/confirm_third_party.json')
|
17
|
+
|
18
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'confirmThirdParty',
|
19
|
+
@shared_values[:client].payout.version)
|
20
|
+
WebMock.stub_request(:post, url)
|
21
|
+
.with(
|
22
|
+
body: request_body,
|
23
|
+
headers: {
|
24
|
+
'x-api-key' => @shared_values[:client].api_key
|
25
|
+
}
|
26
|
+
)
|
27
|
+
.to_return(
|
28
|
+
body: response_body
|
29
|
+
)
|
31
30
|
|
32
31
|
result = @shared_values[:client].payout.reviewing_api.confirm_third_party(request_body)
|
33
32
|
response_hash = result.response
|
34
33
|
|
35
|
-
expect(result.status)
|
36
|
-
to eq(200)
|
37
|
-
expect(response_hash)
|
38
|
-
to eq(JSON.parse(response_body))
|
39
|
-
expect(response_hash)
|
40
|
-
to be_a Adyen::HashWithAccessors
|
41
|
-
expect(response_hash)
|
42
|
-
to be_a_kind_of Hash
|
34
|
+
expect(result.status)
|
35
|
+
.to eq(200)
|
36
|
+
expect(response_hash)
|
37
|
+
.to eq(JSON.parse(response_body))
|
38
|
+
expect(response_hash)
|
39
|
+
.to be_a Adyen::HashWithAccessors
|
40
|
+
expect(response_hash)
|
41
|
+
.to be_a_kind_of Hash
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
46
|
-
|
@@ -1,46 +1,44 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
RSpec.describe Adyen::PosTerminalManagement, service: "PosTerminalManagement" do
|
4
|
+
RSpec.describe Adyen::PosTerminalManagement, service: 'PosTerminalManagement' do
|
7
5
|
before(:all) do
|
8
6
|
@shared_values = {
|
9
7
|
client: create_client(:api_key),
|
10
|
-
service:
|
8
|
+
service: 'LegalEntityManagement'
|
11
9
|
}
|
12
10
|
end
|
13
11
|
|
14
12
|
# must be created manually because every field in the response is an array
|
15
|
-
it
|
16
|
-
request_body = JSON.parse(json_from_file(
|
17
|
-
|
18
|
-
response_body = json_from_file(
|
19
|
-
|
20
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
it 'makes a assign_terminals POST call' do
|
14
|
+
request_body = JSON.parse(json_from_file('mocks/requests/Terminal/assign_terminals.json'))
|
15
|
+
|
16
|
+
response_body = json_from_file('mocks/responses/Terminal/assign_terminals.json')
|
17
|
+
|
18
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'assignTerminals',
|
19
|
+
@shared_values[:client].pos_terminal_management.version)
|
20
|
+
WebMock.stub_request(:post, url)
|
21
|
+
.with(
|
22
|
+
body: request_body,
|
23
|
+
headers: {
|
24
|
+
'x-api-key' => @shared_values[:client].api_key
|
25
|
+
}
|
26
|
+
)
|
27
|
+
.to_return(
|
28
|
+
body: response_body
|
29
|
+
)
|
31
30
|
|
32
31
|
result = @shared_values[:client].pos_terminal_management.assign_terminals(request_body)
|
33
32
|
response_hash = result.response
|
34
33
|
|
35
|
-
expect(result.status)
|
36
|
-
to eq(200)
|
37
|
-
expect(response_hash)
|
38
|
-
to eq(JSON.parse(response_body))
|
39
|
-
expect(response_hash)
|
40
|
-
to be_a Adyen::HashWithAccessors
|
41
|
-
expect(response_hash)
|
42
|
-
to be_a_kind_of Hash
|
34
|
+
expect(result.status)
|
35
|
+
.to eq(200)
|
36
|
+
expect(response_hash)
|
37
|
+
.to eq(JSON.parse(response_body))
|
38
|
+
expect(response_hash)
|
39
|
+
.to be_a Adyen::HashWithAccessors
|
40
|
+
expect(response_hash)
|
41
|
+
.to be_a_kind_of Hash
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
46
|
-
|
44
|
+
# rubocop:enable Metrics/BlockLength
|
data/spec/recurring_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require_relative
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../lib/adyen/errors'
|
3
3
|
|
4
|
-
RSpec.describe Adyen::Payment, service:
|
4
|
+
RSpec.describe Adyen::Payment, service: 'recurring service' do
|
5
5
|
# client instance to be used in dynamically generated tests
|
6
6
|
client = create_client(:basic)
|
7
7
|
|
8
8
|
# methods / values to test for
|
9
9
|
# format is defined in spec_helper
|
10
10
|
test_sets = [
|
11
|
-
[
|
12
|
-
[
|
13
|
-
[
|
14
|
-
[
|
11
|
+
['list_recurring_details', 'creationDate', '2017-03-01T11:53:11+01:00'],
|
12
|
+
['disable', 'response', '[detail-successfully-disabled]'],
|
13
|
+
['create_permit', 'pspReference', '8815260599791117'],
|
14
|
+
['schedule_account_updater', 'result', 'Success']
|
15
15
|
]
|
16
16
|
|
17
|
-
generate_tests(client,
|
17
|
+
generate_tests(client, 'Recurring', test_sets, client.recurring)
|
18
18
|
end
|
data/spec/service_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# rubocop:disable Metrics/MethodLength
|
2
|
+
# rubocop:disable Metrics/AbcSize
|
3
|
+
|
4
|
+
require 'webmock/rspec'
|
5
|
+
require 'base64'
|
6
|
+
require_relative '../lib/adyen-ruby-api-library'
|
4
7
|
|
5
8
|
# disable external connections
|
6
9
|
WebMock.disable_net_connect!(allow_localhost: true)
|
@@ -18,47 +21,46 @@ def create_test(client, service, method_name, parent_object)
|
|
18
21
|
request_body = JSON.parse(json_from_file("mocks/requests/#{service}/#{method_name}.json"))
|
19
22
|
response_body = json_from_file("mocks/responses/#{service}/#{method_name}.json")
|
20
23
|
|
21
|
-
|
22
24
|
# client-generated headers
|
23
25
|
headers = {
|
24
|
-
|
26
|
+
'Content-Type'.to_sym => 'application/json'
|
25
27
|
}
|
26
28
|
|
27
29
|
# authentication headers
|
28
|
-
if
|
29
|
-
headers[
|
30
|
-
elsif
|
31
|
-
auth_header = "Basic
|
32
|
-
headers[
|
30
|
+
if !client.api_key.nil?
|
31
|
+
headers['x-api-key'] = client.api_key
|
32
|
+
elsif !client.ws_user.nil? && !client.ws_password.nil?
|
33
|
+
auth_header = "Basic #{Base64.encode64("#{client.ws_user}:#{client.ws_password}")}"
|
34
|
+
headers['Authorization'] = auth_header.strip
|
33
35
|
else
|
34
|
-
raise ArgumentError,
|
36
|
+
raise ArgumentError, 'Authentication not set correctly in test case'
|
35
37
|
end
|
36
38
|
|
37
39
|
# stub request
|
38
40
|
action = Adyen::Service.action_for_method_name(method_name)
|
39
41
|
url = client.service_url(service, action, parent_object.version)
|
40
|
-
WebMock.stub_request(:post, url)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
WebMock.stub_request(:post, url)
|
43
|
+
.with(
|
44
|
+
body: request_body,
|
45
|
+
headers: headers
|
46
|
+
)
|
47
|
+
.to_return(
|
48
|
+
body: response_body
|
49
|
+
)
|
48
50
|
result = parent_object.public_send(method_name, request_body)
|
49
51
|
|
50
52
|
# result.response is already a Ruby object (Adyen::HashWithAccessors) (rather than an unparsed JSON string)
|
51
53
|
response_hash = result.response
|
52
54
|
|
53
55
|
# boilerplate error checks
|
54
|
-
expect(result.status)
|
55
|
-
to eq(200)
|
56
|
-
expect(response_hash)
|
57
|
-
to eq(JSON.parse(response_body))
|
58
|
-
expect(response_hash)
|
59
|
-
to be_a Adyen::HashWithAccessors
|
60
|
-
expect(response_hash)
|
61
|
-
to be_a_kind_of Hash
|
56
|
+
expect(result.status)
|
57
|
+
.to eq(200)
|
58
|
+
expect(response_hash)
|
59
|
+
.to eq(JSON.parse(response_body))
|
60
|
+
expect(response_hash)
|
61
|
+
.to be_a Adyen::HashWithAccessors
|
62
|
+
expect(response_hash)
|
63
|
+
.to be_a_kind_of Hash
|
62
64
|
|
63
65
|
response_hash
|
64
66
|
end
|
@@ -70,8 +72,8 @@ def generate_tests(client, service, test_sets, parent_object)
|
|
70
72
|
test_sets.each do |test_set|
|
71
73
|
it "makes a #{test_set[0]} call" do
|
72
74
|
parsed_body = create_test(client, service, test_set[0], parent_object)
|
73
|
-
expect(parsed_body[test_set[1]])
|
74
|
-
to eq(test_set[2])
|
75
|
+
expect(parsed_body[test_set[1]])
|
76
|
+
.to eq(test_set[2])
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
@@ -81,15 +83,15 @@ end
|
|
81
83
|
def create_client(auth_type)
|
82
84
|
client = Adyen::Client.new
|
83
85
|
client.env = :mock
|
84
|
-
|
85
86
|
if auth_type == :basic
|
86
|
-
client.ws_user =
|
87
|
-
client.ws_password =
|
87
|
+
client.ws_user = 'user'
|
88
|
+
client.ws_password = 'password'
|
88
89
|
elsif auth_type == :api_key
|
89
|
-
client.api_key =
|
90
|
+
client.api_key = 'api_key'
|
90
91
|
else
|
91
|
-
raise ArgumentError
|
92
|
+
raise ArgumentError 'Invalid auth type for test client'
|
92
93
|
end
|
93
|
-
|
94
94
|
client
|
95
95
|
end
|
96
|
+
# rubocop:enable Metrics/MethodLength
|
97
|
+
# rubocop:enable Metrics/AbcSize
|
data/spec/stored_value_spec.rb
CHANGED
@@ -1,43 +1,44 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
3
|
|
4
|
-
RSpec.describe Adyen::BalancePlatform, service:
|
4
|
+
RSpec.describe Adyen::BalancePlatform, service: 'balancePlatform' do
|
5
5
|
before(:all) do
|
6
6
|
@shared_values = {
|
7
7
|
client: create_client(:api_key),
|
8
|
-
service:
|
8
|
+
service: 'BalancePlatform'
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
12
12
|
# must be created manually because every field in the response is an array
|
13
|
-
it
|
14
|
-
request_body = JSON.parse(json_from_file(
|
13
|
+
it 'makes a issue POST call' do
|
14
|
+
request_body = JSON.parse(json_from_file('mocks/requests/StoredValue/issue_giftcard.json'))
|
15
15
|
|
16
|
-
response_body = json_from_file(
|
16
|
+
response_body = json_from_file('mocks/responses/StoredValue/issue_giftcard.json')
|
17
17
|
|
18
|
-
url = @shared_values[:client].service_url(@shared_values[:service],
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
url = @shared_values[:client].service_url(@shared_values[:service], 'issue',
|
19
|
+
@shared_values[:client].stored_value.version)
|
20
|
+
WebMock.stub_request(:post, url)
|
21
|
+
.with(
|
22
|
+
body: request_body,
|
23
|
+
headers: {
|
24
|
+
'x-api-key' => @shared_values[:client].api_key
|
25
|
+
}
|
26
|
+
)
|
27
|
+
.to_return(
|
28
|
+
body: response_body
|
29
|
+
)
|
29
30
|
|
30
31
|
result = @shared_values[:client].stored_value.issue(request_body)
|
31
32
|
response_hash = result.response
|
32
33
|
|
33
|
-
expect(result.status)
|
34
|
-
to eq(200)
|
35
|
-
expect(response_hash)
|
36
|
-
to eq(JSON.parse(response_body))
|
37
|
-
expect(response_hash)
|
38
|
-
to be_a Adyen::HashWithAccessors
|
39
|
-
expect(response_hash)
|
40
|
-
to be_a_kind_of Hash
|
34
|
+
expect(result.status)
|
35
|
+
.to eq(200)
|
36
|
+
expect(response_hash)
|
37
|
+
.to eq(JSON.parse(response_body))
|
38
|
+
expect(response_hash)
|
39
|
+
.to be_a Adyen::HashWithAccessors
|
40
|
+
expect(response_hash)
|
41
|
+
.to be_a_kind_of Hash
|
41
42
|
end
|
42
|
-
|
43
43
|
end
|
44
|
+
# rubocop:enable Metrics/BlockLength
|