from django.shortcuts import render from rest_framework import status, viewsets from rest_framework.response import Response from .models import Connection from .serializers import ConnectionSerializer from rest_framework.decorators import action import plaid # Create your views here. class ConnectionViewSet(viewsets.ModelViewSet): """API endpoint that allows connections to be seen or created """ queryset = Connection.objects.all() serializer_class = ConnectionSerializer # Make connections somewhat immutable from the users perspective http_method_names = [ 'get', 'post', 'delete', 'options'] @action(detail=False, methods=['post'], url_path='oauth/plaid') def oauth(self, request, public_token=None): if public_token is None: return Response( status=status.HTTP_400_BAD_REQUEST, data="ERROR: missing public_token") print(request) return Response(200)