from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from rest_framework.permissions import AllowAny, IsAuthenticated
from .serializers import UserProfileSerializer

class HealthCheckView(APIView):
    """
    A simple API endpoint to verify the API is up and running.
    """
    permission_classes = [AllowAny]

    def get(self, request):
        return Response(
            {"status": "healthy", "message": "API is operational"},
            status=status.HTTP_200_OK
        )

class UserProfileView(APIView):
    """
    Returns the profile details of the authenticated user.
    """
    permission_classes = [IsAuthenticated]

    def get(self, request):
        serializer = UserProfileSerializer(request.user)
        return Response(serializer.data, status=status.HTTP_200_OK)
