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

Get translated interactive template content

Updates an interactive template

Link to this section Functions

Link to this function

clean_template_title(interactive_content)

View Source
@spec clean_template_title(map() | nil) :: map() | nil

Cleaning interactive template title as per WhatsApp policy

Link to this function

copy_interactive_template(interactive_template, attrs)

View Source
@spec copy_interactive_template(Glific.Templates.InteractiveTemplate.t(), map()) ::
  {:ok, Glific.Templates.InteractiveTemplate.t()} | {:error, String.t()}

Make a copy of a interactive_template

Link to this function

count_interactive_templates(args)

View Source
@spec count_interactive_templates(map()) :: integer()

Return the count of interactive templates, using the same filter as list_interactives

Link to this function

create_interactive_template(attrs)

View Source
@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{}}
Link to this function

delete_interactive_template(interactive)

View Source
@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{}}
Link to this function

fetch_interactive_template(id)

View Source
@spec fetch_interactive_template(integer()) :: {:ok, any()} | {:error, any()}

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"]}
Link to this function

formatted_data(interactive_template, language_id)

View Source
@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

Link to this function

get_clean_interactive_content(interactive_content, arg2, arg3)

View Source
@spec get_clean_interactive_content(map(), boolean(), atom()) :: map()

Returns interactive content based on send_interactive_title field

Link to this function

get_interactive_body(interactive_content)

View Source
@spec get_interactive_body(map()) :: String.t()

get interactive body from the interactive content

Link to this function

get_interactive_template!(id)

View Source
@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)
Link to this function

get_media(interactive_content, organization_id)

View Source
@spec get_media(map(), non_neg_integer()) :: non_neg_integer() | nil

Create a message media from interactive content and return id

Link to this function

get_translations(interactive_template, language_id)

View Source
@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{}, ...]
Link to this function

process_dynamic_interactive_content(interactive_content, params, attachment)

View Source
@spec process_dynamic_interactive_content(map(), list(), map()) :: map()

Process dynamic interactive messages.

Link to this function

translated_content(interactive_template, language_id)

View Source
@spec translated_content(Glific.Templates.InteractiveTemplate.t(), non_neg_integer()) ::
  map() | nil

Get translated interactive template content

Link to this function

update_interactive_template(interactive, attrs)

View Source
@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{}}