From 5df28ebed0a659935777d96790f2463505675205 Mon Sep 17 00:00:00 2001 From: Tamas Voros Date: Wed, 25 Oct 2023 18:57:25 +0200 Subject: [PATCH 1/2] Add onlyFavorite parameter to tickets method --- lidlplus/api.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lidlplus/api.py b/lidlplus/api.py index cc1caf4..719a12c 100644 --- a/lidlplus/api.py +++ b/lidlplus/api.py @@ -238,11 +238,18 @@ def _default_headers(self): "Accept-Language": self._language, } - def tickets(self): - """Get list of all tickets""" + def tickets(self, onlyFavorite=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={onlyFavorite}", **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"] From 05136336c1587a1ee9f45c873701969596719930 Mon Sep 17 00:00:00 2001 From: Tamas Voros Date: Wed, 25 Oct 2023 19:10:28 +0200 Subject: [PATCH 2/2] rename parameter --- lidlplus/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lidlplus/api.py b/lidlplus/api.py index 719a12c..e60f20a 100644 --- a/lidlplus/api.py +++ b/lidlplus/api.py @@ -238,7 +238,7 @@ def _default_headers(self): "Accept-Language": self._language, } - def tickets(self, onlyFavorite=False): + def tickets(self, only_favorite=False): """ Get a list of all tickets. @@ -249,7 +249,7 @@ def tickets(self, onlyFavorite=False): """ url = f"{self._TICKET_API}/{self._country}/tickets" kwargs = {"headers": self._default_headers(), "timeout": self._TIMEOUT} - ticket = requests.get(f"{url}?pageNumber=1&onlyFavorite={onlyFavorite}", **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"]