33from typing_extensions import NotRequired , TypedDict
44
55from resend import request
6- from resend .emails ._received_email import (ReceivedEmailAttachment ,
7- ReceivedEmailAttachmentDetails )
6+ from resend .emails ._received_email import (EmailAttachment ,
7+ EmailAttachmentDetails )
88from resend .pagination_helper import PaginationHelper
99
1010
11- # Internal wrapper type for get attachment API response
12- class _GetAttachmentResponse (TypedDict ):
13- object : str
14- data : ReceivedEmailAttachmentDetails
15-
16-
1711class _ListParams (TypedDict ):
1812 limit : NotRequired [int ]
1913 """
@@ -34,7 +28,7 @@ class _ListResponse(TypedDict):
3428 """
3529 The object type: "list"
3630 """
37- data : List [ReceivedEmailAttachment ]
31+ data : List [EmailAttachment ]
3832 """
3933 The list of attachment objects.
4034 """
@@ -44,9 +38,9 @@ class _ListResponse(TypedDict):
4438 """
4539
4640
47- class Receiving :
41+ class Attachments :
4842 """
49- Receiving class that provides methods for retrieving attachments from received emails.
43+ Attachments class that provides methods for retrieving attachments from sent emails.
5044 """
5145
5246 class ListParams (_ListParams ):
@@ -65,49 +59,48 @@ class ListResponse(_ListResponse):
6559
6660 Attributes:
6761 object (str): The object type: "list"
68- data (List[ReceivedEmailAttachment ]): The list of attachment objects.
62+ data (List[EmailAttachment ]): The list of attachment objects.
6963 has_more (bool): Whether there are more attachments available for pagination.
7064 """
7165
7266 @classmethod
73- def get (cls , email_id : str , attachment_id : str ) -> ReceivedEmailAttachmentDetails :
67+ def get (cls , email_id : str , attachment_id : str ) -> EmailAttachmentDetails :
7468 """
75- Retrieve a single attachment from a received email.
76- see more: https://resend.com/docs/api-reference/attachments/retrieve-attachment
69+ Retrieve a single attachment from a sent email.
70+ see more: https://resend.com/docs/api-reference/attachments/retrieve-sent-email- attachment
7771
7872 Args:
79- email_id (str): The ID of the received email
73+ email_id (str): The ID of the sent email
8074 attachment_id (str): The ID of the attachment to retrieve
8175
8276 Returns:
83- ReceivedEmailAttachmentDetails : The attachment details including download URL
77+ EmailAttachmentDetails : The attachment details including download URL
8478 """
85- path = f"/emails/receiving/ { email_id } /attachments/{ attachment_id } "
86- resp = request .Request [_GetAttachmentResponse ](
79+ path = f"/emails/{ email_id } /attachments/{ attachment_id } "
80+ resp = request .Request [EmailAttachmentDetails ](
8781 path = path ,
8882 params = {},
8983 verb = "get" ,
9084 ).perform_with_content ()
91- # Extract the data field from the wrapped response
92- return resp ["data" ]
85+ return resp
9386
9487 @classmethod
9588 def list (cls , email_id : str , params : Optional [ListParams ] = None ) -> ListResponse :
9689 """
97- Retrieve a list of attachments from a received email.
98- see more: https://resend.com/docs/api-reference/attachments/list-attachments
90+ Retrieve a list of attachments from a sent email.
91+ see more: https://resend.com/docs/api-reference/attachments/list-sent-email- attachments
9992
10093 Args:
101- email_id (str): The ID of the received email
94+ email_id (str): The ID of the sent email
10295 params (Optional[ListParams]): The list parameters for pagination
10396
10497 Returns:
10598 ListResponse: A paginated list of attachment objects
10699 """
107- base_path = f"/emails/receiving/ { email_id } /attachments"
100+ base_path = f"/emails/{ email_id } /attachments"
108101 query_params = cast (Dict [Any , Any ], params ) if params else None
109102 path = PaginationHelper .build_paginated_path (base_path , query_params )
110- resp = request .Request [Receiving .ListResponse ](
103+ resp = request .Request [Attachments .ListResponse ](
111104 path = path ,
112105 params = {},
113106 verb = "get" ,
0 commit comments