Skip to content

feat(pagination): add interfaces for pagination feature #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apimatic_core_interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
'client',
'factories',
'types',
'logger'
'logger',
'pagination'
]
3 changes: 3 additions & 0 deletions apimatic_core_interfaces/pagination/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__all__=[
"paginated_data_manager"
]
33 changes: 33 additions & 0 deletions apimatic_core_interfaces/pagination/paginated_data_manager.py
Original file line number Diff line number Diff line change
@@ -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.
"""
...
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down