Skip to content

Commit 9ab6ada

Browse files
authored
Merge pull request #553 from JoGruen/main
updated auth version from v3->v4
2 parents c994adc + f8cfd7c commit 9ab6ada

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tests/test_tgtg.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010

1111
from tgtg_scanner.models import Config
1212
from tgtg_scanner.tgtg.tgtg_client import (
13+
API_ITEM_ENDPOINT,
14+
AUTH_BY_EMAIL_ENDPOINT,
15+
AUTH_POLLING_ENDPOINT,
1316
BASE_URL,
1417
FAVORITE_ITEM_ENDPOINT,
18+
REFRESH_ENDPOINT,
1519
USER_AGENTS,
1620
TgtgClient,
1721
)
@@ -53,18 +57,18 @@ def test_tgtg_login_with_mail(mocker: MockerFixture):
5357
}
5458
responses.add(
5559
responses.POST,
56-
"https://apptoogoodtogo.com/api/auth/v3/authByEmail",
60+
urljoin(BASE_URL, AUTH_BY_EMAIL_ENDPOINT),
5761
json.dumps(auth_response_data),
5862
status=200,
5963
)
6064
responses.add(
6165
responses.POST,
62-
"https://apptoogoodtogo.com/api/auth/v3/authByRequestPollingId",
66+
urljoin(BASE_URL, AUTH_POLLING_ENDPOINT),
6367
status=202,
6468
)
6569
responses.add(
6670
responses.POST,
67-
"https://apptoogoodtogo.com/api/auth/v3/authByRequestPollingId",
71+
urljoin(BASE_URL, AUTH_POLLING_ENDPOINT),
6872
json.dumps(poll_response_data),
6973
status=200,
7074
)
@@ -99,7 +103,7 @@ def test_tgtg_login_with_token(mocker: MockerFixture):
99103
}
100104
responses.add(
101105
responses.POST,
102-
"https://apptoogoodtogo.com/api/auth/v3/token/refresh",
106+
urljoin(BASE_URL, REFRESH_ENDPOINT),
103107
json.dumps(response_data),
104108
status=200,
105109
)
@@ -117,7 +121,7 @@ def test_tgtg_get_items(mocker: MockerFixture, tgtg_item: dict):
117121
mocker.patch("tgtg_scanner.tgtg.tgtg_client.TgtgClient.login", return_value=None)
118122
responses.add(
119123
responses.POST,
120-
"https://apptoogoodtogo.com/api/item/v8/",
124+
urljoin(BASE_URL, API_ITEM_ENDPOINT),
121125
json.dumps({"items": [tgtg_item]}),
122126
status=200,
123127
)
@@ -141,7 +145,7 @@ def test_tgtg_get_item(mocker: MockerFixture, tgtg_item: dict):
141145
item_id = tgtg_item.get("item", {}).get("item_id")
142146
responses.add(
143147
responses.POST,
144-
f"https://apptoogoodtogo.com/api/item/v8/{item_id}",
148+
urljoin(BASE_URL, API_ITEM_ENDPOINT + item_id),
145149
json.dumps(tgtg_item),
146150
status=200,
147151
)

tgtg_scanner/tgtg/tgtg_client.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
BASE_URL = "https://apptoogoodtogo.com/api/"
2626
API_ITEM_ENDPOINT = "item/v8/"
2727
FAVORITE_ITEM_ENDPOINT = "user/favorite/v1/{}/update"
28-
AUTH_BY_EMAIL_ENDPOINT = "auth/v3/authByEmail"
29-
AUTH_POLLING_ENDPOINT = "auth/v3/authByRequestPollingId"
30-
SIGNUP_BY_EMAIL_ENDPOINT = "auth/v3/signUpByEmail"
31-
REFRESH_ENDPOINT = "auth/v3/token/refresh"
28+
AUTH_BY_EMAIL_ENDPOINT = "auth/v4/authByEmail"
29+
AUTH_POLLING_ENDPOINT = "auth/v4/authByRequestPollingId"
30+
SIGNUP_BY_EMAIL_ENDPOINT = "auth/v4/signUpByEmail"
31+
REFRESH_ENDPOINT = "auth/v4/token/refresh"
3232
ACTIVE_ORDER_ENDPOINT = "order/v7/active"
3333
INACTIVE_ORDER_ENDPOINT = "order/v7/inactive"
3434
CREATE_ORDER_ENDPOINT = "order/v7/create/"

0 commit comments

Comments
 (0)