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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/release.yml +18 -0
  4. data/.github/workflows/gh_release.yml +16 -0
  5. data/.github/workflows/release_request.yml +15 -0
  6. data/.github/workflows/ruby.yml +1 -1
  7. data/.github/workflows/services.yml +28 -0
  8. data/.rubocop.yml +8 -0
  9. data/Gemfile +7 -7
  10. data/Makefile +14 -10
  11. data/README.md +13 -10
  12. data/Rakefile +3 -3
  13. data/adyen-ruby-api-library.gemspec +6 -3
  14. data/bin/console +2 -2
  15. data/lib/adyen/client.rb +96 -76
  16. data/lib/adyen/errors.rb +23 -18
  17. data/lib/adyen/hash_with_accessors.rb +12 -7
  18. data/lib/adyen/services/balanceControlService.rb +7 -14
  19. data/lib/adyen/services/balancePlatform/account_holders_api.rb +22 -38
  20. data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +48 -79
  21. data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +6 -13
  22. data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +6 -13
  23. data/lib/adyen/services/balancePlatform/grant_offers_api.rb +12 -22
  24. data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +16 -29
  25. data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +26 -45
  26. data/lib/adyen/services/balancePlatform/platform_api.rb +12 -22
  27. data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +21 -37
  28. data/lib/adyen/services/balancePlatform.rb +38 -40
  29. data/lib/adyen/services/binLookup.rb +12 -22
  30. data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +11 -21
  31. data/lib/adyen/services/checkout/modifications_api.rb +31 -53
  32. data/lib/adyen/services/checkout/orders_api.rb +16 -29
  33. data/lib/adyen/services/checkout/payment_links_api.rb +16 -29
  34. data/lib/adyen/services/checkout/payments_api.rb +40 -53
  35. data/lib/adyen/services/checkout/recurring_api.rb +13 -23
  36. data/lib/adyen/services/checkout/utility_api.rb +11 -21
  37. data/lib/adyen/services/checkout.rb +32 -34
  38. data/lib/adyen/services/dataProtection.rb +7 -14
  39. data/lib/adyen/services/dispute.rb +6 -5
  40. data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +21 -37
  41. data/lib/adyen/services/legalEntityManagement/documents_api.rb +21 -37
  42. data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +16 -29
  43. data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +26 -45
  44. data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +21 -37
  45. data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +25 -29
  46. data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +21 -37
  47. data/lib/adyen/services/legalEntityManagement.rb +32 -34
  48. data/lib/adyen/services/management/account_company_level_api.rb +18 -31
  49. data/lib/adyen/services/management/account_merchant_level_api.rb +22 -38
  50. data/lib/adyen/services/management/account_store_level_api.rb +43 -71
  51. data/lib/adyen/services/management/allowed_origins_company_level_api.rb +21 -37
  52. data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +21 -37
  53. data/lib/adyen/services/management/api_credentials_company_level_api.rb +22 -38
  54. data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +22 -38
  55. data/lib/adyen/services/management/api_key_company_level_api.rb +6 -13
  56. data/lib/adyen/services/management/api_key_merchant_level_api.rb +6 -13
  57. data/lib/adyen/services/management/client_key_company_level_api.rb +6 -13
  58. data/lib/adyen/services/management/client_key_merchant_level_api.rb +6 -13
  59. data/lib/adyen/services/management/my_api_credential_api.rb +26 -45
  60. data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +32 -54
  61. data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +26 -45
  62. data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +92 -0
  63. data/lib/adyen/services/management/terminal_actions_company_level_api.rb +24 -40
  64. data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +6 -13
  65. data/lib/adyen/services/management/terminal_orders_company_level_api.rb +55 -89
  66. data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +55 -89
  67. data/lib/adyen/services/management/terminal_settings_company_level_api.rb +23 -39
  68. data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +23 -39
  69. data/lib/adyen/services/management/terminal_settings_store_level_api.rb +45 -73
  70. data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +21 -37
  71. data/lib/adyen/services/management/terminals_terminal_level_api.rb +7 -14
  72. data/lib/adyen/services/management/users_company_level_api.rb +22 -38
  73. data/lib/adyen/services/management/users_merchant_level_api.rb +22 -38
  74. data/lib/adyen/services/management/webhooks_company_level_api.rb +37 -62
  75. data/lib/adyen/services/management/webhooks_merchant_level_api.rb +37 -62
  76. data/lib/adyen/services/management.rb +99 -96
  77. data/lib/adyen/services/marketpay.rb +42 -36
  78. data/lib/adyen/services/payment/general_api.rb +56 -0
  79. data/lib/adyen/services/payment/modifications_api.rb +83 -0
  80. data/lib/adyen/services/payment.rb +10 -158
  81. data/lib/adyen/services/payout/initialization_api.rb +16 -29
  82. data/lib/adyen/services/payout/instant_payouts_api.rb +6 -13
  83. data/lib/adyen/services/payout/reviewing_api.rb +11 -21
  84. data/lib/adyen/services/payout.rb +19 -21
  85. data/lib/adyen/services/posTerminalManagement.rb +27 -46
  86. data/lib/adyen/services/recurring.rb +32 -54
  87. data/lib/adyen/services/service.rb +5 -4
  88. data/lib/adyen/services/storedValue.rb +32 -54
  89. data/lib/adyen/services/transfers/capital_api.rb +38 -0
  90. data/lib/adyen/services/transfers/transactions_api.rb +12 -22
  91. data/lib/adyen/services/transfers/transfers_api.rb +6 -13
  92. data/lib/adyen/services/transfers.rb +20 -17
  93. data/lib/adyen/utils/hmac_validator.rb +9 -9
  94. data/lib/adyen/version.rb +3 -3
  95. data/lib/adyen-ruby-api-library.rb +21 -21
  96. data/spec/account_spec.rb +20 -20
  97. data/spec/balance_control_spec.rb +28 -29
  98. data/spec/balance_platform_spec.rb +108 -102
  99. data/spec/bin_lookup_spec.rb +50 -50
  100. data/spec/checkout_spec.rb +581 -515
  101. data/spec/client_spec.rb +118 -71
  102. data/spec/data_protection_spec.rb +4 -4
  103. data/spec/dispute_spec.rb +7 -7
  104. data/spec/errors_spec.rb +37 -17
  105. data/spec/fund_spec.rb +10 -10
  106. data/spec/hash_with_accessors_spec.rb +18 -8
  107. data/spec/hop_spec.rb +4 -4
  108. data/spec/lem_spec.rb +44 -49
  109. data/spec/management_spec.rb +46 -48
  110. data/spec/notification_spec.rb +9 -9
  111. data/spec/payments_spec.rb +31 -32
  112. data/spec/payouts_spec.rb +29 -32
  113. data/spec/pos_terminal_management_spec.rb +30 -32
  114. data/spec/recurring_spec.rb +8 -8
  115. data/spec/service_spec.rb +4 -0
  116. data/spec/spec_helper.rb +37 -35
  117. data/spec/stored_value_spec.rb +28 -27
  118. data/spec/transfers_spec.rb +48 -47
  119. data/spec/utils/hmac_validator_spec.rb +15 -14
  120. data/templates/api-single.mustache +13 -15
  121. data/templates/api-small.mustache +8 -15
  122. data/templates/api.mustache +7 -14
  123. metadata +27 -18
  124. data/.github/dependabot.yml +0 -8
  125. /data/spec/mocks/responses/Webhooks/{backslash_notification.json → backslash_webhook.json} +0 -0
  126. /data/spec/mocks/responses/Webhooks/{colon_notification.json → colon_webhook.json} +0 -0
  127. /data/spec/mocks/responses/Webhooks/{forwardslash_notification.json → forwardslash_webhook.json} +0 -0
  128. /data/spec/mocks/responses/Webhooks/{mixed_notification.json → mixed_webhook.json} +0 -0
