add getters for response & raw response
This commit is contained in:
parent
0951e3cfb3
commit
73d7f71c99
@ -13,7 +13,8 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.4.0",
|
"php": ">=5.4.0",
|
||||||
"ext-curl": "*"
|
"ext-curl": "*",
|
||||||
|
"ext-json": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "4.*",
|
"phpunit/phpunit": "4.*",
|
||||||
|
@ -33,6 +33,9 @@ class ApiResponse implements \ArrayAccess
|
|||||||
// HTTP response status code
|
// HTTP response status code
|
||||||
protected $statusCode;
|
protected $statusCode;
|
||||||
|
|
||||||
|
// raw json response
|
||||||
|
protected $rawResponse;
|
||||||
|
|
||||||
// response assoc array
|
// response assoc array
|
||||||
protected $response;
|
protected $response;
|
||||||
|
|
||||||
@ -47,6 +50,7 @@ class ApiResponse implements \ArrayAccess
|
|||||||
public function __construct($statusCode, $responseBody = null)
|
public function __construct($statusCode, $responseBody = null)
|
||||||
{
|
{
|
||||||
$this->statusCode = (int) $statusCode;
|
$this->statusCode = (int) $statusCode;
|
||||||
|
$this->rawResponse = $responseBody;
|
||||||
|
|
||||||
if (!empty($responseBody)) {
|
if (!empty($responseBody)) {
|
||||||
$response = json_decode($responseBody, true);
|
$response = json_decode($responseBody, true);
|
||||||
@ -72,6 +76,26 @@ class ApiResponse implements \ArrayAccess
|
|||||||
return $this->statusCode;
|
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
|
* HTTP request was successful
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user