Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions lib/adyen/services/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def initialize(client, version = DEFAULT_VERSION)
end

def modifications_api
@modifications_api ||= Adyen::ModificationsApi.new(@client, @version)
@modifications_api ||= Adyen::ClassicModificationsApi.new(@client, @version)
end

def payments_api
@payments_api ||= Adyen::PaymentsApi.new(@client, @version)
@payments_api ||= Adyen::ClassicPaymentsApi.new(@client, @version)
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/adyen/services/payment/modifications_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Adyen
# Ref: https://openapi-generator.tech
#
# Do not edit the class manually.
class ModificationsApi < Service
class ClassicModificationsApi < Service
attr_accessor :service, :version

def initialize(client, version = DEFAULT_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion lib/adyen/services/payment/payments_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Adyen
# Ref: https://openapi-generator.tech
#
# Do not edit the class manually.
class PaymentsApi < Service
class ClassicPaymentsApi < Service
attr_accessor :service, :version

def initialize(client, version = DEFAULT_VERSION)
Expand Down
32 changes: 32 additions & 0 deletions spec/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,38 @@
service: 'Checkout'
}
end

it 'detects a namespace collision between Checkout and Payment PaymentsApi classes' do
# Load both auto-generated PaymentsApi classes manually
payment_api_path = File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__)
checkout_api_path = File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__)

load payment_api_path
load checkout_api_path

# Instantiate what the Checkout facade will call
checkout = Adyen::Checkout.new(@shared_values[:client])

# Retrieve the PaymentsApi class reference that the facade resolves to
resolved_class = checkout.payments_api.class

# Verify which service it actually represents
service_name =
if resolved_class.instance_methods.include?(:service_name)
resolved_class.new(@shared_values[:client], @shared_values[:client].checkout.version).service_name
else
resolved_class.to_s
end

puts "service_name"
puts service_name
# This expectation documents the current buggy behavior.
# It should fail once the namespace is properly fixed.
expect(service_name)
.to eq('Adyen::PaymentsApi'),
"Expected Checkout.payments_api to instantiate the Checkout::PaymentsApi class, " \
"but it appears to be using the Payment service implementation instead (#{resolved_class})"
end

# must be created manually because every field in the response is an array
it 'makes a payment_methods call' do
Expand Down
2 changes: 1 addition & 1 deletion templates/api-single.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Adyen
{{#apiInfo}}
{{#apis}}
def {{classFilename}}
@{{classFilename}} ||= Adyen::{{classname}}.new(@client, @version)
@{{classFilename}} ||= Adyen::{{classicPrefix}}{{classname}}.new(@client, @version)
end

{{/apis}}
Expand Down
2 changes: 1 addition & 1 deletion templates/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Adyen
# Ref: https://openapi-generator.tech
#
# Do not edit the class manually.
class {{classname}} < Service
class {{classicPrefix}}{{classname}} < Service
attr_accessor :service, :version

def initialize(client, version = DEFAULT_VERSION)
Expand Down