From 80b7ab709fd6485cceca567070a3d28e3eacf01b Mon Sep 17 00:00:00 2001 From: Ron Klinkien Date: Wed, 20 Jan 2021 20:32:13 +0100 Subject: [PATCH] Added get hydration data --- README.md | 20 ++++++++++++++++++++ garminconnect/__init__.py | 10 ++++++++++ garminconnect/__version__.py | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bbdb9ae..ab322c0 100644 --- a/README.md +++ b/README.md @@ -474,4 +474,24 @@ except ( except Exception: # pylint: disable=broad-except print("Unknown error occurred during Garmin Connect Client get personal record") quit() + + +""" +Get hydration data +""" +print("client.get_hydration_data(%s)", today.isoformat()) +print("----------------------------------------------------------------------------------------") +try: + print(client.get_hydration_data(today.isoformat())) +except ( + GarminConnectConnectionError, + GarminConnectAuthenticationError, + GarminConnectTooManyRequestsError, +) as err: + print("Error occurred during Garmin Connect Client get hydration data: %s" % err) + quit() +except Exception: # pylint: disable=broad-except + print("Unknown error occurred during Garmin Connect Client get hydration data") + quit() + ``` diff --git a/garminconnect/__init__.py b/garminconnect/__init__.py index 42b7578..1f26985 100755 --- a/garminconnect/__init__.py +++ b/garminconnect/__init__.py @@ -28,6 +28,7 @@ class Garmin(object): '/proxy/weight-service/weight/daterangesnapshot' url_activities = MODERN_URL + \ '/proxy/activitylist-service/activities/search/activities' + url_hydrationdata = MODERN_URL + '/proxy/usersummary-service/usersummary/hydration/daily/' url_activity = MODERN_URL + '/proxy/activity-service/activity/' url_personal_record = MODERN_URL + '/proxy/personalrecord-service/personalrecord/' url_tcx_download = MODERN_URL + "/proxy/download-service/export/tcx/activity/" @@ -404,6 +405,15 @@ def get_device_last_used(self): "Fetching device last used with url %s", device_last_used_url) return self.fetch_data(device_last_used_url) + def get_hydration_data(self, cdate): # cDate = 'YYYY-mm-dd' + """ + Fetch available hydration data + """ + hydration_url = self.url_hydrationdata + cdate + self.logger.debug("Fetching hydration data with url %s", hydration_url) + + return self.fetch_data(hydration_url) + class ActivityDownloadFormat(Enum): ORIGINAL = auto() TCX = auto() diff --git a/garminconnect/__version__.py b/garminconnect/__version__.py index 76face3..8be9cdb 100644 --- a/garminconnect/__version__.py +++ b/garminconnect/__version__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- """Python 3 API wrapper for Garmin Connect to get your statistics.""" -__version__ = "0.1.17" +__version__ = "0.1.18"