Skip to content

Commit 9ad493a

Browse files
feat:new-settings
Add new settings
2 parents af70a7b + 1272207 commit 9ad493a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/celine/sdk/nudging/client.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
NotificationOutSchema,
4343
SendTestResponseSchema,
4444
StatusResponseSchema,
45+
UserPreferenceSchema,
4546
VapidPublicKeyResponseSchema,
4647
)
4748
from celine.sdk.openapi.nudging.types import UNSET, Unset
@@ -193,6 +194,31 @@ async def unsubscribe(
193194
)
194195
return to_schema(res.parsed, StatusResponseSchema)
195196

197+
# ------------------------------------------------------------------ #
198+
# Preferences #
199+
# ------------------------------------------------------------------ #
200+
201+
async def get_preferences(
202+
self,
203+
*,
204+
token: Optional[str] = None,
205+
) -> UserPreferenceSchema:
206+
client = self._get_client(token).get_async_httpx_client()
207+
res = await client.get("/preferences/me")
208+
res.raise_for_status()
209+
return UserPreferenceSchema.model_validate(res.json())
210+
211+
async def update_preferences(
212+
self,
213+
max_per_day: int,
214+
*,
215+
token: Optional[str] = None,
216+
) -> UserPreferenceSchema:
217+
client = self._get_client(token).get_async_httpx_client()
218+
res = await client.put("/preferences/me", json={"max_per_day": max_per_day})
219+
res.raise_for_status()
220+
return UserPreferenceSchema.model_validate(res.json())
221+
196222

197223
class NudgingAdminClient:
198224
"""Admin nudging client. Requires nudging.admin scope or admin group.

src/celine/sdk/openapi/nudging/schemas.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ class StatusResponseSchema(BaseModel):
106106
status: str = Field(..., examples=['ok'], title='Status')
107107

108108

109+
class UserPreferenceSchema(BaseModel):
110+
max_per_day: int = Field(..., title='Max Per Day')
111+
112+
109113
class UnsubscribeRequestSchema(BaseModel):
110114
"""
111115
user_id is derived from the JWT – not accepted from the caller.

0 commit comments

Comments
 (0)