Skip to content

Commit

Permalink
Add 'mark message as seen'
Browse files Browse the repository at this point in the history
'add mark message as seen'
  • Loading branch information
SHELA authored Aug 18, 2024
1 parent b4073f4 commit 0409c4e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pymailtm/pymailtm.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,23 @@ def get_messages(self, page=1):
message_data["intro"],
text,
html,
message_data["seen"],
message_data))

return messages

def mark_seen_message(self, message_id):
headers = self.auth_headers
headers["Content-Type"] = "application/ld+json";

r = requests.patch(
f"{self.api_address}/messages/{message_id}", headers=headers,
data=json.dumps({'seen': True}))
if r.status_code not in [200, 201]:
print(r.text)
raise CouldNotGetUpdateMessageException(f"HTTP {r.status_code}")
return r.json()

def delete_account(self):
"""Try to delete the account. Returns True if it succeeds."""
r = requests.delete("{}/accounts/{}".format(self.api_address,
Expand Down Expand Up @@ -111,6 +124,7 @@ class Message:
intro: str
text: str
html: str
seen: bool
data: Dict

def open_web(self):
Expand Down Expand Up @@ -153,6 +167,10 @@ class CouldNotGetMessagesException(Exception):
"""Raised if a GET on /messages returns with a failed status code."""


class CouldNotGetUpdateMessageException(Exception):
"""Raised if a PATCH on /messages returns with a failed status code."""


class CouldNotGetAccountException(Exception):
"""Raised if a POST on /accounts or /authorization_token returns with a failed status code."""

Expand Down

0 comments on commit 0409c4e

Please sign in to comment.