Skip to content

Commit 8aaf7b4

Browse files
Automatically update Python SDK
1 parent 5590aa8 commit 8aaf7b4

File tree

9 files changed

+90
-15
lines changed

9 files changed

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

trophy/achievements/client.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ def with_raw_response(self) -> RawAchievementsClient:
2929
return self._raw_client
3030

3131
def all_(
32-
self, *, request_options: typing.Optional[RequestOptions] = None
32+
self, *, user_attributes: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
3333
) -> typing.List[AchievementWithStatsResponse]:
3434
"""
3535
Get all achievements and their completion stats.
3636
3737
Parameters
3838
----------
39+
user_attributes : typing.Optional[str]
40+
Optional colon-delimited user attributes in the format attribute:value,attribute:value. Only achievements accessible to a user with the provided attributes will be returned.
41+
3942
request_options : typing.Optional[RequestOptions]
4043
Request-specific configuration.
4144
@@ -51,9 +54,11 @@ def all_(
5154
client = TrophyApi(
5255
api_key="YOUR_API_KEY",
5356
)
54-
client.achievements.all_()
57+
client.achievements.all_(
58+
user_attributes="plan-type:premium,region:us-east",
59+
)
5560
"""
56-
_response = self._raw_client.all_(request_options=request_options)
61+
_response = self._raw_client.all_(user_attributes=user_attributes, request_options=request_options)
5762
return _response.data
5863

