diff --git a/lib/adyen/services/recurring.rb b/lib/adyen/services/recurring.rb index 98d868f..4a507df 100644 --- a/lib/adyen/services/recurring.rb +++ b/lib/adyen/services/recurring.rb @@ -17,7 +17,7 @@ def initialize(client, version = DEFAULT_VERSION) end def recurring_api - @recurring_api ||= Adyen::RecurringApi.new(@client, @version) + @recurring_api ||= Adyen::LegacyRecurringApi.new(@client, @version) end end diff --git a/lib/adyen/services/recurring/recurring_api.rb b/lib/adyen/services/recurring/recurring_api.rb index 7d2c90a..c7b304d 100644 --- a/lib/adyen/services/recurring/recurring_api.rb +++ b/lib/adyen/services/recurring/recurring_api.rb @@ -5,7 +5,7 @@ module Adyen # Ref: https://openapi-generator.tech # # Do not edit the class manually. - class RecurringApi < Service + class LegacyRecurringApi < Service attr_accessor :service, :version def initialize(client, version = DEFAULT_VERSION) diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 074a9fa..70edb1c 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -43,6 +43,40 @@ @shared_values[:client].api_key = 'api_key' end + describe 'service name resolution' do + let(:client) { Adyen::Client.new(env: :mock, mock_service_url_base: 'https://mock.test') } + + it 'is Checkout service when using checkout.payments_api' do + expect(client.checkout.payments_api.service) + .to eq('Checkout') + end + + it 'is Checkout service when using checkout.recurring_api' do + expect(client.checkout.recurring_api.service) + .to eq('Checkout') + end + + it 'is Recurring service when using recurring.recurring_api' do + expect(client.recurring.recurring_api.service) + .to eq('Recurring') + end + + it 'is Payment service when using payment.payments_api' do + expect(client.payment.payments_api.service) + .to eq('Payment') + end + + it 'is Payment service when using payment.modifications_api' do + expect(client.payment.modifications_api.service) + .to eq('Payment') + end + + it 'is Payout service when using payout.instant_payouts_api' do + expect(client.payout.instant_payouts_api.service) + .to eq('Payout') + end + end + it 'uses the specified mock service URL' do client = Adyen::Client.new(env: :mock, mock_service_url_base: 'https://mock.test') expect(client.service_url_base('Account')) @@ -206,6 +240,7 @@ expect(client.service_url('Checkout', 'paymentMethods', '70')) .to eq('https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/checkout/v70/paymentMethods') end + it 'checks the creation of lem url' do client = Adyen::Client.new(api_key: 'api_key', env: :live) expect(client.service_url('LegalEntityManagement', 'businessLines', '3')) @@ -321,6 +356,13 @@ .to eq('https://authe-live.adyen.com/authe/api') end + it 'checks the creation of Recurring API url for the test env' do + client = Adyen::Client.new(env: :test) + expect(client.service_url_base('Recurring')) + .to eq('https://pal-test.adyen.com/pal/servlet/Recurring') + end + + it 'raises FormatError on 400 response and checks content' do client = Adyen::Client.new(api_key: 'api_key', env: :test) mock_faraday_connection = double(Faraday::Connection)