HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/unlimited-leads/Unlimited-Leads-Be/payment/paginations.py
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework import status

class TransactionPagination(PageNumberPagination):
    page_size = 10
    page_size_query_param = 'page_size'
    max_page_size = 100

    def get_paginated_response(self, data):
        return Response({
            "count": self.page.paginator.count,
            "current_page": self.page.number,
            "next_page": self.page.number + 1 if self.page.has_next() else None,
            "previous_page": self.page.number - 1 if self.page.has_previous() else None,
            "total_pages": self.page.paginator.num_pages,
            "data": data,
            "success": True,
            "statusCode": status.HTTP_200_OK,
            "message": "Transactions retrieved successfully."
        })