List, fetch, and manage outbound campaigns and their contacts.
client = Guava.Client.new!()
{:ok, counts} = Guava.Campaigns.status(client, "camp_abc")Campaigns are identified by their code. Every function here takes either a
code or a %Guava.Campaign{} from get_by_code/2 or list/1, so if you
already have one, pass it:
{:ok, campaign} = Guava.Campaigns.get_by_code(client, "camp_abc")
{:ok, counts} = Guava.Campaigns.status(client, campaign)A handful of endpoints are still keyed on the legacy campaign id rather than
the code. status/2, delete/2, and has_callable_contacts/2 therefore make
an extra lookup when given a bare code, and none when given a struct that
already carries the id. This goes away as those endpoints move to v2.
Summary
Types
A campaign, given either as its code or as a fetched struct.
Contact counts per status, e.g. %{"completed" => 12, "trying" => 3}.
Functions
Delete a campaign.
Fetch a campaign by its code.
Whether a campaign has contacts left to call.
List all campaigns.
Get a campaign's contact counts by status. See status_counts/0.
Upload contacts to a campaign, returning the number of contacts created.
Types
@type campaign() :: Guava.Campaign.t() | String.t()
A campaign, given either as its code or as a fetched struct.
@type result(x) :: {:ok, x} | {:error, Guava.Error.t()}
@type status_counts() :: %{required(String.t()) => non_neg_integer()}
Contact counts per status, e.g. %{"completed" => 12, "trying" => 3}.
Statuses are "trying", "failed", "completed", "partially_completed",
and "do_not_call". Only statuses with at least one contact are included.
Functions
@spec delete(Guava.Client.t(), campaign()) :: result(:ok)
Delete a campaign.
@spec delete!(Guava.Client.t(), campaign()) :: :ok
@spec get_by_code(Guava.Client.t(), String.t()) :: result(Guava.Campaign.t())
Fetch a campaign by its code.
@spec get_by_code!(Guava.Client.t(), String.t()) :: Guava.Campaign.t()
@spec has_callable_contacts(Guava.Client.t(), campaign()) :: result(boolean())
Whether a campaign has contacts left to call.
@spec has_callable_contacts!(Guava.Client.t(), campaign()) :: boolean()
@spec list(Guava.Client.t()) :: result([Guava.Campaign.t()])
List all campaigns.
@spec list!(Guava.Client.t()) :: [Guava.Campaign.t()]
@spec status(Guava.Client.t(), campaign()) :: result(status_counts())
Get a campaign's contact counts by status. See status_counts/0.
@spec status!(Guava.Client.t(), campaign()) :: status_counts()
@spec upload_contacts(Guava.Client.t(), campaign(), [Guava.Contact.t()], keyword()) :: result(non_neg_integer())
Upload contacts to a campaign, returning the number of contacts created.
Options
:allow_duplicates(defaultfalse):accepted_terms_of_service(defaultfalse):outreach_modalities— applied to contacts that don't set their own.
@spec upload_contacts!(Guava.Client.t(), campaign(), [Guava.Contact.t()], keyword()) :: non_neg_integer()