Skip to content

Commit

Permalink
Revert "Revert "Finalsurge changed their api a bit, update to keep wo…
Browse files Browse the repository at this point in the history
…rking.""

This reverts commit 4705f7e.
(make up your mind finalsurge!)
  • Loading branch information
gazpachoking committed Jun 1, 2021
1 parent 80ea53b commit ed6165d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "trainaspower"
version = "0.6.3"
version = "0.6.4"
description = "Convert TrainAsOne plans to power and upload to Final Surge for use with Stryd pod."
authors = ["Chase Sterling <[email protected]>"]
license = "MIT"
Expand Down
17 changes: 7 additions & 10 deletions trainaspower/finalsurge.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def login(email: str, password: str) -> None:
"deviceUniqueIdentifier": "",
}
r = finalsurge_session.post(
"https://beta.finalsurge.com/api/Data?request=login",
data=json.dumps(login_params).replace(" ", ""),
"https://beta.finalsurge.com/api/login",
json=login_params,
)
login_info = r.json()
if not login_info["success"]:
Expand Down Expand Up @@ -114,7 +114,6 @@ def get_existing_tap_workout(wo_date: date) -> Optional[str]:
"""Checks if TrainAsPower already has an (uncompleted) workout on the same day as given workout."""
logger.debug(f"Checking TrainAsPower workout exists on Final Surge")
params = {
"request": "WorkoutList",
"scope": "USER",
"scopekey": user_key,
"startdate": wo_date.strftime("%Y-%m-%d"),
Expand All @@ -123,7 +122,7 @@ def get_existing_tap_workout(wo_date: date) -> Optional[str]:
"completedonly": False,
}
data = finalsurge_session.get(
"https://beta.finalsurge.com/api/Data", params=params
"https://beta.finalsurge.com/api/WorkoutList", params=params
).json()
for existing_workout in data["data"]:
if existing_workout["workout_completion"] == 1:
Expand All @@ -140,10 +139,10 @@ def add_workout(workout: models.Workout) -> None:
else:
logger.info(f"Posting workout `{workout.name}` to Final Surge")
wo = convert_workout(workout)
params = {"request": "WorkoutSave", "scope": "USER", "scope_key": user_key}
params = {"scope": "USER", "scope_key": user_key}

add_wo = finalsurge_session.post(
"https://beta.finalsurge.com/api/Data",
"https://beta.finalsurge.com/api/WorkoutSave",
params=params,
json={
"key": wo_key,
Expand All @@ -164,13 +163,12 @@ def add_workout(workout: models.Workout) -> None:
if not wo_key:
wo_key = add_wo.json()["new_workout_key"]
params = {
"request": "WorkoutBuilderSave",
"scope": "USER",
"scopekey": user_key,
"workout_key": wo_key,
}
finalsurge_session.post(
"https://beta.finalsurge.com/api/Data", params=params, json=wo
"https://beta.finalsurge.com/api/WorkoutBuilderSave", params=params, json=wo
)


Expand All @@ -180,11 +178,10 @@ def remove_workout(wo_date: date) -> None:
return
logger.info(f"Deleting existing TrainAsPower workout `{wo_key}`")
params = {
"request": "WorkoutDelete",
"scope": "USER",
"scopekey": user_key,
"workout_key": wo_key,
}
response = finalsurge_session.get(
"https://beta.finalsurge.com/api/Data", params=params
"https://beta.finalsurge.com/api/WorkoutDelete", params=params
)

0 comments on commit ed6165d

Please sign in to comment.