Guava.Campaigns (Guava v0.36.0)

Copy Markdown View Source

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}.

Types

campaign()

@type campaign() :: Guava.Campaign.t() | String.t()

A campaign, given either as its code or as a fetched struct.

result(x)

@type result(x) :: {:ok, x} | {:error, Guava.Error.t()}

status_counts()

@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

delete(client, campaign)

@spec delete(Guava.Client.t(), campaign()) :: result(:ok)

Delete a campaign.

delete!(client, campaign)

@spec delete!(Guava.Client.t(), campaign()) :: :ok

get_by_code(client, campaign_code)

@spec get_by_code(Guava.Client.t(), String.t()) :: result(Guava.Campaign.t())

Fetch a campaign by its code.

get_by_code!(client, campaign_code)

@spec get_by_code!(Guava.Client.t(), String.t()) :: Guava.Campaign.t()

has_callable_contacts(client, campaign)

@spec has_callable_contacts(Guava.Client.t(), campaign()) :: result(boolean())

Whether a campaign has contacts left to call.

has_callable_contacts!(client, campaign)

@spec has_callable_contacts!(Guava.Client.t(), campaign()) :: boolean()

list(client)

@spec list(Guava.Client.t()) :: result([Guava.Campaign.t()])

List all campaigns.

list!(client)

@spec list!(Guava.Client.t()) :: [Guava.Campaign.t()]

status(client, campaign)

@spec status(Guava.Client.t(), campaign()) :: result(status_counts())

Get a campaign's contact counts by status. See status_counts/0.

status!(client, campaign)

@spec status!(Guava.Client.t(), campaign()) :: status_counts()

upload_contacts(client, campaign, contacts, opts \\ [])

@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 (default false)
  • :accepted_terms_of_service (default false)
  • :outreach_modalities — applied to contacts that don't set their own.

upload_contacts!(client, campaign, contacts, opts \\ [])

@spec upload_contacts!(Guava.Client.t(), campaign(), [Guava.Contact.t()], keyword()) ::
  non_neg_integer()