View Source Glific.Triggers (Glific v5.1.6)

The trigger manager for all the trigger system that starts flows within Glific

Link to this section Summary

Functions

Return the count of triggers, using the same filter as list_triggers

Creates a trigger.

Periodic call to execute the triggers outstanding for the day

Gets a single trigger.

Returns the list of triggers filtered by args

Updates a trigger.

Link to this section Functions

@spec count_triggers(map()) :: integer()

Return the count of triggers, using the same filter as list_triggers

@spec create_trigger(map()) ::
  {:ok, Glific.Triggers.Trigger.t()} | {:error, Ecto.Changeset.t()}

Creates a trigger.

examples

Examples

iex> create_trigger(%{field: value})
{:ok, %Trigger{}}

iex> create_trigger(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

execute_triggers(organization_id, now \\ DateTime.utc_now())

View Source
@spec execute_triggers(non_neg_integer(), DateTime.t()) :: [
  Glific.Triggers.Trigger.t()
]

Periodic call to execute the triggers outstanding for the day

@spec get_trigger!(integer()) :: Glific.Triggers.Trigger.t()

Gets a single trigger.

Raises Ecto.NoResultsError if the Trigger does not exist.

examples

Examples

iex> get_trigger!(123)
%Trigger{}

iex> get_trigger!(456)
** (Ecto.NoResultsError)
@spec list_triggers(map()) :: [Glific.Triggers.Trigger.t()]

Returns the list of triggers filtered by args

examples

Examples

iex> list_triggers()
[%Trigger{}, ...]
Link to this function

update_trigger(trigger, attrs)

View Source
@spec update_trigger(Glific.Triggers.Trigger.t(), map()) ::
  {:ok, Glific.Triggers.Trigger.t()} | {:error, Ecto.Changeset.t()}

Updates a trigger.

examples

Examples

iex> update_trigger(trigger, %{field: new_value})
{:ok, %Trigger{}}

iex> update_trigger(trigger, %{field: bad_value})
{:error, %Ecto.Changeset{}}