protected function checkResponse(array $response)
    {
        $responseCode = intval(array_get($response, '_curl_info.http_code'));
        $message = array_get($response, 'message');

        if ($responseCode >= 400) {
            $context = ['response_headers' => array_get($response, '_curl_info.response_headers')];
            throw new RestException($responseCode, $message, null, null, $context);
        }
    }