Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

resend

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resend - npm Package Compare versions

Comparing version
2.17.0
to
2.18.0a1
resend/attachments/__init__.py
+9
from resend.attachments._receiving import Receiving
class Attachments:
"""
Attachments class that provides methods for managing email attachments.
"""
Receiving = Receiving
from typing import Any, Dict, List, Optional, cast
from typing_extensions import NotRequired, TypedDict
from resend import request
from resend.emails._received_email import (ReceivedEmailAttachment,
ReceivedEmailAttachmentDetails)
from resend.pagination_helper import PaginationHelper
# Internal wrapper type for get attachment API response
class _GetAttachmentResponse(TypedDict):
object: str
data: ReceivedEmailAttachmentDetails
class _ListParams(TypedDict):
limit: NotRequired[int]
"""
The maximum number of attachments to return. Maximum 100, minimum 1.
"""
after: NotRequired[str]
"""
Return attachments after this cursor for pagination.
"""
before: NotRequired[str]
"""
Return attachments before this cursor for pagination.
"""
class _ListResponse(TypedDict):
object: str
"""
The object type: "list"
"""
data: List[ReceivedEmailAttachment]
"""
The list of attachment objects.
"""
has_more: bool
"""
Whether there are more attachments available for pagination.
"""
class Receiving:
"""
Receiving class that provides methods for retrieving attachments from received emails.
"""
class ListParams(_ListParams):
"""
ListParams is the class that wraps the parameters for the list method.
Attributes:
limit (NotRequired[int]): The maximum number of attachments to return. Maximum 100, minimum 1.
after (NotRequired[str]): Return attachments after this cursor for pagination.
before (NotRequired[str]): Return attachments before this cursor for pagination.
"""
class ListResponse(_ListResponse):
"""
ListResponse is the type that wraps the response for listing attachments.
Attributes:
object (str): The object type: "list"
data (List[ReceivedEmailAttachment]): The list of attachment objects.
has_more (bool): Whether there are more attachments available for pagination.
"""
@classmethod
def get(cls, email_id: str, attachment_id: str) -> ReceivedEmailAttachmentDetails:
"""
Retrieve a single attachment from a received email.
see more: https://resend.com/docs/api-reference/attachments/retrieve-attachment
Args:
email_id (str): The ID of the received email
attachment_id (str): The ID of the attachment to retrieve
Returns:
ReceivedEmailAttachmentDetails: The attachment details including download URL
"""
path = f"/emails/receiving/{email_id}/attachments/{attachment_id}"
resp = request.Request[_GetAttachmentResponse](
path=path,
params={},
verb="get",
).perform_with_content()
# Extract the data field from the wrapped response
return resp["data"]
@classmethod
def list(cls, email_id: str, params: Optional[ListParams] = None) -> ListResponse:
"""
Retrieve a list of attachments from a received email.
see more: https://resend.com/docs/api-reference/attachments/list-attachments
Args:
email_id (str): The ID of the received email
params (Optional[ListParams]): The list parameters for pagination
Returns:
ListResponse: A paginated list of attachment objects
"""
base_path = f"/emails/receiving/{email_id}/attachments"
query_params = cast(Dict[Any, Any], params) if params else None
path = PaginationHelper.build_paginated_path(base_path, query_params)
resp = request.Request[Receiving.ListResponse](
path=path,
params={},
verb="get",
).perform_with_content()
return resp
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict
class ReceivedEmailAttachment(TypedDict):
"""
ReceivedEmailAttachment type that wraps an attachment object from a received email.
Attributes:
id (str): The attachment ID.
filename (str): The filename of the attachment.
content_type (str): The content type of the attachment.
content_disposition (str): The content disposition of the attachment.
content_id (NotRequired[str]): The content ID for inline attachments.
size (NotRequired[int]): The size of the attachment in bytes.
"""
id: str
"""
The attachment ID.
"""
filename: str
"""
The filename of the attachment.
"""
content_type: str
"""
The content type of the attachment.
"""
content_disposition: str
"""
The content disposition of the attachment.
"""
content_id: NotRequired[str]
"""
The content ID for inline attachments.
"""
size: NotRequired[int]
"""
The size of the attachment in bytes.
"""
class ReceivedEmailAttachmentDetails(TypedDict):
"""
ReceivedEmailAttachmentDetails type that wraps a received email attachment with download details.
Attributes:
id (str): The attachment ID.
filename (str): The filename of the attachment.
content_type (str): The content type of the attachment.
content_disposition (str): The content disposition of the attachment.
content_id (NotRequired[str]): The content ID for inline attachments.
download_url (str): The URL to download the attachment.
expires_at (str): When the download URL expires.
"""
id: str
"""
The attachment ID.
"""
filename: str
"""
The filename of the attachment.
"""
content_type: str
"""
The content type of the attachment.
"""
content_disposition: str
"""
The content disposition of the attachment.
"""
content_id: NotRequired[str]
"""
The content ID for inline attachments.
"""
download_url: str
"""
The URL to download the attachment.
"""
expires_at: str
"""
When the download URL expires.
"""
# Uses functional typed dict syntax here in order to support "from" reserved keyword
_ReceivedEmailFromParam = TypedDict(
"_ReceivedEmailFromParam",
{
"from": str,
},
)
# For list responses (omits html, text, headers, object from full email)
_ListReceivedEmailFromParam = TypedDict(
"_ListReceivedEmailFromParam",
{
"from": str,
},
)
class _ReceivedEmailDefaultAttrs(_ReceivedEmailFromParam):
object: str
"""
The object type.
"""
id: str
"""
The received email ID.
"""
to: List[str]
"""
List of recipient email addresses.
"""
created_at: str
"""
When the email was received.
"""
subject: str
"""
The subject of the email.
"""
html: Optional[str]
"""
The HTML content of the email.
"""
text: Optional[str]
"""
The text content of the email.
"""
bcc: Optional[List[str]]
"""
Bcc recipients.
"""
cc: Optional[List[str]]
"""
Cc recipients.
"""
reply_to: Optional[List[str]]
"""
Reply-to addresses.
"""
message_id: str
"""
The message ID of the email.
"""
headers: NotRequired[Dict[str, str]]
"""
Email headers.
"""
attachments: List[ReceivedEmailAttachment]
"""
List of attachments.
"""
class ReceivedEmail(_ReceivedEmailDefaultAttrs):
"""
ReceivedEmail type that wraps a received (inbound) email object.
Attributes:
object (str): The object type.
id (str): The received email ID.
to (List[str]): List of recipient email addresses.
from (str): The sender email address.
created_at (str): When the email was received.
subject (str): The subject of the email.
html (Optional[str]): The HTML content of the email.
text (Optional[str]): The text content of the email.
bcc (Optional[List[str]]): Bcc recipients.
cc (Optional[List[str]]): Cc recipients.
reply_to (Optional[List[str]]): Reply-to addresses.
message_id (str): The message ID of the email.
headers (NotRequired[Dict[str, str]]): Email headers.
attachments (List[ReceivedEmailAttachment]): List of attachments.
"""
class _ListReceivedEmailDefaultAttrs(_ListReceivedEmailFromParam):
id: str
"""
The received email ID.
"""
to: List[str]
"""
List of recipient email addresses.
"""
created_at: str
"""
When the email was received.
"""
subject: str
"""
The subject of the email.
"""
bcc: Optional[List[str]]
"""
Bcc recipients.
"""
cc: Optional[List[str]]
"""
Cc recipients.
"""
reply_to: Optional[List[str]]
"""
Reply-to addresses.
"""
message_id: str
"""
The message ID of the email.
"""
attachments: List[ReceivedEmailAttachment]
"""
List of attachments.
"""
class ListReceivedEmail(_ListReceivedEmailDefaultAttrs):
"""
ListReceivedEmail type for received email items in list responses.
Omits html, text, headers, and object fields from the full email.
Attributes:
id (str): The received email ID.
to (List[str]): List of recipient email addresses.
from (str): The sender email address.
created_at (str): When the email was received.
subject (str): The subject of the email.
bcc (Optional[List[str]]): Bcc recipients.
cc (Optional[List[str]]): Cc recipients.
reply_to (Optional[List[str]]): Reply-to addresses.
message_id (str): The message ID of the email.
attachments (List[ReceivedEmailAttachment]): List of attachments.
"""
from typing import Any, Dict, List, Optional, cast
from typing_extensions import NotRequired, TypedDict
from resend import request
from resend.emails._received_email import ListReceivedEmail, ReceivedEmail
from resend.pagination_helper import PaginationHelper
class _ListParams(TypedDict):
limit: NotRequired[int]
"""
The maximum number of emails to return. Maximum 100, minimum 1.
"""
after: NotRequired[str]
"""
Return emails after this cursor for pagination.
"""
before: NotRequired[str]
"""
Return emails before this cursor for pagination.
"""
class _ListResponse(TypedDict):
object: str
"""
The object type: "list"
"""
data: List[ListReceivedEmail]
"""
The list of received email objects.
"""
has_more: bool
"""
Whether there are more emails available for pagination.
"""
class Receiving:
"""
Receiving class that provides methods for retrieving received (inbound) emails.
"""
class ListParams(_ListParams):
"""
ListParams is the class that wraps the parameters for the list method.
Attributes:
limit (NotRequired[int]): The maximum number of emails to return. Maximum 100, minimum 1.
after (NotRequired[str]): Return emails after this cursor for pagination.
before (NotRequired[str]): Return emails before this cursor for pagination.
"""
class ListResponse(_ListResponse):
"""
ListResponse is the type that wraps the response for listing received emails.
Attributes:
object (str): The object type: "list"
data (List[ListReceivedEmail]): The list of received email objects.
has_more (bool): Whether there are more emails available for pagination.
"""
@classmethod
def get(cls, email_id: str) -> ReceivedEmail:
"""
Retrieve a single received email.
see more: https://resend.com/docs/api-reference/emails/retrieve-received-email
Args:
email_id (str): The ID of the received email to retrieve
Returns:
ReceivedEmail: The received email object
"""
path = f"/emails/receiving/{email_id}"
resp = request.Request[ReceivedEmail](
path=path,
params={},
verb="get",
).perform_with_content()
return resp
@classmethod
def list(cls, params: Optional[ListParams] = None) -> ListResponse:
"""
Retrieve a list of received emails.
see more: https://resend.com/docs/api-reference/emails/list-received-emails
Args:
params (Optional[ListParams]): The list parameters for pagination
Returns:
ListResponse: A paginated list of received email objects
"""
base_path = "/emails/receiving"
query_params = cast(Dict[Any, Any], params) if params else None
path = PaginationHelper.build_paginated_path(base_path, query_params)
resp = request.Request[Receiving.ListResponse](
path=path,
params={},
verb="get",
).perform_with_content()
return resp
from typing_extensions import TypedDict
class Topic(TypedDict):
id: str
"""
The unique identifier of the topic.
"""
name: str
"""
The topic name.
"""
default_subscription: str
"""
The default subscription preference for new contacts. Possible values: opt_in or opt_out.
"""
description: str
"""
The topic description.
"""
created_at: str
"""
The date and time the topic was created.
"""
from typing import Any, Dict, List, Optional, cast
from typing_extensions import NotRequired, TypedDict
from resend import request
from resend.pagination_helper import PaginationHelper
from ._topic import Topic
class Topics:
class CreateTopicResponse(TypedDict):
"""
CreateTopicResponse is the type that wraps the response of the topic that was created
Attributes:
id (str): The ID of the created topic
"""
id: str
"""
The ID of the created topic
"""
class CreateParams(TypedDict):
name: str
"""
The topic name. Max length is 50 characters.
"""
default_subscription: str
"""
The default subscription preference for new contacts. Possible values: opt_in or opt_out.
This value cannot be changed later.
"""
description: NotRequired[str]
"""
The topic description. Max length is 200 characters.
"""
class UpdateTopicResponse(TypedDict):
"""
UpdateTopicResponse is the type that wraps the response of the topic that was updated
Attributes:
id (str): The ID of the updated topic
"""
id: str
"""
The ID of the updated topic
"""
class UpdateParams(TypedDict, total=False):
name: str
"""
The topic name. Max length is 50 characters.
"""
description: str
"""
The topic description. Max length is 200 characters.
"""
class RemoveTopicResponse(TypedDict):
"""
RemoveTopicResponse is the type that wraps the response of the topic that was removed
Attributes:
object (str): The object type, "topic"
id (str): The ID of the removed topic
deleted (bool): Whether the topic was deleted
"""
object: str
"""
The object type, "topic"
"""
id: str
"""
The ID of the removed topic
"""
deleted: bool
"""
Whether the topic was deleted
"""
class ListParams(TypedDict):
limit: NotRequired[int]
"""
Number of topics to retrieve. Maximum is 100, and minimum is 1.
"""
after: NotRequired[str]
"""
The ID after which we'll retrieve more topics (for pagination).
This ID will not be included in the returned list.
Cannot be used with the before parameter.
"""
before: NotRequired[str]
"""
The ID before which we'll retrieve more topics (for pagination).
This ID will not be included in the returned list.
Cannot be used with the after parameter.
"""
class ListResponse(TypedDict):
"""
ListResponse type that wraps a list of topic objects with pagination metadata
Attributes:
object (str): The object type, always "list"
data (List[Topic]): A list of topic objects
has_more (bool): Whether there are more results available
"""
object: str
"""
The object type, always "list"
"""
data: List[Topic]
"""
A list of topic objects
"""
has_more: bool
"""
Whether there are more results available for pagination
"""
@classmethod
def create(cls, params: CreateParams) -> CreateTopicResponse:
"""
Create a topic.
see more: https://resend.com/docs/api-reference/topics/create-topic
Args:
params (CreateParams): The topic creation parameters
- name: The topic name (max 50 characters)
- default_subscription: The default subscription preference ("opt_in" or "opt_out")
- description: Optional topic description (max 200 characters)
Returns:
CreateTopicResponse: The created topic response with the topic ID
"""
path = "/topics"
resp = request.Request[Topics.CreateTopicResponse](
path=path, params=cast(Dict[Any, Any], params), verb="post"
).perform_with_content()
return resp
@classmethod
def get(cls, id: str) -> Topic:
"""
Retrieve a single topic by its ID.
see more: https://resend.com/docs/api-reference/topics/get-topic
Args:
id (str): The topic ID
Returns:
Topic: The topic object
"""
path = f"/topics/{id}"
resp = request.Request[Topic](
path=path, params={}, verb="get"
).perform_with_content()
return resp
@classmethod
def update(cls, id: str, params: UpdateParams) -> UpdateTopicResponse:
"""
Update an existing topic.
see more: https://resend.com/docs/api-reference/topics/update-topic
Args:
id (str): The topic ID
params (UpdateParams): The topic update parameters
- name: Optional topic name (max 50 characters)
- description: Optional topic description (max 200 characters)
Returns:
UpdateTopicResponse: The updated topic response with the topic ID
"""
path = f"/topics/{id}"
resp = request.Request[Topics.UpdateTopicResponse](
path=path, params=cast(Dict[Any, Any], params), verb="patch"
).perform_with_content()
return resp
@classmethod
def remove(cls, id: str) -> RemoveTopicResponse:
"""
Delete a single topic.
see more: https://resend.com/docs/api-reference/topics/delete-topic
Args:
id (str): The topic ID
Returns:
RemoveTopicResponse: The removed topic response
"""
path = f"/topics/{id}"
resp = request.Request[Topics.RemoveTopicResponse](
path=path, params={}, verb="delete"
).perform_with_content()
return resp
@classmethod
def list(cls, params: Optional[ListParams] = None) -> ListResponse:
"""
Retrieve a list of topics.
see more: https://resend.com/docs/api-reference/topics/list-topics
Args:
params (Optional[ListParams]): Optional pagination parameters
- limit: Number of topics to retrieve (max 100, min 1).
If not provided, all topics will be returned without pagination.
- after: ID after which to retrieve more topics
- before: ID before which to retrieve more topics
Returns:
ListResponse: A list of topic objects
"""
base_path = "/topics"
query_params = cast(Dict[Any, Any], params) if params else None
path = PaginationHelper.build_paginated_path(base_path, query_params)
resp = request.Request[Topics.ListResponse](
path=path, params={}, verb="get"
).perform_with_content()
return resp
+1
-1
Metadata-Version: 2.1
Name: resend
Version: 2.17.0
Version: 2.18.0a1
Summary: Resend Python SDK

