Skip to content

Commit e80cc06

Browse files
Automatically update Python SDK
1 parent 64a6012 commit e80cc06

File tree

9 files changed

+600
-1
lines changed

9 files changed

+600
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "trophy"
7-
version = "1.0.40"
7+
version = "1.0.42"
88
description = "A Python library for the Trophy API"
99
license = {text = "MIT"}
1010
readme = "README.md"

trophy/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
MetricEventStreakResponse,
3535
MetricResponse,
3636
MetricStatus,
37+
NotificationChannel,
38+
NotificationPreferences,
39+
NotificationType,
3740
PointsAward,
3841
PointsRange,
3942
PointsSummaryResponse,
@@ -59,6 +62,7 @@
5962
UserAchievementWithStatsResponse,
6063
UserLeaderboardResponse,
6164
UserLeaderboardResponseWithHistory,
65+
UserPreferencesResponse,
6266
WebhookUserLeaderboardResponse,
6367
WebhooksAchievementCompletedPayload,
6468
WebhooksLeaderboardChangedPayload,
@@ -128,6 +132,9 @@
128132
"MetricResponse": ".types",
129133
"MetricStatus": ".types",
130134
"NotFoundError": ".errors",
135+
"NotificationChannel": ".types",
136+
"NotificationPreferences": ".types",
137+
"NotificationType": ".types",
131138
"PointsAward": ".types",
132139
"PointsRange": ".types",
133140
"PointsSummaryResponse": ".types",
@@ -158,6 +165,7 @@
158165
"UserAchievementWithStatsResponse": ".types",
159166
"UserLeaderboardResponse": ".types",
160167
"UserLeaderboardResponseWithHistory": ".types",
168+
"UserPreferencesResponse": ".types",
161169
"UsersMetricEventSummaryRequestAggregation": ".users",
162170
"UsersMetricEventSummaryResponseItem": ".users",
163171
"UsersPointsEventSummaryRequestAggregation": ".users",
@@ -249,6 +257,9 @@ def __dir__():
249257
"MetricResponse",
250258
"MetricStatus",
251259
"NotFoundError",
260+
"NotificationChannel",
261+
"NotificationPreferences",
262+
"NotificationType",
252263
"PointsAward",
253264
"PointsRange",
254265
"PointsSummaryResponse",
@@ -279,6 +290,7 @@ def __dir__():
279290
"UserAchievementWithStatsResponse",
280291
"UserLeaderboardResponse",
281292
"UserLeaderboardResponseWithHistory",
293+
"UserPreferencesResponse",
282294
"UsersMetricEventSummaryRequestAggregation",
283295
"UsersMetricEventSummaryResponseItem",
284296
"UsersPointsEventSummaryRequestAggregation",

