View Source Glific.Templates.InteractiveTemplates (Glific v5.1.6)
The InteractiveTemplate Context, which encapsulates and manages interactive templates
Link to this section Summary
Functions
Cleaning interactive template title as per WhatsApp policy
Make a copy of a interactive_template
Return the count of interactive templates, using the same filter as list_interactives
Creates an interactive template
Deletes an interactive template
Fetches a single interactive template
A single function to fetch all the interactive templates related info
Returns interactive content based on send_interactive_title field
get interactive body from the interactive content
Gets a single interactive template
Create a message media from interactive content and return id
Fetch for translation of interactive message
Returns the list of interactive templates
Process dynamic interactive messages.
Get translated interactive template content
Updates an interactive template
Link to this section Functions
Cleaning interactive template title as per WhatsApp policy
@spec copy_interactive_template(Glific.Templates.InteractiveTemplate.t(), map()) :: {:ok, Glific.Templates.InteractiveTemplate.t()} | {:error, String.t()}
Make a copy of a interactive_template
Return the count of interactive templates, using the same filter as list_interactives
@spec create_interactive_template(map()) :: {:ok, Glific.Templates.InteractiveTemplate.t()} | {:error, Ecto.Changeset.t()}
Creates an interactive template
examples
Examples
iex> create_interactive_template(%{field: value})
{:ok, %InteractiveTemplate{}}
iex> create_interactive_template(%{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec delete_interactive_template(Glific.Templates.InteractiveTemplate.t()) :: {:ok, Glific.Templates.InteractiveTemplate.t()} | {:error, Ecto.Changeset.t()}
Deletes an interactive template
examples
Examples
iex> delete_interactive_template(interactive)
{:ok, %InteractiveTemplate{}}
iex> delete_interactive_template(interactive)
{:error, %Ecto.Changeset{}}
Fetches a single interactive template
Returns Resource not found
if the Interactive Template does not exist.
examples
Examples
iex> fetch_interactive_template(123, 1)
{:ok, %InteractiveTemplate{}}
iex> fetch_interactive_template(456, 1)
{:error, ["Elixir.Glific.Templates.InteractiveTemplate", "Resource not found"]}
@spec formatted_data(Glific.Templates.InteractiveTemplate.t(), non_neg_integer()) :: {map(), binary(), nil | non_neg_integer()}
A single function to fetch all the interactive templates related info
Returns interactive content based on send_interactive_title field
get interactive body from the interactive content
@spec get_interactive_template!(integer()) :: Glific.Templates.InteractiveTemplate.t()
Gets a single interactive template
Raises Ecto.NoResultsError
if the Interactive Template does not exist.
examples
Examples
iex> get_interactive_template!(123)
%InteractiveTemplate{}
iex> get_interactive_template!(456)
** (Ecto.NoResultsError)
@spec get_media(map(), non_neg_integer()) :: non_neg_integer() | nil
Create a message media from interactive content and return id
@spec get_translations(Glific.Templates.InteractiveTemplate.t(), non_neg_integer()) :: map()
Fetch for translation of interactive message
@spec list_interactives(map()) :: [Glific.Templates.InteractiveTemplate.t()]
Returns the list of interactive templates
examples
Examples
iex> list_interactives()
[%InteractiveTemplate{}, ...]
process_dynamic_interactive_content(interactive_content, params, attachment)
View SourceProcess dynamic interactive messages.
@spec translated_content(Glific.Templates.InteractiveTemplate.t(), non_neg_integer()) :: map() | nil
Get translated interactive template content
@spec update_interactive_template(Glific.Templates.InteractiveTemplate.t(), map()) :: {:ok, Glific.Templates.InteractiveTemplate.t()} | {:error, Ecto.Changeset.t()}
Updates an interactive template
examples
Examples
iex> update_interactive_template(interactive, %{field: new_value})
{:ok, %InteractiveTemplate{}}
iex> update_interactive_template(interactive, %{field: bad_value})
{:error, %Ecto.Changeset{}}