from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response


class CustomPageNumberPagination(PageNumberPagination):
    page_size = 20  # default
    page_size_query_param = 'page_size'  # set from client
    max_page_size = 100  # maximum items to show
    message = None

    def get_paginated_response(self, data):
        return Response({
            'message': self.message,  # Custom message
            'count': self.page.paginator.count,
            'next': self.get_next_link(),
            'previous': self.get_previous_link(),
            'results': data
        })

    def set_message(self, message):
        self.message = message
