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
data/spec/client_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Adyen do
4
4
  before(:all) do
@@ -7,119 +7,120 @@ RSpec.describe Adyen do
7
7
  }
8
8
  end
9
9
 
10
- it "creates Adyen client" do
10
+ it 'creates Adyen client' do
11
11
  @shared_values[:client] = Adyen::Client.new
12
12
  expect(@shared_values[:client]).is_a? Adyen::Client
13
13
  end
14
14
 
15
- it "sets env to :mock" do
15
+ it 'sets env to :mock' do
16
16
  @shared_values[:client].env = :test
17
- expect(@shared_values[:client].env).
18
- to eq(:test)
17
+ expect(@shared_values[:client].env)
18
+ .to eq(:test)
19
19
  end
20
20
 
21
- it "sets the version number" do
21
+ it 'sets the version number' do
22
22
  @shared_values[:client].checkout.version = @shared_values[:version]
23
- expect(@shared_values[:client].checkout.version).
24
- to eq(@shared_values[:version])
23
+ expect(@shared_values[:client].checkout.version)
24
+ .to eq(@shared_values[:version])
25
25
  end
26
26
 
27
- it "fails payments call without WS user and password" do
28
- expect{ @shared_values[:client].payment.authorise("{}") }.
29
- to raise_error(Adyen::AuthenticationError)
27
+ it 'fails payments call without WS user and password' do
28
+ expect { @shared_values[:client].payment.general_api.authorise('{}') }
29
+ .to raise_error(Adyen::AuthenticationError)
30
30
  @shared_values[:client].ws_user = @shared_values[:ws_user]
31
- expect{ @shared_values[:client].payment.authorise("{}") }.
32
- to raise_error(Adyen::AuthenticationError)
31
+ expect { @shared_values[:client].payment.general_api.authorise('{}') }
32
+ .to raise_error(Adyen::AuthenticationError)
33
33
  end
34
34
 
35
- it "fails a checkout call without api key" do
36
- expect{ @shared_values[:client].checkout.payments_api.payment_methods("{}") }.
37
- to raise_error(Adyen::AuthenticationError)
38
- @shared_values[:client].api_key = "api_key"
35
+ it 'fails a checkout call without api key' do
36
+ expect { @shared_values[:client].checkout.payments_api.payment_methods('{}') }
37
+ .to raise_error(Adyen::AuthenticationError)
38
+ @shared_values[:client].api_key = 'api_key'
39
39
  end
40
40
 
41
- it "uses the specified mock service URL" do
42
- client = Adyen::Client.new(env: :mock, mock_service_url_base: "https://mock.test")
43
- expect(client.service_url_base("Account")).
44
- to eq("https://mock.test")
41
+ it 'uses the specified mock service URL' do
42
+ client = Adyen::Client.new(env: :mock, mock_service_url_base: 'https://mock.test')
43
+ expect(client.service_url_base('Account'))
44
+ .to eq('https://mock.test')
45
45
  end
46
46
 
47
- it "generates localhost service URL when a mock port is specified" do
47
+ it 'generates localhost service URL when a mock port is specified' do
48
48
  client = Adyen::Client.new(env: :mock, mock_port: 3005)
49
- expect(client.service_url_base("Account")).
50
- to eq("http://localhost:3005")
49
+ expect(client.service_url_base('Account'))
50
+ .to eq('http://localhost:3005')
51
51
  end
52
52
 
53
- it "prefers the mock service URL when both mock service URL and port are specified" do
54
- client = Adyen::Client.new(env: :mock, mock_port: 3005, mock_service_url_base: "https://this-url-wins.test")
55
- expect(client.service_url_base("Account")).
56
- to eq("https://this-url-wins.test")
53
+ it 'prefers the mock service URL when both mock service URL and port are specified' do
54
+ client = Adyen::Client.new(env: :mock, mock_port: 3005, mock_service_url_base: 'https://this-url-wins.test')
55
+ expect(client.service_url_base('Account'))
56
+ .to eq('https://this-url-wins.test')
57
57
  end
