1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
# frozen_string_literal: true
module Integrations
module Test
class BaseService
include BaseServiceUtility
attr_accessor :integration, :current_user, :event
# @param integration [Service] The external service that will be called
# @param current_user [User] The user calling the service
# @param event [String/nil] The event that triggered this
def initialize(integration, current_user, event = nil)
@integration = integration
@current_user = current_user
@event = event
end
def execute
if event && (integration.supported_events.exclude?(event) || data.blank?)
return error('Testing not available for this event')
end
integration.test(data)
rescue ArgumentError => e
error(e.message)
end
private
def data
raise NotImplementedError
end
end
end
end
|