sweatstack 0.44.0__py3-none-any.whl → 0.45.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sweatstack/client.py +27 -0
- sweatstack/schemas.py +12 -1
- {sweatstack-0.44.0.dist-info → sweatstack-0.45.0.dist-info}/METADATA +1 -1
- {sweatstack-0.44.0.dist-info → sweatstack-0.45.0.dist-info}/RECORD +6 -6
- {sweatstack-0.44.0.dist-info → sweatstack-0.45.0.dist-info}/WHEEL +0 -0
- {sweatstack-0.44.0.dist-info → sweatstack-0.45.0.dist-info}/entry_points.txt +0 -0
sweatstack/client.py
CHANGED
|
@@ -1204,6 +1204,32 @@ class Client(OAuth2Mixin, DelegationMixin, TokenStorageMixin):
|
|
|
1204
1204
|
self._raise_for_status(response)
|
|
1205
1205
|
return UserInfoResponse.model_validate(response.json())
|
|
1206
1206
|
|
|
1207
|
+
def whoami(self) -> UserSummary:
|
|
1208
|
+
"""Gets the authenticated user's summary information.
|
|
1209
|
+
|
|
1210
|
+
This method retrieves basic information about the currently authenticated user
|
|
1211
|
+
by extracting the user ID from the JWT token and fetching the user details.
|
|
1212
|
+
|
|
1213
|
+
Returns:
|
|
1214
|
+
UserSummary: A UserSummary object containing the authenticated user's information.
|
|
1215
|
+
|
|
1216
|
+
Raises:
|
|
1217
|
+
ValueError: If no authentication token is available.
|
|
1218
|
+
HTTPStatusError: If the API request fails or user is not found.
|
|
1219
|
+
"""
|
|
1220
|
+
if not self.api_key:
|
|
1221
|
+
raise ValueError("Not authenticated. Please call authenticate() or login() first.")
|
|
1222
|
+
|
|
1223
|
+
try:
|
|
1224
|
+
jwt_body = decode_jwt_body(self.api_key)
|
|
1225
|
+
user_id = jwt_body.get("sub")
|
|
1226
|
+
if not user_id:
|
|
1227
|
+
raise ValueError("Unable to extract user ID from token")
|
|
1228
|
+
except Exception as e:
|
|
1229
|
+
raise ValueError(f"Invalid authentication token: {e}")
|
|
1230
|
+
|
|
1231
|
+
return self._get_user_by_id(user_id)
|
|
1232
|
+
|
|
1207
1233
|
|
|
1208
1234
|
_default_client = Client()
|
|
1209
1235
|
|
|
@@ -1248,6 +1274,7 @@ _generate_singleton_methods(
|
|
|
1248
1274
|
"get_user",
|
|
1249
1275
|
"get_users",
|
|
1250
1276
|
"get_userinfo",
|
|
1277
|
+
"whoami",
|
|
1251
1278
|
|
|
1252
1279
|
"get_activities",
|
|
1253
1280
|
|
sweatstack/schemas.py
CHANGED
|
@@ -101,4 +101,15 @@ def display_name(sport: Sport) -> str:
|
|
|
101
101
|
Sport.root_sport = root_sport
|
|
102
102
|
Sport.parent_sport = parent_sport
|
|
103
103
|
Sport.is_sub_sport_of = is_sub_sport_of
|
|
104
|
-
Sport.display_name = display_name
|
|
104
|
+
Sport.display_name = display_name
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def metric_display_name(metric: Metric) -> str:
|
|
108
|
+
"""Returns a human-readable display name for a metric.
|
|
109
|
+
|
|
110
|
+
This function converts a Metric enum value into a formatted string suitable for display.
|
|
111
|
+
"""
|
|
112
|
+
return metric.value.replace("_", " ")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
Metric.display_name = metric_display_name
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
sweatstack/__init__.py,sha256=tiVfgKlswRPaDMEy0gA7u8rveqEYZTA_kyB9lJ3J6Sc,21
|
|
2
2
|
sweatstack/cli.py,sha256=N1NWOgEZR2yaJvIXxo9qvp_jFlypZYb0nujpbVNYQ6A,720
|
|
3
|
-
sweatstack/client.py,sha256=
|
|
3
|
+
sweatstack/client.py,sha256=bea8IY72fH93PES-dKMbNaB02k_GepRDzVMxEQuBI4g,46966
|
|
4
4
|
sweatstack/constants.py,sha256=fGO6ksOv5HeISv9lHRoYm4besW1GTveXS8YD3K0ljg0,41
|
|
5
5
|
sweatstack/ipython_init.py,sha256=OtBB9dQvyLXklD4kA2x1swaVtU9u73fG4V4-zz4YRAg,139
|
|
6
6
|
sweatstack/jupyterlab_oauth2_startup.py,sha256=YcjXvzeZ459vL_dCkFi1IxX_RNAu80ZX9rwa0OXJfTM,1023
|
|
7
7
|
sweatstack/openapi_schemas.py,sha256=uS5p_ksdF605FNTOhJ_VPPUCxJHOVJwyIOwVfXS-wEI,37019
|
|
8
8
|
sweatstack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
sweatstack/schemas.py,sha256=
|
|
9
|
+
sweatstack/schemas.py,sha256=cYefSktNv9VJoq4PQ5SrUvZRRwB637xNOaj7kjzjocM,3667
|
|
10
10
|
sweatstack/streamlit.py,sha256=_PER03s0dYu5eF1MZdewPDqSvYHqMr0lZLu_EnGit3Y,13257
|
|
11
11
|
sweatstack/sweatshell.py,sha256=MYLNcWbOdceqKJ3S0Pe8dwHXEeYsGJNjQoYUXpMTftA,333
|
|
12
12
|
sweatstack/utils.py,sha256=AwHRdC1ziOZ5o9RBIB21Uxm-DoClVRAJSVvgsmSmvps,1801
|
|
13
13
|
sweatstack/Sweat Stack examples/Getting started.ipynb,sha256=k2hiSffWecoQ0VxjdpDcgFzBXDQiYEebhnAYlu8cgX8,6335204
|
|
14
|
-
sweatstack-0.
|
|
15
|
-
sweatstack-0.
|
|
16
|
-
sweatstack-0.
|
|
17
|
-
sweatstack-0.
|
|
14
|
+
sweatstack-0.45.0.dist-info/METADATA,sha256=cos9ZNDCxVPlXUjrcqEiozVN5js56jh0qy_Gx3zElos,814
|
|
15
|
+
sweatstack-0.45.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
+
sweatstack-0.45.0.dist-info/entry_points.txt,sha256=kCzOUQI3dqbTpEYqtgYDeiKFaqaA7BMlV6D24BMzCFU,208
|
|
17
|
+
sweatstack-0.45.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|