Class: JiraConnectInstallations::ProxyLifecycleEventService
- Inherits:
-
Object
- Object
- JiraConnectInstallations::ProxyLifecycleEventService
- Defined in:
- app/services/jira_connect_installations/proxy_lifecycle_event_service.rb
Constant Summary collapse
- SUPPOERTED_EVENTS =
%i[installed uninstalled].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(installation, event, instance_url) ⇒ ProxyLifecycleEventService
constructor
A new instance of ProxyLifecycleEventService.
Constructor Details
#initialize(installation, event, instance_url) ⇒ ProxyLifecycleEventService
Returns a new instance of ProxyLifecycleEventService.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/jira_connect_installations/proxy_lifecycle_event_service.rb', line 11 def initialize(installation, event, instance_url) # To ensure the event is sent to the right instance, this makes # a copy of the installation and assigns the instance_url # # The installation might be modified already with a new instance_url. # This can be the case for an uninstalled event. # The installation is updated first, and the uninstalled event has to be sent to # the old instance_url. @installation = installation.dup @installation.instance_url = instance_url @event = event.to_sym raise(ArgumentError, "Unknown event '#{@event}'") unless SUPPOERTED_EVENTS.include?(@event) end |
Class Method Details
.execute(installation, event, instance_url) ⇒ Object
7 8 9 |
# File 'app/services/jira_connect_installations/proxy_lifecycle_event_service.rb', line 7 def self.execute(installation, event, instance_url) new(installation, event, instance_url).execute end |
Instance Method Details
#execute ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/jira_connect_installations/proxy_lifecycle_event_service.rb', line 27 def execute result = send_hook return ServiceResponse.new(status: :success) if result.code == 200 log_unsuccessful_response(result.code, result.body) ServiceResponse.error(message: { type: :response_error, code: result.code }) rescue *Gitlab::HTTP::HTTP_ERRORS => error ServiceResponse.error(message: { type: :network_error, message: error. }) end |