Skip to content

Commit 7261125

Browse files
Automatically update Python SDK
1 parent 9562d7e commit 7261125

20 files changed

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

trophy/__init__.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
PointsTriggerResponseUserAttributesItem,
5050
PointsTriggerTimeUnit,
5151
PointsTriggerType,
52+
RestoreStreaksResponse,
5253
StreakFrequency,
5354
StreakRankingUser,
5455
StreakResponse,
@@ -70,6 +71,17 @@
7071
WebhooksStreakFreezeEarnedPayload,
7172
WebhooksStreakLostPayload,
7273
WebhooksStreakStartedPayload,
74+
WrappedActivity,
75+
WrappedActivityPeriod,
76+
WrappedEntireYear,
77+
WrappedMetric,
78+
WrappedMetricByAttributeValueValue,
79+
WrappedMostActiveDay,
80+
WrappedMostActiveMonth,
81+
WrappedMostActiveWeek,
82+
WrappedPoints,
83+
WrappedResponse,
84+
WrappedStreak,
7385
)
7486
from .errors import BadRequestError, NotFoundError, UnauthorizedError, UnprocessableEntityError
7587
from . import achievements, admin, leaderboards, metrics, points, streaks, users
@@ -131,6 +143,7 @@
131143
"PointsTriggerResponseUserAttributesItem": ".types",
132144
"PointsTriggerTimeUnit": ".types",
133145
"PointsTriggerType": ".types",
146+
"RestoreStreaksResponse": ".types",
134147
"StreakFrequency": ".types",
135148
"StreakRankingUser": ".types",
136149
"StreakResponse": ".types",
@@ -161,6 +174,17 @@
161174
"WebhooksStreakFreezeEarnedPayload": ".types",
162175
"WebhooksStreakLostPayload": ".types",
163176
"WebhooksStreakStartedPayload": ".types",
177+
"WrappedActivity": ".types",
178+
"WrappedActivityPeriod": ".types",
179+
"WrappedEntireYear": ".types",
180+
"WrappedMetric": ".types",
181+
"WrappedMetricByAttributeValueValue": ".types",
182+
"WrappedMostActiveDay": ".types",
183+
"WrappedMostActiveMonth": ".types",
184+
"WrappedMostActiveWeek": ".types",
185+
"WrappedPoints": ".types",
186+
"WrappedResponse": ".types",
187+
"WrappedStreak": ".types",
164188
"achievements": ".achievements",
165189
"admin": ".admin",
166190
"leaderboards": ".leaderboards",
@@ -240,6 +264,7 @@ def __dir__():
240264
"PointsTriggerResponseUserAttributesItem",
241265
"PointsTriggerTimeUnit",
242266
"PointsTriggerType",
267+
"RestoreStreaksResponse",
243268
"StreakFrequency",
244269
"StreakRankingUser",
245270
"StreakResponse",
@@ -270,6 +295,17 @@ def __dir__():
270295
"WebhooksStreakFreezeEarnedPayload",
271296
"WebhooksStreakLostPayload",
272297
"WebhooksStreakStartedPayload",
298+
"WrappedActivity",
299+
"WrappedActivityPeriod",
300+
"WrappedEntireYear",
301+
"WrappedMetric",
302+
"WrappedMetricByAttributeValueValue",
303+
"WrappedMostActiveDay",
304+
"WrappedMostActiveMonth",
305+
"WrappedMostActiveWeek",
306+
"WrappedPoints",
307+
"WrappedResponse",
308+
"WrappedStreak",
273309
"achievements",
274310
"admin",
275311
"leaderboards",

trophy/admin/streaks/client.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
import typing
66

77
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8+
from ...core.request_options import RequestOptions
9+
from ...types.restore_streaks_response import RestoreStreaksResponse
810
from .raw_client import AsyncRawStreaksClient, RawStreaksClient
911

1012
if typing.TYPE_CHECKING:
1113
from .freezes.client import AsyncFreezesClient, FreezesClient
14+
# this is used as the default value for optional parameters
15+
OMIT = typing.cast(typing.Any, ...)
1216

1317

