Skip to content

Commit

Permalink
use create_user_settings for new users posting settings for the first…
Browse files Browse the repository at this point in the history
… time (#837)
  • Loading branch information
yang-ruoxi authored Aug 16, 2023
1 parent 5f15be1 commit 7cbf363
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions mp_api/client/routes/_user_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,22 @@ class UserSettingsRester(BaseRester[UserSettingsDoc]): # pragma: no cover
monty_decode = False
use_document_model = False

def set_user_settings(self, consumer_id, settings): # pragma: no cover
"""Set user settings.
def create_user_settings(self, consumer_id, settings):
"""Create user settings.
Args:
consumer_id: Consumer ID for the user
settings: Dictionary with user settings that
use UserSettingsDoc schema
Returns:
Dictionary with consumer_id and write status.
"""
return self._post_resource(
body=settings, params={"consumer_id": consumer_id}
).get("data")

def patch_user_settings(self, consumer_id, settings): # pragma: no cover
"""Patch user settings.
Args:
consumer_id: Consumer ID for the user
Expand All @@ -32,7 +46,8 @@ def set_user_settings(self, consumer_id, settings): # pragma: no cover
"is_email_subscribed",
]:
raise ValueError(
f"Invalid setting key {key}. Must be one of institution, sector, job_role, is_email_subscribed"
f"Invalid setting key {key}. Must be one of"
"institution, sector, job_role, is_email_subscribed"
)
body[f"settings.{key}"] = settings[key]

Expand All @@ -41,7 +56,7 @@ def set_user_settings(self, consumer_id, settings): # pragma: no cover
)

def patch_user_time_settings(self, consumer_id, time): # pragma: no cover
"""Set user settings.
"""Set user settings last_read_message field.
Args:
consumer_id: Consumer ID for the user
Expand All @@ -53,7 +68,6 @@ def patch_user_time_settings(self, consumer_id, time): # pragma: no cover
Raises:
MPRestError.
"""

return self._patch_resource(
body={"settings.message_last_read": time.isoformat()},
params={"consumer_id": consumer_id},
Expand Down

0 comments on commit 7cbf363

Please sign in to comment.