Skip to content

Commit

Permalink
Added method to get training status
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberjunky committed Oct 21, 2022
1 parent 51bbcde commit 58734a1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ menu_options = {
"7": f"Get stats and body composition data for '{today.isoformat()}'",
"8": f"Get steps data for '{today.isoformat()}'",
"9": f"Get heart rate data for '{today.isoformat()}'",
"0": f"Get training readiness for '{today.isoformat()}'",
"0": f"Get training readiness data for '{today.isoformat()}'",
".": f"Get training status data for '{today.isoformat()}'",
"a": f"Get resting heart rate data for {today.isoformat()}'",
"b": f"Get hydration data for '{today.isoformat()}'",
"c": f"Get sleep data for '{today.isoformat()}'",
Expand Down Expand Up @@ -268,6 +269,9 @@ def switch(api, i):
elif i == "0":
# Get training readiness data for 'YYYY-MM-DD'
logger.info(api.get_training_readiness(today.isoformat()))
elif i == ".":
# Get training status data for 'YYYY-MM-DD'
logger.info(api.get_training_status(today.isoformat()))
elif i == "a":
# Get resting heart rate data for 'YYYY-MM-DD'
logger.info(api.get_rhr_day(today.isoformat()))
Expand Down
6 changes: 5 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"7": f"Get stats and body composition data for '{today.isoformat()}'",
"8": f"Get steps data for '{today.isoformat()}'",
"9": f"Get heart rate data for '{today.isoformat()}'",
"0": f"Get training readiness for '{today.isoformat()}'",
"0": f"Get training readiness data for '{today.isoformat()}'",
".": f"Get training status data for '{today.isoformat()}'",
"a": f"Get resting heart rate data for {today.isoformat()}'",
"b": f"Get hydration data for '{today.isoformat()}'",
"c": f"Get sleep data for '{today.isoformat()}'",
Expand Down Expand Up @@ -187,6 +188,9 @@ def switch(api, i):
elif i == "0":
# Get training readiness data for 'YYYY-MM-DD'
logger.info(api.get_training_readiness(today.isoformat()))
elif i == ".":
# Get training status data for 'YYYY-MM-DD'
logger.info(api.get_training_status(today.isoformat()))
elif i == "a":
# Get resting heart rate data for 'YYYY-MM-DD'
logger.info(api.get_rhr_day(today.isoformat()))
Expand Down
10 changes: 10 additions & 0 deletions garminconnect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def __init__(self, email=None, password=None, is_cn=False, session_data=None):

self.garmin_connect_training_readiness_url = "proxy/metrics-service/metrics/trainingreadiness"

self.garmin_connect_training_status_url = "proxy/metrics-service/metrics/trainingstatus/aggregated"

self.garmin_connect_user_summary_chart = (
"proxy/wellness-service/wellness/dailySummaryChart"
)
Expand Down Expand Up @@ -582,6 +584,14 @@ def get_training_readiness(self, cdate: str) -> Dict[str, Any]:

return self.modern_rest_client.get(url).json()

def get_training_status(self, cdate: str) -> Dict[str, Any]:
"""Return training status data for current user."""

url = f"{self.garmin_connect_training_status_url}/{cdate}"
logger.debug("Requesting training status data")

return self.modern_rest_client.get(url).json()

def get_devices(self) -> Dict[str, Any]:
"""Return available devices for the current user account."""

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def read(*parts):
long_description=readme,
url="https://github.com/cyberjunky/python-garminconnect",
packages=["garminconnect"],
version="0.1.46"
version="0.1.47"
)

0 comments on commit 58734a1

Please sign in to comment.