enhavo/cleverreach

CleverReach REST API v3 client

v0.9.18 2021-05-03 05:36 UTC

This package is auto-updated.

Last update: 2021-12-31 00:23:31 UTC


README

alt text

CleverReach REST API v3 client

This library makes it easy to interact with the CleverReach REST API v3.

Installation

composer require enhavo/cleverreach

Usage

Initialize an API manager

use Enhavo\Component\CleverReach\ApiManager;
use Enhavo\Component\CleverReach\Http\GuzzleAdapter;

$adapter = new GuzzleAdapter();

// Authorize your app by credentials
$adapter->authorize('<CLIENT_ID>', '<CLIENT_SECRET>');

// Create the API manager
$apiManager = new ApiManager($adapter);

Create an inactive subscriber

$response = $apiManager->createSubscriber(
    '<EMAIL>',
    '<GROUP_ID>',
    false, // not activated
    [
        'salutation' => 'Mr.',
        'firstname' => 'John',
        'lastname' => 'Doe',
    ]
);

if (isset($response['id'])) {
    // ...
}

Trigger Double-Opt-In email for an inactive subscriber

$response = $apiManager->triggerDoubleOptInEmail('<EMAIL>', '<FORM_ID>');

if (isset($response['success'])) {
    // ...
}

Trigger Double-Opt-Out email for an active subscriber

$response = $apiManager->triggerDoubleOptOutEmail('<EMAIL>', '<FORM_ID>');

if (isset($response['success'])) {
    // ...
}

Get subscriber

$response = $apiManager->getSubscriber('<EMAIL>', '<GROUP_ID>');

if (isset($response['id'])) {
    // ...
}

Set active status of a subscriber

$response = $apiManager->getSubscriber('<EMAIL>', '<GROUP_ID>', '<TRUE_OR_FALSE>');

if (true === $response) {
    // ...
}

Delete subscriber

$response = $apiManager->deleteSubscriber('<EMAIL>', '<GROUP_ID>');

if (true === $response) {
    // ...
}