View Source Glific.Profiles (Glific v5.1.6)
The Profiles context.
Link to this section Summary
Functions
Creates a profile.
Deletes a profile.
Get a profile associated with a contact indexed and sorted in ascending order
Gets a single profile.
Handles flow action based on type of operation on Profile
Returns the list of profiles.
Switches active profile of a contact
Updates a profile.
Link to this section Functions
@spec create_profile(map()) :: {:ok, Glific.Profiles.Profile.t()} | {:error, Ecto.Changeset.t()}
Creates a profile.
examples
Examples
iex> create_profile(%{field: value})
{:ok, %Profile{}}
iex> create_profile(%{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec delete_profile(Glific.Profiles.Profile.t()) :: {:ok, Glific.Profiles.Profile.t()} | {:error, Ecto.Changeset.t()}
Deletes a profile.
examples
Examples
iex> delete_profile(profile)
{:ok, %Profile{}}
iex> delete_profile(profile)
{:error, %Ecto.Changeset{}}
@spec get_indexed_profile(Glific.Contacts.Contact.t()) :: [{any(), integer()}]
Get a profile associated with a contact indexed and sorted in ascending order
examples
Examples
iex> Glific.Profiles.get_indexed_profile(con)
[{%Profile{}, 1}, {%Profile{}, 2}]
@spec get_profile!(integer()) :: Glific.Profiles.Profile.t()
Gets a single profile.
Raises Ecto.NoResultsError
if the Profile does not exist.
examples
Examples
iex> get_profile!(123)
%Profile{}
iex> get_profile!(456)
** (Ecto.NoResultsError)
@spec handle_flow_action( atom() | nil, Glific.Flows.FlowContext.t(), Glific.Flows.Action.t() ) :: {Glific.Flows.FlowContext.t(), Glific.Messages.Message.t()}
Handles flow action based on type of operation on Profile
@spec list_profiles(map()) :: [Glific.Profiles.Profile.t()]
Returns the list of profiles.
examples
Examples
iex> list_profiles()
[%Profile{}, ...]
Get the list of profiles filtered by various search options
@spec switch_profile(Glific.Contacts.Contact.t(), String.t()) :: {:ok, Glific.Contacts.Contact.t()} | {:error, Glific.Contacts.Contact.t()}
Switches active profile of a contact
examples
Examples
iex> switch_profile(contact)
{:ok, %Profile{}}
@spec update_profile(Glific.Profiles.Profile.t(), map()) :: {:ok, Glific.Profiles.Profile.t()} | {:error, Ecto.Changeset.t()}
Updates a profile.
examples
Examples
iex> update_profile(profile, %{field: new_value})
{:ok, %Profile{}}
iex> update_profile(profile, %{field: bad_value})
{:error, %Ecto.Changeset{}}