1- from typing import Any , Dict , List , cast
1+ from typing import Any , Dict , List , Optional , cast
22
33from typing_extensions import NotRequired , TypedDict
44
@@ -132,26 +132,35 @@ def list(cls, audience_id: str) -> ListResponse:
132132 return resp
133133
134134 @classmethod
135- def get (cls , id : str , audience_id : str ) -> Contact :
135+ def get (
136+ cls , audience_id : str , id : Optional [str ] = None , email : Optional [str ] = None
137+ ) -> Contact :
136138 """
137139 Get a contact.
138140 see more: https://resend.com/docs/api-reference/contacts/get-contact
139141
140142 Args:
141143 id (str): The contact ID
142144 audience_id (str): The audience ID
145+ email (Optional[str]): The contact email
143146
144147 Returns:
145148 Contact: The contact object
146149 """
147- path = f"/audiences/{ audience_id } /contacts/{ id } "
150+ contact = email if id is None else id
151+ if contact is None :
152+ raise ValueError ("id or email must be provided" )
153+
154+ path = f"/audiences/{ audience_id } /contacts/{ contact } "
148155 resp = request .Request [Contact ](
149156 path = path , params = {}, verb = "get"
150157 ).perform_with_content ()
151158 return resp
152159
153160 @classmethod
154- def remove (cls , audience_id : str , id : str = "" , email : str = "" ) -> Contact :
161+ def remove (
162+ cls , audience_id : str , id : Optional [str ] = None , email : Optional [str ] = None
163+ ) -> Contact :
155164 """
156165 Remove a contact by ID or by Email
157166 see more: https://resend.com/docs/api-reference/contacts/delete-contact
@@ -164,8 +173,8 @@ def remove(cls, audience_id: str, id: str = "", email: str = "") -> Contact:
164173 Returns:
165174 Contact: The removed contact object
166175 """
167- contact = email if id == "" else id
168- if contact == "" :
176+ contact = email if id is None else id
177+ if contact is None :
169178 raise ValueError ("id or email must be provided" )
170179 path = f"/audiences/{ audience_id } /contacts/{ contact } "
171180
0 commit comments