Merge pull request #60 from jchamberlain/raw-response

Return non-JSON response data
This commit is contained in:
Travis Swientek 2014-11-17 17:24:52 -08:00
commit 0a62c7cbe1

View File

@ -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);