class CampaignService extends BaseService (View source)

The campaign manager class used to handle campaigns.

Methods

__construct(KlaviyoApi $api)

The constructor for the list manager class.

static 
create(KlaviyoApi $api)

Instantiates a new instance of this class.

string
getResourcePath($resource)

Retrieve the full resource path.

CampaignModel
getCampaign(string $id)

Retrieve a specific campaign from Klaviyo.

CampaignModel
createCampaign(array $configuration)

Create a new campaign.

array
sendCampaignImmediately(string $id)

Send a campaign immediately.

array
scheduleCampaign(string $id, DateTime $send_time)

Schedule a campaign for a time in the future.

Details

in BaseService at line line 28
__construct(KlaviyoApi $api)

The constructor for the list manager class.

Parameters

KlaviyoApi $api The Klaviyo API object to use for communicating with the Klaviyo API.

in BaseService at line line 35
static create(KlaviyoApi $api)

Instantiates a new instance of this class.

Parameters

KlaviyoApi $api

in BaseService at line line 46
string getResourcePath($resource)

Retrieve the full resource path.

Parameters

$resource

Return Value

string The full resource path incuding the resource prefix and resource path. Example: /api/v1/lists

at line line 21
CampaignModel getCampaign(string $id)

Retrieve a specific campaign from Klaviyo.

Parameters

string $id The id for which to retrieve a campaign.

Return Value

CampaignModel The campaign object retrieved by the specified id.

at line line 58
CampaignModel createCampaign(array $configuration)

Create a new campaign.

Parameters

array $configuration An array of configuration parameters for the new campaign.

Allowed elements: * listid: string The ID of the List object you will send this campaign to. * templateid: string The ID of the Email Template object that will be the content of this campaign. Note the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign. * fromemail: string The email address your email will be sent from and will be used in the reply-to header.fromnamestringThe name or label associated with the email address you're sending from. * subject: string * name (optional): string A name for this campaign. If not specified, this will default to the subject of the campaign. * usesmartsending (optional): boolean If set, limits the number of emails sent to an individual within a short period. If not specified, defaults to True. * addgoogleanalytics (optional): boolean If specified, adds Google Analytics tracking tags to links. If not specified, defaults to False.

Return Value

CampaignModel The newly created campaign object.

at line line 72
array sendCampaignImmediately(string $id)

Send a campaign immediately.

Parameters

string $id The id of the campaign to send immediately.

Return Value

array The response from the api.

at line line 88
array scheduleCampaign(string $id, DateTime $send_time)

Schedule a campaign for a time in the future.

Parameters

string $id The id of the campaign to send immediately.
DateTime $send_time A future date and time to send the campaign.

Return Value

array The response from the api.