Skip to content

Commit

Permalink
Improve docstrings on list classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Hendrikx committed Oct 13, 2023
1 parent 92e68d9 commit 547bffe
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions mollie/api/objects/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ def new(self, result):


class PaginationList(ListBase):
"""
Pagination lists are used to return a paginated list of Objects.
You can use the `has_next` and `get_next` methods to get the next page of result data from the API.
The `has_previous` and `get_previous` methods return the previous page.
"""

_parent: "ResourceBase"

def __init__(self, result: Any, parent: "ResourceBase", client: "Client"):
Expand All @@ -105,15 +112,15 @@ def __init__(self, result: Any, parent: "ResourceBase", client: "Client"):
super().__init__(result, client)

def get_next(self):
"""Return the next set of objects in an ObjectList."""
"""Return the next set of objects in the paginated list."""
url = self._get_link("next")
if url is None:
return None
resp = self._parent.perform_api_call(self._parent.REST_READ, url)
return PaginationList(resp, self._parent, self.client)

def get_previous(self):
"""Return the previous set of objects in an ObjectList."""
"""Return the previous set of objects in the paginated list."""
url = self._get_link("previous")
if url is None:
return None
Expand All @@ -129,6 +136,12 @@ def new(self, result):


class ObjectList(ListBase):
"""
Object lists are used to return an embedded list on an object.
It works to similar to PaginationList, but has no pagination (as all data is already embedded).
"""

_object_type: Type[ObjectBase]

def __init__(self, result: Any, object_type: Type[ObjectBase], client: Optional["Client"] = None):
Expand Down

0 comments on commit 547bffe

Please sign in to comment.