glorand/drip-php

A PHP wrapper for Drip's REST API v2.0

Maintainers

Details

github.com/glorand/drip

Source

Issues

Installs: 120

Dependents: 1

Suggesters: 0

Security: 0

Stars: 2

Watchers: 3

Forks: 1

Open Issues: 2

Type:package

1.0.4 2018-12-20 14:03 UTC

This package is auto-updated.

Last update: 2024-04-18 01:14:28 UTC


README

49755957-17ec0980-fcc2-11e8-9e04-0339714f979b.png

A PHP wrapper for Drip's REST API

Latest Stable Version Build Status Software License CodeFactor StyleCI Scrutinizer Code Quality Code Coverage

Drip PHP

A PHP wrapper for Drip's REST API v2.0 for PHP 7.1+

Author: Gombos Lorand

Table of contents

Installation

$ composer require glorand/drip-php
{
    "require": {
        "glorand/drip-php": "^1.0"
    }
}

Current Features

Instantiation

use Glorand\Drip\Drip;

$drip = new Drip('your-account-id', 'your-api-token', 'user-agent-optional');

ApiResponse

Methods

//http status code
public function getStatusCode(): int {}

public function isSuccess(): bool {}

public function getHttpMessage(): string {}

//drip response
public function getContents(): array {}

Accounts

List all accounts

$accounts = $drip->accounts()->list();

if($accounts->isSuccess()) {
    foreach($accounts->getContents() as $acount) {
        //
    }
}

Fetch an account

$account = $drip->accounts()->show('acount-id');

if($account->isSuccess()) {
    // $account->getContents()
}

Events

Event Model

$event = new Event();
$event->setEmail('test@email.com')
    ->setAction('Action')
    ->setOccurredAt(new \DateTime('2018-12-01'))
    ->setProperties(['prop_0' => 'val_prop_0'])
    ->addProperty('prop_1', 'val_prop_1')
    ->removeProperty('prop_1');

Record an event

/** Event Model */
$event = new Event();

/** boolean */
$drip->events()->store($event);

List all custom events actions used in an account

/** ApiResponse */
$events = $drip->events()->list();

Subscribers

Subscriber Model

$subscriber = new Subscriber();
$subscriber->setEmail('test@email.com')
    ->setNewEmail('new@email.com')
    ->addCustomField('custom_f_1', 'val_custom_f_1')
    ->removeCustomField('custom_f_0')
    ->addTag('tag_1', 'val_tag_1')
    ->removeTag('tag_2')

Create or update a subscriber

/** Subscriber Model */
$subscriber = new Subscriber(); 

/** boolean */
$drip->subscribers()->store($subscriber);

List all subscribers

/** ApiResponse */
$events = $drip->subscribers()->list();

Batch Operations

Create or update a batch of subscribers

$testData = [
    [
        "email"     => "john@acme.com",
        "time_zone" => "America/Los_Angeles",
    ],
    (new Subscriber())->setEmail('joe@acme.com')->setTimeZone('America/Los_Angeles'),
];

/** boolean */
$drip->subscribers()->batchStore($testData);

Unsubscribe a batch of subscribers

$testData = [
    [
        "email"     => "john@acme.com",
    ],
    (new Subscriber())->setEmail('joe@acme.com'),
];

/** boolean */
$drip->subscribers()->batchUnsubscribe($testData);

Record a batch of events

$testData = [
    [
        "email"  => "john@acme.com",
        "action" => "Opened a door",
    ],
    (new Event())->setEmail('joe@acme.com')->setAction('Closed a door'),
];

/** boolean */
$drip->events()->batchStore($testData);

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

License

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