58
58
 
59
- it "generates the correct service URL base for CAL TEST" do
59
+ it 'generates the correct service URL base for CAL TEST' do
60
60
  client = Adyen::Client.new(env: :test)
61
- client.live_url_prefix = "abcdef1234567890-TestCompany"
62
- expect(client.service_url_base("Account")).
63
- to eq("https://cal-test.adyen.com/cal/services/Account")
61
+ client.live_url_prefix = 'abcdef1234567890-TestCompany'
62
+ expect(client.service_url_base('Account'))
63
+ .to eq('https://cal-test.adyen.com/cal/services/Account')
64
64
  end
65
65
 
66
- it "generates the correct service URL base for CAL LIVE" do
66
+ it 'generates the correct service URL base for CAL LIVE' do
67
67
  client = Adyen::Client.new(env: :live)
68
- client.live_url_prefix = "abcdef1234567890-TestCompany"
69
- expect(client.service_url_base("Account")).
70
- to eq("https://cal-live.adyen.com/cal/services/Account")
68
+ client.live_url_prefix = 'abcdef1234567890-TestCompany'
69
+ expect(client.service_url_base('Account'))
70
+ .to eq('https://cal-live.adyen.com/cal/services/Account')
71
71
  end
72
72
 
73
- it "generates the correct service URL base for PAL TEST" do
73
+ it 'generates the correct service URL base for PAL TEST' do
74
74
  client = Adyen::Client.new(env: :test)
75
- client.live_url_prefix = "abcdef1234567890-TestCompany"
76
- expect(client.service_url_base("Payment")).
77
- to eq("https://pal-test.adyen.com/pal/servlet/Payment")
75
+ client.live_url_prefix = 'abcdef1234567890-TestCompany'
76
+ expect(client.service_url_base('Payment'))
77
+ .to eq('https://pal-test.adyen.com/pal/servlet/Payment')
78
78
  end
79
79
 
80
- it "generates the correct service URL base for PAL LIVE" do
80
+ it 'generates the correct service URL base for PAL LIVE' do
81
81
  client = Adyen::Client.new(env: :live)
82
- client.live_url_prefix = "abcdef1234567890-TestCompany"
83
- expect(client.service_url_base("Payment")).
84
- to eq("https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet/Payment")
82
+ client.live_url_prefix = 'abcdef1234567890-TestCompany'
83
+ expect(client.service_url_base('Payment'))
84
+ .to eq('https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet/Payment')
85
85
  end
86
-
87
- it "generates the correct service URL PAL authorise TEST" do
86
+
87
+ it 'generates the correct service URL PAL authorise TEST' do
88
88
  client = Adyen::Client.new(env: :test)
89
- expect(client.service_url("Payment", "authorise", "68")).
90
- to eq("https://pal-test.adyen.com/pal/servlet/Payment/v68/authorise")
89
+ expect(client.service_url('Payment', 'authorise', '68'))
90
+ .to eq('https://pal-test.adyen.com/pal/servlet/Payment/v68/authorise')
91
91
  end
92
92
 
93
- it "generates the correct service URL base for PAL LIVE" do
93
+ it 'generates the correct service URL base for PAL LIVE' do
94
94
  client = Adyen::Client.new(env: :live)
95
- client.live_url_prefix = "abcdef1234567890-TestCompany"
96
- expect(client.service_url("Payment", "authorise", "68")).
97
- to eq("https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet/Payment/v68/authorise")
95
+ client.live_url_prefix = 'abcdef1234567890-TestCompany'
96
+ expect(client.service_url('Payment', 'authorise', '68'))
97
+ .to eq('https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet/Payment/v68/authorise')
98
98
  end
99
99
 
100
- it "generates a new set of ConnectionOptions when none are provided" do
100
+ it 'generates a new set of ConnectionOptions when none are provided' do
101
101
  expect(Faraday::ConnectionOptions).to receive(:new).and_call_original
