phaxio/api.py
def parse_response(self, response):
        """Parses the API response and raises appropriate
        errors if raise_errors was set to True

        :param response: response from requests http call
        :returns: dictionary of response
        :rtype: dict
        """
        payload = None
        try:
            if isinstance(response.json, collections.Callable):
                payload = response.json()
            else:
                # json isn't callable in old versions of requests
                payload = response.json
        except ValueError:
            # response does not have JSON content
            payload = response.content

        if not self._raise_errors:
            return payload
        else:
            if response.status_code == 401:
                raise AuthenticationError(payload['message'])
            elif response.status_code == 500:
                raise ServerError(payload['message'])
            elif isinstance(payload, dict) and not payload['success']:
                raise APIError(payload['message'])
            else:
                return payload
def parse_response(self, response):
        """Parses the API response and raises appropriate
        errors if raise_errors was set to True

        :param response: response from requests http call
        :returns: dictionary of response
        :rtype: dict
        """
        payload = None
        try:
            if isinstance(response.json, collections.Callable):
                payload = response.json()
            else:
                # json isn't callable in old versions of requests
                payload = response.json
        except ValueError:
            # response does not have JSON content
            payload = response.content

        if not self._raise_errors:
            return payload
        else:
            if response.status_code == 401:
                raise AuthenticationError(payload['message'])
            elif response.status_code == 500:
                raise ServerError(payload['message'])
            elif isinstance(payload, dict) and not payload['success']:
                raise APIError(payload['message'])
            else:
                return payload
Parses the API response and raises appropriate
        errors if raise_errors was set to True

        :param response: response from requests http call
        :returns: dictionary of response
        :rtype: dict