def _parse_response(response, decode_json):
    """
    Helper function that extracts the status code and
    parses the response text.
    """
    ret = {'status': response.status_code}
    if decode_json:
        try:
            ret['response'] = response.json()
        except ValueError:
            ret['response'] = response.text
    else:
        ret['response'] = response.text

    return ret