Skip to content

Commit 840e786

Browse files
authored
feat: add support for terminal region (#256)
* feat: add support for terminal region * fix: use not nil? instead of present?
1 parent d35b515 commit 840e786

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/adyen/client.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
module Adyen
1414
class Client
1515
attr_accessor :ws_user, :ws_password, :api_key, :oauth_token, :client, :adapter
16-
attr_reader :env, :connection_options, :adapter_options
16+
attr_reader :env, :connection_options, :adapter_options, :terminal_region
1717

1818
def initialize(ws_user: nil, ws_password: nil, api_key: nil, oauth_token: nil, env: :live, adapter: nil, mock_port: 3001,
19-
live_url_prefix: nil, mock_service_url_base: nil, connection_options: nil, adapter_options: nil)
19+
live_url_prefix: nil, mock_service_url_base: nil, connection_options: nil, adapter_options: nil, terminal_region: nil)
2020
@ws_user = ws_user
2121
@ws_password = ws_password
2222
@api_key = api_key
@@ -33,6 +33,7 @@ def initialize(ws_user: nil, ws_password: nil, api_key: nil, oauth_token: nil, e
3333
@mock_service_url_base = mock_service_url_base || "http://localhost:#{mock_port}"
3434
@live_url_prefix = live_url_prefix
3535
@connection_options = connection_options || Faraday::ConnectionOptions.new
36+
@terminal_region = terminal_region
3637
end
3738

3839
# make sure that env can only be :live, :test, or :mock
@@ -84,7 +85,11 @@ def service_url_base(service)
8485
url = "https://management-#{@env}.adyen.com"
8586
supports_live_url_prefix = false
8687
when 'TerminalCloudAPI'
87-
url = "https://terminal-api-#{@env}.adyen.com"
88+
url = if !terminal_region.nil?
89+
"https://terminal-api-#{@env}-#{terminal_region}.adyen.com"
90+
else
91+
"https://terminal-api-#{@env}.adyen.com"
92+
end
8893
supports_live_url_prefix = false
8994
else
9095
raise ArgumentError, 'Invalid service specified'

0 commit comments

Comments
 (0)