Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions resend/emails/_email.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import List, Union
from typing import List, Optional, Union

from typing_extensions import TypedDict
from typing_extensions import NotRequired, TypedDict

from resend.emails._tag import Tag

# Uses functional typed dict syntax here in order to support "from" reserved keyword
_FromParam = TypedDict(
Expand Down Expand Up @@ -56,6 +58,18 @@ class _EmailDefaultAttrs(_FromParam):
"""
The last event of the email.
"""
object: NotRequired[str]
"""
The object type: email. Not present on items returned by list.
"""
scheduled_at: NotRequired[Optional[str]]
"""
When the email is scheduled to be sent, or None if it is not scheduled.
"""
tags: NotRequired[List[Tag]]
"""
The tags attached to the email. Not present on items returned by list.
"""


class Email(_EmailDefaultAttrs):
Expand All @@ -75,4 +89,7 @@ class Email(_EmailDefaultAttrs):
cc (Union[List[str], str]): Cc
reply_to (Union[List[str], str]): Reply to
last_event (str): The last event of the email.
object (NotRequired[str]): The object type: email.
scheduled_at (NotRequired[Optional[str]]): When the email is scheduled to be sent.
tags (NotRequired[List[Tag]]): The tags attached to the email.
"""
5 changes: 5 additions & 0 deletions tests/emails_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def test_email_get(self) -> None:
"cc": [None],
"reply_to": [None],
"last_event": "delivered",
"scheduled_at": None,
"tags": [{"name": "category", "value": "confirm_email"}],
}
)

Expand All @@ -61,6 +63,9 @@ def test_email_get(self) -> None:
)
assert email["id"] == "4ef9a417-02e9-4d39-ad75-9611e0fcc33c"
assert email["message_id"] == "<111-222-333@email.example.com>"
assert email["object"] == "email"
assert email["scheduled_at"] is None
assert email["tags"] == [{"name": "category", "value": "confirm_email"}]

def test_should_get_email_raise_exception_when_no_content(self) -> None:
self.set_mock_json(None)
Expand Down