Skip to content

Commit c54898a

Browse files
Automatically update Python SDK
1 parent b085352 commit c54898a

25 files changed

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

trophy/__init__.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@
33
from .types import (
44
AchievementCompletionResponse,
55
AchievementResponse,
6+
AchievementResponseTrigger,
67
AchievementWithStatsResponse,
78
BaseStreakResponse,
89
CompletedAchievementResponse,
910
ErrorBody,
1011
EventResponse,
11-
IncrementMetricStreakResponse,
12+
GetUserPointsResponse,
13+
MetricEventPointsResponse,
14+
MetricEventStreakResponse,
1215
MetricResponse,
1316
MetricStatus,
17+
PointsAward,
18+
PointsRange,
19+
PointsSummaryResponse,
20+
PointsTrigger,
21+
PointsTriggerResponse,
22+
PointsTriggerResponseStatus,
23+
PointsTriggerResponseType,
24+
PointsTriggerType,
1425
StreakFrequency,
1526
StreakResponse,
1627
StreakResponseStreakHistoryItem,
@@ -24,28 +35,41 @@
2435
UnauthorizedError,
2536
UnprocessableEntityError,
2637
)
27-
from . import achievements, metrics, users
38+
from . import achievements, metrics, points, users
2839
from .client import AsyncTrophyApi, TrophyApi
2940
from .environment import TrophyApiEnvironment
3041
from .users import (
3142
UsersMetricEventSummaryRequestAggregation,
3243
UsersMetricEventSummaryResponseItem,
44+
UsersPointsEventSummaryRequestAggregation,
45+
UsersPointsEventSummaryResponseItem,
3346
)
3447

3548
__all__ = [
3649
"AchievementCompletionResponse",
3750
"AchievementResponse",
51+
"AchievementResponseTrigger",
3852
"AchievementWithStatsResponse",
3953
"AsyncTrophyApi",
4054
"BadRequestError",
4155
"BaseStreakResponse",
4256
"CompletedAchievementResponse",
4357
"ErrorBody",
4458
"EventResponse",
45-
"IncrementMetricStreakResponse",
59+
"GetUserPointsResponse",
60+
"MetricEventPointsResponse",
61+
"MetricEventStreakResponse",
4662
"MetricResponse",
4763
"MetricStatus",
4864
"NotFoundError",
65+
"PointsAward",
66+
"PointsRange",
67+
"PointsSummaryResponse",
68+
"PointsTrigger",
69+
"PointsTriggerResponse",
70+
"PointsTriggerResponseStatus",
71+
"PointsTriggerResponseType",
72+
"PointsTriggerType",
4973
"StreakFrequency",
5074
"StreakResponse",
5175
"StreakResponseStreakHistoryItem",
@@ -58,7 +82,10 @@
5882
"User",
5983
"UsersMetricEventSummaryRequestAggregation",
6084
"UsersMetricEventSummaryResponseItem",
85+
"UsersPointsEventSummaryRequestAggregation",
86+
"UsersPointsEventSummaryResponseItem",
6187
"achievements",
6288
"metrics",
89+
"points",
6390
"users",
6491
]

trophy/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
from .achievements.client import AchievementsClient
88
from .metrics.client import MetricsClient
99
from .users.client import UsersClient
10+
from .points.client import PointsClient
1011
from .core.client_wrapper import AsyncClientWrapper
1112
from .achievements.client import AsyncAchievementsClient
1213
from .metrics.client import AsyncMetricsClient
1314
from .users.client import AsyncUsersClient
15+
from .points.client import AsyncPointsClient
1416

1517

