7
7
from typing import Any , Dict , List , Optional
8
8
9
9
import garth
10
+
10
11
from .fit import FitEncoderWeight
11
12
12
13
logger = logging .getLogger (__name__ )
@@ -16,7 +17,12 @@ class Garmin:
16
17
"""Class for fetching data from Garmin Connect."""
17
18
18
19
def __init__ (
19
- self , email = None , password = None , is_cn = False , prompt_mfa = None , return_on_mfa = False
20
+ self ,
21
+ email = None ,
22
+ password = None ,
23
+ is_cn = False ,
24
+ prompt_mfa = None ,
25
+ return_on_mfa = False ,
20
26
):
21
27
"""Create a new class instance."""
22
28
self .username = email
@@ -233,14 +239,18 @@ def login(self, /, tokenstore: Optional[str] = None) -> tuple[Any, Any]:
233
239
self .display_name = self .garth .profile ["displayName" ]
234
240
self .full_name = self .garth .profile ["fullName" ]
235
241
236
- settings = self .garth .connectapi (self .garmin_connect_user_settings_url )
242
+ settings = self .garth .connectapi (
243
+ self .garmin_connect_user_settings_url
244
+ )
237
245
self .unit_system = settings ["userData" ]["measurementSystem" ]
238
246
239
247
return None , None
240
248
else :
241
249
if self .return_on_mfa :
242
250
token1 , token2 = self .garth .login (
243
- self .username , self .password , return_on_mfa = self .return_on_mfa
251
+ self .username ,
252
+ self .password ,
253
+ return_on_mfa = self .return_on_mfa ,
244
254
)
245
255
else :
246
256
token1 , token2 = self .garth .login (
@@ -249,12 +259,14 @@ def login(self, /, tokenstore: Optional[str] = None) -> tuple[Any, Any]:
249
259
self .display_name = self .garth .profile ["displayName" ]
250
260
self .full_name = self .garth .profile ["fullName" ]
251
261
252
- settings = self .garth .connectapi (self .garmin_connect_user_settings_url )
262
+ settings = self .garth .connectapi (
263
+ self .garmin_connect_user_settings_url
264
+ )
253
265
self .unit_system = settings ["userData" ]["measurementSystem" ]
254
266
255
267
return token1 , token2
256
268
257
- def resume_login (self ,client_state : dict , mfa_code : str ):
269
+ def resume_login (self , client_state : dict , mfa_code : str ):
258
270
"""Resume login using Garth."""
259
271
result1 , result2 = self .garth .resume_login (client_state , mfa_code )
260
272
@@ -980,7 +992,12 @@ def get_device_last_used(self):
980
992
981
993
return self .connectapi (url )
982
994
983
- def get_activities (self , start : int = 0 , limit : int = 20 , activitytype : Optional [str ] = None ):
995
+ def get_activities (
996
+ self ,
997
+ start : int = 0 ,
998
+ limit : int = 20 ,
999
+ activitytype : Optional [str ] = None ,
1000
+ ):
984
1001
"""
985
1002
Return available activities.
986
1003
:param start: Starting activity offset, where 0 means the most recent activity
@@ -1393,7 +1410,7 @@ def get_activity_gear(self, activity_id):
1393
1410
1394
1411
return self .connectapi (url , params = params )
1395
1412
1396
- def get_gear_ativities (self , gearUUID , limit = 9999 ):
1413
+ def get_gear_ativities (self , gearUUID , limit = 9999 ):
1397
1414
"""Return activities where gear uuid was used.
1398
1415
:param gearUUID: UUID of the gear to get activities for
1399
1416
:param limit: Maximum number of activities to return (default: 9999)
0 commit comments