glorand/drip-php

Drip的REST API v2.0的PHP包装器

维护者

详细信息

github.com/glorand/drip

源代码

问题

安装: 120

依赖关系: 1

建议者: 0

安全: 0

星标: 2

关注者: 3

分支: 1

开放问题: 2

类型:

1.0.4 2018-12-20 14:03 UTC

This package is auto-updated.

Last update: 2024-09-18 02:13:49 UTC


README

Drip的REST API的PHP包装器

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

Drip PHP

PHP 7.1+版本的Drip的REST API v2.0的PHP包装器

作者:Gombos Lorand

目录

安装

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

当前特性

实例化

use Glorand\Drip\Drip;

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

ApiResponse

方法

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

public function isSuccess(): bool {}

public function getHttpMessage(): string {}

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

账户

列出所有账户

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

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

获取一个账户

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

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

事件

事件模型

$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');

记录一个事件

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

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

列出账户中使用的所有自定义事件操作

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

订阅者

订阅者模型

$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')

创建或更新一个订阅者

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

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

列出所有订阅者

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

批量操作

创建或更新一批订阅者

$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);

取消一批订阅者的订阅

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

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

记录一批事件

$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了解最近更改的信息。

贡献

请参阅CONTRIBUTING获取详细信息。

许可

MIT许可(MIT)。请参阅LICENSE获取更多信息。