Class: AlertManagement::HttpIntegrations::UpdateService

Inherits:
Object
  • Object
show all
Defined in:
app/services/alert_management/http_integrations/update_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(integration, current_user, params) ⇒ UpdateService

Returns a new instance of UpdateService.

Parameters:


9
10
11
12
13
# File 'app/services/alert_management/http_integrations/update_service.rb', line 9

def initialize(integration, current_user, params)
  @integration = integration
  @current_user = current_user
  @params = params.with_indifferent_access
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/alert_management/http_integrations/update_service.rb', line 15

def execute
  return error_no_permissions unless allowed?

  params[:token] = nil if params.delete(:regenerate_token)

  if integration.update(permitted_params)
    success
  else
    error(integration.errors.full_messages.to_sentence)
  end
end