Skip to content

Commit

Permalink
Events and Subscribers (#4)
Browse files Browse the repository at this point in the history
Events and Subscribers
  • Loading branch information
glorand committed Dec 11, 2018
1 parent cc0a96d commit 39eaf42
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 3,980 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ composer.phar
vendor/
/.idea
.php_cs.cache
composer.lock

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ before_script:

script:
- vendor/bin/phpunit --coverage-clover=coverage.xml
- composer stan
#- vendor/bin/phpstan analyse src --level=7

after_success:
#- wget https://scrutinizer-ci.com/ocular.phar
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `glorand/drip-php` will be documented in this file

## 1.0.2 - 2018-12-11
### Added
- Events & Subscribers

## 1.0.1 - 2018-12-06
### Added
- Accounts endpoint
Expand Down
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/883989/49755957-17ec0980-fcc2-11e8-9e04-0339714f979b.png">
</p>

[![Latest Stable Version](https://poser.pugx.org/glorand/drip-php/v/stable)](https://packagist.org/packages/glorand/drip-php)
[![Build Status](https://travis-ci.com/glorand/drip.svg?branch=master)](https://travis-ci.com/glorand/drip)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md)
[![CodeFactor](https://www.codefactor.io/repository/github/glorand/drip/badge/master)](https://www.codefactor.io/repository/github/glorand/drip/overview/master)
[![StyleCI](https://github.styleci.io/repos/160333136/shield?branch=master)](https://github.styleci.io/repos/160333136)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/glorand/drip/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/glorand/drip/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/glorand/drip/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/glorand/drip/?branch=master)

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

Expand All @@ -14,7 +19,10 @@ Author: Gombos Lorand
- [Installation](#installation)
- [Current Features](#current_features)
- [Instantiation](#instantiation)
- [Api Response](#apiresponse)
- [Accounts](#accounts)
- [Events](#events)
- [Subscribers](#subscribers)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -42,6 +50,21 @@ use Glorand\Drip\Drip;
$drip = new Drip('your-account-id', 'your-api-token', 'user-agent-optional');
```

### ApiResponse <a name="apiresponse"></a>

**Methods**
```php
//http status code
public function getStatusCode(): int {}

public function isSuccess(): bool {}

public function getHttpMessage(): string {}

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

### Accounts <a name="accounts"></a>
**List all accounts**
```php
Expand All @@ -62,11 +85,66 @@ if($account->isSuccess()) {
}
```

### Events <a name="events"></a>

**Event Model**
```php
$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**
```php
/** Event Model */
$event = new Event();

/** boolean */
$drip->events()->store($event);
```
**List all custom events actions used in an account**
```php
/** ApiResponse */
$events = $drip->events()->list();
```

### Subscribers <a name="subscribers"></a>

**Subscriber Model**
```php
$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**
```php
/** Subscriber Model */
$subscriber = new Subscriber();

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

**List all subscribers**
```php
/** ApiResponse */
$events = $drip->subscribers()->list();
```

## Changelog <a name="changelog"></a>
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Contributing <a name="contributing"></a>
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## License <a name="license"></a>
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
],
"minimum-stability": "dev",
"scripts": {
"php-cs-fixer": "php-cs-fixer fix --rules=@PSR2 src",
"php-stan": "vendor/bin/phpstan analyse src"
"cs-fixer": "php-cs-fixer fix --rules=@PSR2 src",
"stan": "vendor/bin/phpstan analyse src --level=7"
}
}
Loading

0 comments on commit 39eaf42

Please sign in to comment.