102
- client = Adyen::Client.new(env: :test)
102
+ Adyen::Client.new(env: :test)
103
103
  end
104
104
 
105
- it "uses the ConnectionOptions provided" do
105
+ it 'uses the ConnectionOptions provided' do
106
106
  connection_options = Faraday::ConnectionOptions.new
107
107
  expect(Faraday::ConnectionOptions).not_to receive(:new)
108
- client = Adyen::Client.new(env: :test, connection_options: connection_options)
108
+ Adyen::Client.new(env: :test, connection_options: connection_options)
109
109
  end
110
110
 
111
- it "initiates a Faraday connection with the provided options" do
111
+ it 'initiates a Faraday connection with the provided options' do
112
112
  connection_options = Faraday::ConnectionOptions.new
113
113
  expect(Faraday::ConnectionOptions).not_to receive(:new)
114
- client = Adyen::Client.new(api_key: "api_key", env: :mock, connection_options: connection_options)
114
+ client = Adyen::Client.new(api_key: 'api_key', env: :mock, connection_options: connection_options)
115
115
 
116
116
  mock_faraday_connection = double(Faraday::Connection)
117
- url = client.service_url(@shared_values[:service], "payments/details", client.checkout.version)
118
- request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment-details.json"))
117
+ client.service_url(@shared_values[:service], 'payments/details', client.checkout.version)
118
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/payment-details.json'))
119
119
  mock_response = Faraday::Response.new(status: 200)
120
120
 
121
121
  expect(Adyen::AdyenResult).to receive(:new)
122
- expect(Faraday).to receive(:new).with("http://localhost:3001/v70/payments/details", connection_options).and_return(mock_faraday_connection)
122
+ expect(Faraday).to receive(:new).with('http://localhost:3001/v70/payments/details',
123
+ connection_options).and_return(mock_faraday_connection)
123
124
  expect(mock_faraday_connection).to receive(:post).and_return(mock_response)
124
125
  client.checkout.payments_api.payments_details(request_body)
125
126
  end
@@ -133,7 +134,7 @@ RSpec.describe Adyen do
133
134
  it "checks the creation of checkout url" do
134
135
  client = Adyen::Client.new(api_key: "api_key", env: :live, live_url_prefix: "YourLiveUrlPrefix")
135
136
  expect(client.service_url("Checkout", "paymentMethods", "70")).
136
- to eq("https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/v70/paymentMethods")
137
+ to eq("https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/checkout/v70/paymentMethods")
137
138
  end
138
139
  it "checks the creation of lem url" do
139
140
  client = Adyen::Client.new(api_key: "api_key", env: :live)
@@ -177,16 +178,62 @@ RSpec.describe Adyen do
177
178
  to eq("https://pal-test.adyen.com/pal/servlet/StoredValue/v46/issue")
178
179
  end
179
180
 
180
- it "check the creation of payout url" do
181
- client = Adyen::Client.new(api_key: "api_key", env: :test)
182
- expect(client.service_url("Payout", "declineThirdParty", "68")).
183
- to eq("https://pal-test.adyen.com/pal/servlet/Payout/v68/declineThirdParty")
181
+ it 'checks the creation of checkout url' do
182
+ client = Adyen::Client.new(api_key: 'api_key', env: :live, live_url_prefix: 'YourLiveUrlPrefix')
183
+ expect(client.service_url('Checkout', 'paymentMethods', '70'))
184
+ .to eq('https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/checkout/v70/paymentMethods')
185
+ end
186
+ it 'checks the creation of lem url' do
187
+ client = Adyen::Client.new(api_key: 'api_key', env: :live)
188
+ expect(client.service_url('LegalEntityManagement', 'businessLines', '3'))
189
+ .to eq('https://kyc-live.adyen.com/lem/v3/businessLines')
184
190
  end
185
191
 
