summaryrefslogtreecommitdiffstats
path: root/lib/SparkPost/SparkPostPromise.php
diff options
context:
space:
mode:
authorAvi Goldman <avrahamymgoldman@gmail.com>2017-01-06 09:09:36 -0500
committerGitHub <noreply@github.com>2017-01-06 09:09:36 -0500
commitf4cb5267c58cbd0b3a4bd06d22aca5c52c2ff765 (patch)
tree590ea1a6299fba349d0b720c0ac9f9309a7121dd /lib/SparkPost/SparkPostPromise.php
parentc54abe82f41d7a6f1b857adf4610d82dba020426 (diff)
parent1abdc8bde168614ce055f9709de5dc788a7a46b9 (diff)
downloadphp-sparkpost-f4cb5267c58cbd0b3a4bd06d22aca5c52c2ff765.zip
php-sparkpost-f4cb5267c58cbd0b3a4bd06d22aca5c52c2ff765.tar.gz
php-sparkpost-f4cb5267c58cbd0b3a4bd06d22aca5c52c2ff765.tar.bz2
Added debug option
Added debug option
Diffstat (limited to 'lib/SparkPost/SparkPostPromise.php')
-rw-r--r--lib/SparkPost/SparkPostPromise.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/SparkPost/SparkPostPromise.php b/lib/SparkPost/SparkPostPromise.php
index df715d5..b7ded0c 100644
--- a/lib/SparkPost/SparkPostPromise.php
+++ b/lib/SparkPost/SparkPostPromise.php
@@ -12,13 +12,19 @@ class SparkPostPromise implements HttpPromise
private $promise;
/**
+ * Array with the request values sent.
+ */
+ private $request;
+
+ /**
* set the promise to be wrapped.
*
* @param HttpPromise $promise
*/
- public function __construct(HttpPromise $promise)
+ public function __construct(HttpPromise $promise, $request = null)
{
$this->promise = $promise;
+ $this->request = $request;
}
/**
@@ -29,13 +35,15 @@ class SparkPostPromise implements HttpPromise
*/
public function then(callable $onFulfilled = null, callable $onRejected = null)
{
- return $this->promise->then(function ($response) use ($onFulfilled) {
+ $request = $this->request;
+
+ return $this->promise->then(function ($response) use ($onFulfilled, $request) {
if (isset($onFulfilled)) {
- $onFulfilled(new SparkPostResponse($response));
+ $onFulfilled(new SparkPostResponse($response, $request));
}
- }, function ($exception) use ($onRejected) {
+ }, function ($exception) use ($onRejected, $request) {
if (isset($onRejected)) {
- $onRejected(new SparkPostException($exception));
+ $onRejected(new SparkPostException($exception, $request));
}
});
}
@@ -64,9 +72,9 @@ class SparkPostPromise implements HttpPromise
try {
$response = $this->promise->wait($unwrap);
- return $response ? new SparkPostResponse($response) : $response;
+ return $response ? new SparkPostResponse($response, $this->request) : $response;
} catch (\Exception $exception) {
- throw new SparkPostException($exception);
+ throw new SparkPostException($exception, $this->request);
}
}
}