|
6 | 6 | from ..core.request_options import RequestOptions |
7 | 7 | from ..types.get_user_points_response import GetUserPointsResponse |
8 | 8 | from ..types.metric_response import MetricResponse |
| 9 | +from ..types.notification_preferences import NotificationPreferences |
9 | 10 | from ..types.streak_response import StreakResponse |
10 | 11 | from ..types.user import User |
11 | 12 | from ..types.user_achievement_with_stats_response import UserAchievementWithStatsResponse |
12 | 13 | from ..types.user_leaderboard_response_with_history import UserLeaderboardResponseWithHistory |
| 14 | +from ..types.user_preferences_response import UserPreferencesResponse |
13 | 15 | from ..types.wrapped_response import WrappedResponse |
14 | 16 | from .raw_client import AsyncRawUsersClient, RawUsersClient |
15 | 17 | from .types.users_metric_event_summary_request_aggregation import UsersMetricEventSummaryRequestAggregation |
@@ -280,6 +282,83 @@ def update( |
280 | 282 | ) |
281 | 283 | return _response.data |
282 | 284 |
|
| 285 | + def get_preferences( |
| 286 | + self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 287 | + ) -> UserPreferencesResponse: |
| 288 | + """ |
| 289 | + Get a user's notification preferences. |
| 290 | +
|
| 291 | + Parameters |
| 292 | + ---------- |
| 293 | + id : str |
| 294 | + The user's ID in your database. |
| 295 | +
|
| 296 | + request_options : typing.Optional[RequestOptions] |
| 297 | + Request-specific configuration. |
| 298 | +
|
| 299 | + Returns |
| 300 | + ------- |
| 301 | + UserPreferencesResponse |
| 302 | + Successful operation |
| 303 | +
|
| 304 | + Examples |
| 305 | + -------- |
| 306 | + from trophy import TrophyApi |
| 307 | +
|
| 308 | + client = TrophyApi( |
| 309 | + api_key="YOUR_API_KEY", |
| 310 | + ) |
| 311 | + client.users.get_preferences( |
| 312 | + id="user-123", |
| 313 | + ) |
| 314 | + """ |
| 315 | + _response = self._raw_client.get_preferences(id, request_options=request_options) |
| 316 | + return _response.data |
| 317 | + |
| 318 | + def update_preferences( |
| 319 | + self, |
| 320 | + id: str, |
| 321 | + *, |
| 322 | + notifications: typing.Optional[NotificationPreferences] = OMIT, |
| 323 | + request_options: typing.Optional[RequestOptions] = None, |
| 324 | + ) -> UserPreferencesResponse: |
| 325 | + """ |
| 326 | + Update a user's notification preferences. |
| 327 | +
|
| 328 | + Parameters |
| 329 | + ---------- |
| 330 | + id : str |
| 331 | + The user's ID in your database. |
| 332 | +
|
| 333 | + notifications : typing.Optional[NotificationPreferences] |
| 334 | +
|
| 335 | + request_options : typing.Optional[RequestOptions] |
| 336 | + Request-specific configuration. |
| 337 | +
|
| 338 | + Returns |
| 339 | + ------- |
| 340 | + UserPreferencesResponse |
| 341 | + Successful operation |
| 342 | +
|
| 343 | + Examples |
| 344 | + -------- |
| 345 | + from trophy import NotificationPreferences, TrophyApi |
| 346 | +
|
| 347 | + client = TrophyApi( |
| 348 | + api_key="YOUR_API_KEY", |
| 349 | + ) |
| 350 | + client.users.update_preferences( |
| 351 | + id="user-123", |
| 352 | + notifications=NotificationPreferences( |
| 353 | + streak_reminder=["email"], |
| 354 | + ), |
| 355 | + ) |
| 356 | + """ |
| 357 | + _response = self._raw_client.update_preferences( |
| 358 | + id, notifications=notifications, request_options=request_options |
| 359 | + ) |
| 360 | + return _response.data |
| 361 | + |
283 | 362 | def all_metrics( |
284 | 363 | self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
285 | 364 | ) -> typing.List[MetricResponse]: |
@@ -977,6 +1056,99 @@ async def main() -> None: |
977 | 1056 | ) |
978 | 1057 | return _response.data |
979 | 1058 |
|
| 1059 | + async def get_preferences( |
| 1060 | + self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1061 | + ) -> UserPreferencesResponse: |
| 1062 | + """ |
| 1063 | + Get a user's notification preferences. |
| 1064 | +
|
| 1065 | + Parameters |
| 1066 | + ---------- |
| 1067 | + id : str |
| 1068 | + The user's ID in your database. |
| 1069 | +
|
| 1070 | + request_options : typing.Optional[RequestOptions] |
| 1071 | + Request-specific configuration. |
| 1072 | +
|
| 1073 | + Returns |
| 1074 | + ------- |
| 1075 | + UserPreferencesResponse |
| 1076 | + Successful operation |
| 1077 | +
|
| 1078 | + Examples |
| 1079 | + -------- |
| 1080 | + import asyncio |
| 1081 | +
|
| 1082 | + from trophy import AsyncTrophyApi |
| 1083 | +
|
| 1084 | + client = AsyncTrophyApi( |
| 1085 | + api_key="YOUR_API_KEY", |
| 1086 | + ) |
| 1087 | +
|
| 1088 | +
|
| 1089 | + async def main() -> None: |
| 1090 | + await client.users.get_preferences( |
| 1091 | + id="user-123", |
| 1092 | + ) |
| 1093 | +
|
| 1094 | +
|
| 1095 | + asyncio.run(main()) |
| 1096 | + """ |
| 1097 | + _response = await self._raw_client.get_preferences(id, request_options=request_options) |
| 1098 | + return _response.data |
| 1099 | + |
| 1100 | + async def update_preferences( |
| 1101 | + self, |
| 1102 | + id: str, |
| 1103 | + *, |
| 1104 | + notifications: typing.Optional[NotificationPreferences] = OMIT, |
| 1105 | + request_options: typing.Optional[RequestOptions] = None, |
| 1106 | + ) -> UserPreferencesResponse: |
| 1107 | + """ |
| 1108 | + Update a user's notification preferences. |
| 1109 | +
|
| 1110 | + Parameters |
| 1111 | + ---------- |
| 1112 | + id : str |
| 1113 | + The user's ID in your database. |
| 1114 | +
|
| 1115 | + notifications : typing.Optional[NotificationPreferences] |
| 1116 | +
|
| 1117 | + request_options : typing.Optional[RequestOptions] |
| 1118 | + Request-specific configuration. |
| 1119 | +
|
| 1120 | + Returns |
| 1121 | + ------- |
| 1122 | + UserPreferencesResponse |
| 1123 | + Successful operation |
| 1124 | +
|
| 1125 | + Examples |
| 1126 | + -------- |
| 1127 | + import asyncio |
| 1128 | +
|
| 1129 | + from trophy import AsyncTrophyApi, NotificationPreferences |
| 1130 | +
|
| 1131 | + client = AsyncTrophyApi( |
| 1132 | + api_key="YOUR_API_KEY", |
| 1133 | + ) |
| 1134 | +
|
| 1135 | +
|
| 1136 | + async def main() -> None: |
| 1137 | + await client.users.update_preferences( |
| 1138 | + id="user-123", |
| 1139 | + notifications=NotificationPreferences( |
| 1140 | + streak_reminder=["email"], |
| 1141 | + ), |
| 1142 | + ) |
| 1143 | +
|
| 1144 | +
|
| 1145 | + asyncio.run(main()) |
| 1146 | + """ |
| 1147 | + _response = await self._raw_client.update_preferences( |
| 1148 | + id, notifications=notifications, request_options=request_options |
| 1149 | + ) |
| 1150 | + return _response.data |
| 1151 | + |
980 | 1152 | async def all_metrics( |
981 | 1153 | self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
982 | 1154 | ) -> typing.List[MetricResponse]: |
|
0 commit comments