Resend: add support for send_at

Resend's new `scheduled_at` API field allows delayed sending
(though not with attachments or batch sending).

Closes #396.
This commit is contained in:
Mike Edmunds
2024-09-06 11:29:01 -07:00
parent af6eaea565
commit 2f2a888f61
6 changed files with 63 additions and 7 deletions

View File

@@ -266,8 +266,16 @@ class ResendPayload(RequestsPayload):
)
self.metadata = metadata # may be needed for batch send in serialize_data
# Resend doesn't support delayed sending
# def set_send_at(self, send_at):
def set_send_at(self, send_at):
try:
# Resend can't handle microseconds; truncate to milliseconds if necessary.
send_at = send_at.isoformat(
timespec="milliseconds" if send_at.microsecond else "seconds"
)
except AttributeError:
# User is responsible for formatting their own string
pass
self.data["scheduled_at"] = send_at
def set_tags(self, tags):
# Send tags using a custom X-Tags header.