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
8 changes: 4 additions & 4 deletions resend/inboxes/drafts/_inbox_drafts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class CreateParams(TypedDict):
subject (NotRequired[Optional[str]]): The subject.
html (NotRequired[Optional[str]]): The HTML body.
text (NotRequired[Optional[str]]): The plain text body.
attachments (NotRequired[List[AttachmentParams]]): Files to store on the draft.
attachments (NotRequired[Optional[List[AttachmentParams]]]): Files to store on the draft.
thread_id (NotRequired[str]): The Thread ID to reply in.
reply_to_email_id (NotRequired[str]): The Email ID to reply to.
"""
Expand Down Expand Up @@ -146,7 +146,7 @@ class CreateParams(TypedDict):
"""
The plain text body.
"""
attachments: NotRequired[List["InboxDrafts.AttachmentParams"]]
attachments: NotRequired[Optional[List["InboxDrafts.AttachmentParams"]]]
"""
Files to store on the draft. Each one needs ``content``, ``filename`` and
``content_type``. A ``path`` or ``content_id`` returns a 422. The files on
Expand Down Expand Up @@ -313,10 +313,10 @@ class SendParams(TypedDict):
SendParams are the optional body parameters for sending a draft.

Attributes:
headers (NotRequired[Dict[str, str]]): Custom headers to be added to the email.
headers (NotRequired[Optional[Dict[str, str]]]): Custom headers to be added to the email.
"""

headers: NotRequired[Dict[str, str]]
headers: NotRequired[Optional[Dict[str, str]]]
"""
Custom headers to be added to the email. The ``In-Reply-To``,
``References`` and ``Reply-To`` headers are set by Resend and cannot be
Expand Down
32 changes: 16 additions & 16 deletions resend/inboxes/threads/emails/_inbox_thread_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ class ReplyParams(TypedDict):
email_id (str): The Email ID of the message to reply to.
html (NotRequired[str]): The HTML body of the reply.
text (NotRequired[str]): The plain-text body of the reply.
cc (NotRequired[Union[str, List[str]]]): CC recipients.
bcc (NotRequired[Union[str, List[str]]]): BCC recipients.
cc (NotRequired[Optional[Union[str, List[str]]]]): CC recipients.
bcc (NotRequired[Optional[Union[str, List[str]]]]): BCC recipients.
subject (NotRequired[str]): The subject of the reply.
reply_all (NotRequired[bool]): Reply to everyone on the original message.
headers (NotRequired[Dict[str, str]]): Custom headers to be added to the email.
attachments (NotRequired[List[Union[Attachment, RemoteAttachment]]]): Files to attach.
headers (NotRequired[Optional[Dict[str, str]]]): Custom headers to be added to the email.
attachments (NotRequired[Optional[List[Union[Attachment, RemoteAttachment]]]]): Files to attach.
"""

inbox_id: str
Expand All @@ -112,7 +112,7 @@ class ReplyParams(TypedDict):
"""
The plain-text body of the reply.
"""
cc: NotRequired[Union[str, List[str]]]
cc: NotRequired[Optional[Union[str, List[str]]]]
"""
CC recipient email address. For multiple addresses, send a list of strings.
Without ``reply_all``, the reply copies only these addresses. With
Expand All @@ -121,7 +121,7 @@ class ReplyParams(TypedDict):
addresses. After the ``to`` recipients are added, the reply cannot exceed
50 recipients.
"""
bcc: NotRequired[Union[str, List[str]]]
bcc: NotRequired[Optional[Union[str, List[str]]]]
"""
BCC recipient email address. For multiple addresses, send a list of strings.
BCC recipients of the original message are never copied.
Expand All @@ -142,15 +142,15 @@ class ReplyParams(TypedDict):
recipients. The inbox address is always excluded, and duplicates are
removed. Defaults to False.
"""
headers: NotRequired[Dict[str, str]]
headers: NotRequired[Optional[Dict[str, str]]]
"""
Custom headers to be added to the email. The ``In-Reply-To``,
``References`` and ``Reply-To`` headers are set by Resend and cannot be
set here. Sending one of them, in any letter case, returns a 422. Header
names cannot be empty, and names and values cannot contain line breaks
or null characters, or the request returns a 422.
"""
attachments: NotRequired[List[Union[Attachment, RemoteAttachment]]]
attachments: NotRequired[Optional[List[Union[Attachment, RemoteAttachment]]]]
"""
Files to attach, as on ``Emails.send``. Each one needs ``content`` or
``path``. The ``content`` of all files can total at most 25 MB. A
Expand Down Expand Up @@ -204,13 +204,13 @@ class ForwardParams(TypedDict):
thread_id (str): The Thread ID.
email_id (str): The Email ID of the message to forward.
to (Union[str, List[str]]): The recipients.
cc (NotRequired[Union[str, List[str]]]): CC recipients.
bcc (NotRequired[Union[str, List[str]]]): BCC recipients.
cc (NotRequired[Optional[Union[str, List[str]]]]): CC recipients.
bcc (NotRequired[Optional[Union[str, List[str]]]]): BCC recipients.
html (NotRequired[str]): An HTML note sent above the quoted original.
text (NotRequired[str]): A plain-text note sent above the quoted original.
subject (NotRequired[str]): The subject of the forward.
headers (NotRequired[Dict[str, str]]): Custom headers to be added to the email.
attachments (NotRequired[List[Union[Attachment, RemoteAttachment]]]): Files to attach.
headers (NotRequired[Optional[Dict[str, str]]]): Custom headers to be added to the email.
attachments (NotRequired[Optional[List[Union[Attachment, RemoteAttachment]]]]): Files to attach.
"""

inbox_id: str
Expand All @@ -232,12 +232,12 @@ class ForwardParams(TypedDict):
Must name at least one address. ``to``, ``cc`` and ``bcc`` combined cannot
exceed 50 recipients.
"""
cc: NotRequired[Union[str, List[str]]]
cc: NotRequired[Optional[Union[str, List[str]]]]
"""
CC recipient email address. For multiple addresses, send a list of strings.
Counts toward the 50-recipient limit.
"""
bcc: NotRequired[Union[str, List[str]]]
bcc: NotRequired[Optional[Union[str, List[str]]]]
"""
BCC recipient email address. For multiple addresses, send a list of strings.
Counts toward the 50-recipient limit.
Expand All @@ -255,15 +255,15 @@ class ForwardParams(TypedDict):
The subject of the forward. Cannot contain a line break. When omitted, the
thread subject is used, prefixed with ``Fwd:`` if it does not already start with it.
"""
headers: NotRequired[Dict[str, str]]
headers: NotRequired[Optional[Dict[str, str]]]
"""
Custom headers to be added to the email. The ``In-Reply-To``,
``References`` and ``Reply-To`` headers are set by Resend and cannot be
set here. Sending one of them, in any letter case, returns a 422. Header
names cannot be empty, and names and values cannot contain line breaks
or null characters, or the request returns a 422.
"""
attachments: NotRequired[List[Union[Attachment, RemoteAttachment]]]
attachments: NotRequired[Optional[List[Union[Attachment, RemoteAttachment]]]]
"""
Files to attach, as on ``Emails.send``. Each one needs ``content`` or
``path``. They share one limit with the attachments of the original
Expand Down
35 changes: 35 additions & 0 deletions tests/test_nullable_inbox_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from resend.inboxes.drafts._inbox_drafts import InboxDrafts
from resend.inboxes.threads.emails._inbox_thread_emails import \
InboxThreadEmails


def test_optional_inbox_params_accept_none() -> None:
reply: InboxThreadEmails.ReplyParams = {
"inbox_id": "inbox_123",
"thread_id": "thread_123",
"email_id": "email_123",
"cc": None,
"bcc": None,
"headers": None,
"attachments": None,
}
forward: InboxThreadEmails.ForwardParams = {
"inbox_id": "inbox_123",
"thread_id": "thread_123",
"email_id": "email_123",
"to": "recipient@example.com",
"cc": None,
"bcc": None,
"headers": None,
"attachments": None,
}
create_draft: InboxDrafts.CreateParams = {
"inbox_id": "inbox_123",
"attachments": None,
}
send_draft: InboxDrafts.SendParams = {"headers": None}

assert reply["cc"] is None
assert forward["bcc"] is None
assert create_draft["attachments"] is None
assert send_draft["headers"] is None
Loading