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.22.0
to
2.23.0
+16
resend/_base_response.py
"""Base response type for all Resend API responses."""
from typing import Dict
from typing_extensions import NotRequired, TypedDict
class BaseResponse(TypedDict):
"""Base response type that all API responses inherit from.
Attributes:
headers: HTTP response headers including rate limit info, request IDs, etc.
Optional field that may not be present in all responses.
"""
headers: NotRequired[Dict[str, str]]
+1
-1
Metadata-Version: 2.1
Name: resend
Version: 2.22.0
Version: 2.23.0
Summary: Resend Python SDK

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

Metadata-Version: 2.1
Name: resend
Version: 2.22.0
Version: 2.23.0
Summary: Resend Python SDK

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

@@ -6,2 +6,3 @@ LICENSE.md

resend/__init__.py
resend/_base_response.py
resend/exceptions.py

@@ -8,0 +9,0 @@ resend/http_client.py

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

from resend import request
from resend._base_response import BaseResponse
from resend.api_keys._api_key import ApiKey

@@ -13,3 +14,3 @@ from resend.pagination_helper import PaginationHelper

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -37,3 +38,3 @@ ListResponse type that wraps a list of API key objects with pagination metadata

class CreateApiKeyResponse(TypedDict):
class CreateApiKeyResponse(BaseResponse):
"""

@@ -40,0 +41,0 @@ CreateApiKeyResponse is the type that wraps the response of the API key that was created

@@ -6,2 +6,3 @@ import warnings

from resend._base_response import BaseResponse
from resend.segments._segments import Segments

@@ -14,3 +15,3 @@

class RemoveAudienceResponse(TypedDict):
class RemoveAudienceResponse(BaseResponse):
"""

@@ -56,3 +57,3 @@ RemoveAudienceResponse is the type that wraps the response of the audience that was removed

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -80,3 +81,3 @@ ListResponse type that wraps a list of audience objects with pagination metadata

class CreateAudienceResponse(TypedDict):
class CreateAudienceResponse(BaseResponse):
"""

@@ -83,0 +84,0 @@ CreateAudienceResponse is the type that wraps the response of the audience that was created

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

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -160,3 +161,3 @@

class CreateResponse(TypedDict):
class CreateResponse(BaseResponse):
"""

@@ -174,3 +175,3 @@ CreateResponse is the class that wraps the response of the create method.

class UpdateResponse(TypedDict):
class UpdateResponse(BaseResponse):
"""

@@ -214,3 +215,3 @@ UpdateResponse is the class that wraps the response of the update method.

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -238,3 +239,3 @@ ListResponse is the class that wraps the response of the list method with pagination metadata.

class RemoveResponse(TypedDict):
class RemoveResponse(BaseResponse):
"""

@@ -241,0 +242,0 @@ RemoveResponse is the class that wraps the response of the remove method.

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

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -14,3 +15,3 @@

class CreateResponse(TypedDict):
class CreateResponse(BaseResponse):
"""

@@ -33,3 +34,3 @@ CreateResponse is the type that wraps the response of the contact property that was created.

class UpdateResponse(TypedDict):
class UpdateResponse(BaseResponse):
"""

@@ -52,3 +53,3 @@ UpdateResponse is the type that wraps the response of the contact property that was updated.

class RemoveResponse(TypedDict):
class RemoveResponse(BaseResponse):
"""

@@ -103,3 +104,3 @@ RemoveResponse is the type that wraps the response of the contact property that was removed.

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -106,0 +107,0 @@ ListResponse type that wraps a list of contact property objects with pagination metadata.

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

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -19,3 +20,3 @@

class RemoveContactResponse(TypedDict):
class RemoveContactResponse(BaseResponse):
"""

@@ -61,3 +62,3 @@ RemoveContactResponse is the type that wraps the response of the contact that was removed

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -85,3 +86,3 @@ ListResponse type that wraps a list of contact objects with pagination metadata