@@ -5,0 +5,0 @@ Home-page: https://github.com/resendlabs/resend-python

Metadata-Version: 2.1
Name: resend
Version: 2.17.0
Version: 2.18.0a1
Summary: Resend Python SDK

@@ -5,0 +5,0 @@ Home-page: https://github.com/resendlabs/resend-python

@@ -22,2 +22,5 @@ LICENSE.md

resend/api_keys/_api_keys.py
resend/attachments/__init__.py
resend/attachments/_attachments.py
resend/attachments/_receiving.py
resend/audiences/__init__.py

@@ -41,2 +44,7 @@ resend/audiences/_audience.py

resend/emails/_emails.py
resend/emails/_tag.py
resend/emails/_received_email.py
resend/emails/_receiving.py
resend/emails/_tag.py
resend/topics/__init__.py
resend/topics/_topic.py
resend/topics/_topics.py

@@ -5,2 +5,4 @@ import os

from .api_keys._api_keys import ApiKeys
from .attachments._attachments import Attachments
from .attachments._receiving import Receiving as AttachmentsReceiving
from .audiences._audience import Audience

@@ -18,2 +20,6 @@ from .audiences._audiences import Audiences

from .emails._emails import Emails
from .emails._received_email import (ListReceivedEmail, ReceivedEmail,
ReceivedEmailAttachment,
ReceivedEmailAttachmentDetails)
from .emails._receiving import Receiving as EmailsReceiving
from .emails._tag import Tag

