From 73d7f71c996b6807d06a223bf57c2337d53950da Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Thu, 28 Feb 2019 18:27:27 +0300 Subject: [PATCH] add getters for response & raw response --- composer.json | 3 ++- lib/RetailCrm/Response/ApiResponse.php | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8a227ea..9f5383d 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ ], "require": { "php": ">=5.4.0", - "ext-curl": "*" + "ext-curl": "*", + "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "4.*", diff --git a/lib/RetailCrm/Response/ApiResponse.php b/lib/RetailCrm/Response/ApiResponse.php index 7e2f776..ca64302 100644 --- a/lib/RetailCrm/Response/ApiResponse.php +++ b/lib/RetailCrm/Response/ApiResponse.php @@ -33,6 +33,9 @@ class ApiResponse implements \ArrayAccess // HTTP response status code protected $statusCode; + // raw json response + protected $rawResponse; + // response assoc array protected $response; @@ -47,6 +50,7 @@ class ApiResponse implements \ArrayAccess public function __construct($statusCode, $responseBody = null) { $this->statusCode = (int) $statusCode; + $this->rawResponse = $responseBody; if (!empty($responseBody)) { $response = json_decode($responseBody, true); @@ -72,6 +76,26 @@ class ApiResponse implements \ArrayAccess return $this->statusCode; } + /** + * Return HTTP response + * + * @return int + */ + public function getResponse() + { + return $this->response; + } + + /** + * Return HTTP raw response body + * + * @return int + */ + public function getResponseBody() + { + return $this->rawResponse; + } + /** * HTTP request was successful *