resend / resend-python

resend's python sdk
MIT License
59 stars 6 forks source link

Email response a bit misleading #105

Open tim-hub opened 1 month ago

tim-hub commented 1 month ago

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. https://github.com/resend/resend-python/blob/752fe35b8ae61f033f1f4aab92ae8ab67acf10ed/resend/emails/_batch.py#L11

https://github.com/resend/resend-python/blob/752fe35b8ae61f033f1f4aab92ae8ab67acf10ed/resend/emails/_batch.py#L20-L25

https://github.com/resend/resend-python/blob/752fe35b8ae61f033f1f4aab92ae8ab67acf10ed/resend/emails/_email.py#L57-L65

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 commented 1 month ago

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

What do you think @drish?

drish commented 1 month ago

@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