186
- it "checks the creation of PosTerminalManagement url" do
187
- client = Adyen::Client.new(api_key: "api_key", env: :test)
188
- expect(client.service_url("PosTerminalManagement", "assignTerminals", "1")).
189
- to eq("https://postfmapi-test.adyen.com/postfmapi/terminal/v1/assignTerminals")
190
- end
192
+ it 'checks the creation of balancePlatform url' do
193
+ client = Adyen::Client.new(api_key: 'api_key', env: :live)
194
+ expect(client.service_url('BalancePlatform', 'legalEntities', '1'))
195
+ .to eq('https://balanceplatform-api-live.adyen.com/bcl/v1/legalEntities')
196
+ end
197
+
198
+ it 'checks the creation of balancePlatform url' do
199
+ client = Adyen::Client.new(api_key: 'api_key', env: :test)
200
+ expect(client.service_url('BalancePlatform', 'legalEntities', '1'))
201
+ .to eq('https://balanceplatform-api-test.adyen.com/bcl/v1/legalEntities')
202
+ end
203
+
204
+ it 'checks the creation of transfers url' do
205
+ client = Adyen::Client.new(api_key: 'api_key', env: :test)
206
+ expect(client.service_url('Transfers', 'transactions', '1'))
207
+ .to eq('https://balanceplatform-api-test.adyen.com/btl/v1/transactions')
208
+ end
209
+
210
+ it 'checks the creation of management url' do
211
+ client = Adyen::Client.new(api_key: 'api_key', env: :test)
212
+ expect(client.service_url('Management', 'companies', '1'))
213
+ .to eq('https://management-test.adyen.com/v1/companies')
214
+ end
215
+
216
+ it 'checks the creation of binLookup url' do
217
+ client = Adyen::Client.new(api_key: 'api_key', env: :test)
218
+ expect(client.service_url('BinLookup', 'getCostEstimate', '54'))
219
+ .to eq('https://pal-test.adyen.com/pal/servlet/BinLookup/v54/getCostEstimate')
220
+ end
191
221
 
222
+ it 'check the creation of storedValue url' do
223
+ client = Adyen::Client.new(api_key: 'api_key', env: :test)
224
+ expect(client.service_url('StoredValue', 'issue', '46'))
225
+ .to eq('https://pal-test.adyen.com/pal/servlet/StoredValue/v46/issue')
226
+ end
227
+
228
+ it 'check the creation of payout url' do
229
+ client = Adyen::Client.new(api_key: 'api_key', env: :test)
230
+ expect(client.service_url('Payout', 'declineThirdParty', '68'))
231
+ .to eq('https://pal-test.adyen.com/pal/servlet/Payout/v68/declineThirdParty')
232
+ end
233
+
234
+ it 'checks the creation of PosTerminalManagement url' do
235
+ client = Adyen::Client.new(api_key: 'api_key', env: :test)
236
+ expect(client.service_url('PosTerminalManagement', 'assignTerminals', '1'))
237
+ .to eq('https://postfmapi-test.adyen.com/postfmapi/terminal/v1/assignTerminals')
238
+ end
192
239
  end
@@ -1,14 +1,14 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- RSpec.describe Adyen::DataProtection, service: "Data Protection Service" do
3
+ RSpec.describe Adyen::DataProtection, service: 'Data Protection 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
- ["request_subject_erasure", "result", "SUCCESS"],
10
+ %w[request_subject_erasure result SUCCESS]
11
11
  ]
12
12
 
13
- generate_tests(client, "DataProtectionService", test_sets, client.data_protection)
13
+ generate_tests(client, 'DataProtectionService', test_sets, client.data_protection)
14
14
  end
