defmodule MessengerBot.Payload.MessageRequest do @moduledoc """ Request struct """ @derive [Poison.Encoder] defstruct [:recipient, :message, :sender_action, :notification_type, :tag] @type t :: %__MODULE__{ recipient: Map.t, message: Map.t, sender_action: String.t, notification_type: String.t, tag: String.t } @doc """ Build struct for message """ def message(%{} = recipient, %{} = message, notification_type \\ nil) do %__MODULE__{recipient: recipient, message: message, notification_type: notification_type} end @doc """ Build struct for typing on """ def typing_on(%{} = recipient) do %__MODULE__{recipient: recipient, sender_action: "typing_on"} end @doc """ Build struct for typing off """ def typing_off(%{} = recipient) do %__MODULE__{recipient: recipient, sender_action: "typing_off"} end @doc """ Build struct for mark seen """ def mark_seen(%{} = recipient) do %__MODULE__{recipient: recipient, sender_action: "mark_seen"} end end