class CreateContactResponse(TypedDict):
class CreateContactResponse(BaseResponse):
"""

@@ -104,3 +105,3 @@ CreateContactResponse is the type that wraps the response of the contact that was created

class UpdateContactResponse(TypedDict):
class UpdateContactResponse(BaseResponse):
"""

@@ -107,0 +108,0 @@ UpdateContactResponse is the type that wraps the response of the contact that was updated

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

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -27,3 +28,3 @@

class _ListResponse(TypedDict):
class _ListResponse(BaseResponse):
object: str

@@ -58,3 +59,3 @@ """

class _UpdateResponse(TypedDict):
class _UpdateResponse(BaseResponse):
id: str

@@ -61,0 +62,0 @@ """

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

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -18,3 +19,3 @@

class AddContactSegmentResponse(TypedDict):
class AddContactSegmentResponse(BaseResponse):
"""

@@ -32,3 +33,3 @@ AddContactSegmentResponse is the type that wraps the response when adding a contact to a segment.

class RemoveContactSegmentResponse(TypedDict):
class RemoveContactSegmentResponse(BaseResponse):
"""

@@ -78,3 +79,3 @@ RemoveContactSegmentResponse is the type that wraps the response when removing a contact from a segment.

class ListContactSegmentsResponse(TypedDict):
class ListContactSegmentsResponse(BaseResponse):
"""

@@ -81,0 +82,0 @@ ListContactSegmentsResponse type that wraps a list of segment objects with pagination metadata.

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

from resend import request
from resend._base_response import BaseResponse
from resend.domains._domain import Domain

@@ -34,3 +35,3 @@ from resend.domains._record import Record

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -58,3 +59,3 @@ ListResponse type that wraps a list of domain objects with pagination metadata

class CreateDomainResponse(TypedDict):
class CreateDomainResponse(BaseResponse):
"""

@@ -61,0 +62,0 @@ CreateDomainResponse is the type that wraps the response of the domain that was created

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

from resend import request
from resend._base_response import BaseResponse
from resend.emails._received_email import (EmailAttachment,

@@ -27,3 +28,3 @@ EmailAttachmentDetails)

class _ListResponse(TypedDict):
class _ListResponse(BaseResponse):
object: str

@@ -30,0 +31,0 @@ """

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

from resend import request
from resend._base_response import BaseResponse

@@ -11,3 +12,3 @@ from ._emails import Emails

class SendEmailResponse(TypedDict):
class SendEmailResponse(BaseResponse):
id: str

@@ -65,3 +66,3 @@ """

class SendResponse(TypedDict):
class SendResponse(BaseResponse):
data: List[SendEmailResponse]

@@ -68,0 +69,0 @@ """

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

from resend import request
from resend._base_response import BaseResponse
from resend.emails._attachment import Attachment, RemoteAttachment

@@ -46,3 +47,3 @@ from resend.emails._attachments import Attachments

class _UpdateEmailResponse(TypedDict):
class _UpdateEmailResponse(BaseResponse):
object: str

@@ -58,3 +59,3 @@ """

class _CancelScheduledEmailResponse(TypedDict):
class _CancelScheduledEmailResponse(BaseResponse):
object: str

@@ -200,3 +201,3 @@ """

class SendResponse(TypedDict):
class SendResponse(BaseResponse):
"""

@@ -207,2 +208,3 @@ SendResponse is the type that wraps the response of the email that was sent.

id (str): The ID of the sent email
headers (NotRequired[Dict[str, str]]): HTTP response headers (inherited from BaseResponse)
"""

@@ -238,3 +240,3 @@

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -247,2 +249,3 @@ ListResponse is the type that wraps the response for listing emails.

has_more (bool): Whether there are more emails available for pagination.
headers (NotRequired[Dict[str, str]]): HTTP response headers (inherited from BaseResponse)
"""

@@ -279,3 +282,3 @@

