mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
Return non-JSON response data
This commit is contained in:
parent
7f2fa66030
commit
c6346e80df
@ -117,9 +117,11 @@ class RestClient{
|
||||
public function responseHandler($responseObj){
|
||||
$httpResponseCode = $responseObj->getStatusCode();
|
||||
if($httpResponseCode === 200){
|
||||
$jsonResponseData = json_decode($responseObj->getBody(), false);
|
||||
$data = (string) $responseObj->getBody();
|
||||
$jsonResponseData = json_decode($data, false);
|
||||
$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){
|
||||
throw new MissingRequiredParameters(EXCEPTION_MISSING_REQUIRED_PARAMETERS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user