diff --git a/apimatic_core_interfaces/__init__.py b/apimatic_core_interfaces/__init__.py index 94e6598..58babed 100644 --- a/apimatic_core_interfaces/__init__.py +++ b/apimatic_core_interfaces/__init__.py @@ -2,5 +2,6 @@ 'client', 'factories', 'types', - 'logger' + 'logger', + 'pagination' ] \ No newline at end of file diff --git a/apimatic_core_interfaces/pagination/__init__.py b/apimatic_core_interfaces/pagination/__init__.py new file mode 100644 index 0000000..e999f0b --- /dev/null +++ b/apimatic_core_interfaces/pagination/__init__.py @@ -0,0 +1,3 @@ +__all__=[ + "paginated_data_manager" +] \ No newline at end of file diff --git a/apimatic_core_interfaces/pagination/paginated_data_manager.py b/apimatic_core_interfaces/pagination/paginated_data_manager.py new file mode 100644 index 0000000..c2ecc57 --- /dev/null +++ b/apimatic_core_interfaces/pagination/paginated_data_manager.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from abc import ABC, abstractmethod + +class PaginationDataManager(ABC): + """An interface for managing pagination in API responses. + + This class should not be instantiated directly but should be subclassed + to provide specific pagination management logic for paginated API responses. + """ + + @abstractmethod + def is_valid(self, paginated_data): + """Checks if the given paginated data contains a valid next page. + + Args: + paginated_data: The paginated response data to check. + + Returns: + bool: True if the paginated data is valid and has a next page, False otherwise. + """ + ... + + @abstractmethod + def get_next_request_builder(self, paginated_data): + """Builds the HTTP request for fetching the next page of data. + + Args: + paginated_data: The current paginated response data. + + Returns: + HttpRequest.Builder: A builder instance configured to request the next page. + """ + ... diff --git a/setup.py b/setup.py index 881af1a..cfb7a70 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='apimatic-core-interfaces', - version='0.1.6', + version='0.1.7', description='An abstract layer of the functionalities provided by apimatic-core-library, requests-client-adapter ' 'and APIMatic SDKs.', long_description=long_description,