View Source Runbox.Scenario.Notification (runbox v17.1.0)

Module contains functions for working with scenario notifications.

Summary

Functions

Lists all channels with templates defined for scenario, notification type and template type.

Lists all template languages defined for scenario, notification type, template type and channel.

Lists all notification types for a scenario.

Lists all template types of the specified notification.

Lists all template files defined for a particular scenario.

Loads and evaluates templates specified by scenario, notification type, template type, channel and language.

Types

@type template() :: %{
  notification_type: String.t(),
  template_type: String.t(),
  channel: String.t(),
  language: String.t(),
  filename: String.t(),
  defined_in: :scenario | :deployment,
  absolute_path: Path.t()
}

Functions

Link to this function

list_channels(scenario_id, notification_type, template_type)

View Source
@spec list_channels(String.t(), String.t(), String.t()) :: {:ok, [String.t()]}

Lists all channels with templates defined for scenario, notification type and template type.

Link to this function

list_languages(scenario_id, notification_type, template_type, channel)

View Source
@spec list_languages(String.t(), String.t(), String.t(), String.t()) ::
  {:ok, [String.t()]}

Lists all template languages defined for scenario, notification type, template type and channel.

Link to this function

list_notification_types(scenario_id)

View Source
@spec list_notification_types(String.t()) :: {:ok, [String.t()]}

Lists all notification types for a scenario.

Link to this function

list_template_types(scenario_id, notification_type)

View Source
@spec list_template_types(String.t(), String.t()) :: {:ok, [String.t()]}

Lists all template types of the specified notification.

Link to this function

list_templates(scenario_id)

View Source
@spec list_templates(String.t()) :: [template()]

Lists all template files defined for a particular scenario.

It returns both templates from the scenario and overrides from the deployment. The source can be discriminated using the :defined_in key.

Link to this function

load_and_eval_templates(scenario, notification_type, template_type, channel, language, data, fallback_language)

View Source
@spec load_and_eval_templates(
  scenario_id :: String.t(),
  notification_type :: String.t(),
  template_type :: String.t(),
  channel :: String.t(),
  language :: String.t(),
  data :: keyword(),
  fallback_language :: String.t()
) :: {:ok, %{required(String.t()) => String.t()}} | {:error, atom(), String.t()}

Loads and evaluates templates specified by scenario, notification type, template type, channel and language.

If language is not defined or does not exist, fallback_language is used.