77from ._contact import Contact
88
99
10- class _ListResponse (TypedDict ):
11- data : List [Contact ]
12- """
13- A list of contact objects
14- """
15-
16-
1710class Contacts :
1811
19- class ListResponse (_ListResponse ):
12+ class ListResponse (TypedDict ):
2013 """
2114 ListResponse type that wraps a list of contact objects
2215
2316 Attributes:
2417 data (List[Contact]): A list of contact objects
2518 """
2619
20+ data : List [Contact ]
21+ """
22+ A list of contact objects
23+ """
24+
25+ class CreateContactResponse (TypedDict ):
26+ """
27+ CreateContactResponse is the type that wraps the response of the contact that was created
28+
29+ Attributes:
30+ object (str): The ID of the created contact
31+ id (str): The ID of the created contact
32+ """
33+
34+ object : str
35+ """
36+ The object type: email
37+ """
38+ id : str
39+ """
40+ The ID of the scheduled email that was canceled.
41+ """
42+
43+ class UpdateContactResponse (TypedDict ):
44+ """
45+ UpdateContactResponse is the type that wraps the response of the contact that was updated
46+
47+ Attributes:
48+ object (str): The ID of the updated contact
49+ id (str): The ID of the updated contact
50+ """
51+
52+ object : str
53+ """
54+ The object type: email
55+ """
56+ id : str
57+ """
58+ The ID of the updated contact.
59+ """
60+
2761 class CreateParams (TypedDict ):
2862 audience_id : str
2963 """
@@ -73,7 +107,7 @@ class UpdateParams(TypedDict):
73107 """
74108
75109 @classmethod
76- def create (cls , params : CreateParams ) -> Contact :
110+ def create (cls , params : CreateParams ) -> CreateContactResponse :
77111 """
78112 Create a new contact.
79113 see more: https://resend.com/docs/api-reference/contacts/create-contact
@@ -82,16 +116,17 @@ def create(cls, params: CreateParams) -> Contact:
82116 params (CreateParams): The contact creation parameters
83117
84118 Returns:
85- Contact : The new contact object
119+ CreateContactResponse : The created contact response
86120 """
121+
87122 path = f"/audiences/{ params ['audience_id' ]} /contacts"
88- resp = request .Request [Contact ](
123+ resp = request .Request [Contacts . CreateContactResponse ](
89124 path = path , params = cast (Dict [Any , Any ], params ), verb = "post"
90125 ).perform_with_content ()
91126 return resp
92127
93128 @classmethod
94- def update (cls , params : UpdateParams ) -> Contact :
129+ def update (cls , params : UpdateParams ) -> UpdateContactResponse :
95130 """
96131 Update an existing contact.
97132 see more: https://resend.com/docs/api-reference/contacts/update-contact
@@ -100,15 +135,15 @@ def update(cls, params: UpdateParams) -> Contact:
100135 params (UpdateParams): The contact update parameters
101136
102137 Returns:
103- Contact : The updated contact object
138+ UpdateContactResponse : The updated contact response.
104139 """
105140 if params .get ("id" ) is None and params .get ("email" ) is None :
106141 raise ValueError ("id or email must be provided" )
107142
108143 val = params .get ("id" ) if params .get ("id" ) is not None else params .get ("email" )
109144
110145 path = f"/audiences/{ params ['audience_id' ]} /contacts/{ val } "
111- resp = request .Request [Contact ](
146+ resp = request .Request [Contacts . UpdateContactResponse ](
112147 path = path , params = cast (Dict [Any , Any ], params ), verb = "patch"
113148 ).perform_with_content ()
114149 return resp
@@ -126,7 +161,7 @@ def list(cls, audience_id: str) -> ListResponse:
126161 ListResponse: A list of contact objects
127162 """
128163 path = f"/audiences/{ audience_id } /contacts"
129- resp = request .Request [_ListResponse ](
164+ resp = request .Request [Contacts . ListResponse ](
130165 path = path , params = {}, verb = "get"
131166 ).perform_with_content ()
132167 return resp
0 commit comments