debian-mirror-gitlab/app/services/integrations/test/base_service.rb

37 lines
918 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# 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)
2023-03-17 16:20:25 +05:30
rescue ArgumentError => e
error(e.message)
2020-06-23 00:09:42 +05:30
end
private
def data
raise NotImplementedError
end
end
end
end