glorand / drip-php
A PHP wrapper for Drip's REST API v2.0
Installs: 122
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 2
Type:package
Requires
- php: ^7.1
- ext-json: *
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14@dev
- phpmd/phpmd: dev-master
- phpstan/phpstan: ^0.11.0@dev
- phpunit/phpunit: ^7.1
- squizlabs/php_codesniffer: ^3.0@dev
This package is auto-updated.
Last update: 2024-12-18 02:39:59 UTC
README
A PHP wrapper for Drip's REST API
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.