trophy/types/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
from .metric_event_streak_response import MetricEventStreakResponse
3434
from .metric_response import MetricResponse
3535
from .metric_status import MetricStatus
36+
from .notification_channel import NotificationChannel
37+
from .notification_preferences import NotificationPreferences
38+
from .notification_type import NotificationType
3639
from .points_award import PointsAward
3740
from .points_range import PointsRange
3841
from .points_summary_response import PointsSummaryResponse
@@ -58,6 +61,7 @@
5861
from .user_achievement_with_stats_response import UserAchievementWithStatsResponse
5962
from .user_leaderboard_response import UserLeaderboardResponse
6063
from .user_leaderboard_response_with_history import UserLeaderboardResponseWithHistory
64+
from .user_preferences_response import UserPreferencesResponse
6165
from .webhook_user_leaderboard_response import WebhookUserLeaderboardResponse
6266
from .webhooks_achievement_completed_payload import WebhooksAchievementCompletedPayload
6367
from .webhooks_leaderboard_changed_payload import WebhooksLeaderboardChangedPayload
@@ -109,6 +113,9 @@
109113
"MetricEventStreakResponse": ".metric_event_streak_response",
110114
"MetricResponse": ".metric_response",
111115
"MetricStatus": ".metric_status",
116+
"NotificationChannel": ".notification_channel",
117+
"NotificationPreferences": ".notification_preferences",
118+
"NotificationType": ".notification_type",
112119
"PointsAward": ".points_award",
113120
"PointsRange": ".points_range",
114121
"PointsSummaryResponse": ".points_summary_response",
@@ -134,6 +141,7 @@
134141
"UserAchievementWithStatsResponse": ".user_achievement_with_stats_response",
135142
"UserLeaderboardResponse": ".user_leaderboard_response",
136143
"UserLeaderboardResponseWithHistory": ".user_leaderboard_response_with_history",
144+
"UserPreferencesResponse": ".user_preferences_response",
137145
"WebhookUserLeaderboardResponse": ".webhook_user_leaderboard_response",
138146
"WebhooksAchievementCompletedPayload": ".webhooks_achievement_completed_payload",
139147
"WebhooksLeaderboardChangedPayload": ".webhooks_leaderboard_changed_payload",
@@ -209,6 +217,9 @@ def __dir__():
209217
"MetricEventStreakResponse",
210218
"MetricResponse",
211219
"MetricStatus",
220+
"NotificationChannel",
221+
"NotificationPreferences",
222+
"NotificationType",
212223
"PointsAward",
213224
"PointsRange",
214225
"PointsSummaryResponse",
@@ -234,6 +245,7 @@ def __dir__():
234245
"UserAchievementWithStatsResponse",
235246
"UserLeaderboardResponse",
236247
"UserLeaderboardResponseWithHistory",
248+
"UserPreferencesResponse",
237249
"WebhookUserLeaderboardResponse",
238250
"WebhooksAchievementCompletedPayload",
239251
"WebhooksLeaderboardChangedPayload",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
NotificationChannel = typing.Union[typing.Literal["email", "push"], typing.Any]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
import pydantic
6+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7+
from .notification_channel import NotificationChannel
8+
9+
10+
class NotificationPreferences(UniversalBaseModel):
11+
"""
12+
Notification preferences for each notification type.
13+
"""
14+
15+
achievement_completed: typing.Optional[typing.List[NotificationChannel]] = pydantic.Field(default=None)
16+
"""
17+
Channels to receive achievement completion notifications on.
18+
"""
19+
20+
recap: typing.Optional[typing.List[NotificationChannel]] = pydantic.Field(default=None)
21+
"""
22+
Channels to receive recap notifications on.
23+
"""
24+
25+
reactivation: typing.Optional[typing.List[NotificationChannel]] = pydantic.Field(default=None)
26+
"""
27+
Channels to receive reactivation notifications on.
28+
"""
29+
30+
streak_reminder: typing.Optional[typing.List[NotificationChannel]] = pydantic.Field(default=None)
31+
"""
32+
Channels to receive streak reminder notifications on.
33+
"""
34+
35+
if IS_PYDANTIC_V2:
36+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
37+
else:
38+
39+
class Config:
40+
frozen = True
41+
smart_union = True
42+
extra = pydantic.Extra.allow

trophy/types/notification_type.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
NotificationType = typing.Union[
6+
typing.Literal["achievement_completed", "recap", "reactivation", "streak_reminder"], typing.Any
7+
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
import pydantic
6+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7+
from .notification_preferences import NotificationPreferences
8+
9+
10+
class UserPreferencesResponse(UniversalBaseModel):
11+
"""
12+
A user's preferences.
13+
"""
14+
15+
notifications: NotificationPreferences
16+
17+
if IS_PYDANTIC_V2:
18+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
19+
else:
20+
21+
class Config:
22+
frozen = True
23+
smart_union = True
24+
extra = pydantic.Extra.allow

trophy/users/client.py

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
from ..core.request_options import RequestOptions
77
from ..types.get_user_points_response import GetUserPointsResponse
88
from ..types.metric_response import MetricResponse
9+
from ..types.notification_preferences import NotificationPreferences
910
from ..types.streak_response import StreakResponse
1011
from ..types.user import User
1112
from ..types.user_achievement_with_stats_response import UserAchievementWithStatsResponse
1213
from ..types.user_leaderboard_response_with_history import UserLeaderboardResponseWithHistory
14+
from ..types.user_preferences_response import UserPreferencesResponse
1315
from ..types.wrapped_response import WrappedResponse
1416
from .raw_client import AsyncRawUsersClient, RawUsersClient
1517
from .types.users_metric_event_summary_request_aggregation import UsersMetricEventSummaryRequestAggregation
@@ -280,6 +282,83 @@ def update(
280282
)
281283
return _response.data
282284

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+
283362
def all_metrics(
284363
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
285364
) -> typing.List[MetricResponse]:
@@ -977,6 +1056,99 @@ async def main() -> None:
9771056
)
9781057
return _response.data
9791058

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+
9801152
async def all_metrics(
9811153
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
9821154
) -> typing.List[MetricResponse]:

0 commit comments

Comments
 (0)