Class: CommandTower::Admin::Messaging::AnnouncementsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/command_tower/admin/messaging/announcements_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/command_tower/admin/messaging/announcements_controller.rb', line 7

def create
  deserialized = CommandTower::Deserializers::Admin::Messaging::CreateAnnouncementDeserializer.call(params)
  unless deserialized.success?
    return render_application_result(
      CommandTower::Workflows::WorkflowResult.failure(
        errors: [CommandTower::Errors::ValidationError.new(details: { base: "Invalid request parameters" })],
        http_status: :unprocessable_entity
      )
    )
  end

  render_application_result(
    CommandTower::Workflows::Admin::Messaging::CreateAnnouncementWorkflow.call(
      input: deserialized.input
    )
  )
end