resend
Advanced tools
| from typing import Any, Dict, List, Optional, cast | ||
| from typing_extensions import NotRequired, TypedDict | ||
| from resend import request | ||
| from resend.emails._received_email import (EmailAttachment, | ||
| EmailAttachmentDetails) | ||
| from resend.pagination_helper import PaginationHelper | ||
| 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[EmailAttachment] | ||
| """ | ||
| The list of attachment objects. | ||
| """ | ||
| has_more: bool | ||
| """ | ||
| Whether there are more attachments available for pagination. | ||
| """ | ||
| class Attachments: | ||
| """ | ||
| Attachments class that provides methods for retrieving attachments from sent 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[EmailAttachment]): 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) -> EmailAttachmentDetails: | ||
| """ | ||
| Retrieve a single attachment from a sent email. | ||
| see more: https://resend.com/docs/api-reference/attachments/retrieve-sent-email-attachment | ||
| Args: | ||
| email_id (str): The ID of the sent email | ||
| attachment_id (str): The ID of the attachment to retrieve | ||
| Returns: | ||
| EmailAttachmentDetails: The attachment details including download URL | ||
| """ | ||
| path = f"/emails/{email_id}/attachments/{attachment_id}" | ||
| resp = request.Request[EmailAttachmentDetails]( | ||
| path=path, | ||
| params={}, | ||
| verb="get", | ||
| ).perform_with_content() | ||
| return resp | ||
| @classmethod | ||
| def list(cls, email_id: str, params: Optional[ListParams] = None) -> ListResponse: | ||
| """ | ||
| Retrieve a list of attachments from a sent email. | ||
| see more: https://resend.com/docs/api-reference/attachments/list-sent-email-attachments | ||
| Args: | ||
| email_id (str): The ID of the sent email | ||
| params (Optional[ListParams]): The list parameters for pagination | ||
| Returns: | ||
| ListResponse: A paginated list of attachment objects | ||
| """ | ||
| base_path = f"/emails/{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[Attachments.ListResponse]( | ||
| path=path, | ||
| params={}, | ||
| verb="get", | ||
| ).perform_with_content() | ||
| return resp |
| """Templates module.""" |
| """Template and Variable type definitions.""" | ||
| from typing import Any, List, Literal, Union | ||
| from typing_extensions import NotRequired, TypedDict | ||
| class Variable(TypedDict): | ||
| """Template variable type. | ||
| Attributes: | ||
| key (str): The key of the variable. We recommend capitalizing the key (e.g. FIRST_NAME). | ||
| type (Literal["string", "number"]): The type of the variable. | ||
| fallback_value (Any): The fallback value of the variable. Must match the type of the variable. | ||
| If no fallback value is provided, you must provide a value for the variable when sending | ||
| an email using the template. | ||
| """ | ||
| key: str | ||
| """The key of the variable. We recommend capitalizing the key (e.g. FIRST_NAME).""" | ||
| type: Literal["string", "number"] | ||
| """The type of the variable.""" | ||
| fallback_value: NotRequired[Any] | ||
| """The fallback value of the variable. Must match the type of the variable.""" | ||
| # Use functional TypedDict syntax to support reserved keyword "from" | ||
| _FromParam = TypedDict( | ||
| "_FromParam", | ||
| { | ||
| "from": NotRequired[str], | ||
| }, | ||
| ) | ||
| class Template(_FromParam): | ||
| """Template type that wraps the template object. | ||
| Attributes: | ||
| id (str): The Template ID. | ||
| object (str): The object type (always "template"). | ||
| name (str): The name of the template. | ||
| alias (str): The alias of the template. | ||
| status (str): The status of the template ("draft" or "published"). | ||
| from (str): Sender email address. | ||
| subject (str): Email subject. | ||
| reply_to (Union[List[str], str]): Reply-to email address(es). | ||
| html (str): The HTML version of the template. | ||
| text (str): The plain text version of the template. | ||
| variables (List[Variable]): The array of variables used in the template. | ||
| created_at (str): The timestamp when the template was created. | ||
| updated_at (str): The timestamp when the template was last updated. | ||
| published_at (str): The timestamp when the template was published. | ||
| """ | ||
| id: str | ||
| """The Template ID.""" | ||
| object: str | ||
| """The object type (always "template").""" | ||
| name: str | ||
| """The name of the template.""" | ||
| alias: NotRequired[str] | ||
| """The alias of the template.""" | ||
| status: NotRequired[Literal["draft", "published"]] | ||
| """The status of the template.""" | ||
| subject: NotRequired[str] | ||
| """Email subject.""" | ||
| reply_to: NotRequired[Union[List[str], str]] | ||
| """Reply-to email address(es).""" | ||
| html: str | ||
| """The HTML version of the template.""" | ||
| text: NotRequired[str] | ||
| """The plain text version of the template.""" | ||
| variables: NotRequired[List[Variable]] | ||
| """The array of variables used in the template.""" | ||
| created_at: NotRequired[str] | ||
| """The timestamp when the template was created.""" | ||
| updated_at: NotRequired[str] | ||
| """The timestamp when the template was last updated.""" | ||
| published_at: NotRequired[str] | ||
| """The timestamp when the template was published.""" | ||
| class TemplateListItem(TypedDict): | ||
| """Template list item type returned in list responses. | ||
| This is a subset of the full Template object, containing only the fields | ||
| that are included in list responses. | ||
| Attributes: | ||
| id (str): The Template ID. | ||
| name (str): The name of the template. | ||
| status (Literal["draft", "published"]): The status of the template. | ||
| published_at (str | None): The timestamp when the template was published, or None if not published. | ||
| created_at (str): The timestamp when the template was created. | ||
| updated_at (str): The timestamp when the template was last updated. | ||
| alias (str): The alias of the template. | ||
| """ | ||
| id: str | ||
| """The Template ID.""" | ||
| name: str | ||
| """The name of the template.""" | ||
| status: Literal["draft", "published"] | ||
| """The status of the template.""" | ||
| published_at: Union[str, None] | ||
| """The timestamp when the template was published, or None if not published.""" | ||
| created_at: str | ||
| """The timestamp when the template was created.""" | ||
| updated_at: str | ||
| """The timestamp when the template was last updated.""" | ||
| alias: str | ||
| """The alias of the template.""" |
| """Templates API operations.""" | ||
| from typing import Any, Dict, List, Optional, Union, cast | ||
| from typing_extensions import NotRequired, TypedDict | ||
| from resend import request | ||
| from resend.pagination_helper import PaginationHelper | ||
| from ._template import Template, TemplateListItem, Variable | ||
| # Use functional TypedDict syntax to support reserved keyword "from" | ||
| _CreateParamsFrom = TypedDict( | ||
| "_CreateParamsFrom", | ||
| { | ||
| "from": NotRequired[str], | ||
| }, | ||
| ) | ||
| class Templates: | ||
| """Templates API resource. | ||
| The Templates API allows you to create, manage, and publish email templates | ||
| with optional variables. | ||
| """ | ||
| class CreateParams(_CreateParamsFrom): | ||
| """Parameters for creating a template. | ||
| Attributes: | ||
| name (str): The name of the template (required). | ||
| alias (str): The alias of the template. | ||
| from (str): Sender email address. To include a friendly name, use the format | ||
| "Your Name <sender@domain.com>". If provided, this value can be overridden | ||
| when sending an email using the template. | ||
| subject (str): Email subject. If provided, this value can be overridden when | ||
| sending an email using the template. | ||
| reply_to (Union[List[str], str]): Reply-to email address(es). For multiple | ||
| addresses, send as an array of strings. If provided, this value can be | ||
| overridden when sending an email using the template. | ||
| html (str): The HTML version of the template (required). | ||
| text (str): The plain text version of the message. If not provided, the HTML | ||
| will be used to generate a plain text version. You can opt out of this | ||
| behavior by setting value to an empty string. | ||
| variables (List[Variable]): The array of variables used in the template. | ||
| Each template may contain up to 20 variables. | ||
| """ | ||
| name: str | ||
| """The name of the template.""" | ||
| html: str | ||
| """The HTML version of the template.""" | ||
| alias: NotRequired[str] | ||
| """The alias of the template.""" | ||
| subject: NotRequired[str] | ||
| """Email subject.""" | ||
| reply_to: NotRequired[Union[List[str], str]] | ||
| """Reply-to email address(es).""" | ||
| text: NotRequired[str] | ||
| """The plain text version of the message.""" | ||
| variables: NotRequired[List[Variable]] | ||
| """The array of variables used in the template.""" | ||
| class CreateResponse(TypedDict): | ||
| """Response from creating a template. | ||
| Attributes: | ||
| id (str): The Template ID. | ||
| object (str): The object type (always "template"). | ||
| """ | ||
| id: str | ||
| """The Template ID.""" | ||
| object: str | ||
| """The object type (always "template").""" | ||
| class UpdateParams(_CreateParamsFrom): | ||
| """Parameters for updating a template. | ||
| Attributes: | ||
| id (str): The Template ID (required). | ||
| name (str): The name of the template. | ||
| alias (str): The alias of the template. | ||
| from (str): Sender email address. | ||
| subject (str): Email subject. | ||
| reply_to (Union[List[str], str]): Reply-to email address(es). | ||
| html (str): The HTML version of the template. | ||
| text (str): The plain text version of the message. | ||
| variables (List[Variable]): The array of variables used in the template. | ||
| """ | ||
| id: str | ||
| """The Template ID.""" | ||
| name: NotRequired[str] | ||
| """The name of the template.""" | ||
| alias: NotRequired[str] | ||
| """The alias of the template.""" | ||
| subject: NotRequired[str] | ||
| """Email subject.""" | ||
| reply_to: NotRequired[Union[List[str], str]] | ||
| """Reply-to email address(es).""" | ||
| html: NotRequired[str] | ||
| """The HTML version of the template.""" | ||
| text: NotRequired[str] | ||
| """The plain text version of the message.""" | ||
| variables: NotRequired[List[Variable]] | ||
| """The array of variables used in the template.""" | ||
| class UpdateResponse(TypedDict): | ||
| """Response from updating a template. | ||
| Attributes: | ||
| id (str): The Template ID. | ||
| object (str): The object type (always "template"). | ||
| """ | ||
| id: str | ||
| """The Template ID.""" | ||
| object: str | ||
| """The object type (always "template").""" | ||
| class ListParams(TypedDict): | ||
| """Parameters for listing templates. | ||
| Attributes: | ||
| limit (int): The number of templates to return (max 100). | ||
| after (str): Return templates after this cursor. | ||
| before (str): Return templates before this cursor. | ||
| """ | ||
| limit: NotRequired[int] | ||
| """The number of templates to return (max 100).""" | ||
| after: NotRequired[str] | ||
| """Return templates after this cursor.""" | ||
| before: NotRequired[str] | ||
| """Return templates before this cursor.""" | ||
| class ListResponse(TypedDict): | ||
| """Response from listing templates. | ||
| Attributes: | ||
| object (str): The object type (always "list"). | ||
| data (List[TemplateListItem]): Array of template list items with a subset of template properties. | ||
| has_more (bool): Whether there are more results available. | ||
| """ | ||
| object: str | ||
| """The object type (always "list").""" | ||
| data: List[TemplateListItem] | ||
| """Array of template list items with a subset of template properties.""" | ||
| has_more: bool | ||
| """Whether there are more results available.""" | ||
| class PublishResponse(TypedDict): | ||
| """Response from publishing a template. | ||
| Attributes: | ||
| id (str): The Template ID. | ||
| object (str): The object type (always "template"). | ||
| """ | ||
| id: str | ||
| """The Template ID.""" | ||
| object: str | ||
| """The object type (always "template").""" | ||
| class DuplicateResponse(TypedDict): | ||
| """Response from duplicating a template. | ||
| Attributes: | ||
| id (str): The Template ID of the duplicated template. | ||
| object (str): The object type (always "template"). | ||
| """ | ||
| id: str | ||
| """The Template ID of the duplicated template.""" | ||
| object: str | ||
| """The object type (always "template").""" | ||
| class RemoveResponse(TypedDict): | ||
| """Response from removing a template. | ||
| Attributes: | ||
| id (str): The Template ID. | ||
| object (str): The object type (always "template"). | ||
| deleted (bool): Whether the template was deleted. | ||
| """ | ||
| id: str | ||
| """The Template ID.""" | ||
| object: str | ||
| """The object type (always "template").""" | ||
| deleted: bool | ||
| """Whether the template was deleted.""" | ||
| @classmethod | ||
| def create(cls, params: CreateParams) -> CreateResponse: | ||
| """Create a new template. | ||
| Before you can use a template, you must publish it first. To publish a template, | ||
| use the Templates dashboard or publish() method. | ||
| Args: | ||
| params: The template creation parameters. | ||
| Returns: | ||
| CreateResponse: The created template response with ID and object type. | ||
| """ | ||
| path = "/templates" | ||
| resp = request.Request[Templates.CreateResponse]( | ||
| path=path, params=cast(Dict[Any, Any], params), verb="post" | ||
| ).perform_with_content() | ||
| return resp | ||
| @classmethod | ||
| def get(cls, template_id: str) -> Template: | ||
| """Retrieve a template by ID. | ||
| Args: | ||
| template_id: The Template ID. | ||
| Returns: | ||
| Template: The template object. | ||
| """ | ||
| path = f"/templates/{template_id}" | ||
| resp = request.Request[Template]( | ||
| path=path, params={}, verb="get" | ||
| ).perform_with_content() | ||
| return resp | ||
| @classmethod | ||
| def list(cls, params: Optional[ListParams] = None) -> ListResponse: | ||
| """List all templates with pagination support. | ||
| Args: | ||
| params: Optional pagination parameters (limit, after, before). | ||
| Returns: | ||
| ListResponse: The paginated list of templates. | ||
| """ | ||
| base_path = "/templates" | ||
| query_params = cast(Dict[Any, Any], params) if params else None | ||
| path = PaginationHelper.build_paginated_path(base_path, query_params) | ||
| resp = request.Request[Templates.ListResponse]( | ||
| path=path, params={}, verb="get" | ||
| ).perform_with_content() | ||
| return resp | ||
| @classmethod | ||
| def update(cls, params: UpdateParams) -> UpdateResponse: | ||
| """Update an existing template. | ||
| Args: | ||
| params: The template update parameters (must include id). | ||
| Returns: | ||
| UpdateResponse: The updated template response with ID and object type. | ||
| """ | ||
| template_id = params["id"] | ||
| path = f"/templates/{template_id}" | ||
| # Remove 'id' from params before sending | ||
| update_params = {k: v for k, v in params.items() if k != "id"} | ||
| resp = request.Request[Templates.UpdateResponse]( | ||
| path=path, params=cast(Dict[Any, Any], update_params), verb="patch" | ||
| ).perform_with_content() | ||
| return resp | ||
| @classmethod | ||
| def publish(cls, template_id: str) -> PublishResponse: | ||
| """Publish a template to make it available for use. | ||
| Before you can use a template to send emails, you must publish it first. | ||
| Args: | ||
| template_id: The Template ID. | ||
| Returns: | ||
| PublishResponse: The published template response with ID and object type. | ||
| """ | ||
| path = f"/templates/{template_id}/publish" | ||
| resp = request.Request[Templates.PublishResponse]( | ||
| path=path, params={}, verb="post" | ||
| ).perform_with_content() | ||
| return resp | ||
| @classmethod | ||
| def duplicate(cls, template_id: str) -> DuplicateResponse: | ||
| """Duplicate a template. | ||
| Creates a copy of the specified template with all its properties and variables. | ||
| Args: | ||
| template_id: The Template ID to duplicate. | ||
| Returns: | ||
| DuplicateResponse: The duplicated template response with new ID and object type. | ||
| """ | ||
| path = f"/templates/{template_id}/duplicate" | ||
| resp = request.Request[Templates.DuplicateResponse]( | ||
| path=path, params={}, verb="post" | ||
| ).perform_with_content() | ||
| return resp | ||
| @classmethod | ||
| def remove(cls, template_id: str) -> RemoveResponse: | ||
| """Delete a template. | ||
| Args: | ||
| template_id: The Template ID. | ||
| Returns: | ||
| RemoveResponse: The deletion response with ID, object type, and deleted status. | ||
| """ | ||
| path = f"/templates/{template_id}" | ||
| resp = request.Request[Templates.RemoveResponse]( | ||
| path=path, params={}, verb="delete" | ||
| ).perform_with_content() | ||
| return resp |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: resend | ||
| Version: 2.18.0a2 | ||
| Version: 2.18.0a3 | ||
| Summary: Resend Python SDK | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/resendlabs/resend-python |
| Metadata-Version: 2.1 | ||
| Name: resend | ||
| Version: 2.18.0a2 | ||
| Version: 2.18.0a3 | ||
| Summary: Resend Python SDK | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/resendlabs/resend-python |
@@ -22,5 +22,2 @@ 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 +38,3 @@ resend/audiences/_audience.py | ||
| resend/emails/_attachment.py | ||
| resend/emails/_attachments.py | ||
| resend/emails/_batch.py | ||
@@ -48,2 +46,5 @@ resend/emails/_email.py | ||
| resend/emails/_tag.py | ||
| resend/templates/__init__.py | ||
| resend/templates/_template.py | ||
| resend/templates/_templates.py | ||
| resend/topics/__init__.py | ||
@@ -50,0 +51,0 @@ resend/topics/_topic.py |
+14
-13
@@ -5,4 +5,2 @@ 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 | ||
@@ -17,8 +15,8 @@ from .audiences._audiences import Audiences | ||
| from .emails._attachment import Attachment, RemoteAttachment | ||
| from .emails._attachments import Attachments as EmailAttachments | ||
| from .emails._batch import Batch, BatchValidationError | ||
| from .emails._email import Email | ||
| from .emails._emails import Emails | ||
| from .emails._received_email import (ListReceivedEmail, ReceivedEmail, | ||
| ReceivedEmailAttachment, | ||
| ReceivedEmailAttachmentDetails) | ||
| from .emails._emails import Emails, EmailTemplate | ||
| from .emails._received_email import (EmailAttachment, EmailAttachmentDetails, | ||
| ListReceivedEmail, ReceivedEmail) | ||
| from .emails._receiving import Receiving as EmailsReceiving | ||
@@ -29,2 +27,4 @@ from .emails._tag import Tag | ||
| from .request import Request | ||
| from .templates._template import Template, TemplateListItem, Variable | ||
| from .templates._templates import Templates | ||
| from .topics._topic import Topic | ||
@@ -44,5 +44,2 @@ from .topics._topics import Topics | ||
| # API resources | ||
| from .emails._emails import Emails # noqa | ||
| __all__ = [ | ||
@@ -59,4 +56,4 @@ "__version__", | ||
| "Broadcasts", | ||
| "Templates", | ||
| "Webhooks", | ||
| "Attachments", | ||
| "Topics", | ||
@@ -71,4 +68,8 @@ # Types | ||
| "RemoteAttachment", | ||
| "EmailTemplate", | ||
| "Tag", | ||
| "Broadcast", | ||
| "Template", | ||
| "TemplateListItem", | ||
| "Variable", | ||
| "Webhook", | ||
@@ -82,10 +83,10 @@ "WebhookEvent", | ||
| "ReceivedEmail", | ||
| "ReceivedEmailAttachment", | ||
| "ReceivedEmailAttachmentDetails", | ||
| "EmailAttachment", | ||
| "EmailAttachmentDetails", | ||
| "ListReceivedEmail", | ||
| # Receiving types (for type hints) | ||
| "EmailsReceiving", | ||
| "AttachmentsReceiving", | ||
| "EmailAttachments", | ||
| # Default HTTP Client | ||
| "RequestsClient", | ||
| ] |
@@ -7,2 +7,3 @@ from typing import Any, Dict, List, Optional, Union, cast | ||
| from resend.emails._attachment import Attachment, RemoteAttachment | ||
| from resend.emails._attachments import Attachments | ||
| from resend.emails._email import Email | ||
@@ -14,2 +15,21 @@ from resend.emails._receiving import Receiving | ||
| class EmailTemplate(TypedDict): | ||
| """ | ||
| EmailTemplate is the class that wraps template configuration for email sending. | ||
| Attributes: | ||
| id (str): The template ID. | ||
| variables (NotRequired[Dict[str, Union[str, int]]]): Optional variables to be used in the template. | ||
| """ | ||
| id: str | ||
| """ | ||
| The template ID. | ||
| """ | ||
| variables: NotRequired[Dict[str, Union[str, int]]] | ||
| """ | ||
| Optional variables to be used in the template. | ||
| """ | ||
| class _UpdateParams(TypedDict): | ||
@@ -55,3 +75,3 @@ id: str | ||
| { | ||
| "from": str, | ||
| "from": NotRequired[str], | ||
| }, | ||
@@ -66,3 +86,3 @@ ) | ||
| """ | ||
| subject: str | ||
| subject: NotRequired[str] | ||
| """ | ||
@@ -108,5 +128,10 @@ The subject of the email. | ||
| """ | ||
| template: NotRequired[EmailTemplate] | ||
| """ | ||
| Template configuration for sending emails using predefined templates. | ||
| """ | ||
| class Emails: | ||
| Attachments = Attachments | ||
| Receiving = Receiving | ||
@@ -146,5 +171,5 @@ | ||
| Attributes: | ||
| from (str): The email address to send the email from. | ||
| from (NotRequired[str]): The email address to send the email from. | ||
| to (Union[str, List[str]]): List of email addresses to send the email to. | ||
| subject (str): The subject of the email. | ||
| subject (NotRequired[str]): The subject of the email. | ||
| bcc (NotRequired[Union[List[str], str]]): Bcc | ||
@@ -158,2 +183,3 @@ cc (NotRequired[Union[List[str], str]]): Cc | ||
| tags (NotRequired[List[Tag]]): List of tags to be added to the email. | ||
| template (NotRequired[EmailTemplate]): Template configuration for sending emails using predefined templates. | ||
| """ | ||
@@ -160,0 +186,0 @@ |
@@ -6,5 +6,5 @@ from typing import Dict, List, Optional | ||
| class ReceivedEmailAttachment(TypedDict): | ||
| class EmailAttachment(TypedDict): | ||
| """ | ||
| ReceivedEmailAttachment type that wraps an attachment object from a received email. | ||
| EmailAttachment type that wraps an attachment object from an email. | ||
@@ -46,7 +46,8 @@ Attributes: | ||
| class ReceivedEmailAttachmentDetails(TypedDict): | ||
| class EmailAttachmentDetails(TypedDict): | ||
| """ | ||
| ReceivedEmailAttachmentDetails type that wraps a received email attachment with download details. | ||
| EmailAttachmentDetails type that wraps an email attachment with download details. | ||
| Attributes: | ||
| object (str): The object type. | ||
| id (str): The attachment ID. | ||
@@ -61,2 +62,6 @@ filename (str): The filename of the attachment. | ||
| object: str | ||
| """ | ||
| The object type. | ||
| """ | ||
| id: str | ||
@@ -159,3 +164,3 @@ """ | ||
| """ | ||
| attachments: List[ReceivedEmailAttachment] | ||
| attachments: List[EmailAttachment] | ||
| """ | ||
@@ -184,3 +189,3 @@ List of attachments. | ||
| headers (NotRequired[Dict[str, str]]): Email headers. | ||
| attachments (List[ReceivedEmailAttachment]): List of attachments. | ||
| attachments (List[EmailAttachment]): List of attachments. | ||
| """ | ||
@@ -222,3 +227,3 @@ | ||
| """ | ||
| attachments: List[ReceivedEmailAttachment] | ||
| attachments: List[EmailAttachment] | ||
| """ | ||
@@ -244,3 +249,3 @@ List of attachments. | ||
| message_id (str): The message ID of the email. | ||
| attachments (List[ReceivedEmailAttachment]): List of attachments. | ||
| attachments (List[EmailAttachment]): List of attachments. | ||
| """ |
@@ -6,3 +6,5 @@ from typing import Any, Dict, List, Optional, cast | ||
| from resend import request | ||
| from resend.emails._received_email import ListReceivedEmail, ReceivedEmail | ||
| from resend.emails._received_email import (EmailAttachment, | ||
| EmailAttachmentDetails, | ||
| ListReceivedEmail, ReceivedEmail) | ||
| from resend.pagination_helper import PaginationHelper | ||
@@ -41,2 +43,32 @@ | ||
| class _AttachmentListParams(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 _AttachmentListResponse(TypedDict): | ||
| object: str | ||
| """ | ||
| The object type: "list" | ||
| """ | ||
| data: List[EmailAttachment] | ||
| """ | ||
| The list of attachment objects. | ||
| """ | ||
| has_more: bool | ||
| """ | ||
| Whether there are more attachments available for pagination. | ||
| """ | ||
| class Receiving: | ||
@@ -47,2 +79,75 @@ """ | ||
| class Attachments: | ||
| """ | ||
| Attachments class that provides methods for retrieving attachments from received emails. | ||
| """ | ||
| class ListParams(_AttachmentListParams): | ||
| """ | ||
| 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(_AttachmentListResponse): | ||
| """ | ||
| ListResponse is the type that wraps the response for listing attachments. | ||
| Attributes: | ||
| object (str): The object type: "list" | ||
| data (List[EmailAttachment]): 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) -> EmailAttachmentDetails: | ||
| """ | ||
| Retrieve a single attachment from a received email. | ||
| see more: https://resend.com/docs/api-reference/attachments/retrieve-received-email-attachment | ||
| Args: | ||
| email_id (str): The ID of the received email | ||
| attachment_id (str): The ID of the attachment to retrieve | ||
| Returns: | ||
| EmailAttachmentDetails: The attachment details including download URL | ||
| """ | ||
| path = f"/emails/receiving/{email_id}/attachments/{attachment_id}" | ||
| resp = request.Request[EmailAttachmentDetails]( | ||
| path=path, | ||
| params={}, | ||
| verb="get", | ||
| ).perform_with_content() | ||
| return resp | ||
| @classmethod | ||
| def list( | ||
| cls, | ||
| email_id: str, | ||
| params: Optional["Receiving.Attachments.ListParams"] = None, | ||
| ) -> "Receiving.Attachments.ListResponse": | ||
| """ | ||
| Retrieve a list of attachments from a received email. | ||
| see more: https://resend.com/docs/api-reference/attachments/list-received-email-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[_AttachmentListResponse]( | ||
| path=path, | ||
| params={}, | ||
| verb="get", | ||
| ).perform_with_content() | ||
| return resp | ||
| class ListParams(_ListParams): | ||
@@ -49,0 +154,0 @@ """ |
@@ -1,2 +0,2 @@ | ||
| __version__ = "2.18.0a2" | ||
| __version__ = "2.18.0a3" | ||
@@ -6,4 +6,4 @@ | ||
| """ | ||
| Returns the current version of this SDK. | ||
| Returns the current version of this lib | ||
| """ | ||
| return __version__ |
| 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 |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
138153
16.36%53
1.92%3646
14.62%