Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/adyen/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@ws_password = ws_password
@api_key = api_key
@oauth_token = oauth_token
@env = env
self.env = env
@application_name = application_name
@adapter = adapter || Faraday.default_adapter
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.1')
Expand All @@ -33,7 +33,7 @@
@adapter_options = adapter_options || {}
end
@mock_service_url_base = mock_service_url_base || "http://localhost:#{mock_port}"
@live_url_prefix = live_url_prefix
self.live_url_prefix = live_url_prefix
if RUBY_VERSION >= '3.2'
# set default timeouts
@connection_options = connection_options || Faraday::ConnectionOptions.new(
Expand All @@ -60,7 +60,9 @@

# remove 'https' from live_url_prefix if necessary
def live_url_prefix=(value)
value['https://'] = '' unless value['https://'].nil?
unless value.nil?

Check warning on line 63 in lib/adyen/client.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "unless" statement with the nested one.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-ruby-api-library&issues=AZzmILhqVeL0hYeMOAP4&open=AZzmILhqVeL0hYeMOAP4&pullRequest=356
value['https://'] = '' unless value['https://'].nil?
end
@live_url_prefix = value
end

Expand Down
16 changes: 16 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
.to eq(:test)
end

it 'raises ArgumentError when initialized with an invalid env string' do
expect { Adyen::Client.new(env: 'live') }
.to raise_error(ArgumentError)
end

it 'raises ArgumentError when initialized with an invalid env value' do
expect { Adyen::Client.new(env: :invalid) }
.to raise_error(ArgumentError)
end

it 'strips https:// from live_url_prefix when passed via constructor' do
client = Adyen::Client.new(env: :live, live_url_prefix: 'https://myprefix')
expect(client.service_url_base('Payment'))
.to eq('https://myprefix-pal-live.adyenpayments.com/pal/servlet/Payment')
end

it 'sets the version number' do
@shared_values[:client].checkout.version = @shared_values[:version]
expect(@shared_values[:client].checkout.version)
Expand Down
Loading