Skip to content

Commit e69d4ef

Browse files
Automatically update Python SDK
1 parent 8aaf7b4 commit e69d4ef

File tree

9 files changed

+219
-215
lines changed

9 files changed

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

trophy/achievements/client.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ def complete(
9494
key="finish-onboarding",
9595
user=UpsertedUser(
9696
email="user@example.com",
97-
name="User",
9897
tz="Europe/London",
99-
device_tokens=["token1", "token2"],
100-
subscribe_to_emails=True,
101-
attributes={"department": "engineering", "role": "developer"},
10298
id="user-id",
10399
),
104100
)
@@ -201,11 +197,7 @@ async def main() -> None:
201197
key="finish-onboarding",
202198
user=UpsertedUser(
203199
email="user@example.com",
204-
name="User",
205200
tz="Europe/London",
206-
device_tokens=["token1", "token2"],
207-
subscribe_to_emails=True,
208-
attributes={"department": "engineering", "role": "developer"},
209201
id="user-id",
210202
),
211203
)

trophy/leaderboards/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get(
7575
Number of rankings to skip for pagination.
7676
7777
limit : typing.Optional[int]
78-
Maximum number of rankings to return.
78+
Maximum number of rankings to return. Cannot be greater than the size of the leaderboard.
7979
8080
run : typing.Optional[str]
8181
Specific run date in YYYY-MM-DD format. If not provided, returns the current run.
@@ -84,7 +84,7 @@ def get(
8484
When provided, offset is relative to this user's position on the leaderboard. If the user is not found in the leaderboard, returns empty rankings array.
8585
8686
user_attributes : typing.Optional[str]
87-
Attribute key and value to filter the rankings by, separated by a colon. This parameter is required, and only valid for leaderboards with a breakdown attribute.
87+
Attribute key and value to filter the rankings by, separated by a colon. For example, `city:London`. This parameter is required, and only valid for leaderboards with a breakdown attribute.
8888
8989
request_options : typing.Optional[RequestOptions]
9090
Request-specific configuration.
@@ -196,7 +196,7 @@ async def get(
196196
Number of rankings to skip for pagination.
197197
198198
limit : typing.Optional[int]
199-
Maximum number of rankings to return.
199+
Maximum number of rankings to return. Cannot be greater than the size of the leaderboard.
200200
201201
run : typing.Optional[str]
202202
Specific run date in YYYY-MM-DD format. If not provided, returns the current run.
@@ -205,7 +205,7 @@ async def get(
205205
When provided, offset is relative to this user's position on the leaderboard. If the user is not found in the leaderboard, returns empty rankings array.
206206
207207
user_attributes : typing.Optional[str]
208-
Attribute key and value to filter the rankings by, separated by a colon. This parameter is required, and only valid for leaderboards with a breakdown attribute.
208+
Attribute key and value to filter the rankings by, separated by a colon. For example, `city:London`. This parameter is required, and only valid for leaderboards with a breakdown attribute.
209209
210210
request_options : typing.Optional[RequestOptions]
211211
Request-specific configuration.

trophy/leaderboards/raw_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def get(
103103
Number of rankings to skip for pagination.
104104
105105
limit : typing.Optional[int]
106-
Maximum number of rankings to return.
106+
Maximum number of rankings to return. Cannot be greater than the size of the leaderboard.
107107
108108
run : typing.Optional[str]
109109
Specific run date in YYYY-MM-DD format. If not provided, returns the current run.
@@ -112,7 +112,7 @@ def get(
112112
When provided, offset is relative to this user's position on the leaderboard. If the user is not found in the leaderboard, returns empty rankings array.
113113
114114
user_attributes : typing.Optional[str]
115-
Attribute key and value to filter the rankings by, separated by a colon. This parameter is required, and only valid for leaderboards with a breakdown attribute.
115+
Attribute key and value to filter the rankings by, separated by a colon. For example, `city:London`. This parameter is required, and only valid for leaderboards with a breakdown attribute.
116116
117117
request_options : typing.Optional[RequestOptions]
118118
Request-specific configuration.
@@ -270,7 +270,7 @@ async def get(
270270
Number of rankings to skip for pagination.
271271
272272
limit : typing.Optional[int]
273-
Maximum number of rankings to return.
273+
Maximum number of rankings to return. Cannot be greater than the size of the leaderboard.
274274
275275
run : typing.Optional[str]
276276
Specific run date in YYYY-MM-DD format. If not provided, returns the current run.
@@ -279,7 +279,7 @@ async def get(
279279
When provided, offset is relative to this user's position on the leaderboard. If the user is not found in the leaderboard, returns empty rankings array.
280280
281281
user_attributes : typing.Optional[str]
282-
Attribute key and value to filter the rankings by, separated by a colon. This parameter is required, and only valid for leaderboards with a breakdown attribute.
282+
Attribute key and value to filter the rankings by, separated by a colon. For example, `city:London`. This parameter is required, and only valid for leaderboards with a breakdown attribute.
283283
284284
request_options : typing.Optional[RequestOptions]
285285
Request-specific configuration.

trophy/metrics/client.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ def event(
7777
idempotency_key="e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
7878
user=UpsertedUser(
7979
email="user@example.com",
80-
name="User",
8180
tz="Europe/London",
82-
device_tokens=["token1", "token2"],
83-
subscribe_to_emails=True,
8481
attributes={"department": "engineering", "role": "developer"},
8582
id="18",
8683
),
@@ -169,10 +166,7 @@ async def main() -> None:
169166
idempotency_key="e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
170167
user=UpsertedUser(
171168
email="user@example.com",
172-
name="User",
173169
tz="Europe/London",
174-
device_tokens=["token1", "token2"],
175-
subscribe_to_emails=True,
176170
attributes={"department": "engineering", "role": "developer"},
177171
id="18",
178172
),

trophy/types/updated_user.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class UpdatedUser(UniversalBaseModel):
1313
An object with editable user fields.
1414
"""
1515

16-
email: str = pydantic.Field()
16+
email: typing.Optional[str] = pydantic.Field(default=None)
1717
"""
1818
The user's email address. Required if subscribeToEmails is true.
1919
"""
2020

21-
name: str = pydantic.Field()
21+
name: typing.Optional[str] = pydantic.Field(default=None)
2222
"""
2323
The name to refer to the user by in emails.
2424
"""
@@ -28,17 +28,21 @@ class UpdatedUser(UniversalBaseModel):
2828
The user's timezone (used for email scheduling).
2929
"""
3030

31-
device_tokens: typing_extensions.Annotated[typing.List[str], FieldMetadata(alias="deviceTokens")] = pydantic.Field()
31+
device_tokens: typing_extensions.Annotated[
32+
typing.Optional[typing.List[str]], FieldMetadata(alias="deviceTokens")
33+
] = pydantic.Field(default=None)
3234
"""
3335
The user's device tokens, used for push notifications.
3436
"""
3537

36-
subscribe_to_emails: typing_extensions.Annotated[bool, FieldMetadata(alias="subscribeToEmails")] = pydantic.Field()
38+
subscribe_to_emails: typing_extensions.Annotated[
39+
typing.Optional[bool], FieldMetadata(alias="subscribeToEmails")
40+
] = pydantic.Field(default=None)
3741
"""
3842
Whether the user should receive Trophy-powered emails. If false, Trophy will not store the user's email address.
3943
"""
4044

41-
attributes: typing.Dict[str, str] = pydantic.Field()
45+
attributes: typing.Optional[typing.Dict[str, str]] = pydantic.Field(default=None)
4246
"""
4347
User attributes as key-value pairs. Keys must match existing user attributes set up in the Trophy dashboard.
4448
"""

trophy/types/user.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,51 @@
44
import typing
55

66
import pydantic
7-
from ..core.pydantic_utilities import IS_PYDANTIC_V2
8-
from .upserted_user import UpsertedUser
7+
import typing_extensions
8+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
9+
from ..core.serialization import FieldMetadata
910

1011

11-
class User(UpsertedUser):
12+
class User(UniversalBaseModel):
1213
"""
1314
A user of your application.
1415
"""
1516

17+
id: str = pydantic.Field()
18+
"""
19+
The ID of the user in your database. Must be a string.
20+
"""
21+
22+
email: typing.Optional[str] = pydantic.Field(default=None)
23+
"""
24+
The user's email address.
25+
"""
26+
27+
name: typing.Optional[str] = pydantic.Field(default=None)
28+
"""
29+
The name of the user.
30+
"""
31+
32+
tz: typing.Optional[str] = pydantic.Field(default=None)
33+
"""
34+
The user's timezone.
35+
"""
36+
37+
device_tokens: typing_extensions.Annotated[typing.List[str], FieldMetadata(alias="deviceTokens")] = pydantic.Field()
38+
"""
39+
The user's device tokens.
40+
"""
41+
42+
subscribe_to_emails: typing_extensions.Annotated[bool, FieldMetadata(alias="subscribeToEmails")] = pydantic.Field()
43+
"""
44+
Whether the user is opted into receiving Trophy-powered emails.
45+
"""
46+
47+
attributes: typing.Dict[str, str] = pydantic.Field()
48+
"""
49+
User attributes as key-value pairs. Keys must match existing user attributes set up in the Trophy dashboard.
50+
"""
51+
1652
control: bool = pydantic.Field()
1753
"""
1854
Whether the user is in the control group, meaning they do not receive emails or other communications from Trophy.

0 commit comments

Comments
 (0)