1618
class TrophyApi:
@@ -78,6 +80,7 @@ def __init__(
7880
self.achievements = AchievementsClient(client_wrapper=self._client_wrapper)
7981
self.metrics = MetricsClient(client_wrapper=self._client_wrapper)
8082
self.users = UsersClient(client_wrapper=self._client_wrapper)
83+
self.points = PointsClient(client_wrapper=self._client_wrapper)
8184

8285

8386
class AsyncTrophyApi:
@@ -145,6 +148,7 @@ def __init__(
145148
self.achievements = AsyncAchievementsClient(client_wrapper=self._client_wrapper)
146149
self.metrics = AsyncMetricsClient(client_wrapper=self._client_wrapper)
147150
self.users = AsyncUsersClient(client_wrapper=self._client_wrapper)
151+
self.points = AsyncPointsClient(client_wrapper=self._client_wrapper)
148152

149153

150154
def _get_base_url(

trophy/points/__init__.py

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

trophy/points/client.py

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
from ..core.client_wrapper import SyncClientWrapper
4+
import typing
5+
from ..core.request_options import RequestOptions
6+
from ..types.points_summary_response import PointsSummaryResponse
7+
from ..core.pydantic_utilities import parse_obj_as
8+
from ..errors.unauthorized_error import UnauthorizedError
9+
from ..types.error_body import ErrorBody
10+
from ..errors.not_found_error import NotFoundError
11+
from json.decoder import JSONDecodeError
12+
from ..core.api_error import ApiError
13+
from ..types.points_trigger_response import PointsTriggerResponse
14+
from ..core.client_wrapper import AsyncClientWrapper
15+
16+
17+
class PointsClient:
18+
def __init__(self, *, client_wrapper: SyncClientWrapper):
19+
self._client_wrapper = client_wrapper
20+
21+
def summary(
22+
self, *, request_options: typing.Optional[RequestOptions] = None
23+
) -> PointsSummaryResponse:
24+
"""
25+
Get a breakdown of the number of users with points in each range.
26+
27+
Parameters
28+
----------
29+
request_options : typing.Optional[RequestOptions]
30+
Request-specific configuration.
31+
32+
Returns
33+
-------
34+
PointsSummaryResponse
35+
Successful operation
36+
37+
Examples
38+
--------
39+
from trophy import TrophyApi
40+
41+
client = TrophyApi(
42+
api_key="YOUR_API_KEY",
43+
)
44+
client.points.summary()
45+
"""
46+
_response = self._client_wrapper.httpx_client.request(
47+
"points/summary",
48+
method="GET",
49+
request_options=request_options,
50+
)
51+
try:
52+
if 200 <= _response.status_code < 300:
53+
return typing.cast(
54+
PointsSummaryResponse,
55+
parse_obj_as(
56+
type_=PointsSummaryResponse, # type: ignore
57+
object_=_response.json(),
58+
),
59+
)
60+
if _response.status_code == 401:
61+
raise UnauthorizedError(
62+
typing.cast(
63+
ErrorBody,
64+
parse_obj_as(
65+
type_=ErrorBody, # type: ignore
66+
object_=_response.json(),
67+
),
68+
)
69+
)
70+
if _response.status_code == 404:
71+
raise NotFoundError(
72+
typing.cast(
73+
ErrorBody,
74+
parse_obj_as(
75+
type_=ErrorBody, # type: ignore
76+
object_=_response.json(),
77+
),
78+
)
79+
)
80+
_response_json = _response.json()
81+
except JSONDecodeError:
82+
raise ApiError(status_code=_response.status_code, body=_response.text)
83+
raise ApiError(status_code=_response.status_code, body=_response_json)
84+
85+
def triggers(
86+
self, *, request_options: typing.Optional[RequestOptions] = None
87+
) -> typing.List[PointsTriggerResponse]:
88+
"""
89+
Get all points triggers.
90+
91+
Parameters
92+
----------
93+
request_options : typing.Optional[RequestOptions]
94+
Request-specific configuration.
95+
96+
Returns
97+
-------
98+
typing.List[PointsTriggerResponse]
99+
Successful operation
100+
101+
Examples
102+
--------
103+
from trophy import TrophyApi
104+
105+
client = TrophyApi(
106+
api_key="YOUR_API_KEY",
107+
)
108+
client.points.triggers()
109+
"""
110+
_response = self._client_wrapper.httpx_client.request(
111+
"points/triggers",
112+
method="GET",
113+
request_options=request_options,
114+
)
115+
try:
116+
if 200 <= _response.status_code < 300:
117+
return typing.cast(
118+
typing.List[PointsTriggerResponse],
119+
parse_obj_as(
120+
type_=typing.List[PointsTriggerResponse], # type: ignore
121+
object_=_response.json(),
122+
),
123+
)
124+
if _response.status_code == 401:
125+
raise UnauthorizedError(
126+
typing.cast(
127+
ErrorBody,
128+
parse_obj_as(
129+
type_=ErrorBody, # type: ignore
130+
object_=_response.json(),
131+
),
132+
)
133+
)
134+
_response_json = _response.json()
135+
except JSONDecodeError:
136+
raise ApiError(status_code=_response.status_code, body=_response.text)
137+
raise ApiError(status_code=_response.status_code, body=_response_json)
138+
139+
140+
class AsyncPointsClient:
141+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
142+
self._client_wrapper = client_wrapper
143+
144+
async def summary(
145+
self, *, request_options: typing.Optional[RequestOptions] = None
146+
) -> PointsSummaryResponse:
147+
"""
148+
Get a breakdown of the number of users with points in each range.
149+
150+
Parameters
151+
----------
152+
request_options : typing.Optional[RequestOptions]
153+
Request-specific configuration.
154+
155+
Returns
156+
-------
157+
PointsSummaryResponse
158+
Successful operation
159+
160+
Examples
161+
--------
162+
import asyncio
163+
164+
from trophy import AsyncTrophyApi
165+
166+
client = AsyncTrophyApi(
167+
api_key="YOUR_API_KEY",
168+
)
169+
170+
171+
async def main() -> None:
172+
await client.points.summary()
173+
174+
175+
asyncio.run(main())
176+
"""
177+
_response = await self._client_wrapper.httpx_client.request(
178+
"points/summary",
179+
method="GET",
180+
request_options=request_options,
181+
)
182+
try:
183+
if 200 <= _response.status_code < 300:
184+
return typing.cast(
185+
PointsSummaryResponse,
186+
parse_obj_as(
187+
type_=PointsSummaryResponse, # type: ignore
188+
object_=_response.json(),
189+
),
190+
)
191+
if _response.status_code == 401:
192+
raise UnauthorizedError(
193+
typing.cast(
194+
ErrorBody,
195+
parse_obj_as(
196+
type_=ErrorBody, # type: ignore
197+
object_=_response.json(),
198+
),
199+
)
200+
)
201+
if _response.status_code == 404:
202+
raise NotFoundError(
203+
typing.cast(
204+
ErrorBody,
205+
parse_obj_as(
206+
type_=ErrorBody, # type: ignore
207+
object_=_response.json(),
208+
),
209+
)
210+
)
211+
_response_json = _response.json()
212+
except JSONDecodeError:
213+
raise ApiError(status_code=_response.status_code, body=_response.text)
214+
raise ApiError(status_code=_response.status_code, body=_response_json)
215+
216+
async def triggers(
217+
self, *, request_options: typing.Optional[RequestOptions] = None
218+
) -> typing.List[PointsTriggerResponse]:
219+
"""
220+
Get all points triggers.
221+
222+
Parameters
223+
----------
224+
request_options : typing.Optional[RequestOptions]
225+
Request-specific configuration.
226+
227+
Returns
228+
-------
229+
typing.List[PointsTriggerResponse]
230+
Successful operation
231+
232+
Examples
233+
--------
234+
import asyncio
235+
236+
from trophy import AsyncTrophyApi
237+
238+
client = AsyncTrophyApi(
239+
api_key="YOUR_API_KEY",
240+
)
241+
242+
243+
async def main() -> None:
244+
await client.points.triggers()
245+
246+
247+
asyncio.run(main())
248+
"""
249+
_response = await self._client_wrapper.httpx_client.request(
250+
"points/triggers",
251+
method="GET",
252+
request_options=request_options,
253+
)
254+
try:
255+
if 200 <= _response.status_code < 300:
256+
return typing.cast(
257+
typing.List[PointsTriggerResponse],
258+
parse_obj_as(
259+
type_=typing.List[PointsTriggerResponse], # type: ignore
260+
object_=_response.json(),
261+
),
262+
)
263+
if _response.status_code == 401:
264+
raise UnauthorizedError(
265+
typing.cast(
266+
ErrorBody,
267+
parse_obj_as(
268+
type_=ErrorBody, # type: ignore
269+
object_=_response.json(),
270+
),
271+
)
272+
)
273+
_response_json = _response.json()
274+
except JSONDecodeError:
275+
raise ApiError(status_code=_response.status_code, body=_response.text)
276+
raise ApiError(status_code=_response.status_code, body=_response_json)

0 commit comments

Comments
 (0)