@@ -23,2 +29,4 @@ from .http_client import HTTPClient

from .request import Request
from .topics._topic import Topic
from .topics._topics import Topics
from .version import __version__, get_version

@@ -47,2 +55,4 @@

"Broadcasts",
"Attachments",
"Topics",
# Types

@@ -58,5 +68,13 @@ "Audience",

"Broadcast",
"Topic",
"BatchValidationError",
"ReceivedEmail",
"ReceivedEmailAttachment",
"ReceivedEmailAttachmentDetails",
"ListReceivedEmail",
# Receiving types (for type hints)
"EmailsReceiving",
"AttachmentsReceiving",
# Default HTTP Client
"RequestsClient",
]

@@ -8,2 +8,3 @@ from typing import Any, Dict, List, Optional, Union, cast

from resend.emails._email import Email
from resend.emails._receiving import Receiving
from resend.emails._tag import Tag

@@ -107,2 +108,3 @@ from resend.pagination_helper import PaginationHelper

class Emails:
Receiving = Receiving

@@ -109,0 +111,0 @@ class CancelScheduledEmailResponse(_CancelScheduledEmailResponse):

@@ -1,2 +0,2 @@

__version__ = "2.17.0"
__version__ = "2.18.0-alpha.1"

@@ -3,0 +3,0 @@