From 60ddaf97ef93d839fff56153d6efd48459d9648f Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Sat, 13 Sep 2025 10:31:46 +0000 Subject: [PATCH 1/5] Delivery --- README.md | 1 + tgtg/__init__.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 639cbf9..0ea3bca 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Handle: - get the status of an order (`/api/order/vX/:id/status`) - get active orders (`/api/order/vX/active`) - get inactive orders (`/api/order/vX/inactive`) +- get delivery items (`api/manufactureritem/v2`) ## Install diff --git a/tgtg/__init__.py b/tgtg/__init__.py index d768eb7..61dc2db 100644 --- a/tgtg/__init__.py +++ b/tgtg/__init__.py @@ -25,6 +25,8 @@ ABORT_ORDER_ENDPOINT = "order/v8/{}/abort" ORDER_STATUS_ENDPOINT = "order/v8/{}/status" API_BUCKET_ENDPOINT = "discover/v1/bucket" +MANUFACTURER_ITEM_ENDPOINT = "manufactureritem/v2/" + DEFAULT_APK_VERSION = "24.11.0" USER_AGENTS = [ "TGTG/{} Dalvik/2.1.0 (Linux; U; Android 9; Nexus 5 Build/M4B30Z)", @@ -430,3 +432,25 @@ def get_inactive(self, page=0, page_size=20): return response.json() else: raise TgtgAPIError(response.status_code, response.content) + + def get_manufacturer_items( + self + ): + self.login() + + data = { + "display_types_accepted": [ "LIST" ], + "element_types_accepted": [ "ITEM", "NPS", "TEXT", "DUO_ITEMS", "MANUFACTURER_STORY_CARD"], + "action_types_accepted": [] + } + response = self.session.post( + self._get_url(MANUFACTURER_ITEM_ENDPOINT), + headers=self._headers, + json=data, + proxies=self.proxies, + timeout=self.timeout, + ) + if response.status_code == HTTPStatus.OK: + return response.json() + else: + raise TgtgAPIError(response.status_code, response.content) \ No newline at end of file From 39f195b02ece36fbe6464bec7749726c456d5864 Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Sat, 13 Sep 2025 10:34:11 +0000 Subject: [PATCH 2/5] fix --- tgtg/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgtg/__init__.py b/tgtg/__init__.py index 61dc2db..a914f2a 100644 --- a/tgtg/__init__.py +++ b/tgtg/__init__.py @@ -25,7 +25,7 @@ ABORT_ORDER_ENDPOINT = "order/v8/{}/abort" ORDER_STATUS_ENDPOINT = "order/v8/{}/status" API_BUCKET_ENDPOINT = "discover/v1/bucket" -MANUFACTURER_ITEM_ENDPOINT = "manufactureritem/v2/" +MANUFACTURER_ITEM_ENDPOINT = "manufactureritem/v2" DEFAULT_APK_VERSION = "24.11.0" USER_AGENTS = [ From 44ee175366bb58dbd7ab99b6fd9d5b10f4ace091 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Sep 2025 11:06:40 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tgtg/__init__.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tgtg/__init__.py b/tgtg/__init__.py index a914f2a..b804e0b 100644 --- a/tgtg/__init__.py +++ b/tgtg/__init__.py @@ -433,15 +433,19 @@ def get_inactive(self, page=0, page_size=20): else: raise TgtgAPIError(response.status_code, response.content) - def get_manufacturer_items( - self - ): + def get_manufacturer_items(self): self.login() data = { - "display_types_accepted": [ "LIST" ], - "element_types_accepted": [ "ITEM", "NPS", "TEXT", "DUO_ITEMS", "MANUFACTURER_STORY_CARD"], - "action_types_accepted": [] + "display_types_accepted": ["LIST"], + "element_types_accepted": [ + "ITEM", + "NPS", + "TEXT", + "DUO_ITEMS", + "MANUFACTURER_STORY_CARD", + ], + "action_types_accepted": [], } response = self.session.post( self._get_url(MANUFACTURER_ITEM_ENDPOINT), @@ -453,4 +457,4 @@ def get_manufacturer_items( if response.status_code == HTTPStatus.OK: return response.json() else: - raise TgtgAPIError(response.status_code, response.content) \ No newline at end of file + raise TgtgAPIError(response.status_code, response.content) From 53e44241dd956f02ed29a072e55d48664d8dbebb Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Thu, 5 Feb 2026 18:04:26 +0000 Subject: [PATCH 4/5] Add tests --- tests/test_items.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_items.py b/tests/test_items.py index 3831718..c5cd570 100644 --- a/tests/test_items.py +++ b/tests/test_items.py @@ -8,6 +8,7 @@ API_ITEM_ENDPOINT, BASE_URL, FAVORITE_ITEM_ENDPOINT, + MANUFACTURER_ITEM_ENDPOINT, TgtgClient, ) from tgtg.exceptions import TgtgAPIError @@ -127,3 +128,22 @@ def test_set_favorite_fail(client): ) with pytest.raises(TgtgAPIError): client.set_favorite(1, True) + + +def test_get_manufacturing_items_fail(client): + responses.add( + responses.POST, urljoin(BASE_URL, MANUFACTURER_ITEM_ENDPOINT), json={}, status=400 + ) + with pytest.raises(TgtgAPIError): + client.get_manufacturer_items() + + +def test_get_manufacturing_items_success(client): + responses.add( + responses.POST, urljoin(BASE_URL, MANUFACTURER_ITEM_ENDPOINT), json={}, status=200 + ) + assert client.get_manufacturer_items() == {} + assert ( + len([call for call in responses.calls if MANUFACTURER_ITEM_ENDPOINT in call.request.url]) + == 1 + ) \ No newline at end of file From 3772c01a9a903584885ec0bc2f68138ca43fab6d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 18:04:38 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_items.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_items.py b/tests/test_items.py index c5cd570..91163ce 100644 --- a/tests/test_items.py +++ b/tests/test_items.py @@ -132,7 +132,10 @@ def test_set_favorite_fail(client): def test_get_manufacturing_items_fail(client): responses.add( - responses.POST, urljoin(BASE_URL, MANUFACTURER_ITEM_ENDPOINT), json={}, status=400 + responses.POST, + urljoin(BASE_URL, MANUFACTURER_ITEM_ENDPOINT), + json={}, + status=400, ) with pytest.raises(TgtgAPIError): client.get_manufacturer_items() @@ -140,10 +143,19 @@ def test_get_manufacturing_items_fail(client): def test_get_manufacturing_items_success(client): responses.add( - responses.POST, urljoin(BASE_URL, MANUFACTURER_ITEM_ENDPOINT), json={}, status=200 + responses.POST, + urljoin(BASE_URL, MANUFACTURER_ITEM_ENDPOINT), + json={}, + status=200, ) assert client.get_manufacturer_items() == {} assert ( - len([call for call in responses.calls if MANUFACTURER_ITEM_ENDPOINT in call.request.url]) + len( + [ + call + for call in responses.calls + if MANUFACTURER_ITEM_ENDPOINT in call.request.url + ] + ) == 1 - ) \ No newline at end of file + )