-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add messages client and 400,404 warnings
- Loading branch information
Jason
committed
Jun 13, 2023
1 parent
04f0662
commit d5fb390
Showing
4 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from ._general_store import GeneralStoreRester | ||
from ._messages import MessagesRester | ||
from ._user_settings import UserSettingsRester |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from datetime import datetime | ||
from typing import List | ||
|
||
from emmet.core._messages import MessagesDoc, MessageType | ||
|
||
from mp_api.client.core import BaseRester | ||
|
||
|
||
class MessagesRester(BaseRester[MessagesDoc]): # pragma: no cover | ||
suffix = "_messages" | ||
document_model = MessagesDoc # type: ignore | ||
primary_key = "title" | ||
monty_decode = False | ||
use_document_model = False | ||
|
||
def set_message( | ||
self, | ||
title: str, | ||
body: str, | ||
type: MessageType = MessageType.generic, | ||
authors: List[str] = [], | ||
): # pragma: no cover | ||
"""Set user settings | ||
Args: | ||
title: Message title | ||
body: Message text body | ||
type: Message type | ||
authors: Message authors | ||
Returns: | ||
Dictionary with updated message data | ||
Raises: | ||
MPRestError. | ||
""" | ||
d = {"title": title, "body": body, "type": type.value, "authors": authors} | ||
|
||
return self._post_resource(body=d).get("data") | ||
|
||
def get_messages(self, last_updated: datetime): # pragma: no cover | ||
"""Get user settings. | ||
Args: | ||
last_updated: Datetime to use to query for newer messages | ||
Returns: | ||
Dictionary with messages data | ||
Raises: | ||
MPRestError. | ||
""" | ||
return self._search(last_updated=last_updated) |