from django.http import HttpRequest
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import permissions, status

from .models import ProfileModel

# Create your views here.
class ProfileView(APIView):
    permission_classes = (permissions.AllowAny,)

    def get(self, request: HttpRequest, pk: int):
        
        profile: ProfileModel = ProfileModel.objects.get(pk=pk)
        if (profile is None):
            return Response(status=status.HTTP_404_NOT_FOUND)
        
        return Response(status=status.HTTP_200_OK, data={'name': profile.user.username,
                             'title': profile.title})