Skip to content

Commit 4676e1f

Browse files
committed
Adding two functions that allow you to add and remove gear from activity. Resolves #282
1 parent 749c248 commit 4676e1f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

garminconnect/__init__.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,38 @@ def get_gear_activities(
20252025

20262026
return self.connectapi(url)
20272027

2028+
def add_gear_to_activity(self, gear_uid: str, activity_id: int) -> dict[str, Any]:
2029+
"""
2030+
Associates gear with an activity. Requires a gear_uid and an activity_id
2031+
2032+
Args:
2033+
gear_uid: UID for gear to add to activity. Findable though the get_gear function
2034+
activity_id: Integer ID for the activity to add the gear to
2035+
2036+
Returns:
2037+
Dictionary containing information for the added gear
2038+
2039+
"""
2040+
2041+
url = f"{self.garmin_connect_gear_baseurl}link/{gear_uid}/activity/{activity_id}"
2042+
return self.garth.put("connectapi", url).json()
2043+
2044+
def remove_gear_from_activity(self, gear_uid: str, activity_id: int) -> dict[str, Any]:
2045+
"""
2046+
Removes gear from an activity. Requires a gear_uid and an activity_id
2047+
2048+
Args:
2049+
gear_uid: UID for gear to remove from activity. Findable though the get_gear method.
2050+
activity_id: Integer ID for the activity to remove the gear from
2051+
2052+
Returns:
2053+
Dictionary containing information for the added gear
2054+
2055+
"""
2056+
2057+
url = f"{self.garmin_connect_gear_baseurl}unlink/{gear_uid}/activity/{activity_id}"
2058+
return self.garth.put("connectapi", url).json()
2059+
20282060
def get_user_profile(self) -> dict[str, Any]:
20292061
"""Get all users settings."""
20302062

0 commit comments

Comments
 (0)