Skip to content

Commit

Permalink
Merge pull request #10 from vorostamas/onlyFavorite-tickets
Browse files Browse the repository at this point in the history
Add onlyFavorite parameter to tickets method
  • Loading branch information
Andre0512 authored Oct 25, 2023
2 parents 62850bf + 0513633 commit 5145a8e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lidlplus/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,18 @@ def _default_headers(self):
"Accept-Language": self._language,
}

def tickets(self):
"""Get list of all tickets"""
def tickets(self, only_favorite=False):
"""
Get a list of all tickets.
:param onlyFavorite: A boolean value indicating whether to only retrieve favorite tickets.
If set to True, only favorite tickets will be returned.
If set to False (the default), all tickets will be retrieved.
:type onlyFavorite: bool
"""
url = f"{self._TICKET_API}/{self._country}/tickets"
kwargs = {"headers": self._default_headers(), "timeout": self._TIMEOUT}
ticket = requests.get(f"{url}?pageNumber=1", **kwargs).json()
ticket = requests.get(f"{url}?pageNumber=1&onlyFavorite={only_favorite}", **kwargs).json()
tickets = ticket["tickets"]
for i in range(2, int(ticket["totalCount"] / ticket["size"] + 2)):
tickets += requests.get(f"{url}?pageNumber={i}", **kwargs).json()["tickets"]
Expand Down

0 comments on commit 5145a8e

Please sign in to comment.