mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-30 00:46:04 +03:00
Merge pull request #60 from jchamberlain/raw-response
Return non-JSON response data
This commit is contained in:
commit
0a62c7cbe1
@ -117,9 +117,11 @@ class RestClient{
|
|||||||
public function responseHandler($responseObj){
|
public function responseHandler($responseObj){
|
||||||
$httpResponseCode = $responseObj->getStatusCode();
|
$httpResponseCode = $responseObj->getStatusCode();
|
||||||
if($httpResponseCode === 200){
|
if($httpResponseCode === 200){
|
||||||
$jsonResponseData = json_decode($responseObj->getBody(), false);
|
$data = (string) $responseObj->getBody();
|
||||||
|
$jsonResponseData = json_decode($data, false);
|
||||||
$result = new \stdClass();
|
$result = new \stdClass();
|
||||||
$result->http_response_body = $jsonResponseData;
|
// return response data as json if possible, raw if not
|
||||||
|
$result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData;
|
||||||
}
|
}
|
||||||
elseif($httpResponseCode == 400){
|
elseif($httpResponseCode == 400){
|
||||||
throw new MissingRequiredParameters(EXCEPTION_MISSING_REQUIRED_PARAMETERS);
|
throw new MissingRequiredParameters(EXCEPTION_MISSING_REQUIRED_PARAMETERS);
|
||||||
|
Loading…
Reference in New Issue
Block a user