1418
class StreaksClient:
@@ -28,6 +32,39 @@ def with_raw_response(self) -> RawStreaksClient:
2832
"""
2933
return self._raw_client
3034

35+
def restore(
36+
self, *, user_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
37+
) -> RestoreStreaksResponse:
38+
"""
39+
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).
40+
41+
Parameters
42+
----------
43+
user_ids : typing.Sequence[str]
44+
Array of user IDs to restore streaks for. Maximum 100 users per request.
45+
46+
request_options : typing.Optional[RequestOptions]
47+
Request-specific configuration.
48+
49+
Returns
50+
-------
51+
RestoreStreaksResponse
52+
Successful operation
53+
54+
Examples
55+
--------
56+
from trophy import TrophyApi
57+
58+
client = TrophyApi(
59+
api_key="YOUR_API_KEY",
60+
)
61+
client.admin.streaks.restore(
62+
user_ids=["user-123", "user-456"],
63+
)
64+
"""
65+
_response = self._raw_client.restore(user_ids=user_ids, request_options=request_options)
66+
return _response.data
67+
3168
@property
3269
def freezes(self):
3370
if self._freezes is None:
@@ -54,6 +91,47 @@ def with_raw_response(self) -> AsyncRawStreaksClient:
5491
"""
5592
return self._raw_client
5693

94+
async def restore(
95+
self, *, user_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
96+
) -> RestoreStreaksResponse:
97+
"""
98+
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).
99+
100+
Parameters
101+
----------
102+
user_ids : typing.Sequence[str]
103+
Array of user IDs to restore streaks for. Maximum 100 users per request.
104+
105+
request_options : typing.Optional[RequestOptions]
106+
Request-specific configuration.
107+
108+
Returns
109+
-------
110+
RestoreStreaksResponse
111+
Successful operation
112+
113+
Examples
114+
--------
115+
import asyncio
116+
117+
from trophy import AsyncTrophyApi
118+
119+
client = AsyncTrophyApi(
120+
api_key="YOUR_API_KEY",
121+
)
122+
123+
124+
async def main() -> None:
125+
await client.admin.streaks.restore(
126+
user_ids=["user-123", "user-456"],
127+
)
128+
129+
130+
asyncio.run(main())
131+
"""
132+
_response = await self._raw_client.restore(user_ids=user_ids, request_options=request_options)
133+
return _response.data
134+
57135
@property
58136
def freezes(self):
59137
if self._freezes is None:

trophy/admin/streaks/raw_client.py

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,188 @@
11
# This file was auto-generated by Fern from our API Definition.
22

3+
import typing
4+
from json.decoder import JSONDecodeError
5+
6+
from ...core.api_error import ApiError
37
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8+
from ...core.http_response import AsyncHttpResponse, HttpResponse
9+
from ...core.pydantic_utilities import parse_obj_as
10+
from ...core.request_options import RequestOptions
11+
from ...errors.bad_request_error import BadRequestError
12+
from ...errors.unauthorized_error import UnauthorizedError
13+
from ...errors.unprocessable_entity_error import UnprocessableEntityError
14+
from ...types.error_body import ErrorBody
15+
from ...types.restore_streaks_response import RestoreStreaksResponse
16+
17+
# this is used as the default value for optional parameters
18+
OMIT = typing.cast(typing.Any, ...)
419

520

621
class RawStreaksClient:
722
def __init__(self, *, client_wrapper: SyncClientWrapper):
823
self._client_wrapper = client_wrapper
924