data/spec/dispute_spec.rb CHANGED
@@ -1,17 +1,17 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- RSpec.describe Adyen::Dispute, service: "dispute service" do
3
+ RSpec.describe Adyen::Dispute, service: 'dispute 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
- ["retrieve_applicable_defense_reasons", "disputeServiceResult", { "success" => true }],
11
- ["supply_defense_document", "disputeServiceResult", { "success" => true }],
12
- ["delete_dispute_defense_document", "disputeServiceResult", { "success" => true }],
13
- ["defend_dispute", "disputeServiceResult", { "success" => true }],
10
+ ['retrieve_applicable_defense_reasons', 'disputeServiceResult', { 'success' => true }],
11
+ ['supply_defense_document', 'disputeServiceResult', { 'success' => true }],
12
+ ['delete_dispute_defense_document', 'disputeServiceResult', { 'success' => true }],
13
+ ['defend_dispute', 'disputeServiceResult', { 'success' => true }]
14
14
  ]
15
15
 
16
- generate_tests(client, "DisputeService", test_sets, client.dispute)
16
+ generate_tests(client, 'DisputeService', test_sets, client.dispute)
17
17
  end
data/spec/errors_spec.rb CHANGED
@@ -7,49 +7,69 @@ RSpec.describe Adyen::AdyenError do
7
7
  @shared_values = {
8
8
  request: {
9
9
  amount: {
10
- currency: "USD",
10
+ currency: 'USD',
11
11
  value: 1000
12
12
  },
13
- reference: "Your order number",
13
+ reference: 'Your order number',
14
14
  paymentMethod: {
15
- type: "scheme",
16
- number: "4111111111111111",
17
- expiryMonth: "10",
18
- expiryYear: "2020",
19
- holderName: "John Smith",
20
- cvc: "737"
15
+ type: 'scheme',
16
+ number: '4111111111111111',
17
+ expiryMonth: '10',
18
+ expiryYear: '2020',
19
+ holderName: 'John Smith',
20
+ cvc: '737'
21
21
  },
22
- returnUrl: "https://your-company.com/",
23
- merchantAccount: "YOUR_MERCHANT_ACCOUNT"
22
+ returnUrl: 'https://your-company.com/',
23
+ merchantAccount: 'YOUR_MERCHANT_ACCOUNT'
24
24
  }
25
25
  }
26
26
  end
27
27
 
28
28
  describe '#to_s' do
29
29
  it 'describes using the error properties' do
30
- expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').to_s).to eq("Adyen::AdyenError code:code, msg:message, request:#{@shared_values[:request]}, response:response")
30
+ expect(Adyen::AdyenError.new(
31
+ @shared_values[:request],
32
+ 'response',
33
+ 'message',
34
+ 'code'
35
+ ).to_s).to eq("Adyen::AdyenError code:code, msg:message, request:#{@shared_values[:request]}, response:response")
31
36
  end
32
37
  it 'skips the null properties' do
33
- expect(Adyen::AdyenError.new(@shared_values[:request], nil, nil, 'code').to_s).to eq("Adyen::AdyenError code:code, request:#{@shared_values[:request]}")
38
+ expect(Adyen::AdyenError.new(
39
+ @shared_values[:request],
40
+ nil,
41
+ nil,
42
+ 'code'
43
+ ).to_s).to eq("Adyen::AdyenError code:code, request:#{@shared_values[:request]}")
34
44
  end
35
45
  it 'uses the proper error class name' do
36
- expect(Adyen::PermissionError.new('message', @shared_values[:request], 'response').to_s).to eq("Adyen::PermissionError code:403, msg:message, request:#{@shared_values[:request]}, response:response")
46
+ expect(Adyen::PermissionError.new(
47
+ 'message',
48
+ @shared_values[:request],
49
+ 'response'
50
+ ).to_s).to eq(
51
+ "Adyen::PermissionError code:403, msg:message, request:#{@shared_values[:request]}, response:response"
52
+ )
37
53
  end
38
54
  end
39
55
  describe '#masking' do
40
56
  it 'masks card number when logging request in errors' do
41
- expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').request[:paymentMethod][:number]).to eq('411111******1111')
57
+ expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message',
58
+ 'code').request[:paymentMethod][:number]).to eq('411111******1111')
42
59
  end
43
60
  it 'masks CVC when logging request in errors' do
