Skip to content

Commit

Permalink
replace method post with patch for user setting to avoid wiping out c…
Browse files Browse the repository at this point in the history
…ertain fields (#829)
  • Loading branch information
yang-ruoxi committed Jul 25, 2023
1 parent b2f2bc0 commit b2431e8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions mp_api/client/routes/_user_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,21 @@ def set_user_settings(self, consumer_id, settings): # pragma: no cover
Raises:
MPRestError.
"""
return self._post_resource(
body=settings, params={"consumer_id": consumer_id}
body = dict()
for key in settings:
if key not in [
"institution",
"sector",
"job_role",
"is_email_subscribed",
]:
raise ValueError(
f"Invalid setting key {key}. Must be one of institution, sector, job_role, is_email_subscribed"
)
body[f"settings.{key}"] = settings[key]

return self._patch_resource(
body=body, params={"consumer_id": consumer_id}
).get("data")

def patch_user_time_settings(self, consumer_id, time): # pragma: no cover
Expand Down

0 comments on commit b2431e8

Please sign in to comment.