Skip to content

Commit 9b476e0

Browse files
Automatically update Python SDK
1 parent 7261125 commit 9b476e0

24 files changed

+200
-104
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.38"
7+
version = "1.0.40-beta.5"
88
description = "A Python library for the Trophy API"
99
license = {text = "MIT"}
1010
readme = "README.md"

trophy/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@
88
if typing.TYPE_CHECKING:
99
from .types import (
1010
AchievementCompletionResponse,
11-
AchievementCompletionResponseAchievement,
1211
AchievementResponse,
12+
AchievementResponseEventAttribute,
1313
AchievementResponseTrigger,
14+
AchievementResponseUserAttributesItem,
1415
AchievementWithStatsResponse,
15-
AchievementWithStatsResponseEventAttribute,
16-
AchievementWithStatsResponseUserAttributesItem,
1716
BaseStreakResponse,
1817
BulkInsertIssue,
1918
BulkInsertIssueLevel,
2019
BulkStreakResponse,
2120
BulkStreakResponseItem,
22-
CompletedAchievementResponse,
2321
CreateStreakFreezesResponse,
2422
ErrorBody,
2523
EventResponse,
@@ -57,6 +55,8 @@
5755
UpdatedUser,
5856
UpsertedUser,
5957
User,
58+
UserAchievementResponse,
59+
UserAchievementWithStatsResponse,
6060
UserLeaderboardResponse,
6161
UserLeaderboardResponseWithHistory,
6262
WebhookUserLeaderboardResponse,
@@ -97,20 +97,18 @@
9797
)
9898
_dynamic_imports: typing.Dict[str, str] = {
9999
"AchievementCompletionResponse": ".types",
100-
"AchievementCompletionResponseAchievement": ".types",
101100
"AchievementResponse": ".types",
101+
"AchievementResponseEventAttribute": ".types",
102102
"AchievementResponseTrigger": ".types",
103+
"AchievementResponseUserAttributesItem": ".types",
103104
"AchievementWithStatsResponse": ".types",
104-
"AchievementWithStatsResponseEventAttribute": ".types",
105-
"AchievementWithStatsResponseUserAttributesItem": ".types",
106105
"AsyncTrophyApi": ".client",
107106
"BadRequestError": ".errors",
108107
"BaseStreakResponse": ".types",
109108
"BulkInsertIssue": ".types",
110109
"BulkInsertIssueLevel": ".types",
111110
"BulkStreakResponse": ".types",
112111
"BulkStreakResponseItem": ".types",
113-
"CompletedAchievementResponse": ".types",
114112
"CreateStreakFreezesResponse": ".types",
115113
"ErrorBody": ".types",
116114
"EventResponse": ".types",
@@ -156,6 +154,8 @@
156154
"UpdatedUser": ".types",
157155
"UpsertedUser": ".types",
158156
"User": ".types",
157+
"UserAchievementResponse": ".types",
158+
"UserAchievementWithStatsResponse": ".types",
159159
"UserLeaderboardResponse": ".types",
160160
"UserLeaderboardResponseWithHistory": ".types",
161161
"UsersMetricEventSummaryRequestAggregation": ".users",
@@ -218,20 +218,18 @@ def __dir__():
218218

219219
__all__ = [
220220
"AchievementCompletionResponse",
221-
"AchievementCompletionResponseAchievement",
222221
"AchievementResponse",
222+
"AchievementResponseEventAttribute",
223223
"AchievementResponseTrigger",
224+
"AchievementResponseUserAttributesItem",
224225
"AchievementWithStatsResponse",
225-
"AchievementWithStatsResponseEventAttribute",
226-
"AchievementWithStatsResponseUserAttributesItem",
227226
"AsyncTrophyApi",
228227
"BadRequestError",
229228
"BaseStreakResponse",
230229
"BulkInsertIssue",
231230
"BulkInsertIssueLevel",
232231
"BulkStreakResponse",
233232
"BulkStreakResponseItem",
234-
"CompletedAchievementResponse",
235233
"CreateStreakFreezesResponse",
236234
"ErrorBody",
237235
"EventResponse",
@@ -277,6 +275,8 @@ def __dir__():
277275
"UpdatedUser",
278276
"UpsertedUser",
279277
"User",
278+
"UserAchievementResponse",
279+
"UserAchievementWithStatsResponse",
280280
"UserLeaderboardResponse",
281281
"UserLeaderboardResponseWithHistory",
282282
"UsersMetricEventSummaryRequestAggregation",

trophy/admin/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
if typing.TYPE_CHECKING:
99
from . import streaks
10-
_dynamic_imports: typing.Dict[str, str] = {"streaks": ".streaks"}
10+
from .streaks import RestoreStreaksRequestUsersItem
11+
_dynamic_imports: typing.Dict[str, str] = {"RestoreStreaksRequestUsersItem": ".streaks", "streaks": ".streaks"}
1112

1213

1314
def __getattr__(attr_name: str) -> typing.Any:
@@ -31,4 +32,4 @@ def __dir__():
3132
return sorted(lazy_attrs)
3233

3334

34-
__all__ = ["streaks"]
35+
__all__ = ["RestoreStreaksRequestUsersItem", "streaks"]

trophy/admin/streaks/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
from importlib import import_module
77

88
if typing.TYPE_CHECKING:
9+
from .types import RestoreStreaksRequestUsersItem
910
from . import freezes
1011
from .freezes import CreateStreakFreezesRequestFreezesItem
11-
_dynamic_imports: typing.Dict[str, str] = {"CreateStreakFreezesRequestFreezesItem": ".freezes", "freezes": ".freezes"}
12+
_dynamic_imports: typing.Dict[str, str] = {
13+
"CreateStreakFreezesRequestFreezesItem": ".freezes",
14+
"RestoreStreaksRequestUsersItem": ".types",
15+
"freezes": ".freezes",
16+
}
1217

1318

1419
def __getattr__(attr_name: str) -> typing.Any:
@@ -32,4 +37,4 @@ def __dir__():
3237
return sorted(lazy_attrs)
3338

3439

35-
__all__ = ["CreateStreakFreezesRequestFreezesItem", "freezes"]
40+
__all__ = ["CreateStreakFreezesRequestFreezesItem", "RestoreStreaksRequestUsersItem", "freezes"]

trophy/admin/streaks/client.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ...core.request_options import RequestOptions
99
from ...types.restore_streaks_response import RestoreStreaksResponse
1010
from .raw_client import AsyncRawStreaksClient, RawStreaksClient
11+
from .types.restore_streaks_request_users_item import RestoreStreaksRequestUsersItem
1112

1213
if typing.TYPE_CHECKING:
1314
from .freezes.client import AsyncFreezesClient, FreezesClient
@@ -33,15 +34,18 @@ def with_raw_response(self) -> RawStreaksClient:
3334
return self._raw_client
3435

3536
def restore(
36-
self, *, user_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
37+
self,
38+
*,
39+
users: typing.Sequence[RestoreStreaksRequestUsersItem],
40+
request_options: typing.Optional[RequestOptions] = None,
3741
) -> RestoreStreaksResponse:
3842
"""
3943
Restore streaks for multiple users to the maximum length in the last 90 days (in the case of daily streaks), one year (in the case of weekly streaks), or two years (in the case of monthly streaks).
4044
4145
Parameters
4246
----------
43-
user_ids : typing.Sequence[str]
44-
Array of user IDs to restore streaks for. Maximum 100 users per request.
47+
users : typing.Sequence[RestoreStreaksRequestUsersItem]
48+
Array of users to restore streaks for. Maximum 100 users per request.
4549
4650
request_options : typing.Optional[RequestOptions]
4751
Request-specific configuration.
@@ -54,15 +58,23 @@ def restore(
5458
Examples
5559
--------
5660
from trophy import TrophyApi
61+
from trophy.admin.streaks import RestoreStreaksRequestUsersItem
5762
5863
client = TrophyApi(
5964
api_key="YOUR_API_KEY",
6065
)
6166
client.admin.streaks.restore(
62-
user_ids=["user-123", "user-456"],
67+
users=[
68+
RestoreStreaksRequestUsersItem(
69+
id="user-123",
70+
),
71+
RestoreStreaksRequestUsersItem(
72+
id="user-456",
73+
),
74+
],
6375
)
6476
"""
65-
_response = self._raw_client.restore(user_ids=user_ids, request_options=request_options)
77+
_response = self._raw_client.restore(users=users, request_options=request_options)
6678
return _response.data
6779

6880
@property
@@ -92,15 +104,18 @@ def with_raw_response(self) -> AsyncRawStreaksClient:
92104
return self._raw_client
93105

94106
async def restore(
95-
self, *, user_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
107+
self,
108+
*,
109+
users: typing.Sequence[RestoreStreaksRequestUsersItem],
110+
request_options: typing.Optional[RequestOptions] = None,
96111
) -> RestoreStreaksResponse:
97112
"""
98113
Restore streaks for multiple users to the maximum length in the last 90 days (in the case of daily streaks), one year (in the case of weekly streaks), or two years (in the case of monthly streaks).
99114
100115
Parameters
101116
----------
102-
user_ids : typing.Sequence[str]
103-
Array of user IDs to restore streaks for. Maximum 100 users per request.
117+
users : typing.Sequence[RestoreStreaksRequestUsersItem]
118+
Array of users to restore streaks for. Maximum 100 users per request.
104119
105120
request_options : typing.Optional[RequestOptions]
106121
Request-specific configuration.
@@ -115,6 +130,7 @@ async def restore(
115130
import asyncio
116131
117132
from trophy import AsyncTrophyApi
133+
from trophy.admin.streaks import RestoreStreaksRequestUsersItem
118134
119135
client = AsyncTrophyApi(
120136
api_key="YOUR_API_KEY",
@@ -123,13 +139,20 @@ async def restore(
123139
124140
async def main() -> None:
125141
await client.admin.streaks.restore(
126-
user_ids=["user-123", "user-456"],
142+
users=[
143+
RestoreStreaksRequestUsersItem(
144+
id="user-123",
145+
),
146+
RestoreStreaksRequestUsersItem(
147+
id="user-456",
148+
),
149+
],
127150
)
128151
129152
130153
asyncio.run(main())
131154
"""
132-
_response = await self._raw_client.restore(user_ids=user_ids, request_options=request_options)
155+
_response = await self._raw_client.restore(users=users, request_options=request_options)
133156
return _response.data
134157

135158
@property

trophy/admin/streaks/raw_client.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
from ...core.http_response import AsyncHttpResponse, HttpResponse
99
from ...core.pydantic_utilities import parse_obj_as
1010
from ...core.request_options import RequestOptions
11+
from ...core.serialization import convert_and_respect_annotation_metadata
1112
from ...errors.bad_request_error import BadRequestError
1213
from ...errors.unauthorized_error import UnauthorizedError
1314
from ...errors.unprocessable_entity_error import UnprocessableEntityError
1415
from ...types.error_body import ErrorBody
1516
from ...types.restore_streaks_response import RestoreStreaksResponse
17+
from .types.restore_streaks_request_users_item import RestoreStreaksRequestUsersItem
1618

1719
# this is used as the default value for optional parameters
1820
OMIT = typing.cast(typing.Any, ...)
@@ -23,15 +25,18 @@ def __init__(self, *, client_wrapper: SyncClientWrapper):
2325
self._client_wrapper = client_wrapper
2426

2527
def restore(
26-
self, *, user_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
28+
self,
29+
*,
30+
users: typing.Sequence[RestoreStreaksRequestUsersItem],
31+
request_options: typing.Optional[RequestOptions] = None,
2732
) -> HttpResponse[RestoreStreaksResponse]:
2833
"""
2934
Restore streaks for multiple users to the maximum length in the last 90 days (in the case of daily streaks), one year (in the case of weekly streaks), or two years (in the case of monthly streaks).
3035
3136
Parameters
3237
----------
33-
user_ids : typing.Sequence[str]
34-
Array of user IDs to restore streaks for. Maximum 100 users per request.
38+
users : typing.Sequence[RestoreStreaksRequestUsersItem]
39+
Array of users to restore streaks for. Maximum 100 users per request.
3540
3641
request_options : typing.Optional[RequestOptions]
3742
Request-specific configuration.
@@ -46,7 +51,9 @@ def restore(
4651
base_url=self._client_wrapper.get_environment().admin,
4752
method="POST",
4853
json={
49-
"userIds": user_ids,
54+
"users": convert_and_respect_annotation_metadata(
55+
object_=users, annotation=typing.Sequence[RestoreStreaksRequestUsersItem], direction="write"
56+
),
5057
},
5158
headers={
5259
"content-type": "application/json",
@@ -108,15 +115,18 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper):
108115
self._client_wrapper = client_wrapper
109116

110117
async def restore(
111-
self, *, user_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
118+
self,
119+
*,
120+
users: typing.Sequence[RestoreStreaksRequestUsersItem],
121+
request_options: typing.Optional[RequestOptions] = None,
112122
) -> AsyncHttpResponse[RestoreStreaksResponse]:
113123
"""
114124
Restore streaks for multiple users to the maximum length in the last 90 days (in the case of daily streaks), one year (in the case of weekly streaks), or two years (in the case of monthly streaks).
115125
116126
Parameters
117127
----------
118-
user_ids : typing.Sequence[str]
119-
Array of user IDs to restore streaks for. Maximum 100 users per request.
128+
users : typing.Sequence[RestoreStreaksRequestUsersItem]
129+
Array of users to restore streaks for. Maximum 100 users per request.
120130
121131
request_options : typing.Optional[RequestOptions]
122132
Request-specific configuration.
@@ -131,7 +141,9 @@ async def restore(
131141
base_url=self._client_wrapper.get_environment().admin,
132142
method="POST",
133143
json={
134-
"userIds": user_ids,
144+
"users": convert_and_respect_annotation_metadata(
145+
object_=users, annotation=typing.Sequence[RestoreStreaksRequestUsersItem], direction="write"
146+
),
135147
},
136148
headers={
137149
"content-type": "application/json",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
# isort: skip_file
4+
5+
import typing
6+
from importlib import import_module
7+
8+
if typing.TYPE_CHECKING:
9+
from .restore_streaks_request_users_item import RestoreStreaksRequestUsersItem
10+
_dynamic_imports: typing.Dict[str, str] = {"RestoreStreaksRequestUsersItem": ".restore_streaks_request_users_item"}
11+
12+
13+
def __getattr__(attr_name: str) -> typing.Any:
14+
module_name = _dynamic_imports.get(attr_name)
15+
if module_name is None:
16+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
17+
try:
18+
module = import_module(module_name, __package__)
19+
if module_name == f".{attr_name}":
20+
return module
21+
else:
22+
return getattr(module, attr_name)
23+
except ImportError as e:
24+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
25+
except AttributeError as e:
26+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
27+
28+
29+
def __dir__():
30+
lazy_attrs = list(_dynamic_imports.keys())
31+
return sorted(lazy_attrs)
32+
33+
34+
__all__ = ["RestoreStreaksRequestUsersItem"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 RestoreStreaksRequestUsersItem(UniversalBaseModel):
10+
id: str = pydantic.Field()
11+
"""
12+
The ID of the user to restore streaks for.
13+
"""
14+
15+
if IS_PYDANTIC_V2:
16+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
17+
else:
18+
19+
class Config:
20+
frozen = True
21+
smart_union = True
22+
extra = pydantic.Extra.allow

0 commit comments

Comments
 (0)