from rest_framework.views import APIView
from rest_framework import status
from rest_framework.response import Response
from .models import Banners
from .serializers import BannersSerializer


class BannersView(APIView):

    def get(self, request):
        try:
            banners = Banners.objects.filter(status = 1)
            serializer = BannersSerializer(banners, many=True)
            return Response({'banners' : serializer.data, 'status':status.HTTP_200_OK})  
        except Exception as e:
            print(e)
            return Response({'message' : "Something went wrong. Please try again later.", 'status':status.HTTP_400_BAD_REQUEST})  
