Overview

Namespaces

  • Antavo
    • RestClient
      • Exceptions
    • SignedToken
      • Exceptions
  • PHP

Classes

  • ApiClient
  • CustomerToken

Exceptions

  • ApiClientException
  • Overview
  • Namespace
  • Class

Class ApiClient

Antavo Loyalty API client class.

Antavo\RestClient\RestClient
Extended by Antavo\ApiClient
Namespace: Antavo
Located at ApiClient.php
Methods summary
public
# __construct( string $api_key, string $secret )

Constructs client object: sets API credentials.

Constructs client object: sets API credentials.

Parameters

$api_key
Antavo Loyalty API key.
$secret
API secret.
public mixed
# autoOptInCustomer( string $customer, array $data = array() )

Automatically opts customer in if consent cookie is present.

Automatically opts customer in if consent cookie is present.

Parameters

$customer
Unique customer ID.
$data

Custom data to store with the event. See event documentation for required an optional keys.

Returns

mixed
public mixed
# call( string $method, string $url, array|string $data = NULL, array $curl_options = array() )

Performs an API request.

Performs an API request.

It automatically appends api_key and calculated signature to request data.

Parameters

$method
HTTP method to use.
$url

URL to send request to. It is prefixed with the base_url unless it starts with a URL scheme.

$data

Data to send with request. It is sent as a request entity where allowed, or appended as a query string otherwise.

$curl_options

Additional cURL options for current request only.

Returns

mixed

Throws

Antavo\RestClient\Exceptions\Exception

If an error occurred during processing response.

Overrides

Antavo\RestClient\RestClient::call()
public mixed
# optInCustomer( string $customer, array $data = array() )

Posts an opt-in event to the Events API.

$client->optInCustomer('8eb1b522', array(
    // Providing an email address is mandatory.
    'email' => 'john.doe@example.com'
));

Posts an opt-in event to the Events API.

$client->optInCustomer('8eb1b522', array(
    // Providing an email address is mandatory.
    'email' => 'john.doe@example.com'
));

Parameters

$customer
Unique customer ID.
$data

Custom data to store with the event. See event documentation for required an optional keys.

Returns

mixed
public mixed
# optOutCustomer( string $customer, array $data = array() )

Posts an opt-out event to the Events API.

$client->optOutCustomer('8eb1b522', array(
    'reason' => 'Not interested'
));

Posts an opt-out event to the Events API.

$client->optOutCustomer('8eb1b522', array(
    'reason' => 'Not interested'
));

Parameters

$customer
Unique customer ID.
$data

Custom data to store with the event. See event documentation for required an optional keys.

Returns

mixed
public mixed
# postEvent( string $action, string $customer, array $data = array() )

Posts an event to the Antavo Loyalty Events API.

$customer = array(
    'id' => '8eb1b522',
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => 'john.doe@example.com'
);
$client = new Antavo\ApiClient('API_KEY', 'API_SECRET');
try {
    $result = $client->postEvent('opt_in', $customer['id'], array(
        'first_name' => $customer['first_name'],
        'last_name' => $customer['last_name'],
        'email' => $customer['email']
    ));
} catch (Antavo\RestClient\Exceptions\Exception $e) {
    echo $e->getMessage();
}

Posts an event to the Antavo Loyalty Events API.

$customer = array(
    'id' => '8eb1b522',
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => 'john.doe@example.com'
);
$client = new Antavo\ApiClient('API_KEY', 'API_SECRET');
try {
    $result = $client->postEvent('opt_in', $customer['id'], array(
        'first_name' => $customer['first_name'],
        'last_name' => $customer['last_name'],
        'email' => $customer['email']
    ));
} catch (Antavo\RestClient\Exceptions\Exception $e) {
    echo $e->getMessage();
}

Parameters

$action
Action name.
$customer
Unique customer ID.
$data
Custom data to store with the event.

Returns

mixed
Methods inherited from Antavo\RestClient\RestClient
getBaseUrl(), getLastError(), getLastResult(), getLastResultHeaders(), getLastResultInfo(), setBaseUrl(), setCurlOption(), setCurlOptions(), setError()
Magic methods inherited from Antavo\RestClient\RestClient
delete(), get(), post(), put()
API documentation generated by ApiGen