44
- expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').request[:paymentMethod][:cvc]).to eq('***')
61
+ expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message',
62
+ 'code').request[:paymentMethod][:cvc]).to eq('***')
45
63
  end
46
64
 
47
65
  context 'when request is string' do
48
66
  it 'masks card number when logging request in errors' do
49
- expect(Adyen::AdyenError.new(JSON.generate(@shared_values[:request]), 'response', 'message', 'code').request[:paymentMethod][:number]).to eq('411111******1111')
67
+ expect(Adyen::AdyenError.new(JSON.generate(@shared_values[:request]), 'response', 'message',
68
+ 'code').request[:paymentMethod][:number]).to eq('411111******1111')
50
69
  end
51
70
  it 'masks CVC when logging request in errors' do
52
- expect(Adyen::AdyenError.new(JSON.generate(@shared_values[:request]), 'response', 'message', 'code').request[:paymentMethod][:cvc]).to eq('***')
71
+ expect(Adyen::AdyenError.new(JSON.generate(@shared_values[:request]), 'response', 'message',
72
+ 'code').request[:paymentMethod][:cvc]).to eq('***')
53
73
  end
54
74
  end
55
75
  end
data/spec/fund_spec.rb CHANGED
@@ -1,20 +1,20 @@
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
- ["payout_account_holder", "pspReference", "9915090894325643"],
11
- ["account_holder_balance", "pspReference", "9914719436100053"],
12
- ["account_holder_transaction_list", "pspReference", "9914721175530029"],
13
- ["refund_not_paid_out_transfers", "pspReference", "9915090894215323"],
14
- ["setup_beneficiary", "pspReference", "9914860354282596"],
15
- ["transfer_funds", "pspReference", "9915090893984580"],
16
- ["refund_funds_transfer", "pspReference", "9915090893984580"]
10
+ %w[payout_account_holder pspReference 9915090894325643],
11
+ %w[account_holder_balance pspReference 9914719436100053],
12
+ %w[account_holder_transaction_list pspReference 9914721175530029],
13
+ %w[refund_not_paid_out_transfers pspReference 9915090894215323],
14
+ %w[setup_beneficiary pspReference 9914860354282596],
15
+ %w[transfer_funds pspReference 9915090893984580],
16
+ %w[refund_funds_transfer pspReference 9915090893984580]
17
17
  ]
18
18
 
19
- generate_tests(client, "Fund", test_sets, client.marketpay.fund)
19
+ generate_tests(client, 'Fund', test_sets, client.marketpay.fund)
20
20
  end
@@ -1,3 +1,5 @@
1
+ # rubocop:disable Lint/ConstantDefinitionInBlock
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe Adyen::HashWithAccessors do
@@ -19,15 +21,24 @@ RSpec.describe Adyen::HashWithAccessors do
19
21
  end
20
22
 
21
23
  it 'complains if there are arguments for the accessor' do
22
- expect { subject.arbitrary_accessor(1) }.to raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 0)')
23
- expect { subject.arbitrary_accessor(1, 2) }.to raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 0)')
24
+ expect do
25
+ subject.arbitrary_accessor(1)
26
+ end.to raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 0)')
27
+ expect do
28
+ subject.arbitrary_accessor(1, 2)
29
+ end.to raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 0)')
24
30
  end
25
31
 
26
32
  it 'complains if there are arguments for the accessor =' do
27
33
  # using send because i'm not sure how to do this wrong with normal ruby setter calling.
28
34
  # just here for completeness
29
- expect { subject.send(:arbitrary_accessor=) }.to raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1)')
30
- expect { subject.send(:arbitrary_accessor=, 1, 2) }.to raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)')
35
+ expect do
36
+ subject.send(:arbitrary_accessor=)
37
+ end.to raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1)')
38
+ expect do
39
+ subject.send(:arbitrary_accessor=, 1,
40
+ 2)
41
+ end.to raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)')
31
42
  end
32
43
 
33
44
  it 'responds to the accessor' do