25+
def restore(
26+
self, *, user_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
27+
) -> HttpResponse[RestoreStreaksResponse]:
28+
"""
29+
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).
30+
31+
Parameters
32+
----------
33+
user_ids : typing.Sequence[str]
34+
Array of user IDs to restore streaks for. Maximum 100 users per request.
35+
36+
request_options : typing.Optional[RequestOptions]
37+
Request-specific configuration.
38+
39+
Returns
40+
-------
41+
HttpResponse[RestoreStreaksResponse]
42+
Successful operation
43+
"""
44+
_response = self._client_wrapper.httpx_client.request(
45+
"streaks/restore",
46+
base_url=self._client_wrapper.get_environment().admin,
47+
method="POST",
48+
json={
49+
"userIds": user_ids,
50+
},
51+
headers={
52+
"content-type": "application/json",
53+
},
54+
request_options=request_options,
55+
omit=OMIT,
56+
)
57+
try:
58+
if 200 <= _response.status_code < 300:
59+
_data = typing.cast(
60+
RestoreStreaksResponse,
61+
parse_obj_as(
62+
type_=RestoreStreaksResponse, # type: ignore
63+
object_=_response.json(),
64+
),
65+
)
66+
return HttpResponse(response=_response, data=_data)
67+
if _response.status_code == 400:
68+
raise BadRequestError(
69+
headers=dict(_response.headers),
70+
body=typing.cast(
71+
ErrorBody,
72+
parse_obj_as(
73+
type_=ErrorBody, # type: ignore
74+
object_=_response.json(),
75+
),
76+
),
77+
)
78+
if _response.status_code == 401:
79+
raise UnauthorizedError(
80+
headers=dict(_response.headers),
81+
body=typing.cast(
82+
ErrorBody,
83+
parse_obj_as(
84+
type_=ErrorBody, # type: ignore
85+
object_=_response.json(),
86+
),
87+
),
88+
)
89+
if _response.status_code == 422:
90+
raise UnprocessableEntityError(
91+
headers=dict(_response.headers),
92+
body=typing.cast(
93+
ErrorBody,
94+
parse_obj_as(
95+
type_=ErrorBody, # type: ignore
96+
object_=_response.json(),
97+
),
98+
),
99+
)
100+
_response_json = _response.json()
101+
except JSONDecodeError:
102+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
103+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
104+
10105

11106
class AsyncRawStreaksClient:
12107
def __init__(self, *, client_wrapper: AsyncClientWrapper):
13108
self._client_wrapper = client_wrapper
109+
110+
async def restore(
111+
self, *, user_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
112+
) -> AsyncHttpResponse[RestoreStreaksResponse]:
113+
"""
114+
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).
115+
116+
Parameters
117+
----------
118+
user_ids : typing.Sequence[str]
119+
Array of user IDs to restore streaks for. Maximum 100 users per request.
120+
121+
request_options : typing.Optional[RequestOptions]
122+
Request-specific configuration.
123+
124+
Returns
125+
-------
126+
AsyncHttpResponse[RestoreStreaksResponse]
127+
Successful operation
128+
"""
129+
_response = await self._client_wrapper.httpx_client.request(
130+
"streaks/restore",
131+
base_url=self._client_wrapper.get_environment().admin,
132+
method="POST",
133+
json={
134+
"userIds": user_ids,
135+
},
136+
headers={
137+
"content-type": "application/json",
138+
},
139+
request_options=request_options,
140+
omit=OMIT,
141+
)
142+
try:
143+
if 200 <= _response.status_code < 300:
144+
_data = typing.cast(
145+
RestoreStreaksResponse,
146+
parse_obj_as(
147+
type_=RestoreStreaksResponse, # type: ignore
148+
object_=_response.json(),
149+
),
150+
)
151+
return AsyncHttpResponse(response=_response, data=_data)
152+
if _response.status_code == 400:
153+
raise BadRequestError(
154+
headers=dict(_response.headers),
155+
body=typing.cast(
156+
ErrorBody,
157+
parse_obj_as(
158+
type_=ErrorBody, # type: ignore
159+
object_=_response.json(),
160+
),
161+
),
162+
)
163+
if _response.status_code == 401:
164+
raise UnauthorizedError(
165+
headers=dict(_response.headers),
166+
body=typing.cast(
167+
ErrorBody,
168+
parse_obj_as(
169+
type_=ErrorBody, # type: ignore
170+
object_=_response.json(),
171+
),
172+
),
173+
)
174+
if _response.status_code == 422:
175+
raise UnprocessableEntityError(
176+
headers=dict(_response.headers),
177+
body=typing.cast(
178+
ErrorBody,
179+
parse_obj_as(
180+
type_=ErrorBody, # type: ignore
181+
object_=_response.json(),
182+
),
183+
),
184+
)
185+
_response_json = _response.json()
186+
except JSONDecodeError:
187+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
188+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

0 commit comments

Comments
 (0)