@api_view(['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
def helix_view(request, helix_path=None):
    if check_access_token_expired():
        refresh_access_token()
    try:
        endpoint_instance = TwitchHelixEndpoint.objects.get(endpoint=helix_path, method=request.method)
        if (endpoint_instance.token_type == 'OA'):
            token = config.TWITCH_ACCESS_TOKEN
        else:
            token = config.TWITCH_APP_ACCESS_TOKEN
    except TwitchHelixEndpoint.DoesNotExist:
        token = config.TWITCH_ACCESS_TOKEN
    body = request.data
    client_id = os.environ.get('TWITCH_APP_ID', None)
    headers = {'Authorization': 'Bearer {}'.format(token), 'Client-Id': client_id}
    url = f'https://api.twitch.tv/helix/{helix_path}'
    uri = request.build_absolute_uri()
    url_params = ''
    if (uri.count('?') > 0):
        url_params = uri.split('?', 1)[1]
    if (url_params != ''):
        url += f'?{url_params}'
    if (request.method == 'GET'):
        data = requests.get(url, headers=headers)
    elif (request.method == 'POST'):
        data = requests.post(url, data=body, headers=headers)
    elif (request.method == 'PUT'):
        data = requests.put(url, data=body, headers=headers)
        print(data)
    elif (request.method == 'PATCH'):
        data = requests.patch(url, data=body, headers=headers)
    elif (request.method == 'DELETE'):
        data = requests.delete(url, headers=headers)
    try:
        if settings.DEBUG_TWITCH_CALLS:
            log_request(data)
        stream_data = data.json()
    except ValueError:
        stream_data = None
    return Response(stream_data, status=data.status_code)
@api_view(['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
def helix_view(request, helix_path=None):
    if check_access_token_expired():
        refresh_access_token()
    try:
        endpoint_instance = TwitchHelixEndpoint.objects.get(endpoint=helix_path, method=request.method)
        if (endpoint_instance.token_type == 'OA'):
            token = config.TWITCH_ACCESS_TOKEN
        else:
            token = config.TWITCH_APP_ACCESS_TOKEN
    except TwitchHelixEndpoint.DoesNotExist:
        token = config.TWITCH_ACCESS_TOKEN
    body = request.data
    client_id = os.environ.get('TWITCH_APP_ID', None)
    headers = {'Authorization': 'Bearer {}'.format(token), 'Client-Id': client_id}
    url = f'https://api.twitch.tv/helix/{helix_path}'
    uri = request.build_absolute_uri()
    url_params = 
    if (uri.count('?') > 0):
        url_params = uri.split('?', 1)[1]
    if (url_params != ):
        url += f'?{url_params}'
    if (request.method == 'GET'):
        data = requests.get(url, headers=headers)
    elif (request.method == 'POST'):
        data = requests.post(url, data=body, headers=headers)
    elif (request.method == 'PUT'):
        data = requests.put(url, data=body, headers=headers)
        print(data)
    elif (request.method == 'PATCH'):
        data = requests.patch(url, data=body, headers=headers)
    elif (request.method == 'DELETE'):
        data = requests.delete(url, headers=headers)
    try:
        if settings.DEBUG_TWITCH_CALLS:
            log_request(data)
        stream_data = data.json()
    except ValueError:
        stream_data = None
    return Response(stream_data, status=data.status_code)