Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email response a bit misleading #105

Open
tim-hub opened this issue May 27, 2024 · 2 comments
Open

Email response a bit misleading #105

tim-hub opened this issue May 27, 2024 · 2 comments

Comments

@tim-hub
Copy link

tim-hub commented May 27, 2024

I am not sure whether it is a future plan to change the email send respons type, however, the python sdk response type and the real RESTful api response type is a bit misleading.

At batch send response.

class _SendResponse(TypedDict):

class SendResponse(_SendResponse):
"""
SendResponse type that wraps a list of email objects
Attributes:
data (List[Email]): A list of email objects

class Email(_EmailDefaultAttrs):
"""
Email type that wraps the email object
Attributes:
id (str): The Email ID.
from (str): The email address the email was sent from.
to (Union[List[str], str]): List of email addresses to send the email to.
created_at (str): When the email was created.

It is useding List[Email] as response, however, that is not the real structure of what the response is.

The real response has id only

{
  "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794"
}

https://resend.com/docs/api-reference/emails/send-email


Suggestion:

Created a different response type class like

class Response:
    id: str
@pedroimpulcetto
Copy link
Contributor

Hum, good catch, I agree, we can improve it and ensure we have the right types.

I'm working to include a Generics type hint to improve the Request class in this PR #107

  • maybe we can also make this improvement and create specific types for the responses

What do you think @drish?

@drish
Copy link
Collaborator

drish commented May 28, 2024

@tim-hub yeah I think returning the type Email for all methods ended up not being the best typing UI since the Email object will not be entirely populated depending on the response. Will update that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants