Skip to content

Commit 1fad25f

Browse files
Automatically update Python SDK
1 parent 74f1fde commit 1fad25f

11 files changed

Lines changed: 156 additions & 9 deletions

‎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.12.0"
7+
version = "1.13.0"
88
description = "A Python library for the Trophy API"
99
license = {text = "MIT"}
1010
readme = "README.md"

‎trophy/__init__.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@
157157
PointsTriggerType,
158158
PointsTriggerUserAttributesItem,
159159
RestoreStreaksResponse,
160+
StreakEvaluationModePreference,
160161
StreakFrequency,
162+
StreakMetricPreference,
163+
StreakPreferences,
161164
StreakResponse,
162165
StreakResponseStreakHistoryItem,
163166
UpdateAttributeRequestItem,
@@ -216,7 +219,7 @@
216219
WrappedResponse,
217220
WrappedStreak,
218221
)
219-
from .errors import BadRequestError, NotFoundError, UnauthorizedError, UnprocessableEntityError
222+
from .errors import BadRequestError, ForbiddenError, NotFoundError, UnauthorizedError, UnprocessableEntityError
220223
from . import achievements, admin, leaderboards, metrics, points, streaks, users
221224
from .client import AsyncTrophyApi, TrophyApi
222225
from .environment import TrophyApiEnvironment
@@ -318,6 +321,7 @@
318321
"DeletedResource": ".types",
319322
"ErrorBody": ".types",
320323
"EventResponse": ".types",
324+
"ForbiddenError": ".errors",
321325
"GetUserPointsResponse": ".types",
322326
"LeaderboardEvent": ".types",
323327
"LeaderboardRanking": ".types",
@@ -383,7 +387,10 @@
383387
"PointsTriggerType": ".types",
384388
"PointsTriggerUserAttributesItem": ".types",
385389
"RestoreStreaksResponse": ".types",
390+
"StreakEvaluationModePreference": ".types",
386391
"StreakFrequency": ".types",
392+
"StreakMetricPreference": ".types",
393+
"StreakPreferences": ".types",
387394
"StreakResponse": ".types",
388395
"StreakResponseStreakHistoryItem": ".types",
389396
"TrophyApi": ".client",
@@ -571,6 +578,7 @@ def __dir__():
571578
"DeletedResource",
572579
"ErrorBody",
573580
"EventResponse",
581+
"ForbiddenError",
574582
"GetUserPointsResponse",
575583
"LeaderboardEvent",
576584
"LeaderboardRanking",
@@ -636,7 +644,10 @@ def __dir__():
636644
"PointsTriggerType",
637645
"PointsTriggerUserAttributesItem",
638646
"RestoreStreaksResponse",
647+
"StreakEvaluationModePreference",
639648
"StreakFrequency",
649+
"StreakMetricPreference",
650+
"StreakPreferences",
640651
"StreakResponse",
641652
"StreakResponseStreakHistoryItem",
642653
"TrophyApi",