@@ -1,68 +1,66 @@
1
- require "spec_helper"
2
- require "json"
1
+ require 'spec_helper'
2
+ require 'json'
3
3
 
4
- # rubocop:disable Metrics/BlockLength
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: "Management",
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 "makes a companies GET call" do
16
- response_body = json_from_file("mocks/responses/Management/get_companies.json")
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], "companies", @shared_values[:client].management.version)
19
- WebMock.stub_request(:get, url).
20
- with(
21
- headers: {
22
- "x-api-key" => @shared_values[:client].api_key
23
- }
24
- ).
25
- to_return(
26
- body: response_body
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 "makes a create_store POST call" do
43
- request_body = JSON.parse(json_from_file("mocks/responses/LegalEntityManagement/create_business_line.json"))
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("mocks/responses/LegalEntityManagement/create_business_line.json")
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], "merchants/merchantID/stores", @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
- )
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, 'merchantID')
60
- response_hash = result.response
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
- expect(result.status).
63
- to eq(200)
63
+ expect(result.status)
64
+ .to eq(200)
64
65
  end
65
-
66
-
67
66
  end
68
-
@@ -1,19 +1,19 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- RSpec.describe Adyen::Payment, service: "marketpay fund service" do
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
- ["create_notification_configuration", "pspReference", "8515077331535427"],
11
- ["delete_notification_configurations", "pspReference", "8515078085249090"],
12
- ["get_notification_configuration", "pspReference", "8815078078131377"],
13
- ["get_notification_configuration_list", "pspReference", "8515078078661665"],
14
- ["test_notification_configuration", "pspReference", "8515078087759211"],
15
- ["update_notification_configuration", "pspReference", "8515078084389038"]
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, "Notification", test_sets, client.marketpay.notification)
18
+ generate_tests(client, 'Notification', test_sets, client.marketpay.notification)
19
19
  end
@@ -1,44 +1,43 @@
1
- require "spec_helper"
2
- require "json"
1
+ require 'spec_helper'
2
+ require 'json'
3
3
 
