Giter Club home page Giter Club logo

cleverreach's Introduction

CleverReach REST API v3 client

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

Installation

composer require rdoepner/cleverreach

Usage

Get an access token

use rdoepner\CleverReach\ApiManager;
use rdoepner\CleverReach\Http\Guzzle as HttpAdapter;

// Create an HTTP adapter
$httpAdapter = new HttpAdapter();

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

if (isset($response['access_token'])) {
    // Persist the access token for later use...
}

Initialize an API manager

use rdoepner\CleverReach\ApiManager;
use rdoepner\CleverReach\Http\Guzzle as HttpAdapter;

// Create an HTTP adapter
$httpAdapter = new HttpAdapter(
    [
        'access_token' => '<ACCESS_TOKEN>',
    ]
);

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

Create an inactive subscriber

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

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

Update a subscriber

$response = $apiManager->updateSubscriber(
    '<EMAIL>',
    '<GROUP_ID>',
    [
        'salutation' => 'Mr.',
        'firstname' => 'John',
        'lastname' => 'Doe',
    ],
    [], // global attributes
    'Source',
    ['tagX'] // tags
);

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

Trigger the Double-Opt-In email for an inactive subscriber

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

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

Trigger the 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'])) {
    // ...
}

Sets the active status of a subscriber

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

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

Delete a subscriber

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

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

Get attributes

$response = $apiManager->getAttributes('<GROUP_ID>');

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

Update the attributes of a subscriber

$response = $apiManager->updateSubscriberAttributes('<POOL_ID>', '<ATTRIBUTE_ID>', '<VALUE>');

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

Replace the tags of a subscriber

$response = $apiManager->replaceSubscriberTags('<EMAIL>', '<GROUP_ID>', ['<TAG1>', '<TAG2>', ...]);

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

Get the groups a subscriber is in

$response = $apiManager->getSubscriberGroups('<EMAIL>');

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

cleverreach's People

Contributors

cruiser13 avatar fabianmu avatar grandeljay avatar infinitystacks avatar mmoollllee avatar rdoepner avatar sschlein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cleverreach's Issues

Update composer requirements and release a new version

Could you release a new version with the composer requirements updated by @sschlein ?

To widen up the use cases you could also set the requirements to
"guzzlehttp/guzzle": "^6.3|^7.0",
as this seems to be the only recent change and no changes have been made to the usage of guzzle.

Thanks,
Robert

Feature Request: Implement Refresh token mechanism

In your code you retrieve the token using the client_credentials grant. You also suggest to store that token for later use, which is very good.
In case that stored token once dies, there is a refresh token you can use to get a new token easily. That is OAuth2 standard. Maybe you could implement something to help people accomplish that? Of course it depends on how the token was stored...

I could think of many people not storing the token and creating a new on each API call...
Also: you would never have to care about the token anymore, as that refresh process can run automated.

For any help on that topic, see the official cleverreach documentation

Too strict requirement for Psr/Log

The commit 5cd32d4 increased the requirement for psr/log from ^1.0 to ^1.1.

This prevents the installation of this package in combination with other packages which have psr/log at ~1.0 (like symfony/cache).

I don't think you need ^1.1, as there were no relevant changes (except test cases):
php-fig/log@1.0.2...1.1.2

^1.0 should work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.