public function processResponse($responseArray, $dataKey = null)
    {
        if ($responseArray === null) {
            //Something went wrong, Checking HTTP Codes
            $httpOK = 200; //Request Successful, OK.
            $httpCreated = 201; //Create Successful.

            //should be null if any other library used for http calls
            $httpCode = CurlRequest::$lastHttpCode;

            if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated) {
                throw new Exception\CurlException("Request failed with HTTP Code $httpCode.");
            }
        }

        if (isset($responseArray['errors'])) {
            $message = $this->castString($responseArray['errors']);

            throw new ApiException($message);
        }

        if ($dataKey && isset($responseArray[$dataKey])) {
            return $responseArray[$dataKey];
        } else {
            return $responseArray;
        }
    }
public function processResponse($responseArray, $dataKey = null)
    {
        if ($responseArray === null) {
            //Something went wrong, Checking HTTP Codes
            $httpOK = 200; //Request Successful, OK.
            $httpCreated = 201; //Create Successful.

            //should be null if any other library used for http calls
            $httpCode = CurlRequest::$lastHttpCode;

            if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated) {
                throw new Exception\CurlException("Request failed with HTTP Code $httpCode.");
            }
        }

        if (isset($responseArray['errors'])) {
            $message = $this->castString($responseArray['errors']);

            throw new ApiException($message);
        }

        if ($dataKey && isset($responseArray[$dataKey])) {
            return $responseArray[$dataKey];
        } else {
            return $responseArray;
        }
    }
public function processResponse ( $ responseArray , $ dataKey = null ) { if ( $ responseArray === null ) { //Something went wrong, Checking HTTP Codes $ httpOK = 200 ; //Request Successful, OK. $ httpCreated = 201 ; //Create Successful. //should be null if any other library used for http calls $ httpCode = CurlRequest :: $ lastHttpCode ; if ( $ httpCode != null && $ httpCode != $ httpOK && $ httpCode != $ httpCreated ) { throw new Exception \ CurlException ( "Request failed with HTTP Code $httpCode." ) ; } } if ( isset ( $ responseArray [ 'errors' ] ) ) { $ message = $ this -> castString ( $ responseArray [ 'errors' ] ) ; throw new ApiException ( $ message ) ; } if ( $ dataKey && isset ( $ responseArray [ $ dataKey ] ) ) { return $ responseArray [ $ dataKey ] ; } else { return $ responseArray ; } }
Process the request response

@param array $responseArray Request response in array format
@param string $dataKey Keyname to fetch data from response array

@throws ApiException if the response has an error specified
@throws CurlException if response received with unexpected HTTP code.

@return array
Process the request response