‎trophy/errors/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
if typing.TYPE_CHECKING:
99
from .bad_request_error import BadRequestError
10+
from .forbidden_error import ForbiddenError
1011
from .not_found_error import NotFoundError
1112
from .unauthorized_error import UnauthorizedError
1213
from .unprocessable_entity_error import UnprocessableEntityError
1314
_dynamic_imports: typing.Dict[str, str] = {
1415
"BadRequestError": ".bad_request_error",
16+
"ForbiddenError": ".forbidden_error",
1517
"NotFoundError": ".not_found_error",
1618
"UnauthorizedError": ".unauthorized_error",
1719
"UnprocessableEntityError": ".unprocessable_entity_error",
@@ -39,4 +41,4 @@ def __dir__():
3941
return sorted(lazy_attrs)
4042

4143

42-
__all__ = ["BadRequestError", "NotFoundError", "UnauthorizedError", "UnprocessableEntityError"]
44+
__all__ = ["BadRequestError", "ForbiddenError", "NotFoundError", "UnauthorizedError", "UnprocessableEntityError"]

‎trophy/errors/forbidden_error.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
from ..core.api_error import ApiError
6+
from ..types.error_body import ErrorBody
7+
8+
9+
class ForbiddenError(ApiError):
10+
def __init__(self, body: ErrorBody, headers: typing.Optional[typing.Dict[str, str]] = None):
11+
super().__init__(status_code=403, headers=headers, body=body)

‎trophy/types/__init__.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@
166166
from .points_trigger_type import PointsTriggerType
167167
from .points_trigger_user_attributes_item import PointsTriggerUserAttributesItem
168168
from .restore_streaks_response import RestoreStreaksResponse
169+
from .streak_evaluation_mode_preference import StreakEvaluationModePreference
169170
from .streak_frequency import StreakFrequency
171+
from .streak_metric_preference import StreakMetricPreference
172+
from .streak_preferences import StreakPreferences
170173
from .streak_response import StreakResponse
171174
from .streak_response_streak_history_item import StreakResponseStreakHistoryItem
172175
from .update_attribute_request_item import UpdateAttributeRequestItem
@@ -375,7 +378,10 @@
375378
"PointsTriggerType": ".points_trigger_type",
376379
"PointsTriggerUserAttributesItem": ".points_trigger_user_attributes_item",
377380
"RestoreStreaksResponse": ".restore_streaks_response",
381+
"StreakEvaluationModePreference": ".streak_evaluation_mode_preference",
378382
"StreakFrequency": ".streak_frequency",
383+
"StreakMetricPreference": ".streak_metric_preference",
384+
"StreakPreferences": ".streak_preferences",
379385
"StreakResponse": ".streak_response",
380386
"StreakResponseStreakHistoryItem": ".streak_response_streak_history_item",
381387
"UpdateAttributeRequestItem": ".update_attribute_request_item",
@@ -608,7 +614,10 @@ def __dir__():
608614
"PointsTriggerType",
609615
"PointsTriggerUserAttributesItem",
610616
"RestoreStreaksResponse",
617+
"StreakEvaluationModePreference",
611618
"StreakFrequency",
619+
"StreakMetricPreference",
620+
"StreakPreferences",
612621
"StreakResponse",
613622
"StreakResponseStreakHistoryItem",
614623
"UpdateAttributeRequestItem",
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+
StreakEvaluationModePreference = typing.Union[typing.Literal["OR", "AND"], typing.Any]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
8+
9+
class StreakMetricPreference(UniversalBaseModel):
10+
"""
11+
Per-metric streak threshold override for a user.
12+
"""
13+
14+
key: str = pydantic.Field()
15+
"""
16+
The metric key.
17+
"""
18+
19+
threshold: float = pydantic.Field()
20+
"""
21+
Minimum metric change in a streak period to count toward the streak.
22+
"""
23+
24+
if IS_PYDANTIC_V2:
25+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
26+
else:
27+
28+
class Config:
29+
frozen = True
30+
smart_union = True
31+
extra = pydantic.Extra.allow

‎trophy/types/streak_preferences.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
import pydantic
6+
import typing_extensions
7+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8+
from ..core.serialization import FieldMetadata
9+
from .streak_evaluation_mode_preference import StreakEvaluationModePreference
10+
from .streak_metric_preference import StreakMetricPreference
11+
12+
13+
class StreakPreferences(UniversalBaseModel):
14+
"""
15+
Per-user streak configuration. Requires streak customization to be enabled in dashboard settings.
16+
"""
17+
18+
evaluation_mode: typing_extensions.Annotated[
19+
typing.Optional[StreakEvaluationModePreference], FieldMetadata(alias="evaluationMode")
20+
] = None
21+
metrics: typing.Optional[typing.List[StreakMetricPreference]] = pydantic.Field(default=None)
22+
"""
23+
Metrics and thresholds that count toward this user's streak.
24+
"""
25+
26+
if IS_PYDANTIC_V2:
27+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
28+
else:
29+
30+
class Config:
31+
frozen = True
32+
smart_union = True
33+
extra = pydantic.Extra.allow

‎trophy/types/user_preferences_response.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pydantic
66
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
77
from .notification_preferences import NotificationPreferences
8+
from .streak_preferences import StreakPreferences
89

910

1011
class UserPreferencesResponse(UniversalBaseModel):
@@ -13,6 +14,7 @@ class UserPreferencesResponse(UniversalBaseModel):
1314
"""
1415

1516
notifications: NotificationPreferences
17+
streak: typing.Optional[StreakPreferences] = None
1618

1719
if IS_PYDANTIC_V2:
1820
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2

‎trophy/users/client.py‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ..types.metric_response import MetricResponse
99
from ..types.notification_preferences import NotificationPreferences
1010
from ..types.points_boost import PointsBoost
11+
from ..types.streak_preferences import StreakPreferences
1112
from ..types.streak_response import StreakResponse
1213
from ..types.user import User
1314
from ..types.user_achievement_with_stats_response import UserAchievementWithStatsResponse
@@ -326,10 +327,11 @@ def update_preferences(
326327
id: str,
327328
*,
328329
notifications: typing.Optional[NotificationPreferences] = OMIT,
330+
streak: typing.Optional[StreakPreferences] = OMIT,
329331
request_options: typing.Optional[RequestOptions] = None,
330332
) -> UserPreferencesResponse:
331333
"""
332-
Update a user's notification preferences.
334+
Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
333335
334336
Parameters
335337
----------
@@ -338,6 +340,8 @@ def update_preferences(
338340
339341
notifications : typing.Optional[NotificationPreferences]
340342
343+
streak : typing.Optional[StreakPreferences]
344+
341345
request_options : typing.Optional[RequestOptions]
342346
Request-specific configuration.
343347
@@ -362,7 +366,7 @@ def update_preferences(
362366
)
363367
"""
364368
_response = self._raw_client.update_preferences(
365-
id, notifications=notifications, request_options=request_options
369+
id, notifications=notifications, streak=streak, request_options=request_options
366370
)
367371
return _response.data
368372

@@ -1161,10 +1165,11 @@ async def update_preferences(
11611165
id: str,
11621166
*,
11631167
notifications: typing.Optional[NotificationPreferences] = OMIT,
1168+
streak: typing.Optional[StreakPreferences] = OMIT,
11641169
request_options: typing.Optional[RequestOptions] = None,
11651170
) -> UserPreferencesResponse:
11661171
"""
1167-
Update a user's notification preferences.
1172+
Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
11681173
11691174
Parameters
11701175
----------
@@ -1173,6 +1178,8 @@ async def update_preferences(
11731178
11741179
notifications : typing.Optional[NotificationPreferences]
11751180
1181+
streak : typing.Optional[StreakPreferences]
1182+
11761183
request_options : typing.Optional[RequestOptions]
11771184
Request-specific configuration.
11781185
@@ -1205,7 +1212,7 @@ async def main() -> None:
12051212
asyncio.run(main())
12061213
"""
12071214
_response = await self._raw_client.update_preferences(
1208-
id, notifications=notifications, request_options=request_options
1215+
id, notifications=notifications, streak=streak, request_options=request_options
12091216
)
12101217
return _response.data
12111218

0 commit comments

Comments
 (0)