Skip to content

Commit bc85f7b

Browse files
committed
Implement training plan list, detail and adaptive detail endpoint
1 parent 749c248 commit bc85f7b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

garminconnect/__init__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ def __init__(
266266

267267
self.garmin_graphql_endpoint = "graphql-gateway/graphql"
268268

269+
self.garmin_training_plan_url = "/trainingplan-service/trainingplan"
270+
269271
self.garth = garth.Client(
270272
domain="garmin.cn" if is_cn else "garmin.com",
271273
pool_connections=20,
@@ -2163,6 +2165,31 @@ def logout(self) -> None:
21632165
"Deprecated: Alternative is to delete the login tokens to logout."
21642166
)
21652167

2168+
def get_training_plans(self) -> dict[str, Any]:
2169+
"""Return all available training plans."""
2170+
2171+
url = f"{self.garmin_training_plan_url}/plans"
2172+
logger.debug("Requesting training plans.")
2173+
return self.connectapi(url)
2174+
2175+
def get_training_plan_by_id(self, plan_id: int | str) -> dict[str, Any]:
2176+
"""Return details for a specific training plan."""
2177+
2178+
plan_id = _validate_positive_integer(int(plan_id), "plan_id")
2179+
2180+
url = f"{self.garmin_training_plan_url}/plans/{plan_id}"
2181+
logger.debug("Requesting training plan details for %s", plan_id)
2182+
return self.connectapi(url)
2183+
2184+
def get_adaptive_training_plan_by_id(self, plan_id: int | str) -> dict[str, Any]:
2185+
"""Return details for a specific adaptive training plan."""
2186+
2187+
plan_id = _validate_positive_integer(int(plan_id), "plan_id")
2188+
url = f"{self.garmin_training_plan_url}/fbt-adaptive/{plan_id}"
2189+
2190+
logger.debug("Requesting adaptive training plan details for %s", plan_id)
2191+
return self.connectapi(url)
2192+
21662193

21672194
class GarminConnectConnectionError(Exception):
21682195
"""Raised when communication ended in error."""

0 commit comments

Comments
 (0)