enhavo/cleverreach

CleverReach REST API v3 client

v0.14.3 2024-06-11 07:28 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\SymfonyAdapter;

$adapter = new SymfonyAdapter();

// 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) {
    // ...
}