path = "/emails"
resp = request.Request[Email](
resp = request.Request[Emails.SendResponse](
path=path,

@@ -282,0 +285,0 @@ params=cast(Dict[Any, Any], params),

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

from resend import request
from resend._base_response import BaseResponse
from resend.emails._received_email import (EmailAttachment,

@@ -28,3 +29,3 @@ EmailAttachmentDetails,

class _ListResponse(TypedDict):
class _ListResponse(BaseResponse):
object: str

@@ -59,3 +60,3 @@ """

class _AttachmentListResponse(TypedDict):
class _AttachmentListResponse(BaseResponse):
object: str

@@ -62,0 +63,0 @@ """

@@ -7,3 +7,3 @@ """Resend Exceptions module.

from typing import Any, Dict, NoReturn, Union
from typing import Any, Dict, NoReturn, Optional, Union

@@ -33,2 +33,3 @@

suggested_action: str,
headers: Optional[Dict[str, str]] = None,
):

@@ -40,2 +41,3 @@ Exception.__init__(self, message)

self.error_type = error_type
self.headers = headers or {}

@@ -51,2 +53,3 @@

code: Union[str, int],
headers: Optional[Dict[str, str]] = None,
):

@@ -64,2 +67,3 @@ suggested_action = """Include the following header

error_type=error_type,
headers=headers,
)

@@ -76,2 +80,3 @@

code: Union[str, int],
headers: Optional[Dict[str, str]] = None,
):

@@ -86,2 +91,3 @@ suggested_action = """Generate a new API key in the dashboard."""

error_type=error_type,
headers=headers,
)

@@ -98,2 +104,3 @@

code: Union[str, int],
headers: Optional[Dict[str, str]] = None,
):

@@ -115,2 +122,3 @@ default_message = """

error_type=error_type,
headers=headers,
)

@@ -127,2 +135,3 @@

code: Union[str, int],
headers: Optional[Dict[str, str]] = None,
):

@@ -144,2 +153,3 @@ default_message = """

error_type=error_type,
headers=headers,
)

@@ -156,2 +166,3 @@

code: Union[str, int],
headers: Optional[Dict[str, str]] = None,
):

@@ -172,2 +183,3 @@ default_message = """

error_type=error_type,
headers=headers,
)

@@ -184,2 +196,3 @@

code: Union[str, int],
headers: Optional[Dict[str, str]] = None,
):

@@ -195,2 +208,3 @@ suggested_action = """Reduce your request rate or wait before retrying. """

error_type=error_type,
headers=headers,
)

@@ -218,3 +232,6 @@

def raise_for_code_and_type(
code: Union[str, int], error_type: str, message: str
code: Union[str, int],
error_type: str,
message: str,
headers: Optional[Dict[str, str]] = None,
) -> NoReturn:

@@ -227,2 +244,3 @@ """Raise the appropriate error based on the code and type.

message (str): The error message
headers (Optional[Dict[str, str]]): The HTTP response headers

@@ -251,3 +269,7 @@ Raises:

raise ResendError(
code=code, message=message, error_type=error_type, suggested_action=""
code=code,
message=message,
error_type=error_type,
suggested_action="",
headers=headers,
)

@@ -263,6 +285,11 @@

error_type=error_type,
headers=headers,
)
# defaults to ResendError if finally can't find error type
raise ResendError(
code=code, message=message, error_type=error_type, suggested_action=""
code=code,
message=message,
error_type=error_type,
suggested_action="",
headers=headers,
)

@@ -269,0 +296,0 @@

@@ -31,2 +31,3 @@ import json

self.options = options
self._response_headers: Dict[str, str] = {}

@@ -41,2 +42,3 @@ def perform(self) -> Union[T, None]:

error_type=data.get("name", "InternalServerError"),
headers=self._response_headers,
)

@@ -98,2 +100,5 @@

