notification_message_controller.ex 530 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
defmodule NotificationDispatcher.Controller.NotificationMessageController do
  alias NotificationDispatcher.Context.NotificationsContext

  @doc """
    Create can return {:ok, notification_message} or {:error, changeset}
  """
  def create(conn, params) do
    case NotificationsContext.create_notification_message(params) do
      {:ok, notification_message} ->
        {:ok, notification_message, "{\"data\": {\"id\": \"#{notification_message.id}\"}}"}
      {:error, changeset} ->
        {:error, changeset}
    end
  end
end