File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 4242 NotificationOutSchema ,
4343 SendTestResponseSchema ,
4444 StatusResponseSchema ,
45+ UserPreferenceSchema ,
4546 VapidPublicKeyResponseSchema ,
4647)
4748from 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
197223class NudgingAdminClient :
198224 """Admin nudging client. Requires nudging.admin scope or admin group.
Original file line number Diff line number Diff 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+
109113class UnsubscribeRequestSchema (BaseModel ):
110114 """
111115 user_id is derived from the JWT – not accepted from the caller.
You can’t perform that action at this time.
0 commit comments