rpwebdevelopment/laravel-blueshift

Blueshift integration package for laravel

v0.1.3 2022-04-13 13:25 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is a Laravel specific package designed to make communication with the Blueshift API quick and easy.

Requirements

Currently this package only functions on Laravel 8.*

Installation

You can install the package via composer:

composer require rpwebdevelopment/laravel-blueshift

Usage

Configuration

Before the library can function, it expects the blueshift configuration to be provided This package provides a base version of the configuration which you can install by running

php artisan vendor:publish --tag=blueshift-config

The Base configuration pulls values from the environment (env) to populate the configuration.

Class Structure

laravel-blueshift provides specific classes for handling different API endpoints, the available classes and their methods are as follows:

  • BlueshiftCustomer
    • search(string $email);
    • get(string $uuid);
    • createJson(string $customer);
    • createArray(array $customer);
    • bulkCreateJson(string $customers);
    • bulkCreateArray(array $customers);
    • manageCustomerSubscriptions(?string $email = null, ?string $uuid = null, bool $unsubscribedEmail = false, bool $unsubscribedPush = false, bool $unsubscribedSms = false);
    • unsubscribeCustomerFromEmail(?string $email = null, ?string $uuid = null);
    • unsubscribeCustomerFromSms(?string $email = null, ?string $uuid = null);
    • unsubscribeCustomerFromPush(?string $email = null, ?string $uuid = null);
    • unsubscribeCustomerFromAll(?string $email = null, ?string $uuid = null);
    • manageEmailListSubscriptions(array $emailList, ?bool $unsubscribedEmail = null, ?bool $unsubscribedPush = null, ?bool $unsubscribedSms = null);
    • startTracking(?string $email, ?string $uuid);
    • stopTracking(?string $email, ?string $uuid);
    • delete(?string $email, ?string $uuid, bool $allMatching)
  • BlueshiftCatalog
    • createCatalog(string $name);
    • getList();
    • addItems(string $uuid, array $items);
    • getCatalog(string $uuid);
  • BlueshiftUserList
    • createList(string $name, string $description, string $source = 'email');
    • addUserToList(int $listId, string $identifierKey, string $identifierValue);
    • removeUserFromList(int $listId, string $identifierKey, string $identifierValue);
  • BlueshiftEvent
    • sendEvent(array $event);

From your laravel application these methods can be called as follows:

try {
    $customer = app(BlueshiftCustomer::class)->search('email_address@example.org');
} catch (\Exception $e) {
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.