@@ -180,6 +180,91 @@ def test_should_verify_domains_raise_exception_when_no_content(self) -> None:
180180 domain_id = "d91cd9bd-1176-453e-8fc1-35364d380206" ,
181181 )
182182
183+ def test_domains_create_with_tracking_subdomain (self ) -> None :
184+ self .set_mock_json (
185+ {
186+ "id" : "4dd369bc-aa82-4ff3-97de-514ae3000ee0" ,
187+ "name" : "example.com" ,
188+ "created_at" : "2023-03-28T17:12:02.059593+00:00" ,
189+ "status" : "not_started" ,
190+ "open_tracking" : True ,
191+ "click_tracking" : True ,
192+ "tracking_subdomain" : "links" ,
193+ "records" : [
194+ {
195+ "record" : "DKIM" ,
196+ "name" : "nhapbbryle57yxg3fbjytyodgbt2kyyg._domainkey" ,
197+ "value" : "nhapbbryle57yxg3fbjytyodgbt2kyyg.dkim.amazonses.com." ,
198+ "type" : "CNAME" ,
199+ "status" : "not_started" ,
200+ "ttl" : "Auto" ,
201+ },
202+ {
203+ "record" : "Tracking" ,
204+ "name" : "links.example.com" ,
205+ "value" : "links1.resend-dns.com" ,
206+ "type" : "CNAME" ,
207+ "ttl" : "Auto" ,
208+ "status" : "not_started" ,
209+ },
210+ ],
211+ "region" : "us-east-1" ,
212+ }
213+ )
214+
215+ create_params : resend .Domains .CreateParams = {
216+ "name" : "example.com" ,
217+ "region" : "us-east-1" ,
218+ "tracking_subdomain" : "links" ,
219+ }
220+ domain : resend .Domains .CreateDomainResponse = resend .Domains .create (
221+ params = create_params
222+ )
223+ assert domain ["id" ] == "4dd369bc-aa82-4ff3-97de-514ae3000ee0"
224+ assert domain ["open_tracking" ] is True
225+ assert domain ["click_tracking" ] is True
226+ assert domain ["tracking_subdomain" ] == "links"
227+ tracking_record = next (
228+ (r for r in (domain ["records" ] or []) if r ["record" ] == "Tracking" ), None
229+ )
230+ assert tracking_record is not None
231+ assert tracking_record ["name" ] == "links.example.com"
232+ assert tracking_record ["value" ] == "links1.resend-dns.com"
233+ assert tracking_record ["type" ] == "CNAME"
234+
235+ def test_domains_get_with_tracking_fields (self ) -> None :
236+ self .set_mock_json (
237+ {
238+ "object" : "domain" ,
239+ "id" : "d91cd9bd-1176-453e-8fc1-35364d380206" ,
240+ "name" : "example.com" ,
241+ "status" : "not_started" ,
242+ "created_at" : "2023-04-26T20:21:26.347412+00:00" ,
243+ "region" : "us-east-1" ,
244+ "open_tracking" : True ,
245+ "click_tracking" : True ,
246+ "tracking_subdomain" : "links" ,
247+ "records" : [
248+ {
249+ "record" : "Tracking" ,
250+ "name" : "links.example.com" ,
251+ "value" : "links1.resend-dns.com" ,
252+ "type" : "CNAME" ,
253+ "ttl" : "Auto" ,
254+ "status" : "verified" ,
255+ }
256+ ],
257+ }
258+ )
259+
260+ domain = resend .Domains .get (
261+ domain_id = "d91cd9bd-1176-453e-8fc1-35364d380206" ,
262+ )
263+ assert domain ["id" ] == "d91cd9bd-1176-453e-8fc1-35364d380206"
264+ assert domain ["open_tracking" ] is True
265+ assert domain ["click_tracking" ] is True
266+ assert domain ["tracking_subdomain" ] == "links"
267+
183268 def test_domains_update (self ) -> None :
184269 self .set_mock_json (
185270 {
@@ -197,6 +282,21 @@ def test_domains_update(self) -> None:
197282 domain = resend .Domains .update (params )
198283 assert domain ["id" ] == "479e3145-dd38-476b-932c-529ceb705947"
199284
285+ def test_domains_update_with_tracking_subdomain (self ) -> None :
286+ self .set_mock_json (
287+ {
288+ "object" : "domain" ,
289+ "id" : "479e3145-dd38-476b-932c-529ceb705947" ,
290+ }
291+ )
292+
293+ params : resend .Domains .UpdateParams = {
294+ "id" : "479e3145-dd38-476b-932c-529ceb705947" ,
295+ "tracking_subdomain" : "links" ,
296+ }
297+ domain = resend .Domains .update (params )
298+ assert domain ["id" ] == "479e3145-dd38-476b-932c-529ceb705947"
299+
200300 def test_should_update_domains_raise_exception_when_no_content (self ) -> None :
201301 self .set_mock_json (None )
202302 params : resend .Domains .UpdateParams = {
0 commit comments