Skip to content

Commit

Permalink
Updated favorite item endpoint (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
floriegl authored Feb 11, 2024
1 parent e7c6c49 commit 708a34f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Handle:
- create an account (`/api/auth/vX/signUpByEmail`)
- login (`/api/auth/vX/authByEmail`)
- refresh token (`/api/auth/vX/token/refresh`)
- list stores (`/api/item/`)
- get a store (`/api/item/:id`)
- get favorites (`/api/discover/v1/bucket`)
- set favorite (`/api/item/:id/setFavorite`)
- create an order (`/api/order/vX/create/`)
- list stores (`/api/item/vX`)
- get a store (`/api/item/vX/:id`)
- get favorites (`/api/discover/vX/bucket`)
- set favorite (`/api/user/favorite/vX/:id/update`)
- create an order (`/api/order/vX/create/:id`)
- abort an order (`/api/order/vX/:id/abort`)
- get the status of an order (`/api/order/vX/:id/status`)
- get active orders (`/api/order/vX/active`)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
import responses

from tgtg import API_ITEM_ENDPOINT, BASE_URL, TgtgClient
from tgtg import API_ITEM_ENDPOINT, BASE_URL, FAVORITE_ITEM_ENDPOINT, TgtgClient
from tgtg.exceptions import TgtgAPIError

from .constants import tgtg_client_fake_tokens
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_get_item_fail(refresh_tokens_response):
def test_set_favorite(refresh_tokens_response):
responses.add(
responses.POST,
urljoin(BASE_URL, API_ITEM_ENDPOINT) + "1/setFavorite",
urljoin(BASE_URL, FAVORITE_ITEM_ENDPOINT.format(1)),
json={},
status=200,
)
Expand All @@ -90,7 +90,7 @@ def test_set_favorite(refresh_tokens_response):
def test_set_favorite_fail(refresh_tokens_response):
responses.add(
responses.POST,
urljoin(BASE_URL, API_ITEM_ENDPOINT) + "1/setFavorite",
urljoin(BASE_URL, FAVORITE_ITEM_ENDPOINT.format(1)),
json={},
status=400,
)
Expand Down
3 changes: 2 additions & 1 deletion tgtg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

BASE_URL = "https://apptoogoodtogo.com/api/"
API_ITEM_ENDPOINT = "item/v8/"
FAVORITE_ITEM_ENDPOINT = "user/favorite/v1/{}/update"
AUTH_BY_EMAIL_ENDPOINT = "auth/v3/authByEmail"
AUTH_POLLING_ENDPOINT = "auth/v3/authByRequestPollingId"
SIGNUP_BY_EMAIL_ENDPOINT = "auth/v3/signUpByEmail"
Expand Down Expand Up @@ -319,7 +320,7 @@ def get_favorites(
def set_favorite(self, item_id, is_favorite):
self.login()
response = self.session.post(
urljoin(self._get_url(API_ITEM_ENDPOINT), f"{item_id}/setFavorite"),
self._get_url(FAVORITE_ITEM_ENDPOINT.format(item_id)),
headers=self._headers,
json={"is_favorite": is_favorite},
proxies=self.proxies,
Expand Down

0 comments on commit 708a34f

Please sign in to comment.