from rest_framework.views import APIView
from rest_framework import status
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from .transition import FinFlotransition

class TransitionApiView(APIView):
    permission_classes = [IsAuthenticated]

    def post(self,request):
        transitions = FinFlotransition()
        type = self.request.query_params.get('type')
        action = self.request.query_params.get('action')
        stage = self.request.query_params.get('stage')
        t_id = self.request.query_params.get('t_id')
        if type and action  is not None:
            transitions.transition(type = type , action = action , stage = stage , id = t_id)
            return Response({"status" : "Transition success"},status = status.HTTP_200_OK)
        return Response({"status" : "Transition failure"},status = status.HTTP_204_NO_CONTENT)