4
- RSpec.describe Adyen::Payment, service: "Payment" do
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: "Payment",
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 "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", @shared_values[:client].payment.version)
19
- WebMock.stub_request(:post, url).
20
- with(
21
- body: request_body,
22
- headers: {
23
- "x-api-key" => @shared_values[:client].api_key
24
- }
25
- ).
26
- to_return(
27
- body: response_body
28
- )
29
-
30
- result = @shared_values[:client].payment.adjust_authorisation(request_body)
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 "spec_helper"
2
- require "json"
1
+ require 'spec_helper'
2
+ require 'json'
3
3
 
4
- # rubocop:disable Metrics/BlockLength
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: "Payout",
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 "makes a business_lines POST call" do
16
- request_body = JSON.parse(json_from_file("mocks/requests/Payout/confirm_third_party.json"))
17
-
18
- response_body = json_from_file("mocks/responses/Payout/confirm_third_party.json")
19
-
20
- url = @shared_values[:client].service_url(@shared_values[:service], "confirmThirdParty", @shared_values[:client].payout.version)
21
- WebMock.stub_request(:post, url).
22
- with(
23
- body: request_body,
24
- headers: {
25
- "x-api-key" => @shared_values[:client].api_key
26
- }
27
- ).
28
- to_return(
29
- body: response_body
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 "spec_helper"
2
- require "json"
1
+ require 'spec_helper'
2
+ require 'json'
3
3
 
4
- # rubocop:disable Metrics/BlockLength
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: "LegalEntityManagement",
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 "makes a assign_terminals POST call" do
16
- request_body = JSON.parse(json_from_file("mocks/requests/Terminal/assign_terminals.json"))
17
-
18
- response_body = json_from_file("mocks/responses/Terminal/assign_terminals.json")
19
-
20
- url = @shared_values[:client].service_url(@shared_values[:service], "assignTerminals", @shared_values[:client].pos_terminal_management.version)
21
- WebMock.stub_request(:post, url).
22
- with(
23
- body: request_body,
24
- headers: {
25
- "x-api-key" => @shared_values[:client].api_key
26
- }
27
- ).
28
- to_return(
29
- body: response_body
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
@@ -1,18 +1,18 @@
1
- require "spec_helper"
2
- require_relative "../lib/adyen/errors"
1
+ require 'spec_helper'
2
+ require_relative '../lib/adyen/errors'
3
3
 
4
- RSpec.describe Adyen::Payment, service: "recurring service" do
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
- ["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"]
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, "Recurring", test_sets, client.recurring)
17
+ generate_tests(client, 'Recurring', test_sets, client.recurring)
18
18
  end
data/spec/service_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # rubocop:disable Layout/LineLength
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe Adyen::Service do
@@ -44,3 +46,5 @@ RSpec.describe Adyen::Service do
44
46
  end
45
47
  end
46
48
  end
49
+ # rubocop:enable Layout/LineLength
50
+ # rubocop:enable Metrics/BlockLength
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,9 @@
1
- require "webmock/rspec"
2
- require "base64"
3
- require_relative "../lib/adyen-ruby-api-library"
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
- "Content-Type".to_sym => "application/json",
26
+ 'Content-Type'.to_sym => 'application/json'
25
27
  }
26
28
 
27
29
  # authentication headers
28
- if not client.api_key.nil?
29
- headers["x-api-key"] = client.api_key
30
- elsif not client.ws_user.nil? and not client.ws_password.nil?
31
- auth_header = "Basic " + Base64::encode64("#{client.ws_user}:#{client.ws_password}")
32
- headers["Authorization"] = auth_header.strip
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, "Authentication not set correctly in test case"
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
- with(
42
- body: request_body,
43
- headers: headers,
44
- ).
45
- to_return(
46
- body: response_body,
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 = "user"
87
- client.ws_password = "password"
87
+ client.ws_user = 'user'
88
+ client.ws_password = 'password'
88
89
  elsif auth_type == :api_key
89
- client.api_key = "api_key"
90
+ client.api_key = 'api_key'
90
91
  else
91
- raise ArgumentError "Invalid auth type for test client"
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
@@ -1,43 +1,44 @@
1
- require "spec_helper"
2
- require "json"
1
+ require 'spec_helper'
2
+ require 'json'
3
3
 
4
- RSpec.describe Adyen::BalancePlatform, service: "balancePlatform" do
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: "BalancePlatform",
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 "makes a issue POST call" do
14
- request_body = JSON.parse(json_from_file("mocks/requests/StoredValue/issue_giftcard.json"))
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("mocks/responses/StoredValue/issue_giftcard.json")
16
+ response_body = json_from_file('mocks/responses/StoredValue/issue_giftcard.json')
17
17
 
18
- url = @shared_values[:client].service_url(@shared_values[:service], "issue", @shared_values[:client].stored_value.version)
19
- WebMock.stub_request(:post, url).
20
- with(
21
- body: request_body,
22
- headers: {
23
- "x-api-key" => @shared_values[:client].api_key
24
- }
25
- ).
26
- to_return(
27
- body: response_body
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