summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Goldman <avrahamymgoldman@gmail.com>2017-01-04 09:17:57 -0500
committerAvi Goldman <avrahamymgoldman@gmail.com>2017-01-04 09:17:57 -0500
commit73baa0387523238a0f3695c2851fca3e149672c0 (patch)
treeaab1b9c325f098665a6503e966ecbd72fc77efee
parentac95fe18ba4f58d713e2f04c6b0807b63947dd89 (diff)
downloadphp-sparkpost-73baa0387523238a0f3695c2851fca3e149672c0.zip
php-sparkpost-73baa0387523238a0f3695c2851fca3e149672c0.tar.gz
php-sparkpost-73baa0387523238a0f3695c2851fca3e149672c0.tar.bz2
added functions in error and response for getting out the request in debug mode
-rw-r--r--lib/SparkPost/SparkPostException.php18
-rw-r--r--lib/SparkPost/SparkPostResponse.php18
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;
}
/**