class ListService extends BaseService (View source)

The list manager class used to handle lists.

Traits

Trait for adding a pager to a class.

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.

getApi()

Retrieve the KlaviyoApi service object.

array
getAllRecords($resource, $query_parameters = array())

Reteive all records for the specified paginated resource.

array
getRecordsFromSpecificPage($resource, $page, $count, $query_parameters = array())

Retrieve the records from a specific page.

array
getPage($resource, $page, $count = 50, $query_parameters = array())

Retrieve a specific page from Klaviyo.

getList(string $id)

Retrieve a specific list from Klaviyo.

array
getAllLists()

Retrieve all lists from Klaviyo.

array
getListsFromPage(int $page, int $count)

Get lists from a specific page.

createList(string $name, string $type = 'list')

Create a new list.

updateList(ListModel $list)

Update/Modify an existing list.

deleteList(ListModel $list)

Delete an existing list.

array
checkMembersAreInList(ListModel $list, array $emails)

Check if the specified members are in the list by email address.

checkMembersAreInSegment(ListModel $segment, $emails)

Check if the specified members are in the segment by email address.

PersonListModel
addPersonToList(ListModel $list, PersonModel $person, bool $confirm_opt_in = TRUE)

Add a person to an existing List.

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

in PagerTrait at line line 15
getApi()

Retrieve the KlaviyoApi service object.

in PagerTrait at line line 28
array getAllRecords($resource, $query_parameters = array())

Reteive all records for the specified paginated resource.

Parameters

$resource
$query_parameters

Return Value

array An array of all records retrieved from the API.

in PagerTrait at line line 50
array getRecordsFromSpecificPage($resource, $page, $count, $query_parameters = array())

Retrieve the records from a specific page.

Parameters

$resource
$page
$count
$query_parameters

Return Value

array An array of all records retrieved from the API for the specified page.

in PagerTrait at line line 66
array getPage($resource, $page, $count = 50, $query_parameters = array())

Retrieve a specific page from Klaviyo.

Parameters

$resource
$page
$count
$query_parameters

Return Value

array An array of information that represents a page.

at line line 25
ListModel getList(string $id)

Retrieve a specific list from Klaviyo.

Parameters

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

Return Value

ListModel The list object retrieved by the specified id.

at line line 36
array getAllLists()

Retrieve all lists from Klaviyo.

Return Value

array An array of ListModels that represent all lists in Klaviyo.

at line line 51
array getListsFromPage(int $page, int $count)

Get lists from a specific page.

Parameters

int $page The page number to retrieve.
int $count The number of items per page.

Return Value

array An array of records from the specified page.

at line line 66
ListModel createList(string $name, string $type = 'list')

Create a new list.

Parameters

string $name The name of the list to be created.
string $type The type of list to be created.

Return Value

ListModel The list object created.

at line line 81
ListModel updateList(ListModel $list)

Update/Modify an existing list.

Parameters

ListModel $list The altered list object to update on Klaviyo.

Return Value

ListModel The updated list object.

at line line 96
ListModel deleteList(ListModel $list)

Delete an existing list.

Parameters

ListModel $list The list object to be deleted.

Return Value

ListModel The deleted list object.

at line line 112
array checkMembersAreInList(ListModel $list, array $emails)

Check if the specified members are in the list by email address.

Parameters

ListModel $list The list for which to retrieve members.
array $emails The emails to check are associated with the specified list.

Return Value

array An array of MembershipModels associated with the specified list.

at line line 124
checkMembersAreInSegment(ListModel $segment, $emails)

Check if the specified members are in the segment by email address.

Parameters

ListModel $segment
$emails

See also

ListService::checkMembersAreInList()

at line line 144
PersonListModel addPersonToList(ListModel $list, PersonModel $person, bool $confirm_opt_in = TRUE)

Add a person to an existing List.

Parameters

ListModel $list The ListModel for which to add the person.
PersonModel $person The PersonModel of the person to add to a List.
bool $confirm_opt_in Default to TRUE. Determines if the person should be asked to confirm subscribing to list. When TRUE the person will recieve an email with a confirmation link before zhe is added to the list. Otherwise, when FALSE the person is automatically added to the list.

Return Value

PersonListModel The PersonList wrapper provided by the Klaviyo API.