summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Goldman <avrahamymgoldman@gmail.com>2016-06-20 11:26:43 -0400
committerGitHub <noreply@github.com>2016-06-20 11:26:43 -0400
commit87552cc2766f4ea8c8a2d6ff6c70dd74faecb687 (patch)
tree0d37219ce699bffd8adc0cd5fb7c5ec012c80df0
parenta5847be109dc6350fb0bc8beb8d0ba8bc23b75b6 (diff)
downloadphp-sparkpost-87552cc2766f4ea8c8a2d6ff6c70dd74faecb687.zip
php-sparkpost-87552cc2766f4ea8c8a2d6ff6c70dd74faecb687.tar.gz
php-sparkpost-87552cc2766f4ea8c8a2d6ff6c70dd74faecb687.tar.bz2
Merged FAD-3148 into 2.x
* FAD-3148 basic non-functioning base class * FAD-3148 a bit more functionality in the base class * FAD-3148 added custom promise class and custom response class. Did good things to SparkPost class * Updated Transmission.php for new refactor, still WIP. Created Resource.php as a parent class for all future resources. * Removed test functions * Cleaned up Transmissions.php according to PSR-2, deleted more test code and comments. * added sync and aysnc, cleaned up code * added support for async/sync option * added support for async/sync option * Added interns to authors * simplified the request function * added comments * added user agent * added comments in SparkPostPromise * added comments in SparkPostException * added comments in SparkPostResponse * cleaning up test * updated composer.json and contributing files for testing * Ran php-cs-fixer * testing for sparkpost response class * updated to newer version of guzzle * updated to newer version of guzzle * Cleaned up getUrl and other functions * cleaned up constructor and overrode getCode with getResponse()->getStatusCode() * fixed up then method * cleaned up getBody * deleted old test * Wrote total coverage tests for SparkPost class * commented out setting up transmissions endpoint until merging with FAD-3146
-rw-r--r--.gitignore1
-rw-r--r--AUTHORS.md2
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--composer.json8
-rw-r--r--composer.lock1460
-rw-r--r--examples/transmission/send_with_bcc.php8
-rw-r--r--examples/transmission/send_with_cc.php12
-rw-r--r--examples/unwrapped/create_transmission.php9
-rw-r--r--lib/SendGridCompatibility/Email.php259
-rw-r--r--lib/SendGridCompatibility/SendGrid.php26
-rw-r--r--lib/SparkPost/APIResource.php265
-rw-r--r--lib/SparkPost/APIResponseException.php62
-rw-r--r--lib/SparkPost/MessageEvents.php64
-rw-r--r--lib/SparkPost/SparkPost.php239
-rw-r--r--lib/SparkPost/SparkPostException.php41
-rw-r--r--lib/SparkPost/SparkPostPromise.php69
-rw-r--r--lib/SparkPost/SparkPostResponse.php105
-rw-r--r--lib/SparkPost/Transmission.php136
-rw-r--r--test/unit/APIResourceExceptionTest.php43
-rw-r--r--test/unit/APIResourceTest.php196
-rw-r--r--test/unit/MessageEventTest.php74
-rw-r--r--test/unit/SendGridCompatibiility/EmailTest.php178
-rw-r--r--test/unit/SparkPostResponseTest.php136
-rw-r--r--test/unit/SparkPostTest.php263
-rw-r--r--test/unit/TransmissionTest.php114
25 files changed, 1098 insertions, 2674 deletions
diff --git a/.gitignore b/.gitignore
index 0a84bbb..e683c24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ test/output/
examples/example-config.json
.idea
/composer.phar
+test.php \ No newline at end of file
diff --git a/AUTHORS.md b/AUTHORS.md
index 34f2ee0..29226af 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -13,3 +13,5 @@ php-sparkpost is maintained by Message Systems.
* Chris Wilson, [@yepher](https://github.com/yepher)
* Maxim Dzhuliy, [@max-si-m](https://github.com/max-si-m)
* [@chandon](https://github.com/chandon)
+* Avi Goldman, [@avrahamgoldman](https://github.com/avrahamgoldman)
+* Vincent Song, [@vwsong](https://github.com/vwsong)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1bc3c40..1bbdaf9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -26,7 +26,7 @@ Add composer install directory to $PATH `~/.composer/vendor/bin/`
#### Install PHPUnit for Testing
```
-composer global require "phpunit/phpunit=4.3.*"
+composer global require "phpunit/phpunit=4.8.*"
```
We recommend increasing PHP’s memory limit, by default it uses 128MB. We ran into some issues during local development without doing so. You can do this by editing your php.ini file and modifying `memory_limit`. We set ours to `memory_limit = 1024M`.
diff --git a/composer.json b/composer.json
index 4ad389e..a38b8c4 100644
--- a/composer.json
+++ b/composer.json
@@ -16,19 +16,19 @@
},
"require": {
"php": ">=5.5.0",
- "egeloen/http-adapter": "*"
+ "php-http/client-implementation": "^1.0",
+ "guzzlehttp/psr7": "1.3.*"
},
"require-dev": {
- "phpunit/phpunit": "4.3.*",
"guzzlehttp/guzzle": "6.*",
+ "php-http/guzzle6-adapter": "*",
+ "php-http/message": "*",
"mockery/mockery": "^0.9.4",
- "satooshi/php-coveralls": "dev-master",
"fabpot/php-cs-fixer": "^1.11"
},
"autoload": {
"psr-4": {
"SparkPost\\": "lib/SparkPost/",
- "SparkPost\\SendGridCompatibility\\": "lib/SendGridCompatibility/",
"SparkPost\\Test\\TestUtils\\": "test/unit/TestUtils/"
}
}
diff --git a/composer.lock b/composer.lock
index b1d62a9..561ee61 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,66 +4,45 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "b07df33073385ce325ea9ef15b5f0da9",
- "content-hash": "c5283ab83042f99acd4dd5b012446822",
+ "hash": "7b514c4fd3556635eab6298f14e03c47",
+ "content-hash": "2a019c7c9fe0fa211dd763cb9c1bcd62",
"packages": [
{
- "name": "egeloen/http-adapter",
- "version": "0.8.0",
+ "name": "guzzlehttp/guzzle",
+ "version": "6.2.0",
"source": {
"type": "git",
- "url": "https://github.com/egeloen/ivory-http-adapter.git",
- "reference": "9641f11487ec26b24c6bbcee4f267cf62f60b855"
+ "url": "https://github.com/guzzle/guzzle.git",
+ "reference": "d094e337976dff9d8e2424e8485872194e768662"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/egeloen/ivory-http-adapter/zipball/9641f11487ec26b24c6bbcee4f267cf62f60b855",
- "reference": "9641f11487ec26b24c6bbcee4f267cf62f60b855",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662",
+ "reference": "d094e337976dff9d8e2424e8485872194e768662",
"shasum": ""
},
"require": {
- "php": ">=5.4.8",
- "zendframework/zend-diactoros": "^1.1"
+ "guzzlehttp/promises": "~1.0",
+ "guzzlehttp/psr7": "~1.1",
+ "php": ">=5.5.0"
},
"require-dev": {
- "cakephp/cakephp": "^3.0.3",
"ext-curl": "*",
- "guzzle/guzzle": "^3.9.4@dev",
- "guzzlehttp/guzzle": "^4.1.4|^5.0|^6.0",
- "kriswallsmith/buzz": "^0.13",
- "nategood/httpful": "^0.2.17",
- "phpunit/phpunit": "^4.0",
- "phpunit/phpunit-mock-objects": "dev-matcher-verify as 2.3.x-dev",
- "psr/log": "^1.0",
- "react/dns": "^0.4.1",
- "react/http-client": "^0.4",
- "satooshi/php-coveralls": "^0.6",
- "symfony/event-dispatcher": "^2.0",
- "zendframework/zend-http": "^2.3.4",
- "zendframework/zendframework1": ">=1.12.9,<=1.12.14|^1.12.16"
- },
- "suggest": {
- "ext-curl": "Allows you to use the cURL adapter",
- "ext-http": "Allows you to use the PECL adapter",
- "guzzle/guzzle": "Allows you to use the Guzzle 3 adapter",
- "guzzlehttp/guzzle": "Allows you to use the Guzzle 4 adapter",
- "kriswallsmith/buzz": "Allows you to use the Buzz adapter",
- "nategood/httpful": "Allows you to use the httpful adapter",
- "psr/log": "Allows you to use the logger event subscriber",
- "symfony/event-dispatcher": "Allows you to use the event lifecycle",
- "symfony/stopwatch": "Allows you to use the stopwatch http adapter and event subscriber",
- "zendframework/zend-http": "Allows you to use the Zend 2 adapter",
- "zendframework/zendframework1": "Allows you to use the Zend 1 adapter"
+ "phpunit/phpunit": "~4.0",
+ "psr/log": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "0.8-dev"
+ "dev-master": "6.2-dev"
}
},
"autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
"psr-4": {
- "Ivory\\HttpAdapter\\": "src/"
+ "GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -72,47 +51,57 @@
],
"authors": [
{
- "name": "Eric GELOEN",
- "email": "geloen.eric@gmail.com"
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
}
],
- "description": "Issue HTTP request for PHP 5.3+.",
+ "description": "Guzzle is a PHP HTTP client library",
+ "homepage": "http://guzzlephp.org/",
"keywords": [
+ "client",
+ "curl",
+ "framework",
"http",
- "http-adapter",
- "http-client",
- "psr-7"
+ "http client",
+ "rest",
+ "web service"
],
- "abandoned": "php-http/httplug",
- "time": "2015-08-12 09:35:40"
+ "time": "2016-03-21 20:02:09"
},
{
- "name": "psr/http-message",
- "version": "1.0",
+ "name": "guzzlehttp/promises",
+ "version": "1.2.0",
"source": {
"type": "git",
- "url": "https://github.com/php-fig/http-message.git",
- "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
+ "url": "https://github.com/guzzle/promises.git",
+ "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
- "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579",
+ "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579",
"shasum": ""
},
"require": {
- "php": ">=5.3.0"
+ "php": ">=5.5.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.0.x-dev"
+ "dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
- "Psr\\Http\\Message\\": "src/"
- }
+ "GuzzleHttp\\Promise\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -120,106 +109,111 @@
],
"authors": [
{
- "name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
}
],
- "description": "Common interface for HTTP messages",
+ "description": "Guzzle promises library",
"keywords": [
- "http",
- "http-message",
- "psr",
- "psr-7",
- "request",
- "response"
+ "promise"
],
- "time": "2015-05-04 20:22:00"
+ "time": "2016-05-18 16:56:05"
},
{
- "name": "zendframework/zend-diactoros",
- "version": "1.3.3",
+ "name": "guzzlehttp/psr7",
+ "version": "1.3.0",
"source": {
"type": "git",
- "url": "https://github.com/zendframework/zend-diactoros.git",
- "reference": "4d54fde709664562eb63356f0250d527824d05de"
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "31382fef2889136415751badebbd1cb022a4ed72"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/4d54fde709664562eb63356f0250d527824d05de",
- "reference": "4d54fde709664562eb63356f0250d527824d05de",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/31382fef2889136415751badebbd1cb022a4ed72",
+ "reference": "31382fef2889136415751badebbd1cb022a4ed72",
"shasum": ""
},
"require": {
- "php": ">=5.4",
+ "php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
- "psr/http-message-implementation": "~1.0.0"
+ "psr/http-message-implementation": "1.0"
},
"require-dev": {
- "phpunit/phpunit": "~4.6",
- "squizlabs/php_codesniffer": "^2.3.1"
+ "phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.3-dev",
- "dev-develop": "1.4-dev"
+ "dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
- "Zend\\Diactoros\\": "src/"
- }
+ "GuzzleHttp\\Psr7\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "BSD-2-Clause"
+ "MIT"
],
- "description": "PSR HTTP Message implementations",
- "homepage": "https://github.com/zendframework/zend-diactoros",
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ }
+ ],
+ "description": "PSR-7 message implementation",
"keywords": [
"http",
- "psr",
- "psr-7"
+ "message",
+ "stream",
+ "uri"
],
- "time": "2016-01-04 21:37:32"
- }
- ],
- "packages-dev": [
+ "time": "2016-04-13 19:56:01"
+ },
{
- "name": "doctrine/instantiator",
- "version": "1.0.5",
+ "name": "php-http/guzzle6-adapter",
+ "version": "v1.1.1",
"source": {
"type": "git",
- "url": "https://github.com/doctrine/instantiator.git",
- "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
+ "url": "https://github.com/php-http/guzzle6-adapter.git",
+ "reference": "a56941f9dc6110409cfcddc91546ee97039277ab"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
- "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
+ "url": "https://api.github.com/repos/php-http/guzzle6-adapter/zipball/a56941f9dc6110409cfcddc91546ee97039277ab",
+ "reference": "a56941f9dc6110409cfcddc91546ee97039277ab",
"shasum": ""
},
"require": {
- "php": ">=5.3,<8.0-DEV"
+ "guzzlehttp/guzzle": "^6.0",
+ "php": ">=5.5.0",
+ "php-http/httplug": "^1.0"
+ },
+ "provide": {
+ "php-http/async-client-implementation": "1.0",
+ "php-http/client-implementation": "1.0"
},
"require-dev": {
- "athletic/athletic": "~0.1.8",
- "ext-pdo": "*",
- "ext-phar": "*",
- "phpunit/phpunit": "~4.0",
- "squizlabs/php_codesniffer": "~2.0"
+ "ext-curl": "*",
+ "php-http/adapter-integration-tests": "^0.4"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.0.x-dev"
+ "dev-master": "1.2-dev"
}
},
"autoload": {
"psr-4": {
- "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
+ "Http\\Adapter\\Guzzle6\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -228,54 +222,54 @@
],
"authors": [
{
- "name": "Marco Pivetta",
- "email": "ocramius@gmail.com",
- "homepage": "http://ocramius.github.com/"
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com"
+ },
+ {
+ "name": "David de Boer",
+ "email": "david@ddeboer.nl"
}
],
- "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
- "homepage": "https://github.com/doctrine/instantiator",
+ "description": "Guzzle 6 HTTP Adapter",
+ "homepage": "http://httplug.io",
"keywords": [
- "constructor",
- "instantiate"
+ "Guzzle",
+ "http"
],
- "time": "2015-06-14 21:17:01"
+ "time": "2016-05-10 06:13:32"
},
{
- "name": "fabpot/php-cs-fixer",
- "version": "v1.11.2",
+ "name": "php-http/httplug",
+ "version": "v1.0.0",
"source": {
"type": "git",
- "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
- "reference": "41f70154642ec0f9ea9ea9c290943f3b5dfa76fc"
+ "url": "https://github.com/php-http/httplug.git",
+ "reference": "2061047ca53a08a6b8f52e997b2a76f386b397dd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/41f70154642ec0f9ea9ea9c290943f3b5dfa76fc",
- "reference": "41f70154642ec0f9ea9ea9c290943f3b5dfa76fc",
+ "url": "https://api.github.com/repos/php-http/httplug/zipball/2061047ca53a08a6b8f52e997b2a76f386b397dd",
+ "reference": "2061047ca53a08a6b8f52e997b2a76f386b397dd",
"shasum": ""
},
"require": {
- "ext-tokenizer": "*",
- "php": ">=5.3.6",
- "sebastian/diff": "~1.1",
- "symfony/console": "~2.3|~3.0",
- "symfony/event-dispatcher": "~2.1|~3.0",
- "symfony/filesystem": "~2.1|~3.0",
- "symfony/finder": "~2.1|~3.0",
- "symfony/process": "~2.3|~3.0",
- "symfony/stopwatch": "~2.5|~3.0"
+ "php": ">=5.4",
+ "php-http/promise": "^1.0",
+ "psr/http-message": "^1.0"
},
"require-dev": {
- "satooshi/php-coveralls": "0.7.*@dev"
+ "henrikbjorn/phpspec-code-coverage": "^1.0",
+ "phpspec/phpspec": "^2.4"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.1-dev"
+ }
},
- "bin": [
- "php-cs-fixer"
- ],
- "type": "application",
"autoload": {
"psr-4": {
- "Symfony\\CS\\": "Symfony/CS/"
+ "Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -284,79 +278,49 @@
],
"authors": [
{
- "name": "Dariusz Rumiński",
- "email": "dariusz.ruminski@gmail.com"
+ "name": "Eric GELOEN",
+ "email": "geloen.eric@gmail.com"
},
{
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com"
}
],
- "description": "A tool to automatically fix PHP code style",
- "time": "2016-02-26 07:37:29"
+ "description": "HTTPlug, the HTTP client abstraction for PHP",
+ "homepage": "http://httplug.io",
+ "keywords": [
+ "client",
+ "http"
+ ],
+ "time": "2016-01-26 14:34:50"
},
{
- "name": "guzzle/guzzle",
- "version": "v3.8.1",
+ "name": "php-http/promise",
+ "version": "v1.0.0",
"source": {
"type": "git",
- "url": "https://github.com/guzzle/guzzle.git",
- "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba"
+ "url": "https://github.com/php-http/promise.git",
+ "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/4de0618a01b34aa1c8c33a3f13f396dcd3882eba",
- "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba",
+ "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980",
+ "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980",
"shasum": ""
},
- "require": {
- "ext-curl": "*",
- "php": ">=5.3.3",
- "symfony/event-dispatcher": ">=2.1"
- },
- "replace": {
- "guzzle/batch": "self.version",
- "guzzle/cache": "self.version",
- "guzzle/common": "self.version",
- "guzzle/http": "self.version",
- "guzzle/inflection": "self.version",
- "guzzle/iterator": "self.version",
- "guzzle/log": "self.version",
- "guzzle/parser": "self.version",
- "guzzle/plugin": "self.version",
- "guzzle/plugin-async": "self.version",
- "guzzle/plugin-backoff": "self.version",
- "guzzle/plugin-cache": "self.version",
- "guzzle/plugin-cookie": "self.version",
- "guzzle/plugin-curlauth": "self.version",
- "guzzle/plugin-error-response": "self.version",
- "guzzle/plugin-history": "self.version",
- "guzzle/plugin-log": "self.version",
- "guzzle/plugin-md5": "self.version",
- "guzzle/plugin-mock": "self.version",
- "guzzle/plugin-oauth": "self.version",
- "guzzle/service": "self.version",
- "guzzle/stream": "self.version"
- },
"require-dev": {
- "doctrine/cache": "*",
- "monolog/monolog": "1.*",
- "phpunit/phpunit": "3.7.*",
- "psr/log": "1.0.*",
- "symfony/class-loader": "*",
- "zendframework/zend-cache": "<2.3",
- "zendframework/zend-log": "<2.3"
+ "henrikbjorn/phpspec-code-coverage": "^1.0",
+ "phpspec/phpspec": "^2.4"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.8-dev"
+ "dev-master": "1.1-dev"
}
},
"autoload": {
- "psr-0": {
- "Guzzle": "src/",
- "Guzzle\\Tests": "tests/"
+ "psr-4": {
+ "Http\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -365,64 +329,47 @@
],
"authors": [
{
- "name": "Michael Dowling",
- "email": "mtdowling@gmail.com",
- "homepage": "https://github.com/mtdowling"
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com"
},
{
- "name": "Guzzle Community",
- "homepage": "https://github.com/guzzle/guzzle/contributors"
+ "name": "Joel Wurtz",
+ "email": "joel.wurtz@gmail.com"
}
],
- "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
- "homepage": "http://guzzlephp.org/",
+ "description": "Promise used for asynchronous HTTP requests",
+ "homepage": "http://httplug.io",
"keywords": [
- "client",
- "curl",
- "framework",
- "http",
- "http client",
- "rest",
- "web service"
+ "promise"
],
- "time": "2014-01-28 22:29:15"
+ "time": "2016-01-26 13:27:02"
},
{
- "name": "guzzlehttp/guzzle",
- "version": "6.1.0",
+ "name": "psr/http-message",
+ "version": "1.0",
"source": {
"type": "git",
- "url": "https://github.com/guzzle/guzzle.git",
- "reference": "66fd14b4d0b8f2389eaf37c5458608c7cb793a81"
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/66fd14b4d0b8f2389eaf37c5458608c7cb793a81",
- "reference": "66fd14b4d0b8f2389eaf37c5458608c7cb793a81",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
+ "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
"shasum": ""
},
"require": {
- "guzzlehttp/promises": "~1.0",
- "guzzlehttp/psr7": "~1.1",
- "php": ">=5.5.0"
- },
- "require-dev": {
- "ext-curl": "*",
- "phpunit/phpunit": "~4.0",
- "psr/log": "~1.0"
+ "php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "6.1-dev"
+ "dev-master": "1.0.x-dev"
}
},
"autoload": {
- "files": [
- "src/functions_include.php"
- ],
"psr-4": {
- "GuzzleHttp\\": "src/"
+ "Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -431,56 +378,47 @@
],
"authors": [
{
- "name": "Michael Dowling",
- "email": "mtdowling@gmail.com",
- "homepage": "https://github.com/mtdowling"
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
}
],
- "description": "Guzzle is a PHP HTTP client library",
- "homepage": "http://guzzlephp.org/",
+ "description": "Common interface for HTTP messages",
"keywords": [
- "client",
- "curl",
- "framework",
"http",
- "http client",
- "rest",
- "web service"
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
],
- "time": "2015-09-08 17:36:26"
- },
+ "time": "2015-05-04 20:22:00"
+ }
+ ],
+ "packages-dev": [
{
- "name": "guzzlehttp/promises",
- "version": "1.0.3",
+ "name": "clue/stream-filter",
+ "version": "v1.3.0",
"source": {
"type": "git",
- "url": "https://github.com/guzzle/promises.git",
- "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea"
+ "url": "https://github.com/clue/php-stream-filter.git",
+ "reference": "e3bf9415da163d9ad6701dccb407ed501ae69785"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea",
- "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea",
+ "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/e3bf9415da163d9ad6701dccb407ed501ae69785",
+ "reference": "e3bf9415da163d9ad6701dccb407ed501ae69785",
"shasum": ""
},
"require": {
- "php": ">=5.5.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0"
+ "php": ">=5.3"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
"autoload": {
"psr-4": {
- "GuzzleHttp\\Promise\\": "src/"
+ "Clue\\StreamFilter\\": "src/"
},
"files": [
- "src/functions_include.php"
+ "src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
@@ -489,54 +427,59 @@
],
"authors": [
{
- "name": "Michael Dowling",
- "email": "mtdowling@gmail.com",
- "homepage": "https://github.com/mtdowling"
+ "name": "Christian Lück",
+ "email": "christian@lueck.tv"
}
],
- "description": "Guzzle promises library",
+ "description": "A simple and modern approach to stream filtering in PHP",
+ "homepage": "https://github.com/clue/php-stream-filter",
"keywords": [
- "promise"
+ "bucket brigade",
+ "callback",
+ "filter",
+ "php_user_filter",
+ "stream",
+ "stream_filter_append",
+ "stream_filter_register"
],
- "time": "2015-10-15 22:28:00"
+ "time": "2015-11-08 23:41:30"
},
{
- "name": "guzzlehttp/psr7",
- "version": "1.2.3",
+ "name": "fabpot/php-cs-fixer",
+ "version": "v1.11.4",
"source": {
"type": "git",
- "url": "https://github.com/guzzle/psr7.git",
- "reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b"
+ "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
+ "reference": "eeb280e909834603ffe03524dbe0066e77c83084"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/2e89629ff057ebb49492ba08e6995d3a6a80021b",
- "reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b",
+ "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/eeb280e909834603ffe03524dbe0066e77c83084",
+ "reference": "eeb280e909834603ffe03524dbe0066e77c83084",
"shasum": ""
},
"require": {
- "php": ">=5.4.0",
- "psr/http-message": "~1.0"
- },
- "provide": {
- "psr/http-message-implementation": "1.0"
+ "ext-tokenizer": "*",
+ "php": ">=5.3.6",
+ "sebastian/diff": "~1.1",
+ "symfony/console": "~2.3|~3.0",
+ "symfony/event-dispatcher": "~2.1|~3.0",
+ "symfony/filesystem": "~2.1|~3.0",
+ "symfony/finder": "~2.1|~3.0",
+ "symfony/process": "~2.3|~3.0",
+ "symfony/stopwatch": "~2.5|~3.0"
},
"require-dev": {
- "phpunit/phpunit": "~4.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
+ "satooshi/php-coveralls": "0.7.*@dev"
},
+ "bin": [
+ "php-cs-fixer"
+ ],
+ "type": "application",
"autoload": {
"psr-4": {
- "GuzzleHttp\\Psr7\\": "src/"
- },
- "files": [
- "src/functions_include.php"
- ]
+ "Symfony\\CS\\": "Symfony/CS/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -544,19 +487,17 @@
],
"authors": [
{
- "name": "Michael Dowling",
- "email": "mtdowling@gmail.com",
- "homepage": "https://github.com/mtdowling"
+ "name": "Dariusz Rumiński",
+ "email": "dariusz.ruminski@gmail.com"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
}
],
- "description": "PSR-7 message implementation",
- "keywords": [
- "http",
- "message",
- "stream",
- "uri"
- ],
- "time": "2016-02-18 21:54:00"
+ "description": "A tool to automatically fix PHP code style",
+ "abandoned": "friendsofphp/php-cs-fixer",
+ "time": "2016-06-07 07:51:27"
},
{
"name": "hamcrest/hamcrest-php",
@@ -605,16 +546,16 @@
},
{
"name": "mockery/mockery",
- "version": "0.9.4",
+ "version": "0.9.5",
"source": {
"type": "git",
"url": "https://github.com/padraic/mockery.git",
- "reference": "70bba85e4aabc9449626651f48b9018ede04f86b"
+ "reference": "4db079511a283e5aba1b3c2fb19037c645e70fc2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/padraic/mockery/zipball/70bba85e4aabc9449626651f48b9018ede04f86b",
- "reference": "70bba85e4aabc9449626651f48b9018ede04f86b",
+ "url": "https://api.github.com/repos/padraic/mockery/zipball/4db079511a283e5aba1b3c2fb19037c645e70fc2",
+ "reference": "4db079511a283e5aba1b3c2fb19037c645e70fc2",
"shasum": ""
},
"require": {
@@ -666,466 +607,101 @@
"test double",
"testing"
],
- "time": "2015-04-02 19:54:00"
+ "time": "2016-05-22 21:52:33"
},
{
- "name": "phpunit/php-code-coverage",
- "version": "2.2.4",
+ "name": "php-http/message",
+ "version": "v1.2.0",
"source": {
"type": "git",
- "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
+ "url": "https://github.com/php-http/message.git",
+ "reference": "c8fadec9533f5e34a8a730a947fa76363f3aa620"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
- "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
+ "url": "https://api.github.com/repos/php-http/message/zipball/c8fadec9533f5e34a8a730a947fa76363f3aa620",
+ "reference": "c8fadec9533f5e34a8a730a947fa76363f3aa620",
"shasum": ""
},
"require": {
- "php": ">=5.3.3",
- "phpunit/php-file-iterator": "~1.3",
- "phpunit/php-text-template": "~1.2",
- "phpunit/php-token-stream": "~1.3",
- "sebastian/environment": "^1.3.2",
- "sebastian/version": "~1.0"
- },
- "require-dev": {
- "ext-xdebug": ">=2.1.4",
- "phpunit/phpunit": "~4"
- },
- "suggest": {
- "ext-dom": "*",
- "ext-xdebug": ">=2.2.1",
- "ext-xmlwriter": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.2.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
- "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
- "keywords": [
- "coverage",
- "testing",
- "xunit"
- ],
- "time": "2015-10-06 15:47:00"
- },
- {
- "name": "phpunit/php-file-iterator",
- "version": "1.3.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
- "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "File/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "include-path": [
- ""
- ],
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "FilterIterator implementation that filters files based on a list of suffixes.",
- "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
- "keywords": [
- "filesystem",
- "iterator"
- ],
- "time": "2013-10-10 15:34:57"
- },
- {
- "name": "phpunit/php-text-template",
- "version": "1.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-text-template.git",
- "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
- "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Simple template engine.",
- "homepage": "https://github.com/sebastianbergmann/php-text-template/",
- "keywords": [
- "template"
- ],
- "time": "2015-06-21 13:50:34"
- },
- {
- "name": "phpunit/php-timer",
- "version": "1.0.7",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-timer.git",
- "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
- "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Utility class for timing",
- "homepage": "https://github.com/sebastianbergmann/php-timer/",
- "keywords": [
- "timer"
- ],
- "time": "2015-06-21 08:01:12"
- },
- {
- "name": "phpunit/php-token-stream",
- "version": "1.4.8",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
- "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
- "shasum": ""
- },
- "require": {
- "ext-tokenizer": "*",
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.2"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Wrapper around PHP's tokenizer extension.",
- "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
- "keywords": [
- "tokenizer"
- ],
- "time": "2015-09-15 10:49:45"
- },
- {
- "name": "phpunit/phpunit",
- "version": "4.3.5",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2dab9d593997db4abcf58d0daf798eb4e9cecfe1",
- "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-json": "*",
- "ext-pcre": "*",
- "ext-reflection": "*",
- "ext-spl": "*",
- "php": ">=5.3.3",
- "phpunit/php-code-coverage": "~2.0",
- "phpunit/php-file-iterator": "~1.3.2",
- "phpunit/php-text-template": "~1.2",
- "phpunit/php-timer": "~1.0.2",
- "phpunit/phpunit-mock-objects": "~2.3",
- "sebastian/comparator": "~1.0",
- "sebastian/diff": "~1.1",
- "sebastian/environment": "~1.0",
- "sebastian/exporter": "~1.0",
- "sebastian/version": "~1.0",
- "symfony/yaml": "~2.0"
- },
- "suggest": {
- "phpunit/php-invoker": "~1.1"
- },
- "bin": [
- "phpunit"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.3.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "include-path": [
- "",
- "../../symfony/yaml/"
- ],
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "The PHP Unit Testing framework.",
- "homepage": "http://www.phpunit.de/",
- "keywords": [
- "phpunit",
- "testing",
- "xunit"
- ],
- "time": "2014-11-11 10:11:09"
- },
- {
- "name": "phpunit/phpunit-mock-objects",
- "version": "2.3.8",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
- "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
- "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
- "shasum": ""
- },
- "require": {
- "doctrine/instantiator": "^1.0.2",
- "php": ">=5.3.3",
- "phpunit/php-text-template": "~1.2",
- "sebastian/exporter": "~1.2"
+ "clue/stream-filter": "^1.3",
+ "php": ">=5.4",
+ "php-http/message-factory": "^1.0.2",
+ "psr/http-message": "^1.0"
},
"require-dev": {
- "phpunit/phpunit": "~4.4"
+ "coduo/phpspec-data-provider-extension": "^1.0",
+ "ext-zlib": "*",
+ "guzzlehttp/psr7": "^1.0",
+ "henrikbjorn/phpspec-code-coverage": "^1.0",
+ "phpspec/phpspec": "^2.4",
+ "zendframework/zend-diactoros": "^1.0"
},
"suggest": {
- "ext-soap": "*"
+ "ext-zlib": "Used with compressor/decompressor streams",
+ "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories",
+ "zendframework/zend-diactoros": "Used with Diactoros Factories"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.3.x-dev"
+ "dev-master": "1.3-dev"
}
},
"autoload": {
- "classmap": [
- "src/"
+ "psr-4": {
+ "Http\\Message\\": "src/"
+ },
+ "files": [
+ "src/filters.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Mock Object library for PHPUnit",
- "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
- "keywords": [
- "mock",
- "xunit"
- ],
- "time": "2015-10-02 06:51:40"
- },
- {
- "name": "psr/log",
- "version": "1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/php-fig/log.git",
- "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
- "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
- "shasum": ""
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "Psr\\Log\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
"MIT"
],
"authors": [
{
- "name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com"
}
],
- "description": "Common interface for logging libraries",
+ "description": "HTTP Message related tools",
+ "homepage": "http://php-http.org",
"keywords": [
- "log",
- "psr",
- "psr-3"
+ "http",
+ "message",
+ "psr-7"
],
- "time": "2012-12-21 11:40:51"
+ "time": "2016-03-29 20:44:24"
},
{
- "name": "satooshi/php-coveralls",
- "version": "dev-master",
+ "name": "php-http/message-factory",
+ "version": "v1.0.2",
"source": {
"type": "git",
- "url": "https://github.com/satooshi/php-coveralls.git",
- "reference": "2fbf803803d179ab1082807308a67bbd5a760c70"
+ "url": "https://github.com/php-http/message-factory.git",
+ "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/50c60bb64054974f8ed7540ae6e75fd7981a5fd3",
- "reference": "2fbf803803d179ab1082807308a67bbd5a760c70",
+ "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1",
+ "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1",
"shasum": ""
},
"require": {
- "ext-json": "*",
- "ext-simplexml": "*",
- "guzzle/guzzle": ">=2.7",
- "php": ">=5.3",
- "psr/log": "1.0.0",
- "symfony/config": ">=2.0",
- "symfony/console": ">=2.0",
- "symfony/stopwatch": ">=2.2",
- "symfony/yaml": ">=2.0"
- },
- "require-dev": {
- "apigen/apigen": "2.8.*@stable",
- "pdepend/pdepend": "dev-master as 2.0.0",
- "phpmd/phpmd": "dev-master",
- "phpunit/php-invoker": ">=1.1.0,<1.2.0",
- "phpunit/phpunit": "3.7.*@stable",
- "sebastian/finder-facade": "dev-master",
- "sebastian/phpcpd": "1.4.*@stable",
- "squizlabs/php_codesniffer": "1.4.*@stable",
- "theseer/fdomdocument": "dev-master"
- },
- "suggest": {
- "symfony/http-kernel": "Allows Symfony integration"
+ "php": ">=5.4",
+ "psr/http-message": "^1.0"
},
- "bin": [
- "composer/bin/coveralls"
- ],
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "0.7-dev"
+ "dev-master": "1.0-dev"
}
},
"autoload": {
- "psr-0": {
- "Satooshi\\Component": "src/",
- "Satooshi\\Bundle": "src/"
+ "psr-4": {
+ "Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -1134,84 +710,20 @@
],
"authors": [
{
- "name": "Kitamura Satoshi",
- "email": "with.no.parachute@gmail.com",
- "homepage": "https://www.facebook.com/satooshi.jp"
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com"
}
],
- "description": "PHP client library for Coveralls API",
- "homepage": "https://github.com/satooshi/php-coveralls",
+ "description": "Factory interfaces for PSR-7 HTTP Message",
+ "homepage": "http://php-http.org",
"keywords": [
- "ci",
- "coverage",
- "github",
- "test"
- ],
- "time": "2014-11-11 15:35:34"
- },
- {
- "name": "sebastian/comparator",
- "version": "1.2.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "937efb279bd37a375bcadf584dec0726f84dbf22"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22",
- "reference": "937efb279bd37a375bcadf584dec0726f84dbf22",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "sebastian/diff": "~1.2",
- "sebastian/exporter": "~1.2"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides the functionality to compare PHP values for equality",
- "homepage": "http://www.github.com/sebastianbergmann/comparator",
- "keywords": [
- "comparator",
- "compare",
- "equality"
+ "factory",
+ "http",
+ "message",
+ "stream",
+ "uri"
],
- "time": "2015-07-26 15:48:44"
+ "time": "2015-12-19 14:08:53"
},
{
"name": "sebastian/diff",
@@ -1266,274 +778,17 @@
"time": "2015-12-08 07:14:41"
},
{
- "name": "sebastian/environment",
- "version": "1.3.5",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf",
- "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.3.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides functionality to handle HHVM/PHP environments",
- "homepage": "http://www.github.com/sebastianbergmann/environment",
- "keywords": [
- "Xdebug",
- "environment",
- "hhvm"
- ],
- "time": "2016-02-26 18:40:46"
- },
- {
- "name": "sebastian/exporter",
- "version": "1.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "7ae5513327cb536431847bcc0c10edba2701064e"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e",
- "reference": "7ae5513327cb536431847bcc0c10edba2701064e",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "sebastian/recursion-context": "~1.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- }
- ],
- "description": "Provides the functionality to export PHP variables for visualization",
- "homepage": "http://www.github.com/sebastianbergmann/exporter",
- "keywords": [
- "export",
- "exporter"
- ],
- "time": "2015-06-21 07:55:53"
- },
- {
- "name": "sebastian/recursion-context",
- "version": "1.0.2",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/recursion-context.git",
- "reference": "913401df809e99e4f47b27cdd781f4a258d58791"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791",
- "reference": "913401df809e99e4f47b27cdd781f4a258d58791",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- }
- ],
- "description": "Provides functionality to recursively process PHP variables",
- "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "time": "2015-11-11 19:50:13"
- },
- {
- "name": "sebastian/version",
- "version": "1.0.6",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/version.git",
- "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
- "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
- "shasum": ""
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library that helps with managing the version number of Git-hosted PHP projects",
- "homepage": "https://github.com/sebastianbergmann/version",
- "time": "2015-06-21 13:59:46"
- },
- {
- "name": "symfony/config",
- "version": "v3.0.3",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/config.git",
- "reference": "79a97025f7bf4bbf8352b5df1905aa136a531066"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/config/zipball/79a97025f7bf4bbf8352b5df1905aa136a531066",
- "reference": "79a97025f7bf4bbf8352b5df1905aa136a531066",
- "shasum": ""
- },
- "require": {
- "php": ">=5.5.9",
- "symfony/filesystem": "~2.8|~3.0"
- },
- "suggest": {
- "symfony/yaml": "To use the yaml reference dumper"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.0-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Config\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony Config Component",
- "homepage": "https://symfony.com",
- "time": "2016-02-23 15:16:06"
- },
- {
"name": "symfony/console",
- "version": "v3.0.3",
+ "version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "2ed5e2706ce92313d120b8fe50d1063bcfd12e04"
+ "reference": "f62db5b8afec27073a4609b8c84b1f9936652259"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/2ed5e2706ce92313d120b8fe50d1063bcfd12e04",
- "reference": "2ed5e2706ce92313d120b8fe50d1063bcfd12e04",
+ "url": "https://api.github.com/repos/symfony/console/zipball/f62db5b8afec27073a4609b8c84b1f9936652259",
+ "reference": "f62db5b8afec27073a4609b8c84b1f9936652259",
"shasum": ""
},
"require": {
@@ -1553,7 +808,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1580,20 +835,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
- "time": "2016-02-28 16:24:34"
+ "time": "2016-05-30 06:58:39"
},
{
"name": "symfony/event-dispatcher",
- "version": "v3.0.3",
+ "version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa"
+ "reference": "0343b2cedd0edb26cdc791212a8eb645c406018b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa",
- "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/0343b2cedd0edb26cdc791212a8eb645c406018b",
+ "reference": "0343b2cedd0edb26cdc791212a8eb645c406018b",
"shasum": ""
},
"require": {
@@ -1613,7 +868,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1640,20 +895,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
- "time": "2016-01-27 05:14:46"
+ "time": "2016-04-12 18:27:47"
},
{
"name": "symfony/filesystem",
- "version": "v3.0.3",
+ "version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
- "reference": "23ae8f9648d0a7fe94a47c8e20e5bf37c489a451"
+ "reference": "5751e80d6f94b7c018f338a4a7be0b700d6f3058"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/23ae8f9648d0a7fe94a47c8e20e5bf37c489a451",
- "reference": "23ae8f9648d0a7fe94a47c8e20e5bf37c489a451",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/5751e80d6f94b7c018f338a4a7be0b700d6f3058",
+ "reference": "5751e80d6f94b7c018f338a4a7be0b700d6f3058",
"shasum": ""
},
"require": {
@@ -1662,7 +917,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1689,20 +944,20 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
- "time": "2016-02-23 15:16:06"
+ "time": "2016-04-12 18:27:47"
},
{
"name": "symfony/finder",
- "version": "v3.0.3",
+ "version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723"
+ "reference": "40d17ed287bf51a2f884c4619ce8ff2a1c5cd219"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/623bda0abd9aa29e529c8e9c08b3b84171914723",
- "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/40d17ed287bf51a2f884c4619ce8ff2a1c5cd219",
+ "reference": "40d17ed287bf51a2f884c4619ce8ff2a1c5cd219",
"shasum": ""
},
"require": {
@@ -1711,7 +966,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1738,20 +993,20 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
- "time": "2016-01-27 05:14:46"
+ "time": "2016-05-13 18:06:41"
},
{
"name": "symfony/polyfill-mbstring",
- "version": "v1.1.0",
+ "version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
- "reference": "1289d16209491b584839022f29257ad859b8532d"
+ "reference": "dff51f72b0706335131b00a7f49606168c582594"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d",
- "reference": "1289d16209491b584839022f29257ad859b8532d",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594",
+ "reference": "dff51f72b0706335131b00a7f49606168c582594",
"shasum": ""
},
"require": {
@@ -1763,7 +1018,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1-dev"
+ "dev-master": "1.2-dev"
}
},
"autoload": {
@@ -1797,20 +1052,20 @@
"portable",
"shim"
],
- "time": "2016-01-20 09:13:37"
+ "time": "2016-05-18 14:26:46"
},
{
"name": "symfony/process",
- "version": "v3.0.3",
+ "version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "dfecef47506179db2501430e732adbf3793099c8"
+ "reference": "1574f3451b40fa9bbae518ef71d19a56f409cac0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/dfecef47506179db2501430e732adbf3793099c8",
- "reference": "dfecef47506179db2501430e732adbf3793099c8",
+ "url": "https://api.github.com/repos/symfony/process/zipball/1574f3451b40fa9bbae518ef71d19a56f409cac0",
+ "reference": "1574f3451b40fa9bbae518ef71d19a56f409cac0",
"shasum": ""
},
"require": {
@@ -1819,7 +1074,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1846,20 +1101,20 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
- "time": "2016-02-02 13:44:19"
+ "time": "2016-04-12 19:11:33"
},
{
"name": "symfony/stopwatch",
- "version": "v3.0.3",
+ "version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
- "reference": "4a204804952ff267ace88cf499e0b4bb302a475e"
+ "reference": "4670f122fa32a4900003a6802f6b8575f3f0b17e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4a204804952ff267ace88cf499e0b4bb302a475e",
- "reference": "4a204804952ff267ace88cf499e0b4bb302a475e",
+ "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4670f122fa32a4900003a6802f6b8575f3f0b17e",
+ "reference": "4670f122fa32a4900003a6802f6b8575f3f0b17e",
"shasum": ""
},
"require": {
@@ -1868,7 +1123,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1895,63 +1150,12 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
- "time": "2016-01-03 15:35:16"
- },
- {
- "name": "symfony/yaml",
- "version": "v2.8.3",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/yaml.git",
- "reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/yaml/zipball/2a4ee40acb880c56f29fb1b8886e7ffe94f3b995",
- "reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.9"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.8-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Yaml\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony Yaml Component",
- "homepage": "https://symfony.com",
- "time": "2016-02-23 07:41:20"
+ "time": "2016-03-04 07:56:56"
}
],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": {
- "satooshi/php-coveralls": 20
- },
+ "stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
diff --git a/examples/transmission/send_with_bcc.php b/examples/transmission/send_with_bcc.php
index ce67862..7479c4a 100644
--- a/examples/transmission/send_with_bcc.php
+++ b/examples/transmission/send_with_bcc.php
@@ -36,8 +36,8 @@ try {
'email' => 'original.recipient@example.com',
],
'substitution_data' => [
- 'recipient_type' => 'Original'
- ]
+ 'recipient_type' => 'Original',
+ ],
],
[
'address' => [
@@ -45,8 +45,8 @@ try {
'header_to' => '"Original Recipient" <original.recipient@example.com>',
],
'substitution_data' => [
- 'recipient_type' => 'BCC'
- ]
+ 'recipient_type' => 'BCC',
+ ],
],
],
]);
diff --git a/examples/transmission/send_with_cc.php b/examples/transmission/send_with_cc.php
index fa1d9e9..7ad2a7b 100644
--- a/examples/transmission/send_with_cc.php
+++ b/examples/transmission/send_with_cc.php
@@ -36,8 +36,8 @@ try {
'email' => 'original.recipient@example.com',
],
'substitution_data' => [
- 'recipient_type' => 'Original'
- ]
+ 'recipient_type' => 'Original',
+ ],
],
[
'address' => [
@@ -46,13 +46,13 @@ try {
'header_to' => '"Original Recipient" <original.recipient@example.com>',
],
'substitution_data' => [
- 'recipient_type' => 'CC'
- ]
+ 'recipient_type' => 'CC',
+ ],
],
],
'customHeaders' => [
- 'CC' => '"Carbon Copy Recipient" <cc.recipient@example.com>'
- ]
+ 'CC' => '"Carbon Copy Recipient" <cc.recipient@example.com>',
+ ],
]);
echo 'Congrats! You sent an email with cc using SparkPost!';
} catch (\Exception $exception) {
diff --git a/examples/unwrapped/create_transmission.php b/examples/unwrapped/create_transmission.php
index f19ee6e..d3a44c5 100644
--- a/examples/unwrapped/create_transmission.php
+++ b/examples/unwrapped/create_transmission.php
@@ -24,8 +24,8 @@ try {
[
'address' => [
'email' => 'john.doe@example.com',
- ]
- ]
+ ],
+ ],
],
'content' => [
'from' => [
@@ -34,8 +34,8 @@ try {
],
'html' => '<p>Hello World!</p>',
'text' => 'Hello World!',
- 'subject' => 'Example Email'
- ]
+ 'subject' => 'Example Email',
+ ],
];
$results = $sparky->transmissions->create($message);
echo 'Congrats! You sent a message using SparkPost!';
@@ -44,4 +44,3 @@ try {
echo $exception->getAPICode()."\n";
echo $exception->getAPIDescription()."\n";
}
-
diff --git a/lib/SendGridCompatibility/Email.php b/lib/SendGridCompatibility/Email.php
deleted file mode 100644
index 3ca2466..0000000
--- a/lib/SendGridCompatibility/Email.php
+++ /dev/null
@@ -1,259 +0,0 @@
-<?php
-
-namespace SparkPost\SendGridCompatibility;
-
-class Email
-{
- public $model;
-
- /**
- * Sets up the model for saving the configuration.
- */
- public function __construct()
- {
- $this->model = array();
- }
-
- /**
- * adds addresses as recipients.
- *
- * @param string $address
- * @param string $name optional
- *
- * @return $this
- */
- public function addTo($address, $name = null)
- {
- if (!isset($this->model['recipients'])) {
- $this->model['recipients'] = array();
- }
-
- if (isset($name)) {
- $address = array('address' => array('email' => $address, 'name' => $name));
- } else {
- $address = array('address' => array('email' => $address));
- }
-
- array_push($this->model['recipients'], $address);
-
- return $this;
- }
-
- /**
- * explicitly sets a list of addresses.
- *
- * @param array $addresses
- *
- * @return $this
- */
- public function setTos(array $addresses)
- {
- $this->model['recipients'] = $addresses;
-
- return $this;
- }
-
- /**
- * sets the from address.
- *
- * @param string $address
- *
- * @return $this
- */
- public function setFrom($address)
- {
- $this->model['from'] = array('email' => $address);
-
- return $this;
- }
-
- /**
- * Sets the name for the from address.
- *
- * @param string $name
- *
- * @return $this
- *
- * @throws \Exception
- */
- public function setFromName($name)
- {
- if (!isset($this->model['from'])) {
- throw new \Exception('Must set \'From\' prior to setting \'From Name\'.');
- }
- $this->model['from']['name'] = $name;
-
- return $this;
- }
-
- /**
- * sets the reply to field.
- *
- * @param string $address
- *
- * @return $this
- */
- public function setReplyTo($address)
- {
- $this->model['replyTo'] = $address;
-
- return $this;
- }
-
- /**
- * throws an error because bcc fields are not yet implemented.
- *
- * @throws \Exception
- *
- * @param string $address
- *
- * @return $this
- */
- public function addBcc($address)
- {
- throw new \Exception('Adding bcc recipients is not yet supported, try adding them as a \'to\' address');
- }
-
- /**
- * sets the subject header.
- *
- * @param string $subject
- *
- * @return $this
- */
- public function setSubject($subject)
- {
- $this->model['subject'] = $subject;
-
- return $this;
- }
-
- /**
- * sets the text body.
- *
- * @param string $text
- *
- * @return $this
- */
- public function setText($text)
- {
- $this->model['text'] = $text;
-
- return $this;
- }
-
- /**
- * sets the html body.
- *
- * @param string $html
- *
- * @return $this
- */
- public function setHtml($html)
- {
- $this->model['html'] = $html;
-
- return $this;
- }
-
- /**
- * Throws an exception since adding categories is not yet supported.
- *
- * @param string $category
- *
- * @throws \Exception
- */
- public function addCategory($category)
- {
- throw new \Exception('Adding categories is not yet supported');
- }
-
- /**
- * Throws an exception since adding attachments is not yet supported.
- *
- * @throws \Exception
- *
- * @param mixed $attachment
- */
- public function addAttachment($attachment)
- {
- throw new \Exception('Adding attachments is not yet supported');
- }
-
- /**
- * Adds transmission level substitution data.
- *
- * @param string $name
- * @param mixed $values
- *
- * @return $this
- */
- public function addSubstitution($name, $values)
- {
- if (!isset($this->model['substitutionData'])) {
- $this->model['substitutionData'] = array();
- }
- $this->model['substitutionData'][$name] = $values;
-
- return $this;
- }
-
- /**
- * Adds transmission level substitution data.
- *
- * @param string $name
- * @param mixed $values
- */
- public function addSection($name, $values)
- {
- $this->addSubstitution($name, $values);
- }
-
- /**
- * Throws an exception because arguments for third party systems is not supported.
- *
- * @throws \Exception
- *
- * @param mixed $value
- */
- public function addUniqueArg($key, $value)
- {
- throw new \Exception('Adding Unique Arguments is not yet supported');
- }
-
- /**
- * Throws an exception because arguments for third party systems is not supported.
- *
- * @throws \Exception
- *
- * @param mixed $values
- */
- public function setUniqueArgs(array $values)
- {
- throw new \Exception('Setting Unique Arguments is not yet supported');
- }
-
- /**
- * Adds custom headers to the email header.
- *
- * @param string $name
- * @param string $value
- */
- public function addHeader($name, $value)
- {
- if (!isset($this->model['customHeaders'])) {
- $this->model['customHeaders'] = array();
- }
- $this->model['customHeaders'][$name] = $value;
- }
-
- /**
- * converts this object to a configuration for a SparkPost transmission.
- *
- * @return array
- */
- public function toSparkPostTransmission()
- {
- return $this->model;
- }
-}
diff --git a/lib/SendGridCompatibility/SendGrid.php b/lib/SendGridCompatibility/SendGrid.php
deleted file mode 100644
index c5e84c1..0000000
--- a/lib/SendGridCompatibility/SendGrid.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-namespace SparkPost\SendGridCompatibility;
-
-use SparkPost\SparkPost;
-
-class SendGrid
-{
- private $sparky;
-
- public function __construct($username, $password, $options = null, $httpAdapter)
- {
- //username isn't used in our system
- $opts = array('key' => $password);
- if (!is_null($options)) {
- $opts = array_merge($opts, $options);
- }
-
- $this->sparky = new SparkPost($httpAdapter, $opts);
- }
-
- public function send(Email $email)
- {
- $this->sparky->transmission->send($email->toSparkPostTransmission());
- }
-}
diff --git a/lib/SparkPost/APIResource.php b/lib/SparkPost/APIResource.php
deleted file mode 100644
index 36b03a8..0000000
--- a/lib/SparkPost/APIResource.php
+++ /dev/null
@@ -1,265 +0,0 @@
-<?php
-
-namespace SparkPost;
-
-/**
- * SDK interface for managing SparkPost API endpoints.
- */
-class APIResource
-{
- /**
- * name of the API endpoint, mainly used for URL construction.
- * This is public to provide an interface.
- *
- * @var string
- */
- public $endpoint;
-
- /**
- * Mapping for values passed into the send method to the values needed for the respective API.
- *
- * @var array
- */
- protected static $parameterMappings = [];
-
- /**
- * Sets up default structure and default values for the model that is acceptable by the API.
- *
- * @var array
- */
- protected static $structure = [];
-
- /**
- * SparkPost reference for httpAdapters and configs.
- */
- protected $sparkpost;
-
- /**
- * Initializes config and httpAdapter for use later.
- *
- * @param $sparkpost \SparkPost\SparkPost provides api configuration information
- */
- public function __construct(SparkPost $sparkpost)
- {
- $this->sparkpost = $sparkpost;
- }
-
- /**
- * Private Method helper to reference parameter mappings and set the right value for the right parameter.
- *
- * @param array $model (pass by reference) the set of values to map
- * @param string $mapKey a dot syntax path determining which value to set
- * @param mixed $value value for the given path
- */
- protected function setMappedValue(&$model, $mapKey, $value)
- {
- //get mapping
- if (empty(static::$parameterMappings)) {
- // if parameterMappings is empty we can assume that no wrapper is defined
- // for the current endpoint and we will use the mapKey to define the mappings directly
- $mapPath = $mapKey;
- } elseif (array_key_exists($mapKey, static::$parameterMappings)) {
- // use only defined parameter mappings to construct $model
- $mapPath = static::$parameterMappings[$mapKey];
- } else {
- return;
- }
-
- $path = explode('.', $mapPath);
- $temp = &$model;
- foreach ($path as $key) {
- if (!isset($temp[$key])) {
- $temp[$key] = null;
- }
- $temp = &$temp[$key];
- }
- $temp = $value;
- }
-
- /**
- * maps values from the passed in model to those needed for the request.
- *
- * @param array $requestConfig the passed in model
- * @param array $model the set of defaults
- *
- * @return array A model ready for the body of a request
- */
- protected function buildRequestModel(array $requestConfig, array $model = [])
- {
- foreach ($requestConfig as $key => $value) {
- $this->setMappedValue($model, $key, $value);
- }
-
- return $model;
- }
-
- /**
- * posts to the api with a supplied body.
- *
- * @param array $body post body for the request
- *
- * @return array Result of the request
- */
- public function create(array $body = [])
- {
- return $this->callResource('post', null, ['body' => $body]);
- }
-
- /**
- * Makes a put request to the api with a supplied body.
- *
- * @param $resourcePath
- * @param array $body Put body for the request
- *
- * @return array Result of the request
- *
- * @throws APIResponseException
- */
- public function update($resourcePath, array $body = [])
- {
- return $this->callResource('put', $resourcePath, ['body' => $body]);
- }
-
- /**
- * Wrapper method for issuing GET request to current API endpoint.
- *
- * @param string $resourcePath (optional) string resource path of specific resource
- * @param array $query (optional) query string parameters
- *
- * @return array Result of the request
- */
- public function get($resourcePath = null, array $query = [])
- {
- return $this->callResource('get', $resourcePath, ['query' => $query]);
- }
-
- /**
- * Wrapper method for issuing DELETE request to current API endpoint.
- *
- * @param string $resourcePath (optional) string resource path of specific resource
- * @param array $query (optional) query string parameters
- *
- * @return array Result of the request
- */
- public function delete($resourcePath = null, array $query = [])
- {
- return $this->callResource('delete', $resourcePath, ['query' => $query]);
- }
-
- /**
- * assembles a URL for a request.
- *
- * @param string $resourcePath path after the initial endpoint
- * @param array $options array with an optional value of query with values to build a querystring from. Any
- * query elements that are themselves arrays will be imploded into a comma separated list.
- *
- * @return string the assembled URL
- */
- private function buildUrl($resourcePath, $options)
- {
- $url = "/{$this->endpoint}/";
- if (!is_null($resourcePath)) {
- $url .= $resourcePath;
- }
-
- if (!empty($options['query'])) {
- // check each query element - if it's an array, implode it to match the API-accepted format
- foreach ($options['query'] as &$element) {
- if (is_array($element)) {
- $element = implode(',', $element);
- }
- }
-
- $queryString = http_build_query($options['query']);
- $url .= '?'.$queryString;
- }
-
- return $url;
- }
-
- /**
- * Prepares a body for put and post requests.
- *
- * @param array $options array with an optional value of body with values to build a request body from.
- *
- * @return string|null A json encoded string or null if no body was provided
- */
- private function buildBody($options)
- {
- $body = null;
- if (!empty($options['body'])) {
- $model = static::$structure;
- $requestModel = $this->buildRequestModel($options['body'], $model);
- $body = json_encode($requestModel);
- }
-
- return $body;
- }
-
- /**
- * Private Method for issuing GET and DELETE request to current API endpoint.
- *
- * This method is responsible for getting the collection _and_
- * a specific entity from the API endpoint
- *
- * If resourcePath parameter is omitted, then we fetch the collection
- *
- * @param string $action HTTP method type
- * @param string $resourcePath (optional) string resource path of specific resource
- * @param array $options (optional) query string parameters
- *
- * @return array Result set of action performed on resource
- *
- * @throws APIResponseException
- */
- private function callResource($action, $resourcePath = null, $options = [])
- {
- $action = strtoupper($action); // normalize
-
- $url = $this->buildUrl($resourcePath, $options);
- $body = $this->buildBody($options);
-
- //make request
- try {
- $response = $this->sparkpost->httpAdapter->send($url, $action, $this->sparkpost->getHttpHeaders(), $body);
-
- $statusCode = $response->getStatusCode();
-
- // Handle 4XX responses, 5XX responses will throw an HttpAdapterException
- if ($statusCode < 400) {
- return json_decode($response->getBody()->getContents(), true);
- } elseif ($statusCode === 403) {
- $response = json_decode($response->getBody(), true);
- throw new APIResponseException(
- 'Request forbidden',
- $statusCode,
- isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : 'Request forbidden',
- isset($response['errors'][0]['code']) ? $response['errors'][0]['code'] : 1100,
- isset($response['errors'][0]['description']) ? $response['errors'][0]['description'] : 'Does this API Key have the correct permissions?'
- );
- } elseif ($statusCode === 404) {
- throw new APIResponseException('The specified resource does not exist', 404);
- } else {
- $response = json_decode($response->getBody(), true);
- throw new APIResponseException(
- 'Received bad response from '.ucfirst($this->endpoint),
- $statusCode,
- isset($response['errors'][0]['message']) ? $response['errors'][0]['message'] : '',
- isset($response['errors'][0]['code']) ? $response['errors'][0]['code'] : 0,
- isset($response['errors'][0]['description']) ? $response['errors'][0]['description'] : ''
- );
- }
- }
-
- /*
- * Configuration Errors, and a catch all for other errors
- */
- catch (\Exception $exception) {
- if ($exception instanceof APIResponseException) {
- throw $exception;
- }
-
- throw new APIResponseException('Unable to contact '.ucfirst($this->endpoint).' API: '.$exception->getMessage(), $exception->getCode());
- }
- }
-}
diff --git a/lib/SparkPost/APIResponseException.php b/lib/SparkPost/APIResponseException.php
deleted file mode 100644
index a491b3c..0000000
--- a/lib/SparkPost/APIResponseException.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-namespace SparkPost;
-
-class APIResponseException extends \Exception
-{
- /**
- * @var string
- */
- protected $apiMessage;
-
- /**
- * @var int
- */
- protected $apiCode;
-
- /**
- * @var string
- */
- protected $apiDescription;
-
- /**
- * Construct the exception.
- */
- public function __construct($message = '', $code = 0, $apiMessage = '', $apiCode = 0, $apiDescription = '')
- {
- $this->apiMessage = $apiMessage;
- $this->apiCode = $apiCode;
- $this->apiDescription = $apiDescription;
- parent::__construct($message, $code);
- }
-
- /**
- * Gets the Exception message.
- *
- * @return string the Exception message as a string.
- */
- public function getAPIMessage()
- {
- return $this->apiMessage;
- }
-
- /**
- * Gets the API Exception code.
- *
- * @return int the exception code as integer.
- */
- public function getAPICode()
- {
- return $this->apiCode;
- }
-
- /**
- * Gets the Exception description.
- *
- * @return string the Exception description as a string.
- */
- public function getAPIDescription()
- {
- return $this->apiDescription;
- }
-}
diff --git a/lib/SparkPost/MessageEvents.php b/lib/SparkPost/MessageEvents.php
deleted file mode 100644
index d44a30f..0000000
--- a/lib/SparkPost/MessageEvents.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-namespace SparkPost;
-
-/**
- * SDK class for querying the Message Events API.
- *
- * @see https://developers.sparkpost.com/api/#/reference/message-events
- */
-class MessageEvents extends APIResource
-{
- /**
- * @var string
- */
- public $endpoint = 'message-events';
-
- /**
- * Method for issuing search requests to the Message Events API.
- *
- * The method passes-through all of the query parameters - the valid ones are listed at
- *
- * @link https://developers.sparkpost.com/api/#/reference/message-events/events-documentation/search-for-message-events
- *
- * @param array $queryParams The query parameters. Note that a query parameter containing an array
- * is collapsed into a comma-separated list.
- *
- * @return array The result of the query.
- */
- public function search(array $queryParams)
- {
- // check for DateTime objects & replace them with the formatted string equivalent
- foreach (['from', 'to'] as $dateTimeParam) {
- if (isset($queryParams[$dateTimeParam]) && $queryParams[$dateTimeParam] instanceof \DateTime) {
- // the message events API doesn't allow the seconds or GMT offset, so strip them
- $queryParams[$dateTimeParam] = substr($queryParams[$dateTimeParam]->format(\DateTime::ATOM), 0, 16);
- }
- }
-
- return $this->get(null, $queryParams);
- }
-
- /**
- * List descriptions of the event fields that could be included in a response from the MessageEvent::search() method.
- *
- * @return array The event field descriptions.
- */
- public function documentation()
- {
- return $this->get('events/documentation');
- }
-
- /**
- * List examples of the event data that will be included in a response from the MessageEvent::search() method.
- *
- * @param array $events (optional) Event types for which to get a sample payload. If not provided, samples
- * for all events will be returned.
- *
- * @return array Sample events.
- */
- public function samples(array $events = [])
- {
- return $this->get('events/samples', ['events' => $events]);
- }
-}
diff --git a/lib/SparkPost/SparkPost.php b/lib/SparkPost/SparkPost.php
index ff8b456..e76bcd0 100644
--- a/lib/SparkPost/SparkPost.php
+++ b/lib/SparkPost/SparkPost.php
@@ -2,151 +2,238 @@
namespace SparkPost;
-use Ivory\HttpAdapter\Configuration;
-use Ivory\HttpAdapter\HttpAdapterInterface;
+use Http\Client\HttpClient;
+use Http\Client\HttpAsyncClient;
+use GuzzleHttp\Psr7\Request as Request;
class SparkPost
{
- public $transmission;
- public $messageEvents;
-
/**
* Library version, used for setting User-Agent.
*/
- private $version = '1.2.1';
+ private $version = '2.0.0';
/**
- * Connection config for making requests.
+ * HttpClient used to make requests.
*/
- private $config;
+ public $httpClient;
/**
- * @var \Ivory\HttpAdapter\HttpAdapterInterface to make requests through.
+ * Options for requests.
*/
- public $httpAdapter;
+ private $options;
/**
- * Default config values. Passed in values will override these.
+ * Default options for requests that can be overridden with the setOptions function.
*/
- private static $apiDefaults = [
+ private static $defaultOptions = [
'host' => 'api.sparkpost.com',
'protocol' => 'https',
'port' => 443,
- 'strictSSL' => true,
'key' => '',
'version' => 'v1',
- 'timeout' => 10
+ 'timeout' => 10,
+ 'async' => true,
];
/**
- * Sets up httpAdapter and config.
- *
- * Sets up instances of sub libraries.
+ * Instance of Transmission class.
+ */
+ public $transmissions;
+
+ /**
+ * Sets up the SparkPost instance.
+ *
+ * @param HttpClient $httpClient - An httplug client or adapter
+ * @param array $options - An array to overide default options or a string to be used as an API key
+ */
+ public function __construct(HttpClient $httpClient, $options)
+ {
+ $this->setOptions($options);
+ $this->setHttpClient($httpClient);
+ $this->setupEndpoints();
+ }
+
+ /**
+ * Sends either sync or async request based on async option.
*
- * @param \Ivory\HttpAdapter\HttpAdapterInterface $httpAdapter - An adapter for making http requests
- * @param string | array $settingsConfig - Hashmap that contains config values
- * for the SDK to connect to SparkPost. If its a string we assume that
- * its just they API Key.
+ * @param string $method
+ * @param string $uri
+ * @param array $payload - either used as the request body or url query params
+ * @param array $headers
+ *
+ * @return SparkPostPromise or SparkPostResponse depending on sync or async request
*/
- public function __construct($httpAdapter, $settingsConfig)
+ public function request($method = 'GET', $uri = '', $payload = [], $headers = [])
{
- //config needs to be setup before adapter because of default adapter settings
- $this->setConfig($settingsConfig);
- $this->setHttpAdapter($httpAdapter);
+ if ($this->options['async'] === true) {
+ return $this->asyncRequest($method, $uri, $payload, $headers);
+ } else {
+ return $this->syncRequest($method, $uri, $payload, $headers);
+ }
+ }
- $this->transmission = new Transmission($this);
- $this->messageEvents = new MessageEvents($this);
+ /**
+ * Sends sync request to SparkPost API.
+ *
+ * @param string $method
+ * @param string $uri
+ * @param array $payload
+ * @param array $headers
+ *
+ * @return SparkPostResponse
+ *
+ * @throws SparkPostException
+ */
+ public function syncRequest($method = 'GET', $uri = '', $payload = [], $headers = [])
+ {
+ $request = $this->buildRequest($method, $uri, $payload, $headers);
+ try {
+ return new SparkPostResponse($this->httpClient->sendRequest($request));
+ } catch (\Exception $exception) {
+ throw new SparkPostException($exception);
+ }
}
/**
- * Creates an unwrapped api interface for endpoints that aren't yet supported.
- * The new resource is attached to this object as well as returned.
+ * Sends async request to SparkPost API.
*
- * @param string $endpoint
+ * @param string $method
+ * @param string $uri
+ * @param array $payload
+ * @param array $headers
+ *
+ * @return SparkPostPromise
+ */
+ public function asyncRequest($method = 'GET', $uri = '', $payload = [], $headers = [])
+ {
+ if ($this->httpClient instanceof HttpAsyncClient) {
+ $request = $this->buildRequest($method, $uri, $payload, $headers);
+
+ return new SparkPostPromise($this->httpClient->sendAsyncRequest($request));
+ } else {
+ throw new \Exception('Your http client does not support asynchronous requests. Please use a different client or use synchronous requests.');
+ }
+ }
+
+ /**
+ * Builds request from given params.
+ *
+ * @param string $method
+ * @param string $uri
+ * @param array $payload
+ * @param array $headers
*
- * @return APIResource - the unwrapped resource
+ * @return GuzzleHttp\Psr7\Request - A Psr7 compliant request
*/
- public function setupUnwrapped($endpoint)
+ public function buildRequest($method, $uri, $payload, $headers)
{
- $this->{$endpoint} = new APIResource($this);
- $this->{$endpoint}->endpoint = $endpoint;
+ $method = trim(strtoupper($method));
+
+ if ($method === 'GET') {
+ $params = $payload;
+ $body = [];
+ } else {
+ $params = [];
+ $body = $payload;
+ }
- return $this->{$endpoint};
+ $url = $this->getUrl($uri, $params);
+ $headers = $this->getHttpHeaders($headers);
+
+ return new Request($method, $url, $headers, json_encode($body));
}
/**
- * Merges passed in headers with default headers for http requests.
+ * Returns an array for the request headers.
+ *
+ * @param array $headers - any custom headers for the request
+ *
+ * @return array $headers - headers for the request
*/
- public function getHttpHeaders()
+ public function getHttpHeaders($headers = [])
{
- $defaultOptions = [
- 'Authorization' => $this->config['key'],
+ $constantHeaders = [
+ 'Authorization' => $this->options['key'],
'Content-Type' => 'application/json',
+ 'User-Agent' => 'php-sparkpost/'.$this->version,
];
- return $defaultOptions;
+ foreach ($constantHeaders as $key => $value) {
+ $headers[$key] = $value;
+ }
+
+ return $headers;
}
/**
- * Helper function for getting the configuration for http requests.
+ * Builds the request url from the options and given params.
*
- * @param array $config
+ * @param string $path - the path in the url to hit
+ * @param array $params - query parameters to be encoded into the url
*
- * @return Configuration
+ * @return string $url - the url to send the desired request to
*/
- private function getHttpConfig($config)
+ public function getUrl($path, $params = [])
{
- // create Configuration for http adapter
- $httpConfig = new Configuration();
- $baseUrl = $config['protocol'].'://'.$config['host'].($config['port'] ? ':'.$config['port'] : '').'/api/'.$config['version'];
- $httpConfig->setBaseUri($baseUrl);
- $httpConfig->setTimeout($this->config['timeout']);
- $httpConfig->setUserAgent('php-sparkpost/'.$this->version);
-
- return $httpConfig;
+ $options = $this->options;
+
+ $paramsArray = [];
+ foreach ($params as $key => $value) {
+ if (is_array($value)) {
+ $value = implode(',', $value);
+ }
+
+ array_push($paramsArray, $key.'='.$value);
+ }
+
+ $paramsString = implode('&', $paramsArray);
+
+ return $options['protocol'].'://'.$options['host'].($options['port'] ? ':'.$options['port'] : '').'/api/'.$options['version'].'/'.$path.($paramsString ? '?'.$paramsString : '');
}
- /**
- * Validates and sets up the httpAdapter.
- *
- * @param $httpAdapter \Ivory\HttpAdapter\HttpAdapterInterface to make requests through.
+ /**
+ * Sets $httpClient to be used for request.
*
- * @throws \Exception
+ * @param Http\Client\HttpClient $httpClient - the client to be used for request
*/
- public function setHttpAdapter(HttpAdapterInterface $httpAdapter)
+ public function setHttpClient(HttpClient $httpClient)
{
- $this->httpAdapter = $httpAdapter;
- $this->httpAdapter->setConfiguration($this->getHttpConfig($this->config));
+ $this->httpClient = $httpClient;
}
/**
- * Allows the user to pass in values to override the defaults and set their API key.
- *
- * @param string | array $settingsConfig - Hashmap that contains config values
- * for the SDK to connect to SparkPost. If its a string we assume that
- * its just they API Key.
+ * Sets the options from the param and defaults for the SparkPost object.
*
- * @throws \Exception
+ * @param array $options - either an string API key or an array of options
*/
- public function setConfig($settingsConfig)
+ public function setOptions($options)
{
- // if the config map is a string we should assume that its an api key
- if (is_string($settingsConfig)) {
- $settingsConfig = ['key' => $settingsConfig];
+ // if the options map is a string we should assume that its an api key
+ if (is_string($options)) {
+ $options = ['key' => $options];
}
// Validate API key because its required
- if (!isset($settingsConfig['key']) || !preg_match('/\S/', $settingsConfig['key'])) {
+ if (!isset($this->options['key']) && (!isset($options['key']) || !preg_match('/\S/', $options['key']))) {
throw new \Exception('You must provide an API key');
}
- $this->config = self::$apiDefaults;
+ $this->options = isset($this->options) ? $this->options : self::$defaultOptions;
- // set config, overriding defaults
- foreach ($settingsConfig as $configOption => $configValue) {
- if (key_exists($configOption, $this->config)) {
- $this->config[$configOption] = $configValue;
+ // set options, overriding defaults
+ foreach ($options as $option => $value) {
+ if (key_exists($option, $this->options)) {
+ $this->options[$option] = $value;
}
}
}
+
+ /**
+ * Sets up any endpoints from custom classes e.g. $this->transmissions.
+ */
+ private function setupEndpoints()
+ {
+ // $this->transmissions = new Transmission($this);
+ }
}
diff --git a/lib/SparkPost/SparkPostException.php b/lib/SparkPost/SparkPostException.php
new file mode 100644
index 0000000..ca92e24
--- /dev/null
+++ b/lib/SparkPost/SparkPostException.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace SparkPost;
+
+use Http\Client\Exception\HttpException as HttpException;
+
+class SparkPostException extends \Exception
+{
+ /**
+ * Variable to hold json decoded body from http response.
+ */
+ private $body = null;
+
+ /**
+ * Sets up the custom exception and copies over original exception values.
+ *
+ * @param Exception $exception - the exception to be wrapped
+ */
+ public function __construct(\Exception $exception)
+ {
+ $message = $exception->getMessage();
+ $code = $exception->getCode();
+ if ($exception instanceof HttpException) {
+ $message = $exception->getResponse()->getBody()->__toString();
+ $this->body = json_decode($message, true);
+ $code = $exception->getResponse()->getStatusCode();
+ }
+
+ parent::__construct($message, $code, $exception->getPrevious());
+ }
+
+ /**
+ * Returns the body.
+ *
+ * @return array $body - the json decoded body from the http response
+ */
+ public function getBody()
+ {
+ return $this->body;
+ }
+}
diff --git a/lib/SparkPost/SparkPostPromise.php b/lib/SparkPost/SparkPostPromise.php
new file mode 100644
index 0000000..15f129f
--- /dev/null
+++ b/lib/SparkPost/SparkPostPromise.php
@@ -0,0 +1,69 @@
+<?php
+
+namespace SparkPost;
+
+use Http\Promise\Promise as HttpPromise;
+
+class SparkPostPromise implements HttpPromise
+{
+ /**
+ * HttpPromise to be wrapped by SparkPostPromise.
+ */
+ private $promise;
+
+ /**
+ * set the promise to be wrapped.
+ *
+ * @param HttpPromise $promise
+ */
+ public function __construct(HttpPromise $promise)
+ {
+ $this->promise = $promise;
+ }
+
+ /**
+ * Hand off the response functions to the original promise and return a custom response or exception.
+ *
+ * @param callable $onFulfilled - function to be called if the promise is fulfilled
+ * @param callable $onRejected - function to be called if the promise is rejected
+ */
+ public function then(callable $onFulfilled = null, callable $onRejected = null)
+ {
+ return $this->promise->then(function($response) use ($onFulfilled) {
+ if (isset($onFulfilled))
+ $onFulfilled(new SparkPostResponse($response));
+ }, function($exception) use ($onRejected) {
+ if (isset($onRejected))
+ $onRejected(new SparkPostException($exception));
+ });
+ }
+
+ /**
+ * Hand back the state.
+ *
+ * @return $state - returns the state of the promise
+ */
+ public function getState()
+ {
+ return $this->promise->getState();
+ }
+
+ /**
+ * Wraps the wait function and returns a custom response or throws a custom exception.
+ *
+ * @param bool $unwrap
+ *
+ * @return SparkPostResponse
+ *
+ * @throws SparkPostException
+ */
+ public function wait($unwrap = true)
+ {
+ try {
+ $response = $this->promise->wait($unwrap);
+ return $response ? new SparkPostResponse($response) : $response;
+ } catch (\Exception $exception) {
+ throw new SparkPostException($exception);
+ }
+ }
+}
diff --git a/lib/SparkPost/SparkPostResponse.php b/lib/SparkPost/SparkPostResponse.php
new file mode 100644
index 0000000..9104b33
--- /dev/null
+++ b/lib/SparkPost/SparkPostResponse.php
@@ -0,0 +1,105 @@
+<?php
+
+namespace SparkPost;
+
+use Psr\Http\Message\ResponseInterface as ResponseInterface;
+use Psr\Http\Message\StreamInterface as StreamInterface;
+
+class SparkPostResponse implements ResponseInterface
+{
+ /**
+ * ResponseInterface to be wrapped by SparkPostResponse.
+ */
+ private $response;
+
+ /**
+ * set the response to be wrapped.
+ *
+ * @param ResponseInterface $response
+ */
+ public function __construct(ResponseInterface $response)
+ {
+ $this->response = $response;
+ }
+
+ /**
+ * Returns the body.
+ *
+ * @return array $body - the json decoded body from the http response
+ */
+ public function getBody()
+ {
+ $body = $this->response->getBody();
+ $body_string = $body->__toString();
+
+ $json = json_decode($body_string, true);
+
+ return $json;
+ }
+
+ // pass these down to the response given in the constructor
+ public function getProtocolVersion()
+ {
+ return $this->response->getProtocolVersion();
+ }
+
+ public function withProtocolVersion($version)
+ {
+ return $this->response->withProtocolVersion($version);
+ }
+
+ public function getHeaders()
+ {
+ return $this->response->getHeaders();
+ }
+
+ public function hasHeader($name)
+ {
+ return $this->response->hasHeader($name);
+ }
+
+ public function getHeader($name)
+ {
+ return $this->response->getHeader($name);
+ }
+
+ public function getHeaderLine($name)
+ {
+ return $this->response->getHeaderLine($name);
+ }
+
+ public function withHeader($name, $value)
+ {
+ return $this->response->withHeader($name, $value);
+ }
+
+ public function withAddedHeader($name, $value)
+ {
+ return $this->response->withAddedHeader($name, $value);
+ }
+
+ public function withoutHeader($name)
+ {
+ return $this->response->withoutHeader($name);
+ }
+
+ public function withBody(StreamInterface $body)
+ {
+ return $this->response->withBody($body);
+ }
+
+ public function getStatusCode()
+ {
+ return $this->response->getStatusCode();
+ }
+
+ public function withStatus($code, $reasonPhrase = '')
+ {
+ return $this->response->withStatus($code, $reasonPhrase);
+ }
+
+ public function getReasonPhrase()
+ {
+ return $this->response->getReasonPhrase();
+ }
+}
diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php
deleted file mode 100644
index ff63722..0000000
--- a/lib/SparkPost/Transmission.php
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-
-namespace SparkPost;
-
-/**
- * SDK interface for managing transmissions.
- */
-class Transmission extends APIResource
-{
- public $endpoint = 'transmissions';
-
- /**
- * Mapping for values passed into the send method to the values needed for the Transmission API.
- *
- * @var array
- */
- protected static $parameterMappings = [
- 'attachments' => 'content.attachments',
- 'campaign' => 'campaign_id',
- 'customHeaders' => 'content.headers',
- 'description' => 'description',
- 'from' => 'content.from',
- 'html' => 'content.html',
- 'inlineCss' => 'options.inline_css',
- 'inlineImages' => 'content.inline_images',
- 'metadata' => 'metadata',
- 'recipientList' => 'recipients.list_id',
- 'recipients' => 'recipients',
- 'replyTo' => 'content.reply_to',
- 'returnPath' => 'return_path',
- 'rfc822' => 'content.email_rfc822',
- 'sandbox' => 'options.sandbox',
- 'startTime' => 'options.start_time',
- 'subject' => 'content.subject',
- 'substitutionData' => 'substitution_data',
- 'template' => 'content.template_id',
- 'text' => 'content.text',
- 'trackClicks' => 'options.click_tracking',
- 'trackOpens' => 'options.open_tracking',
- 'transactional' => 'options.transactional',
- 'useDraftTemplate' => 'use_draft_template',
- ];
-
- /**
- * Sets up default structure and default values for the model that is acceptable by the API.
- *
- * @var array
- */
- protected static $structure = [
- 'return_path' => 'default@sparkpostmail.com',
- 'content' => [
- 'html' => null,
- 'text' => null,
- 'email_rfc822' => null,
- ],
- 'use_draft_template' => false,
- ];
-
- /**
- * Method for issuing POST request to the Transmissions API.
- *
- * This method assumes that all the appropriate fields have
- * been populated by the user through configuration. Acceptable
- * configuration values are:
- * 'attachments': array,
- * 'campaign': string,
- * 'customHeaders': array,
- * 'description': string,
- * 'from': string,
- * 'html': string,
- * 'inlineCss': boolean,
- * 'inlineImages': array,
- * 'metadata': array,
- * 'recipientList': string,
- * 'recipients': array,
- * 'replyTo': string,
- * 'rfc822': string,
- * 'sandbox': boolean,
- * 'startTime': string | \DateTime,
- * 'subject': string,
- * 'substitutionData': array,
- * 'template': string,
- * 'text': string,
- * 'trackClicks': boolean,
- * 'trackOpens': boolean,
- * 'transactional': boolean,
- * 'useDraftTemplate': boolean
- *
- * @param array $transmissionConfig
- *
- * @return array API repsonse represented as key-value pairs
- */
- public function send($transmissionConfig)
- {
- if (isset($transmissionConfig['startTime']) && $transmissionConfig['startTime'] instanceof \DateTime) {
- $transmissionConfig['startTime'] = $transmissionConfig['startTime']->format(\DateTime::ATOM);
- }
-
- return $this->create($transmissionConfig);
- }
-
- /**
- * Method for retrieving information about all transmissions
- * Wrapper method for a cleaner interface.
- *
- * @param null|string $campaignID
- * @param null|string $templateID
- *
- * @return array result Set of transmissions
- */
- public function all($campaignID = null, $templateID = null)
- {
- $options = [];
- if ($campaignID !== null) {
- $options['campaign_id'] = $campaignID;
- }
- if ($templateID !== null) {
- $options['template_id'] = $templateID;
- }
-
- return $this->get(null, $options);
- }
-
- /**
- * Method for retrieving information about a single transmission
- * Wrapper method for a cleaner interface.
- *
- * @param string $transmissionID Identifier of the transmission to be found
- *
- * @return array result Single transmission represented in key-value pairs
- */
- public function find($transmissionID)
- {
- return $this->get($transmissionID);
- }
-}
diff --git a/test/unit/APIResourceExceptionTest.php b/test/unit/APIResourceExceptionTest.php
deleted file mode 100644
index 8ae80de..0000000
--- a/test/unit/APIResourceExceptionTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-namespace SparkPost\Test;
-
-use SparkPost\APIResponseException;
-
-class APIResourceExceptionTest extends \PHPUnit_Framework_TestCase
-{
- private $message;
- private $code;
- private $description;
- private $exception;
-
- /**
- * (non-PHPdoc).
- *
- * @before
- *
- * @see PHPUnit_Framework_TestCase::setUp()
- */
- public function setUp()
- {
- $this->message = 'Test message';
- $this->code = 400;
- $this->description = 'Test description';
- $this->exception = new APIResponseException(null, 0, $this->message, $this->code, $this->description);
- }
-
- public function testAPIMessage()
- {
- $this->assertEquals($this->message, $this->exception->getAPIMessage());
- }
-
- public function testAPICode()
- {
- $this->assertEquals($this->code, $this->exception->getAPICode());
- }
-
- public function testAPIDescription()
- {
- $this->assertEquals($this->description, $this->exception->getAPIDescription());
- }
-}
diff --git a/test/unit/APIResourceTest.php b/test/unit/APIResourceTest.php
deleted file mode 100644
index 67c37ab..0000000
--- a/test/unit/APIResourceTest.php
+++ /dev/null
@@ -1,196 +0,0 @@
-<?php
-
-namespace SparkPost\Test;
-
-use SparkPost\APIResource;
-use SparkPost\Test\TestUtils\ClassUtils;
-use Mockery;
-
-class APIResourceTest extends \PHPUnit_Framework_TestCase
-{
- private static $utils;
- private $adapterMock;
- private $resource;
-
- private function getExceptionMock($statusCode)
- {
- $exception = new \Ivory\HttpAdapter\HttpAdapterException();
- $response = Mockery::mock('Ivory\HttpAdapter\Message\ResponseInterface');
- $response->shouldReceive('getStatusCode')->andReturn($statusCode);
- $exception->setResponse($response);
-
- return $exception;
- }
-
- /**
- * (non-PHPdoc).
- *
- * @before
- *
- * @see PHPUnit_Framework_TestCase::setUp()
- */
- public function setUp()
- {
- $this->sparkPostMock = Mockery::mock('SparkPost\SparkPost', function ($mock) {
- $mock->shouldReceive('getHttpHeaders')->andReturn([]);
- });
- $this->sparkPostMock->httpAdapter = Mockery::mock();
- $this->resource = new APIResource($this->sparkPostMock);
- self::$utils = new ClassUtils($this->resource);
- self::$utils->setProperty($this->resource, 'sparkpost', $this->sparkPostMock);
- }
-
- public function tearDown()
- {
- Mockery::close();
- }
-
- public function testConstructorSetsUpSparkPostObject()
- {
- $this->sparkPostMock->newProp = 'new value';
- $this->assertEquals($this->sparkPostMock, self::$utils->getProperty($this->resource, 'sparkpost'));
- }
-
- public function testCreate()
- {
- $testInput = ['test' => 'body'];
- $testBody = ['results' => ['my' => 'test']];
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with(Mockery::type('string'), 'POST', Mockery::type('array'), json_encode($testInput))->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
-
- $this->assertEquals($testBody, $this->resource->create($testInput));
- }
-
- public function testUpdate()
- {
- $testInput = ['test' => 'body'];
- $testBody = ['results' => ['my' => 'test']];
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/.*\/test/', 'PUT', Mockery::type('array'), json_encode($testInput))->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
-
- $this->assertEquals($testBody, $this->resource->update('test', $testInput));
- }
-
- public function testGet()
- {
- $testBody = ['results' => ['my' => 'test']];
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/.*\/test/', 'GET', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
-
- $this->assertEquals($testBody, $this->resource->get('test'));
- }
-
- public function testGetCommaSeparated()
- {
- $testBody = ['results' => ['my' => 'test']];
- $requestArray = [
- 'param1' => 'param1val',
- 'param2' => ['param2val1', 'param2val2'],
- ];
- $expectedGetParams = 'param1=param1val&param2='.urlencode('param2val1,param2val2');
-
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with(matchesPattern("/.*\/test\?{$expectedGetParams}/"), 'GET', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
-
- $this->assertEquals($testBody, $this->resource->get('test', $requestArray));
- }
-
- public function testDelete()
- {
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/.*\/test/', 'DELETE', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn('');
-
- $this->assertEquals(null, $this->resource->delete('test'));
- }
-
- public function testAdapter404Exception()
- {
- try {
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(404);
-
- $this->resource->get('test');
- } catch (\Exception $e) {
- $this->assertRegExp('/.*resource does not exist.*/', $e->getMessage());
- }
- }
-
- public function testAdapter403Exception()
- {
- $testBody = ['errors' => [
- [
- 'message' => 'Forbidden.',
- ],
- ]];
- try {
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(403);
- $responseMock->shouldReceive('getBody')->andReturn(json_encode($testBody));
-
- $this->resource->get('test');
- } catch (\Exception $e) {
- $this->assertRegExp('/Request forbidden/', $e->getMessage());
- }
- }
-
- public function testAdapter4XXException()
- {
- try {
- $testBody = ['errors' => ['my' => 'test']];
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(400);
- $responseMock->shouldReceive('getBody')->andReturn(json_encode($testBody));
-
- $this->resource->get('test');
- } catch (\Exception $e) {
- $this->assertRegExp('/Received bad response.*/', $e->getMessage());
- }
- }
-
- public function testAdapter5XXException()
- {
- try {
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- andThrow(new \Exception('Something went wrong.'));
-
- $this->resource->get('test');
- } catch (\Exception $e) {
- $this->assertRegExp('/Unable to contact.*API.*/', $e->getMessage());
- }
- }
-}
diff --git a/test/unit/MessageEventTest.php b/test/unit/MessageEventTest.php
deleted file mode 100644
index 3d92412..0000000
--- a/test/unit/MessageEventTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-namespace SparkPost;
-
-use Mockery;
-
-class MessageEventTest extends \PHPUnit_Framework_TestCase
-{
- private $sparkPostMock;
- private $sut;
-
- /**
- * (non-PHPdoc).
- *
- * @before
- *
- * @see PHPUnit_Framework_TestCase::setUp()
- */
- public function setUp()
- {
- $this->sparkPostMock = Mockery::mock('SparkPost\SparkPost', function ($mock) {
- $mock->shouldReceive('getHttpHeaders')->andReturn([]);
- });
- $this->sparkPostMock->httpAdapter = Mockery::mock();
- $this->sut = new MessageEvents($this->sparkPostMock);
- }
-
- public function testDateTimeConversion()
- {
- $testBody = ['results' => ['my' => 'test']];
- $testFrom = new \DateTime('1978-08-27 04:05:02');
- $testFromStr = urlencode('1978-08-27T04:05');
- $testTo = new \DateTime('2016-04-04 19:00');
- $testToStr = urlencode('2016-04-04T19:00');
-
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with("/message-events/?from={$testFromStr}&to={$testToStr}", 'GET', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
-
- $this->assertEquals($testBody, $this->sut->search(['from' => $testFrom, 'to' => $testTo]));
- }
-
- public function testDocumentation()
- {
- $testBody = ['results' => ['my' => 'test']];
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/message-events/events/documentation', 'GET', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
-
- $this->assertEquals($testBody, $this->sut->documentation());
- }
-
- public function testSamples()
- {
- $testBody = ['results' => ['my' => 'test']];
- $responseMock = Mockery::mock();
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/message-events/events/samples?events='.urlencode('delivery,bounce'), 'GET', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($testBody));
-
- $this->assertEquals($testBody, $this->sut->samples(['delivery', 'bounce']));
- }
-}
diff --git a/test/unit/SendGridCompatibiility/EmailTest.php b/test/unit/SendGridCompatibiility/EmailTest.php
deleted file mode 100644
index 2846e9e..0000000
--- a/test/unit/SendGridCompatibiility/EmailTest.php
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php
-
-use SparkPost\SendGridCompatibility\Email;
-
-class SendGridCompatibilityEmailTest extends \PHPUnit_Framework_TestCase
-{
- private $email;
-
- public function setup()
- {
- $this->email = new Email();
- }
-
- public function testConstruct()
- {
- $email = new Email();
-
- $this->assertInstanceOf('SparkPost\SendGridCompatibility\Email', $email);
- $this->assertInternalType('array', $email->model);
- }
-
- public function testAddTo()
- {
- $fakeEmail = 'joe.schmoe@test.com';
- $this->email->addTo($fakeEmail);
-
- $this->assertEquals(array(array('address' => array('email' => $fakeEmail))), $this->email->model['recipients']);
- }
-
- public function testAddToWithName()
- {
- $fakeEmail = 'joe.schmoe@test.com';
- $fakeName = 'Joe Schmoe';
- $this->email->addTo($fakeEmail, $fakeName);
-
- $this->assertEquals(array(array('address' => array('email' => $fakeEmail, 'name' => $fakeName))), $this->email->model['recipients']);
- }
-
- public function testSetTos()
- {
- $tos = array();
- array_push($tos, array('address' => array('email' => 'joe.schmoe@test.com', 'name' => 'Joe Schmoe')));
- array_push($tos, array('address' => array('email' => 'jill.schmoe@test.com', 'name' => 'Jill Schmoe')));
- $this->email->setTos($tos);
-
- $this->assertEquals($tos, $this->email->model['recipients']);
- }
-
- public function testSetFrom()
- {
- $this->email->setFrom('test@email.com');
-
- $this->assertEquals(array('email' => 'test@email.com'), $this->email->model['from']);
- }
-
- public function testSetFromName()
- {
- $this->email->setFrom('test@email.com');
- $this->email->setFromName('Test Bot');
-
- $this->assertEquals(array('email' => 'test@email.com', 'name' => 'Test Bot'), $this->email->model['from']);
- }
-
- /**
- * @desc Tests that setting the fromName prior to setting the From field throws an exception
- * @expectedException Exception
- * @expectedExceptionMessage Must set 'From' prior to setting 'From Name'.
- */
- public function testSetFromNameWithoutAddress()
- {
- $this->email->setFromName('Test Bot');
- }
-
- public function testSetReplyto()
- {
- $this->email->setReplyTo('test@email.com');
-
- $this->assertEquals('test@email.com', $this->email->model['replyTo']);
- }
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Adding bcc recipients is not yet supported, try adding them as a 'to' address
- */
- public function testAddBcc()
- {
- $this->email->addBcc('test@email.com');
- }
-
- public function testSetSubject()
- {
- $this->email->setSubject('Awesome Subject');
-
- $this->assertEquals('Awesome Subject', $this->email->model['subject']);
- }
-
- public function testSetText()
- {
- $value = 'This is some plain/text';
- $this->email->setText($value);
-
- $this->assertEquals($value, $this->email->model['text']);
- }
-
- public function testSetHtml()
- {
- $value = '<html><body><p>This is some html</p></body></html>';
- $this->email->setHtml($value);
-
- $this->assertEquals($value, $this->email->model['html']);
- }
-
- /**
- * @desc test that adding a category throws an exception since we don't support tags at transmission level yet
- * @expectedException Exception
- * @expectedExceptionMessage Adding categories is not yet supported
- */
- public function testAddCategory()
- {
- $this->email->addCategory('');
- }
-
- /**
- * @desc Tests that setting an attachment throws a meaningful exception
- * @expectedException Exception
- * @expectedExceptionMessage Adding attachments is not yet supported
- */
- public function testAddAttachment()
- {
- $this->email->addAttachment('blah');
- }
-
- public function testAddSubstitution()
- {
- $this->email->addSubstitution('item', 'baseball bat');
-
- $this->assertEquals(array('item' => 'baseball bat'), $this->email->model['substitutionData']);
- }
-
- public function testAddSection()
- {
- $this->email->addSection('item', 'baseball bat');
-
- $this->assertEquals(array('item' => 'baseball bat'), $this->email->model['substitutionData']);
- }
-
- /**
- * @desc Tests that setting an attachment throws a meaningful exception
- * @expectedException Exception
- * @expectedExceptionMessage Adding Unique Arguments is not yet supported
- */
- public function testAddUniqueArguement()
- {
- $this->email->addUniqueArg('blah', 'someblah');
- }
-
- /**
- * @desc Tests that setting an unique argument throws a meaningful exception
- * @expectedException Exception
- * @expectedExceptionMessage Setting Unique Arguments is not yet supported
- */
- public function testSetUniqueArgs()
- {
- $this->email->setUniqueArgs(array('blah', 'andBlah'));
- }
-
- public function testAddHeader()
- {
- $value = 'My Header';
- $this->email->addHeader('X-header', $value);
-
- $this->assertEquals(array('X-header' => $value), $this->email->model['customHeaders']);
- }
-
- public function testToSparkPostTransmission()
- {
- $this->assertInternalType('array', $this->email->toSparkPostTransmission());
- }
-}
diff --git a/test/unit/SparkPostResponseTest.php b/test/unit/SparkPostResponseTest.php
new file mode 100644
index 0000000..db8600a
--- /dev/null
+++ b/test/unit/SparkPostResponseTest.php
@@ -0,0 +1,136 @@
+<?php
+namespace SparkPost\Test;
+
+use SparkPost\SparkPostResponse;
+use Psr\Http\Message\StreamInterface;
+use Psr\Http\Message\ResponseInterface;
+use Mockery;
+
+class SparkPostResponseTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * (non-PHPdoc).
+ *
+ * @before
+ *
+ * @see PHPUnit_Framework_TestCase::setUp()
+ */
+ public function setUp()
+ {
+ $this->returnValue = 'some_value_to_return';
+ $this->responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface');
+ }
+
+ public function testGetProtocolVersion()
+ {
+ $this->responseMock->shouldReceive('getProtocolVersion')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->getProtocolVersion(), $sparkpostResponse->getProtocolVersion());
+ }
+
+ public function testWithProtocolVersion()
+ {
+ $param = 'protocol version';
+
+ $this->responseMock->shouldReceive('withProtocolVersion')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->withProtocolVersion($param), $sparkpostResponse->withProtocolVersion($param));
+ }
+
+ public function testGetHeaders()
+ {
+ $this->responseMock->shouldReceive('getHeaders')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->getHeaders(), $sparkpostResponse->getHeaders());
+ }
+
+ public function testHasHeader()
+ {
+ $param = 'header';
+
+ $this->responseMock->shouldReceive('hasHeader')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->hasHeader($param), $sparkpostResponse->hasHeader($param));
+ }
+
+ public function testGetHeader()
+ {
+ $param = 'header';
+
+ $this->responseMock->shouldReceive('getHeader')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->getHeader($param), $sparkpostResponse->getHeader($param));
+ }
+
+ public function testGetHeaderLine()
+ {
+ $param = 'header';
+
+ $this->responseMock->shouldReceive('getHeaderLine')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->getHeaderLine($param), $sparkpostResponse->getHeaderLine($param));
+ }
+
+ public function testWithHeader()
+ {
+ $param = 'header';
+ $param2 = 'value';
+
+ $this->responseMock->shouldReceive('withHeader')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->withHeader($param, $param2), $sparkpostResponse->withHeader($param, $param2));
+ }
+
+ public function testWithAddedHeader()
+ {
+ $param = 'header';
+ $param2 = 'value';
+
+
+ $this->responseMock->shouldReceive('withAddedHeader')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->withAddedHeader($param, $param2), $sparkpostResponse->withAddedHeader($param, $param2));
+ }
+
+ public function testWithoutHeader()
+ {
+ $param = 'header';
+
+ $this->responseMock->shouldReceive('withoutHeader')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->withoutHeader($param), $sparkpostResponse->withoutHeader($param));
+ }
+
+ public function testWithBody()
+ {
+ $param = Mockery::mock('Psr\Http\Message\StreamInterface');
+
+ $this->responseMock->shouldReceive('withBody')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->withBody($param), $sparkpostResponse->withBody($param));
+ }
+
+ public function testGetStatusCode()
+ {
+ $this->responseMock->shouldReceive('getStatusCode')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->getStatusCode(), $sparkpostResponse->getStatusCode());
+ }
+
+ public function testWithStatus()
+ {
+ $param = 'status';
+
+ $this->responseMock->shouldReceive('withStatus')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->withStatus($param), $sparkpostResponse->withStatus($param));
+ }
+
+ public function testGetReasonPhrase()
+ {
+ $this->responseMock->shouldReceive('getReasonPhrase')->andReturn($this->returnValue);
+ $sparkpostResponse = new SparkPostResponse($this->responseMock);
+ $this->assertEquals($this->responseMock->getReasonPhrase(), $sparkpostResponse->getReasonPhrase());
+ }
+}
+?> \ No newline at end of file
diff --git a/test/unit/SparkPostTest.php b/test/unit/SparkPostTest.php
index 26563c3..c5dca08 100644
--- a/test/unit/SparkPostTest.php
+++ b/test/unit/SparkPostTest.php
@@ -2,18 +2,43 @@
namespace SparkPost\Test;
-use Ivory\HttpAdapter\CurlHttpAdapter;
-use Mockery;
use SparkPost\SparkPost;
+use SparkPost\SparkPostResponse;
+use SparkPost\SparkPostPromise;
+use Psr\Http\Message\ResponseInterface;
+use Http\Promise\Promise;
+use GuzzleHttp\Promise\Promise as GuzzlePromise;
+use GuzzleHttp\Promise\FulfilledPromise as GuzzleFulfilledPromise;
+use GuzzleHttp\Promise\RejectedPromise as GuzzleRejectedPromise;
+use Http\Adapter\Guzzle6\Promise as GuzzleAdapterPromise;
+use Http\Client\Exception\HttpException;
+use Http\Adapter\Guzzle6\Client;
+use Mockery;
use SparkPost\Test\TestUtils\ClassUtils;
class SparkPostTest extends \PHPUnit_Framework_TestCase
{
private static $utils;
- private $adapterMock;
+ private $clientMock;
/** @var SparkPost */
private $resource;
+ private $postTransmissionPayload = [
+ 'content' => [
+ 'from' => [ 'name' => 'Sparkpost Team', 'email' => 'postmaster@sendmailfor.me' ],
+ 'subject' => 'First Mailing From PHP',
+ 'text' => 'Congratulations, {{name}}!! You just sent your very first mailing!',
+ ],
+ 'substitution_data' => ['name' => 'Avi'],
+ 'recipients' => [
+ ['address' => 'avi.goldman@sparkpost.com']
+ ]
+ ];
+
+ private $getTransmissionPayload = [
+ 'campaign_id' => 'thanksgiving'
+ ];
+
/**
* (non-PHPdoc).
*
@@ -24,14 +49,10 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
//setup mock for the adapter
- $this->adapterMock = Mockery::mock('Ivory\HttpAdapter\HttpAdapterInterface', function ($mock) {
- $mock->shouldReceive('setConfiguration');
- $mock->shouldReceive('getConfiguration->getUserAgent')->andReturn('php-sparkpost/0.2.0');
- });
+ $this->clientMock = Mockery::mock('Http\Adapter\Guzzle6\Client');
- $this->resource = new SparkPost($this->adapterMock, ['key' => 'a key']);
+ $this->resource = new SparkPost($this->clientMock, ['key' => 'SPARKPOST_API_KEY']);
self::$utils = new ClassUtils($this->resource);
- self::$utils->setProperty($this->resource, 'httpAdapter', $this->adapterMock);
}
public function tearDown()
@@ -39,45 +60,221 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase
Mockery::close();
}
- /**
- * @desc Ensures that the configuration class is not instantiable.
- */
- public function testConstructorSetsUpTransmissions()
+ public function testRequest() {
+ $responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface');
+ $this->resource->setOptions(['async' => false]);
+ $this->resource->httpClient->shouldReceive('sendRequest')->andReturn($responseMock);
+ $this->assertInstanceOf('SparkPost\SparkPostResponse', $this->resource->request('POST', 'transmissions', $this->postTransmissionPayload));
+
+
+ $promiseMock = Mockery::mock('Http\Promise\Promise');
+ $this->resource->setOptions(['async' => true]);
+ $this->resource->httpClient->shouldReceive('sendAsyncRequest')->andReturn($promiseMock);
+ $this->assertInstanceOf('SparkPost\SparkPostPromise', $this->resource->request('GET', 'transmissions', $this->getTransmissionPayload));
+ }
+
+ public function testSuccessfulSyncRequest()
{
- $sparky = new SparkPost(new CurlHttpAdapter(), ['key' => 'a key']);
- $this->assertEquals('SparkPost\Transmission', get_class($sparky->transmission));
- $adapter = self::$utils->getProperty($this->resource, 'httpAdapter');
- $this->assertRegExp('/php-sparkpost.*/', $adapter->getConfiguration()->getUserAgent());
+ $responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface');
+ $responseBodyMock = Mockery::mock();
+
+ $responseBody = ['results' => 'yay'];
+
+ $this->resource->httpClient->shouldReceive('sendRequest')->
+ once()->
+ with(Mockery::type('GuzzleHttp\Psr7\Request'))->
+ andReturn($responseMock);
+
+ $responseMock->shouldReceive('getStatusCode')->andReturn(200);
+ $responseMock->shouldReceive('getBody')->andReturn($responseBodyMock);
+ $responseBodyMock->shouldReceive('__toString')->andReturn(json_encode($responseBody));
+
+ $response = $this->resource->syncRequest('POST', 'transmissions', $this->postTransmissionPayload);
+
+ $this->assertEquals($responseBody, $response->getBody());
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+
+ public function testUnsuccessfulSyncRequest()
+ {
+ $exceptionMock = Mockery::mock('Http\Client\Exception\HttpException');
+
+ $responseBody = ['results' => 'failed'];
+
+ $this->resource->httpClient->shouldReceive('sendRequest')->
+ once()->
+ with(Mockery::type('GuzzleHttp\Psr7\Request'))->
+ andThrow($exceptionMock);
+
+ $exceptionMock->shouldReceive('getResponse->getStatusCode')->andReturn(500);
+ $exceptionMock->shouldReceive('getResponse->getBody->__toString')->andReturn(json_encode($responseBody));
+
+ try {
+ $this->resource->syncRequest('POST', 'transmissions', $this->postTransmissionPayload);
+ } catch (\Exception $e) {
+ $this->assertEquals($responseBody, $e->getBody());
+ $this->assertEquals(500, $e->getCode());
+ }
}
- public function testSetConfigStringKey()
+ public function testSuccessfulAsyncRequestWithWait()
{
- $this->resource->setConfig('a key');
- $config = self::$utils->getProperty($this->resource, 'config');
- $this->assertEquals('a key', $config['key']);
+ $promiseMock = Mockery::mock('Http\Promise\Promise');
+ $responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface');
+ $responseBodyMock = Mockery::mock();
+
+ $responseBody = ['results' => 'yay'];
+
+ $this->resource->httpClient->shouldReceive('sendAsyncRequest')->
+ once()->
+ with(Mockery::type('GuzzleHttp\Psr7\Request'))->
+ andReturn($promiseMock);
+
+ $promiseMock->shouldReceive('wait')->andReturn($responseMock);
+
+ $responseMock->shouldReceive('getStatusCode')->andReturn(200);
+ $responseMock->shouldReceive('getBody')->andReturn($responseBodyMock);
+ $responseBodyMock->shouldReceive('__toString')->andReturn(json_encode($responseBody));
+
+ $promise = $this->resource->asyncRequest('POST', 'transmissions', $this->postTransmissionPayload);
+
+ $response = $promise->wait();
+
+ $this->assertEquals($responseBody, $response->getBody());
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+
+ public function testUnsuccessfulAsyncRequestWithWait()
+ {
+ $promiseMock = Mockery::mock('Http\Promise\Promise');
+ $exceptionMock = Mockery::mock('Http\Client\Exception\HttpException');
+
+ $responseBody = ['results' => 'failed'];
+
+ $this->resource->httpClient->shouldReceive('sendAsyncRequest')->
+ once()->
+ with(Mockery::type('GuzzleHttp\Psr7\Request'))->
+ andReturn($promiseMock);
+
+ $promiseMock->shouldReceive('wait')->andThrow($exceptionMock);
+
+ $exceptionMock->shouldReceive('getResponse->getStatusCode')->andReturn(500);
+ $exceptionMock->shouldReceive('getResponse->getBody->__toString')->andReturn(json_encode($responseBody));
+
+ $promise = $this->resource->asyncRequest('POST', 'transmissions', $this->postTransmissionPayload);
+
+ try {
+ $response = $promise->wait();
+ } catch (\Exception $e) {
+ $this->assertEquals($responseBody, $e->getBody());
+ $this->assertEquals(500, $e->getCode());
+ }
+ }
+
+ public function testSuccessfulAsyncRequestWithThen() {
+ $responseBody = ['results' => 'yay'];
+ $responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface');
+ $responseBodyMock = Mockery::mock();
+ $responseMock->shouldReceive('getStatusCode')->andReturn(200);
+ $responseMock->shouldReceive('getBody')->andReturn($responseBodyMock);
+ $responseBodyMock->shouldReceive('__toString')->andReturn(json_encode($responseBody));
+
+ $guzzlePromise = new GuzzleFulfilledPromise($responseMock);
+
+ $promise = new SparkPostPromise(new GuzzleAdapterPromise($guzzlePromise, $this->resource->buildRequest('POST', 'transmissions', $this->postTransmissionPayload, [])));
+
+ $promise->then(function ($exception) use ($responseBody) {
+ $this->assertEquals(200, $exception->getStatusCode());
+ $this->assertEquals($responseBody, $exception->getBody());
+ }, null)->wait();
+ }
+
+ public function testUnsuccessfulAsyncRequestWithThen() {
+ $responseBody = ['results' => 'failed'];
+ $exceptionMock = Mockery::mock('Http\Client\Exception\HttpException');
+ $exceptionMock->shouldReceive('getResponse->getStatusCode')->andReturn(500);
+ $exceptionMock->shouldReceive('getResponse->getBody->__toString')->andReturn(json_encode($responseBody));
+
+ $guzzlePromise = new GuzzleRejectedPromise($exceptionMock);
+
+ $promise = new SparkPostPromise(new GuzzleAdapterPromise($guzzlePromise, $this->resource->buildRequest('POST', 'transmissions', $this->postTransmissionPayload, [])));
+
+ $promise->then(null, function ($exception) use ($responseBody) {
+ $this->assertEquals(500, $exception->getCode());
+ $this->assertEquals($responseBody, $exception->getBody());
+ })->wait();
+ }
+
+ public function testPromise()
+ {
+ $promiseMock = Mockery::mock('Http\Promise\Promise');
+
+ $this->resource->httpClient->shouldReceive('sendAsyncRequest')->
+ once()->
+ with(Mockery::type('GuzzleHttp\Psr7\Request'))->
+ andReturn($promiseMock);
+
+ $promise = $this->resource->asyncRequest('POST', 'transmissions', $this->postTransmissionPayload);
+
+ $promiseMock->shouldReceive('getState')->twice()->andReturn('pending');
+ $this->assertEquals($promiseMock->getState(), $promise->getState());
+
+ $promiseMock->shouldReceive('getState')->once()->andReturn('rejected');
+ $this->assertEquals('rejected', $promise->getState());
}
/**
* @expectedException Exception
- * @expectedExceptionMessageRegExp /API key/
*/
- public function testSetBadConfig()
+ public function testUnsupportedAsyncRequest()
{
- $this->resource->setConfig(['not' => 'a key']);
+
+ $this->resource->setHttpClient(Mockery::mock('Http\Client\HttpClient'));
+
+ $this->resource->asyncRequest('POST', 'transmissions', $this->postTransmissionPayload);
+ }
+
+ public function testGetHttpHeaders()
+ {
+ $headers = $this->resource->getHttpHeaders([
+ 'Custom-Header' => 'testing'
+ ]);
+
+ $version = self::$utils->getProperty($this->resource, 'version');
+
+ $this->assertEquals('SPARKPOST_API_KEY', $headers['Authorization']);
+ $this->assertEquals('application/json', $headers['Content-Type']);
+ $this->assertEquals('testing', $headers['Custom-Header']);
+ $this->assertEquals('php-sparkpost/'.$version, $headers['User-Agent']);
+ }
+
+ public function testGetUrl()
+ {
+ $url = 'https://api.sparkpost.com:443/api/v1/transmissions?key=value 1,value 2,value 3';
+ $testUrl = $this->resource->getUrl('transmissions', ['key' => ['value 1', 'value 2', 'value 3']]);
+ $this->assertEquals($url, $testUrl);
+ }
+
+ public function testSetHttpClient()
+ {
+ $this->resource->setHttpClient($this->clientMock);
+ $this->assertEquals($this->clientMock, self::$utils->getProperty($this->resource, 'httpClient'));
}
- public function testGetHeaders()
+ public function testSetOptionsStringKey()
{
- $results = $this->resource->getHttpHeaders();
- $this->assertEquals('a key', $results['Authorization']);
- $this->assertEquals('application/json', $results['Content-Type']);
+ $this->resource->setOptions('SPARKPOST_API_KEY');
+ $options = self::$utils->getProperty($this->resource, 'options');
+ $this->assertEquals('SPARKPOST_API_KEY', $options['key']);
}
- public function testSetUnwrapped()
+ /**
+ * @expectedException Exception
+ */
+ public function testSetBadOptions()
{
- $results = $this->resource->setupUnwrapped('ASweetEndpoint');
- $this->assertEquals($this->resource->ASweetEndpoint, $results);
- $this->assertInstanceOf('SparkPost\APIResource', $results);
- $this->assertEquals('ASweetEndpoint', $results->endpoint);
+ self::$utils->setProperty($this->resource, 'options', []);
+ $this->resource->setOptions(['not' => 'SPARKPOST_API_KEY']);
}
+
}
diff --git a/test/unit/TransmissionTest.php b/test/unit/TransmissionTest.php
deleted file mode 100644
index d606c53..0000000
--- a/test/unit/TransmissionTest.php
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-
-namespace SparkPost\Test;
-
-use SparkPost\Transmission;
-use SparkPost\Test\TestUtils\ClassUtils;
-use Mockery;
-
-class TransmissionTest extends \PHPUnit_Framework_TestCase
-{
- private static $utils;
- private $sparkPostMock;
- private $resource;
-
- /**
- * (non-PHPdoc).
- *
- * @before
- *
- * @see PHPUnit_Framework_TestCase::setUp()
- */
- public function setUp()
- {
- $this->sparkPostMock = Mockery::mock('SparkPost\SparkPost', function ($mock) {
- $mock->shouldReceive('getHttpHeaders')->andReturn([]);
- });
- $this->sparkPostMock->httpAdapter = Mockery::mock();
- $this->resource = new Transmission($this->sparkPostMock);
- self::$utils = new ClassUtils($this->resource);
- }
-
- public function tearDown()
- {
- Mockery::close();
- }
-
- public function testSend()
- {
- $responseMock = Mockery::mock();
- $body = ['text' => 'awesomesauce', 'content' => ['subject' => 'awesomeness']];
- $responseBody = ['results' => 'yay'];
-
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/.*\/transmissions/', 'POST', Mockery::type('array'), Mockery::type('string'))->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
-
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
-
- $this->assertEquals($responseBody, $this->resource->send($body));
- }
-
- public function testSendDateTimeConversion()
- {
- $testStartTime = new \DateTime('2016-08-27 13:01:02', new \DateTimeZone('UTC'));
-
- $responseMock = Mockery::mock();
- $responseBody = ['results' => 'yay'];
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/.*\/transmissions/', 'POST', Mockery::type('array'), matchesPattern('/"start_time":"2016-08-27T13:01:02\+00:00"/'))->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
-
- $this->assertEquals($responseBody, $this->resource->send(['startTime' => $testStartTime]));
- }
-
- public function testAllWithFilter()
- {
- $responseMock = Mockery::mock();
- $responseBody = ['results' => 'yay'];
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/.*transmissions.*?campaign_id=campaign&template_id=template/', 'GET', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
-
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
-
- $this->assertEquals($responseBody, $this->resource->all('campaign', 'template'));
- }
-
- public function testAllWithOutFilter()
- {
- $responseMock = Mockery::mock();
- $responseBody = ['results' => 'yay'];
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/.*\/transmissions/', 'GET', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
-
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
-
- $this->assertEquals($responseBody, $this->resource->all());
- }
-
- public function testFind()
- {
- $responseMock = Mockery::mock();
- $responseBody = ['results' => 'yay'];
- $this->sparkPostMock->httpAdapter->shouldReceive('send')->
- once()->
- with('/.*\/transmissions.*\/test/', 'GET', Mockery::type('array'), null)->
- andReturn($responseMock);
- $responseMock->shouldReceive('getStatusCode')->andReturn(200);
-
- $responseMock->shouldReceive('getBody->getContents')->andReturn(json_encode($responseBody));
-
- $this->assertEquals($responseBody, $this->resource->find('test'));
- }
-}