Skip to content

Commit a2ebecb

Browse files
authored
Merge pull request #212 from tboerstad/master
Add grouping option to progress summary and fix type annotations
2 parents 469d3c7 + 77cfd7c commit a2ebecb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

garminconnect/__init__.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44
import os
5-
from datetime import datetime, timezone, date
5+
from datetime import date, datetime, timezone
66
from enum import Enum, auto
77
from typing import Any, Dict, List, Optional
88

@@ -47,7 +47,7 @@ def __init__(
4747
self.garmin_connect_daily_hydration_url = (
4848
"/usersummary-service/usersummary/hydration/daily"
4949
)
50-
self.garmin_connect_set_hydration_url = (
50+
self.garmin_connect_set_hydration_url = (
5151
"usersummary-service/usersummary/hydration/log"
5252
)
5353
self.garmin_connect_daily_stats_steps_url = (
@@ -495,7 +495,9 @@ def get_max_metrics(self, cdate: str) -> Dict[str, Any]:
495495

496496
return self.connectapi(url)
497497

498-
def add_hydration_data(self, value_in_ml: float, timestamp=None, cdate: str=None) -> Dict[str, Any]:
498+
def add_hydration_data(
499+
self, value_in_ml: float, timestamp=None, cdate: Optional[str] = None
500+
) -> Dict[str, Any]:
499501
"""Add hydration data in ml. Defaults to current date and current timestamp if left empty
500502
:param float required - value_in_ml: The number of ml of water you wish to add (positive) or subtract (negative)
501503
:param timestamp optional - timestamp: The timestamp of the hydration update, format 'YYYY-MM-DDThh:mm:ss.ms' Defaults to current timestamp
@@ -784,7 +786,7 @@ def get_hill_score(self, startdate: str, enddate=None):
784786

785787
return self.connectapi(url, params=params)
786788

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

790792
url = self.garmin_connect_devices_url
@@ -826,7 +828,7 @@ def get_device_solar_data(
826828

827829
return self.connectapi(url, params=params)["deviceSolarInput"]
828830

829-
def get_device_alarms(self) -> Dict[str, Any]:
831+
def get_device_alarms(self) -> List[Any]:
830832
"""Get list of active alarms from all devices."""
831833

832834
logger.debug("Requesting device alarms")
@@ -959,14 +961,15 @@ def get_activities_by_date(self, startdate, enddate, activitytype=None):
959961
return activities
960962

961963
def get_progress_summary_between_dates(
962-
self, startdate, enddate, metric="distance"
964+
self, startdate, enddate, metric="distance", groupbyactivities=True
963965
):
964966
"""
965967
Fetch progress summary data between specific dates
966968
:param startdate: String in the format YYYY-MM-DD
967969
:param enddate: String in the format YYYY-MM-DD
968970
:param metric: metric to be calculated in the summary:
969971
"elevationGain", "duration", "distance", "movingDuration"
972+
:param groupbyactivities: group the summary by activity type
970973
:return: list of JSON activities with their aggregated progress summary
971974
"""
972975

@@ -975,7 +978,7 @@ def get_progress_summary_between_dates(
975978
"startDate": str(startdate),
976979
"endDate": str(enddate),
977980
"aggregation": "lifetime",
978-
"groupByParentActivityType": "true",
981+
"groupByParentActivityType": str(groupbyactivities),
979982
"metric": str(metric),
980983
}
981984

0 commit comments

Comments
 (0)