5964
def complete(
@@ -118,13 +123,16 @@ def with_raw_response(self) -> AsyncRawAchievementsClient:
118123
return self._raw_client
119124

120125
async def all_(
121-
self, *, request_options: typing.Optional[RequestOptions] = None
126+
self, *, user_attributes: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
122127
) -> typing.List[AchievementWithStatsResponse]:
123128
"""
124129
Get all achievements and their completion stats.
125130
126131
Parameters
127132
----------
133+
user_attributes : typing.Optional[str]
134+
Optional colon-delimited user attributes in the format attribute:value,attribute:value. Only achievements accessible to a user with the provided attributes will be returned.
135+
128136
request_options : typing.Optional[RequestOptions]
129137
Request-specific configuration.
130138
@@ -145,12 +153,14 @@ async def all_(
145153
146154
147155
async def main() -> None:
148-
await client.achievements.all_()
156+
await client.achievements.all_(
157+
user_attributes="plan-type:premium,region:us-east",
158+
)
149159
150160
151161
asyncio.run(main())
152162
"""
153-
_response = await self._raw_client.all_(request_options=request_options)
163+
_response = await self._raw_client.all_(user_attributes=user_attributes, request_options=request_options)
154164
return _response.data
155165

156166
async def complete(

trophy/achievements/raw_client.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ def __init__(self, *, client_wrapper: SyncClientWrapper):
2727
self._client_wrapper = client_wrapper
2828

2929
def all_(
30-
self, *, request_options: typing.Optional[RequestOptions] = None
30+
self, *, user_attributes: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
3131
) -> HttpResponse[typing.List[AchievementWithStatsResponse]]:
3232
"""
3333
Get all achievements and their completion stats.
3434
3535
Parameters
3636
----------
37+
user_attributes : typing.Optional[str]
38+
Optional colon-delimited user attributes in the format attribute:value,attribute:value. Only achievements accessible to a user with the provided attributes will be returned.
39+
3740
request_options : typing.Optional[RequestOptions]
3841
Request-specific configuration.
3942
@@ -46,6 +49,9 @@ def all_(
4649
"achievements",
4750
base_url=self._client_wrapper.get_environment().api,
4851
method="GET",
52+
params={
53+
"userAttributes": user_attributes,
54+
},
4955
request_options=request_options,
5056
)
5157
try:
@@ -176,13 +182,16 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper):
176182
self._client_wrapper = client_wrapper
177183

178184
async def all_(
179-
self, *, request_options: typing.Optional[RequestOptions] = None
185+
self, *, user_attributes: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
180186
) -> AsyncHttpResponse[typing.List[AchievementWithStatsResponse]]:
181187
"""
182188
Get all achievements and their completion stats.
183189
184190
Parameters
185191
----------
192+
user_attributes : typing.Optional[str]
193+
Optional colon-delimited user attributes in the format attribute:value,attribute:value. Only achievements accessible to a user with the provided attributes will be returned.
194+
186195
request_options : typing.Optional[RequestOptions]
187196
Request-specific configuration.
188197
@@ -195,6 +204,9 @@ async def all_(
195204
"achievements",
196205
base_url=self._client_wrapper.get_environment().api,
197206
method="GET",
207+
params={
208+
"userAttributes": user_attributes,
209+
},
198210
request_options=request_options,
199211
)
200212
try:

trophy/leaderboards/client.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def get(
6060
limit: typing.Optional[int] = None,
6161
run: typing.Optional[str] = None,
6262
user_id: typing.Optional[str] = None,
63+
user_attributes: typing.Optional[str] = None,
6364
request_options: typing.Optional[RequestOptions] = None,
6465
) -> LeaderboardResponseWithRankings:
6566
"""
@@ -82,6 +83,9 @@ def get(
8283
user_id : typing.Optional[str]
8384
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.
8485
86+
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.
88+
8589
request_options : typing.Optional[RequestOptions]
8690
Request-specific configuration.
8791
@@ -103,10 +107,17 @@ def get(
103107
limit=1,
104108
run="2025-01-15",
105109
user_id="user-123",
110+
user_attributes="city:London",
106111
)
107112
"""
108113
_response = self._raw_client.get(
109-
key, offset=offset, limit=limit, run=run, user_id=user_id, request_options=request_options
114+
key,
115+
offset=offset,
116+
limit=limit,
117+
run=run,
118+
user_id=user_id,
119+
user_attributes=user_attributes,
120+
request_options=request_options,
110121
)
111122
return _response.data
112123

@@ -170,6 +181,7 @@ async def get(
170181
limit: typing.Optional[int] = None,
171182
run: typing.Optional[str] = None,
172183
user_id: typing.Optional[str] = None,
184+
user_attributes: typing.Optional[str] = None,
173185
request_options: typing.Optional[RequestOptions] = None,
174186
) -> LeaderboardResponseWithRankings:
175187
"""
@@ -192,6 +204,9 @@ async def get(
192204
user_id : typing.Optional[str]
193205
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.
194206
207+
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.
209+
195210
request_options : typing.Optional[RequestOptions]
196211
Request-specific configuration.
197212
@@ -218,12 +233,19 @@ async def main() -> None:
218233
limit=1,
219234
run="2025-01-15",
220235
user_id="user-123",
236+
user_attributes="city:London",
221237
)
222238
223239
224240
asyncio.run(main())
225241
"""
226242
_response = await self._raw_client.get(
227-
key, offset=offset, limit=limit, run=run, user_id=user_id, request_options=request_options
243+
key,
244+
offset=offset,
245+
limit=limit,
246+
run=run,
247+
user_id=user_id,
248+
user_attributes=user_attributes,
249+
request_options=request_options,
228250
)
229251
return _response.data

trophy/leaderboards/raw_client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def get(
8888
limit: typing.Optional[int] = None,
8989
run: typing.Optional[str] = None,
9090
user_id: typing.Optional[str] = None,
91+
user_attributes: typing.Optional[str] = None,
9192
request_options: typing.Optional[RequestOptions] = None,
9293
) -> HttpResponse[LeaderboardResponseWithRankings]:
9394
"""
@@ -110,6 +111,9 @@ def get(
110111
user_id : typing.Optional[str]
111112
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.
112113
114+
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.
116+
113117
request_options : typing.Optional[RequestOptions]
114118
Request-specific configuration.
115119
@@ -127,6 +131,7 @@ def get(
127131
"limit": limit,
128132
"run": run,
129133
"userId": user_id,
134+
"userAttributes": user_attributes,
130135
},
131136
request_options=request_options,
132137
)
@@ -250,6 +255,7 @@ async def get(
250255
limit: typing.Optional[int] = None,
251256
run: typing.Optional[str] = None,
252257
user_id: typing.Optional[str] = None,
258+
user_attributes: typing.Optional[str] = None,
253259
request_options: typing.Optional[RequestOptions] = None,
254260
) -> AsyncHttpResponse[LeaderboardResponseWithRankings]:
255261
"""
@@ -272,6 +278,9 @@ async def get(
272278
user_id : typing.Optional[str]
273279
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.
274280
281+
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.
283+
275284
request_options : typing.Optional[RequestOptions]
276285
Request-specific configuration.
277286
@@ -289,6 +298,7 @@ async def get(
289298
"limit": limit,
290299
"run": run,
291300
"userId": user_id,
301+
"userAttributes": user_attributes,
292302
},
293303
request_options=request_options,
294304
)

trophy/points/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def summary(
4040
Key of the points system.
4141
4242
user_attributes : typing.Optional[str]
43-
Optional colon-delimited user attribute filters in the format attributeKey:value,attributeKey:value. Only users matching ALL specified attributes will be included in the points breakdown.
43+
Optional colon-delimited user attribute filters in the format attribute:value,attribute:value. Only users matching ALL specified attributes will be included in the points breakdown.
4444
4545
request_options : typing.Optional[RequestOptions]
4646
Request-specific configuration.
@@ -128,7 +128,7 @@ async def summary(
128128
Key of the points system.
129129
130130
user_attributes : typing.Optional[str]
131-
Optional colon-delimited user attribute filters in the format attributeKey:value,attributeKey:value. Only users matching ALL specified attributes will be included in the points breakdown.
131+
Optional colon-delimited user attribute filters in the format attribute:value,attribute:value. Only users matching ALL specified attributes will be included in the points breakdown.
132132
133133
request_options : typing.Optional[RequestOptions]
134134
Request-specific configuration.

trophy/points/raw_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def summary(
3737
Key of the points system.
3838
3939
user_attributes : typing.Optional[str]
40-
Optional colon-delimited user attribute filters in the format attributeKey:value,attributeKey:value. Only users matching ALL specified attributes will be included in the points breakdown.
40+
Optional colon-delimited user attribute filters in the format attribute:value,attribute:value. Only users matching ALL specified attributes will be included in the points breakdown.
4141
4242
request_options : typing.Optional[RequestOptions]
4343
Request-specific configuration.
@@ -187,7 +187,7 @@ async def summary(
187187
Key of the points system.
188188
189189
user_attributes : typing.Optional[str]
190-
Optional colon-delimited user attribute filters in the format attributeKey:value,attributeKey:value. Only users matching ALL specified attributes will be included in the points breakdown.
190+
Optional colon-delimited user attribute filters in the format attribute:value,attribute:value. Only users matching ALL specified attributes will be included in the points breakdown.
191191
192192
request_options : typing.Optional[RequestOptions]
193193
Request-specific configuration.

trophy/types/leaderboard_response.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ class LeaderboardResponse(UniversalBaseModel):
3535
What the leaderboard ranks by.
3636
"""
3737

38+
breakdown_attribute: typing_extensions.Annotated[
39+
typing.Optional[str], FieldMetadata(alias="breakdownAttribute")
40+
] = pydantic.Field(default=None)
41+
"""
42+
The key of the attribute to break down this leaderboard by.
43+
"""
44+
3845
metric_key: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="metricKey")] = pydantic.Field(
3946
default=None
4047
)

trophy/types/metric_event_leaderboard_response.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class MetricEventLeaderboardResponse(UniversalBaseModel):
3333
The minimum value required to enter the leaderboard according to its current rankings.
3434
"""
3535

36+
breakdown_attribute_value: typing_extensions.Annotated[
37+
typing.Optional[str], FieldMetadata(alias="breakdownAttributeValue")
38+
] = pydantic.Field(default=None)
39+
"""
40+
For leaderboards with a breakdown attribute, the value of the attribute for the user.
41+
"""
42+
3643
id: str = pydantic.Field()
3744
"""
3845
The unique ID of the leaderboard.
@@ -53,6 +60,13 @@ class MetricEventLeaderboardResponse(UniversalBaseModel):
5360
What the leaderboard ranks by.
5461
"""
5562

63+
breakdown_attribute: typing_extensions.Annotated[
64+
typing.Optional[str], FieldMetadata(alias="breakdownAttribute")
65+
] = pydantic.Field(default=None)
66+
"""
67+
The key of the attribute to break down this leaderboard by.
68+
"""
69+
5670
metric_key: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="metricKey")] = pydantic.Field(
5771
default=None
5872
)

0 commit comments

Comments
 (0)