protected function response($respBody, $respHeaders, $respCode)
    {
        // Handle non successful HTTP status codes
        if ($respCode > 400) {
            $type = $respCode > 500 ? 'Internal error' : 'Request error';
            throw new GeneralException(
                'The request to NeverBounce was unsuccessful '
                . 'Try the request again, if this error persists'
                . ' let us know at support@neverbounce.com.'
                . "\n\n($type [status $respCode: $respBody])"
            );
        }

        // Check that the response type is expected
        $contentType = $respHeaders['content-type'];
        if ($this->acceptedType !== $contentType) {
            throw new GeneralException(
                'The request to NeverBounce was unsuccessful '
                . "Expected a response type of '{$this->acceptedType}' but "
                . "received a response type of '{$contentType}. "
                . 'Try the request again, if this error persists'
                . ' let us know at support@neverbounce.com.'
                . "\n\n(Unexpected Type [status $respCode: $respBody])"
            );
        }

        // Handle response based on Content-Type
        if ($this->acceptedType === 'application/json') {
            return $this->jsonResponse($respBody, $respCode);
        }

        return $this->decodedResponse = $respBody;
    }
protected function response($respBody, $respHeaders, $respCode)
    {
        // Handle non successful HTTP status codes
        if ($respCode > 400) {
            $type = $respCode > 500 ? 'Internal error' : 'Request error';
            throw new GeneralException(
                'The request to NeverBounce was unsuccessful '
                . 'Try the request again, if this error persists'
                . ' let us know at support@neverbounce.com.'
                . "\n\n($type [status $respCode: $respBody])"
            );
        }

        // Check that the response type is expected
        $contentType = $respHeaders['content-type'];
        if ($this->acceptedType !== $contentType) {
            throw new GeneralException(
                'The request to NeverBounce was unsuccessful '
                . "Expected a response type of '{$this->acceptedType}' but "
                . "received a response type of '{$contentType}. "
                . 'Try the request again, if this error persists'
                . ' let us know at support@neverbounce.com.'
                . "\n\n(Unexpected Type [status $respCode: $respBody])"
            );
        }

        // Handle response based on Content-Type
        if ($this->acceptedType === 'application/json') {
            return $this->jsonResponse($respBody, $respCode);
        }

        return $this->decodedResponse = $respBody;
    }
protected function response ( $ respBody , $ respHeaders , $ respCode ) { // Handle non successful HTTP status codes if ( $ respCode > 400 ) { $ type = $ respCode > 500 ? 'Internal error' : 'Request error' ; throw new GeneralException ( 'The request to NeverBounce was unsuccessful ' . 'Try the request again, if this error persists' . ' let us know at support@neverbounce.com.' . "\n\n($type [status $respCode: $respBody])" ) ; } // Check that the response type is expected $ contentType = $ respHeaders [ 'content-type' ] ; if ( $ this -> acceptedType !== $ contentType ) { throw new GeneralException ( 'The request to NeverBounce was unsuccessful ' . "Expected a response type of '{$this->acceptedType}' but " . "received a response type of '{$contentType}. " . 'Try the request again, if this error persists' . ' let us know at support@neverbounce.com.' . "\n\n(Unexpected Type [status $respCode: $respBody])" ) ; } // Handle response based on Content-Type if ( $ this -> acceptedType === 'application/json' ) { return $ this -> jsonResponse ( $ respBody , $ respCode ) ; } return $ this -> decodedResponse = $ respBody ; }
Parses the response string and handles any errors
@param $respBody
@param $respHeaders
@param $respCode
@return mixed
@throws GeneralException
Parses the response string and handles any errors