Glific v0.3.1 Glific.Partners View Source
The Partners context. This is the gateway for the application to access/update all the organization and Provider information.
Link to this section Summary
Functions
List of organizations that are active within the system
Returns an %Ecto.Changeset{}
for tracking organization changes.
Returns an %Ecto.Changeset{}
for tracking provider changes.
Return the count of organizations, using the same filter as list_organizations
Return the count of providers, using the same filter as list_providers
Creates a organization.
Creates a provider.
Deletes an Organization.
Deletes a provider.
Gets a single organization.
Gets a single provider.
Returns the list of organizations.
Returns the list of providers.
Cache the entire organization structure.
This contact id is special since it is the sender for all outbound messages and the receiver for all inbound messages
Temorary hack to get the organization id while we get tests to pass
Get the default language id
Return the days of week and the hours for each day for this organization. At some point we will unify the structures, so each day can have a different set of hours
Get the timezone
Execute a function across all active organizations. This function is typically called by a cron job worker process
Updates an organization.
Updates a provider.
Link to this section Functions
Specs
active_organizations() :: map()
List of organizations that are active within the system
Specs
change_organization(Glific.Partners.Organization.t(), map()) :: Ecto.Changeset.t()
Returns an %Ecto.Changeset{}
for tracking organization changes.
Examples
iex> Glific.Partners.change_organization(organization)
%Ecto.Changeset{data: %Glific.Partners.Organization{}}
Specs
change_provider( %Glific.Partners.Provider{ __meta__: term(), api_end_point: term(), id: term(), inserted_at: term(), name: term(), organizations: term(), updated_at: term(), url: term() }, map() ) :: Ecto.Changeset.t()
Returns an %Ecto.Changeset{}
for tracking provider changes.
Examples
iex> change_provider(provider)
%Ecto.Changeset{data: %Provider{}}
Specs
Return the count of organizations, using the same filter as list_organizations
Specs
Return the count of providers, using the same filter as list_providers
Specs
create_organization(map()) :: {:ok, Glific.Partners.Organization.t()} | {:error, Ecto.Changeset.t()}
Creates a organization.
Examples
iex> Glific.Partners.create_organization(%{name: value})
{:ok, %Glific.Partners.Organization{}}
iex> Glific.Partners.create_organization(%{bad_field: bad_value})
{:error, %Ecto.Changeset{}}
Specs
create_provider(map()) :: {:ok, %Glific.Partners.Provider{ __meta__: term(), api_end_point: term(), id: term(), inserted_at: term(), name: term(), organizations: term(), updated_at: term(), url: term() }} | {:error, Ecto.Changeset.t()}
Creates a provider.
Examples
iex> create_provider(%{field: value})
{:ok, %Provider{}}
iex> create_provider(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Specs
delete_organization(Glific.Partners.Organization.t()) :: {:ok, Glific.Partners.Organization.t()} | {:error, Ecto.Changeset.t()}
Deletes an Organization.
Examples
iex> Glific.Partners.delete_organization(organization)
{:ok, %Glific.Partners.Organization{}}
iex> delete_organization(organization)
{:error, %Ecto.Changeset{}}
Specs
delete_provider(%Glific.Partners.Provider{ __meta__: term(), api_end_point: term(), id: term(), inserted_at: term(), name: term(), organizations: term(), updated_at: term(), url: term() }) :: {:ok, %Glific.Partners.Provider{ __meta__: term(), api_end_point: term(), id: term(), inserted_at: term(), name: term(), organizations: term(), updated_at: term(), url: term() }} | {:error, Ecto.Changeset.t()}
Deletes a provider.
Examples
iex> delete_provider(provider)
{:ok, %Provider{}}
iex> delete_provider(provider)
{:error, %Ecto.Changeset{}}
Specs
get_organization!(integer()) :: Glific.Partners.Organization.t()
Gets a single organization.
Raises Ecto.NoResultsError
if the organization does not exist.
Examples
iex> Glific.Partners.get_organization!(1)
%Glific.Partners.Organization{}
iex> Glific.Partners.get_organization!(-1)
** (Ecto.NoResultsError)
Specs
get_provider!(id :: integer()) :: %Glific.Partners.Provider{ __meta__: term(), api_end_point: term(), id: term(), inserted_at: term(), name: term(), organizations: term(), updated_at: term(), url: term() }
Gets a single provider.
Raises Ecto.NoResultsError
if the Provider does not exist.
Examples
iex> get_provider!(123)
%Provider{}
iex> get_provider!(456)
** (Ecto.NoResultsError)
Specs
list_organizations(map()) :: [Glific.Partners.Organization.t()]
Returns the list of organizations.
Examples
iex> Glific.Partners.list_organizations()
[%Glific.Partners.Organization{}, ...]
Specs
list_providers(map()) :: [ %Glific.Partners.Provider{ __meta__: term(), api_end_point: term(), id: term(), inserted_at: term(), name: term(), organizations: term(), updated_at: term(), url: term() }, ... ]
Returns the list of providers.
Examples
iex> list_providers()
[%Provider{}, ...]
Specs
organization(non_neg_integer()) :: Glific.Partners.Organization.t()
Cache the entire organization structure.
In v0.4, we should cache it based on organization id, and that should be a parameter
Specs
organization_contact_id(non_neg_integer()) :: integer()
This contact id is special since it is the sender for all outbound messages and the receiver for all inbound messages
Specs
organization_id(non_neg_integer()) :: integer()
Temorary hack to get the organization id while we get tests to pass
Specs
organization_language_id(non_neg_integer()) :: integer()
Get the default language id
Specs
organization_out_of_office_summary(non_neg_integer()) :: {[Time.t()], [integer()]}
Return the days of week and the hours for each day for this organization. At some point we will unify the structures, so each day can have a different set of hours
Specs
organization_timezone(non_neg_integer()) :: String.t()
Get the timezone
Specs
perform_all((non_neg_integer(), map() -> nil), map()) :: :ok
Execute a function across all active organizations. This function is typically called by a cron job worker process
The handler is expected to take the organization id as its first argument. The second argument is expected to be a map of arguments passed in by the cron job, and can be ignored if not used
Specs
update_organization(Glific.Partners.Organization.t(), map()) :: {:ok, Glific.Partners.Organization.t()} | {:error, Ecto.Changeset.t()}
Updates an organization.
Examples
iex> Glific.Partners.update_organization(Organization, %{name: new_name})
{:ok, %Glific.Partners.Organization{}}
iex> Glific.Partners.update_organization(Organization, %{abc: bad_value})
{:error, %Ecto.Changeset{}}
Specs
update_provider( %Glific.Partners.Provider{ __meta__: term(), api_end_point: term(), id: term(), inserted_at: term(), name: term(), organizations: term(), updated_at: term(), url: term() }, map() ) :: {:ok, %Glific.Partners.Provider{ __meta__: term(), api_end_point: term(), id: term(), inserted_at: term(), name: term(), organizations: term(), updated_at: term(), url: term() }} | {:error, Ecto.Changeset.t()}
Updates a provider.
Examples
iex> update_provider(provider, %{field: new_value})
{:ok, %Provider{}}
iex> update_provider(provider, %{field: bad_value})
{:error, %Ecto.Changeset{}}