@@ -84,8 +95,7 @@ RSpec.describe Adyen::HashWithAccessors do
84
95
 
85
96
  before(:all) do
86
97
  class Hash
87
- def called_super(*args)
88
- end
98
+ def called_super(*args); end
89
99
 
90
100
  def method_missing(*args)
91
101
  called_super(:method_missing, *args)
@@ -118,10 +128,10 @@ RSpec.describe Adyen::HashWithAccessors do
118
128
  expect(subject).to receive(:called_super).with(:method_missing, :something_else)
119
129
  expect { subject.something_else }.to raise_error(NoMethodError)
120
130
  end
121
-
122
131
  end
123
132
 
124
133
  it "doesn't modify all hashes" do
125
- expect { {a: 1}.a }.to raise_error(NoMethodError)
134
+ expect { { a: 1 }.a }.to raise_error(NoMethodError)
126
135
  end
127
136
  end
137
+ # rubocop:enable Lint/ConstantDefinitionInBlock
data/spec/hop_spec.rb CHANGED
@@ -1,14 +1,14 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- RSpec.describe Adyen::Payment, service: "marketpay hop service" do
3
+ RSpec.describe Adyen::Payment, service: 'marketpay hop 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
- ["get_onboarding_url", "pspReference", "8815850625171183"]
10
+ %w[get_onboarding_url pspReference 8815850625171183]
11
11
  ]
12
12
 
13
- generate_tests(client, "Hop", test_sets, client.marketpay.hop)
13
+ generate_tests(client, 'Hop', test_sets, client.marketpay.hop)
14
14
  end
data/spec/lem_spec.rb CHANGED
@@ -1,68 +1,63 @@
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::LegalEntityManagement, service: "LegalEntityManagement" do
4
+ RSpec.describe Adyen::LegalEntityManagement, service: 'LegalEntityManagement' 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 business_lines POST call" do
16
- request_body = JSON.parse(json_from_file("mocks/requests/LegalEntityManagement/create_business_line.json"))
17
-
18
- response_body = json_from_file("mocks/responses/LegalEntityManagement/create_business_line.json")
19
-
20
- url = @shared_values[:client].service_url(@shared_values[:service], "businessLines", @shared_values[:client].legal_entity_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 business_lines POST call' do
14
+ request_body = JSON.parse(json_from_file('mocks/requests/LegalEntityManagement/create_business_line.json'))
15
+
16
+ response_body = json_from_file('mocks/responses/LegalEntityManagement/create_business_line.json')
17
+
18
+ url = @shared_values[:client].service_url(@shared_values[:service], 'businessLines',
19
+ @shared_values[:client].legal_entity_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].legal_entity_management.business_lines_api.create_business_line(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
43
 
45
- it "makes a documents DELETE call" do
46
-
47
-
48
- url = @shared_values[:client].service_url(@shared_values[:service], "documents/123", @shared_values[:client].legal_entity_management.version)
49
- WebMock.stub_request(:delete, url).
50
- with(
51
- headers: {
52
- "x-api-key" => @shared_values[:client].api_key
53
- }
54
- ).
55
- to_return(
56
- body: "{}"
57
- )
44
+ it 'makes a documents DELETE call' do
45
+ url = @shared_values[:client].service_url(@shared_values[:service], 'documents/123',
46
+ @shared_values[:client].legal_entity_management.version)
47
+ WebMock.stub_request(:delete, url)
48
+ .with(
49
+ headers: {
50
+ 'x-api-key' => @shared_values[:client].api_key
51
+ }
52
+ )
53
+ .to_return(
54
+ body: '{}'
55
+ )
58
56
 
59
57
  result = @shared_values[:client].legal_entity_management.documents_api.delete_document('123')
60
- response_hash = result.response
58
+ result.response
61
59
 
62
- expect(result.status).
63
- to eq(200)
60
+ expect(result.status)
61
+ .to eq(200)
64
62
  end
65
-
66
-
67
63
  end
68
-