# Store response headers for later access
self._response_headers = dict(resp_headers)
content_type = {k.lower(): v for k, v in resp_headers.items()}.get(

@@ -108,6 +113,12 @@ "content-type", ""

error_type="InternalServerError",
headers=self._response_headers,
)
try:
return cast(Union[Dict[str, Any], List[Any]], json.loads(content))
parsed_data = cast(Union[Dict[str, Any], List[Any]], json.loads(content))
# Inject headers into dict responses
if isinstance(parsed_data, dict):
parsed_data["headers"] = dict(self._response_headers)
# For list responses, return as-is (lists can't have headers key)
return parsed_data
except json.JSONDecodeError:

@@ -118,2 +129,3 @@ raise_for_code_and_type(

error_type="InternalServerError",
headers=self._response_headers,
)

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

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -14,3 +15,3 @@

class RemoveSegmentResponse(TypedDict):
class RemoveSegmentResponse(BaseResponse):
"""

@@ -56,3 +57,3 @@ RemoveSegmentResponse is the type that wraps the response of the segment that was removed

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -80,3 +81,3 @@ ListResponse type that wraps a list of segment objects with pagination metadata

class CreateSegmentResponse(TypedDict):
class CreateSegmentResponse(BaseResponse):
"""

@@ -83,0 +84,0 @@ CreateSegmentResponse is the type that wraps the response of the segment that was created

@@ -8,2 +8,3 @@ """Templates API operations."""

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -72,3 +73,3 @@

class CreateResponse(TypedDict):
class CreateResponse(BaseResponse):
"""Response from creating a template.

@@ -126,3 +127,3 @@

class UpdateResponse(TypedDict):
class UpdateResponse(BaseResponse):
"""Response from updating a template.

@@ -159,3 +160,3 @@

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""Response from listing templates.

@@ -178,3 +179,3 @@

class PublishResponse(TypedDict):
class PublishResponse(BaseResponse):
"""Response from publishing a template.

@@ -193,3 +194,3 @@

class DuplicateResponse(TypedDict):
class DuplicateResponse(BaseResponse):
"""Response from duplicating a template.

@@ -208,3 +209,3 @@

class RemoveResponse(TypedDict):
class RemoveResponse(BaseResponse):
"""Response from removing a template.

@@ -211,0 +212,0 @@

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

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -14,3 +15,3 @@

class CreateTopicResponse(TypedDict):
class CreateTopicResponse(BaseResponse):
"""

@@ -43,3 +44,3 @@ CreateTopicResponse is the type that wraps the response of the topic that was created

class UpdateTopicResponse(TypedDict):
class UpdateTopicResponse(BaseResponse):
"""

@@ -67,3 +68,3 @@ UpdateTopicResponse is the type that wraps the response of the topic that was updated

class RemoveTopicResponse(TypedDict):
class RemoveTopicResponse(BaseResponse):
"""

@@ -109,3 +110,3 @@ RemoveTopicResponse is the type that wraps the response of the topic that was removed

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -112,0 +113,0 @@ ListResponse type that wraps a list of topic objects with pagination metadata

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

__version__ = "2.22.0"
__version__ = "2.23.0"

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

@@ -10,2 +10,3 @@ import base64

from resend import request
from resend._base_response import BaseResponse
from resend.pagination_helper import PaginationHelper

@@ -39,3 +40,3 @@ from resend.webhooks._webhook import (VerifyWebhookOptions, Webhook,

class ListResponse(TypedDict):
class ListResponse(BaseResponse):
"""

@@ -63,3 +64,3 @@ ListResponse type that wraps a list of webhook objects with pagination metadata

class CreateWebhookResponse(TypedDict):
class CreateWebhookResponse(BaseResponse):
"""

@@ -116,3 +117,3 @@ CreateWebhookResponse is the type that wraps the response of the webhook that was created

class UpdateWebhookResponse(TypedDict):
class UpdateWebhookResponse(BaseResponse):
"""

@@ -135,3 +136,3 @@ UpdateWebhookResponse is the type that wraps the response of the webhook that was updated

class DeleteWebhookResponse(TypedDict):
class DeleteWebhookResponse(BaseResponse):
"""

@@ -138,0 +139,0 @@ DeleteWebhookResponse is the type that wraps the response of the webhook that was deleted