-
Notifications
You must be signed in to change notification settings - Fork 0
Campaign
Through the campaign endpoint you can find and list the campaigns, achieve the API Goals and add or remove contacts from a specific sequence in a campaign. The campaign model has the following attributes:
[
"created_by_global_id" => int
"date_created" => datetime
"error_message" => string
"goals" => array
"id" => int
"locked" => bool
"name" => string
"published_date" => datetime
"published_status" => bool
"sequences" => array
"timezone" => string
]
The method list
retrieves a list of all the campaigns.
use KeapGeek\Keap\Facades\Keap;
Keap::campaign()->list([
'limit' => ?int,
'offset' => ?int,
'order' => ?string,
'order_direction' => ?string, //ASCENDING or DESCENDING
'search_text' => ?string,
]);
This method accepts different optional parameters, to query on:
-
limit
is the amount of campaigns to return, it defaults to 1000. -
offset
is the first item that starts the set, it defaults to 0. -
order
is the attribute to order campaigns by. It can be id, name, published_date, completed_contact_count, active_contact_count, date_created, last_updated. -
order_direction
can be either ASCENDING or DESCENDING -
search_text
is optional text to search.
It returns an array with all the retrieved Campaign Models.
The method count
returns the count of items in the query.
use KeapGeek\Keap\Facades\Keap;
Keap::campaign()->count([
'search_text' => ?string,
]);
As for the list, this method accepts an optional parameter search_text
to query campaign on.
The find
method allows to retrieve the campaign model from the id of the campaign.
use KeapGeek\Keap\Facades\Keap;
Keap::campaign()->find($campaign_id, ['sequences', 'goals']);
This method returns the campaign model or null if not found.
The second argument as array is optional. These are additional properties to be returned with the model.
The method achieve
achieves the goal as completed for a given contact id and call name.
use KeapGeek\Keap\Facades\Keap;
Keap::campaign()->achieve(
int $contact_id,
string $call_name,
?string $integration
);
An API goal can be achieved through this method. The arguments are:
-
contact_id
the id of the contact, -
call_name
the name of the call, it gets decided on the campaign builder, -
integration
is the name of the integration, it is optional.
If no integration is specified the default integration stated in the config file keap.php
will be used. Read more about the config file here.
This method returns true if the call was successfull.
The method addToSequence
adds one or more contacts to a sequence of a specific campaign.
use KeapGeek\Keap\Facades\Keap;
Keap::campaign()->addToSequence(
int $campaign_id,
int $sequence_id
array | int $contact_id,
);
You can add one contact (int) or an array of contact ids, you can add them to the sequence of a campaign, by their respective ids. It will return an array with each ids as follows:
[
$id_1 => 'SUCCESS',
$id_2 => 'SUCCESS',
]
The method removeFromSequence
removes one or more contacts to a sequence of a specific campaign.
use KeapGeek\Keap\Facades\Keap;
Keap::campaign()->removeFromSequence(
int $campaign_id,
int $sequence_id
array | int $contact_id,
);
You can remove one contact (as int) or an array of contact ids. Through this endpoint you can remove them from the sequence of a specific campaign.
This methods just returns true if the request succeeded.