Class: AlertManagement::Alerts::Todo::CreateService

Inherits:
Object
  • Object
show all
Defined in:
app/services/alert_management/alerts/todo/create_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(alert, current_user) ⇒ CreateService

Returns a new instance of CreateService.

Parameters:



9
10
11
12
# File 'app/services/alert_management/alerts/todo/create_service.rb', line 9

def initialize(alert, current_user)
  @alert = alert
  @current_user = current_user
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
# File 'app/services/alert_management/alerts/todo/create_service.rb', line 14

def execute
  return error_no_permissions unless allowed?

  todos = TodoService.new.mark_todo(alert, current_user)
  todo = todos&.first

  return error_existing_todo unless todo

  success(todo)
end