class KlaviyoApi (View source)

The main Klaviyo API class for communicating with the Klaviyo API.

Properties

static $endPoint
static $dataMap

Methods

__construct(ClientInterface $http_client, $api_key = '', $options = array())

The constructor for KlaviyoApi.

static string
getModelType(string $model_type, bool $reverse = FALSE)

Retrieve the model type based on the percieved model type.

static KlaviyoApi
create($api_key = '', $options = array())

Helper method for creating a new API object.

mixed
getOption(string $option)

Retrieve a specific option.

$this
setOption(string $option, mixed $value)

Set a specific option.

getAllOptions()

Retrieve an an array of all available options.

ResponseInterface
request($method, $resource, $options = array(), $public = FALSE)

Perform a request against the API.

array
prepareRequestOptions($method, $options, $public = FALSE)

Prepare the options array before use in the request.

Details

at line line 40
__construct(ClientInterface $http_client, $api_key = '', $options = array())

The constructor for KlaviyoApi.

Parameters

ClientInterface $http_client
$api_key
$options

Exceptions

ApiException

at line line 71
static string getModelType(string $model_type, bool $reverse = FALSE)

Retrieve the model type based on the percieved model type.

Sometimes Klaviyo changinges the model type by placing "$" in front of them also I am not sure if there are other mutations that might happen on this or if they might change. In order to attempt to prevent this we will use a getter for the Klaviyo model type.

Parameters

string $model_type The percieved model type.
bool $reverse Should we try looking of the model type in the reverse direction? e.x. The way Klaviyo might hand us a transformed model type.

Return Value

string The model type or the percieved model type depending on the specified direction.

at line line 94
static KlaviyoApi create($api_key = '', $options = array())

Helper method for creating a new API object.

Parameters

$api_key
$options

Return Value

KlaviyoApi An instance of the KlaviyoApi.

at line line 109
mixed getOption(string $option)

Retrieve a specific option.

Parameters

string $option The option name to retrieve.

Return Value

mixed The value of the option requested.

at line line 129
$this setOption(string $option, mixed $value)

Set a specific option.

Parameters

string $option The option name to set.
mixed $value The value of the option to set.

Return Value

$this

at line line 138
getAllOptions()

Retrieve an an array of all available options.

at line line 155
ResponseInterface request($method, $resource, $options = array(), $public = FALSE)

Perform a request against the API.

Parameters

$method
$resource
$options
$public

Return Value

ResponseInterface The response of the request as provided by the HTTP client.

at line line 192
array prepareRequestOptions($method, $options, $public = FALSE)

Prepare the options array before use in the request.

Parameters

$method
$options
$public

Return Value

array The prepared additional options to pass on to the HTTP client.