diff options
-rw-r--r-- | lib/SparkPost/SparkPostException.php | 18 | ||||
-rw-r--r-- | lib/SparkPost/SparkPostResponse.php | 18 |
2 files changed, 34 insertions, 2 deletions
diff --git a/lib/SparkPost/SparkPostException.php b/lib/SparkPost/SparkPostException.php index ca92e24..ee4664c 100644 --- a/lib/SparkPost/SparkPostException.php +++ b/lib/SparkPost/SparkPostException.php @@ -12,12 +12,19 @@ class SparkPostException extends \Exception private $body = null; /** + * Array with the request values sent + */ + private $request; + + /** * Sets up the custom exception and copies over original exception values. * * @param Exception $exception - the exception to be wrapped */ - public function __construct(\Exception $exception) + public function __construct(\Exception $exception, $request) { + $this->request = $request; + $message = $exception->getMessage(); $code = $exception->getCode(); if ($exception instanceof HttpException) { @@ -30,6 +37,15 @@ class SparkPostException extends \Exception } /** + * Returns the request values sent + * + * @return Array $request + */ + public function getRequest() { + return $this->request; + } + + /** * Returns the body. * * @return array $body - the json decoded body from the http response diff --git a/lib/SparkPost/SparkPostResponse.php b/lib/SparkPost/SparkPostResponse.php index e6a8fd1..ef1be92 100644 --- a/lib/SparkPost/SparkPostResponse.php +++ b/lib/SparkPost/SparkPostResponse.php @@ -4,6 +4,7 @@ namespace SparkPost; use Psr\Http\Message\ResponseInterface as ResponseInterface; use Psr\Http\Message\StreamInterface as StreamInterface; +use Psr\Http\Message\RequestInterface as RequestInterface; class SparkPostResponse implements ResponseInterface { @@ -13,13 +14,28 @@ class SparkPostResponse implements ResponseInterface private $response; /** + * Array with the request values sent + */ + private $request; + + /** * set the response to be wrapped. * * @param ResponseInterface $response */ - public function __construct(ResponseInterface $response) + public function __construct(ResponseInterface $response, $request) { $this->response = $response; + $this->request = $request; + } + + /** + * Returns the request values sent + * + * @return Array $request + */ + public function getRequest() { + return $this->request; } /** |