src/StackTonic/Calendly/Rest/Api.php
/**
     * Create the best possible exception for the response.
     *
     * Attempts to parse the response for Twilio Standard error messages and use
     * those to populate the exception, falls back to generic error message and
     * HTTP status code.
     *
     * @param Response $response Error response
     * @param string $header Header for exception message
     * @return CalendlyException
     */
Create the best possible exception for the response.
Attempts to parse the response for Twilio Standard error messages and use
those to populate the exception, falls back to generic error message and
HTTP status code.

@param Response $response Error response
@param string $header Header for exception message
@return CalendlyException
Create the best possible exception for the response . Attempts to parse the response for Twilio Standard error messages and use those to populate the exception falls back to generic error message and HTTP status code . @param Response $response Error response @param string $header Header for exception message @return CalendlyException
protected function exception(Response $response, string $header): CalendlyException {
        $message = '[HTTP ' . $response->getStatusCode() . '] ' . $header;
        $content = $response->getContent();
        if (\is_array($content)) {
            $message .= isset($content['message']) ? ': ' . $content['message'] : '';
            $code = isset($content['code']) ? $content['code'] : $response->getStatusCode();
            $moreInfo = $content['more_info'] ?? '';
            $details = $content['details'] ?? [];
            return new RestException($message, $code, $response->getStatusCode(), $moreInfo, $details);
        }
        return new RestException($message, $response->getStatusCode(), $response->getStatusCode());
    }
protected function exception ( Response $ response , string $ header ) : CalendlyException { $ message = '[HTTP ' . $ response -> getStatusCode ( ) . '] ' . $ header ; $ content = $ response -> getContent ( ) ; if ( \ is_array ( $ content ) ) { $ message .= isset ( $ content [ 'message' ] ) ? ': ' . $ content [ 'message' ] : '' ; $ code = isset ( $ content [ 'code' ] ) ? $ content [ 'code' ] : $ response -> getStatusCode ( ) ; $ moreInfo = $ content [ 'more_info' ] ?? '' ; $ details = $ content [ 'details' ] ?? [ ] ; return new RestException ( $ message , $ code , $ response -> getStatusCode ( ) , $ moreInfo , $ details ) ; } return new RestException ( $ message , $ response -> getStatusCode ( ) , $ response -> getStatusCode ( ) ) ; }
Create the best possible exception for the response.
Create the best possible exception for the response .