@staticmethod
def _handle_api_response(json_response):
    """
        Throw exceptions on errors from API.

        :param json_response:
        :return:
        """
    if not json_response:
        raise ValueError('Error getting data from the api, no data returned')
    if 'error' in json_response:
        raise ValueError('Standard Error:: {} : {}'.format(json_response[
            'error'], json_response['error_description']))
    elif 'description' in json_response:
        if 'Service Error' in json_response['description']:
            raise ValueError('Service Error:: {} : {}'.format(json_response
                ['id'], json_response['description']))
    else:
        try:
            codes = json_response[list(json_response.keys())[0]]['return'][
                'returnCode']
            if codes['majorReturnCode'] != '000' or codes['minorReturnCode'
                ] != '0000':
                raise ValueError('Return Code Error:: Major: {}, Minor: {}'
                    .format(codes['majorReturnCode'], codes['minorReturnCode'])
                    )
        except KeyError:
            pass
    return json_response
