Skip to content

Commit c454c44

Browse files
committed
fix(Audiences): use RemoveAudienceResponse type on Audiences.remove
1 parent fab59f9 commit c454c44

4 files changed

Lines changed: 34 additions & 10 deletions

File tree

examples/audiences.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
audiences: resend.Audiences.ListResponse = resend.Audiences.list()
2323
print("List of audiences:", [a["id"] for a in audiences["data"]])
2424

25-
rmed: resend.Audience = resend.Audiences.remove(id=audience["id"])
26-
print(f"Deleted audience")
25+
rmed: resend.Audiences.RemoveAudienceResponse = resend.Audiences.remove(
26+
id=audience["id"]
27+
)
28+
print(f"Deleted audience with ID: {audience['id']}")
2729
print(rmed)

resend/audiences/_audience.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,3 @@ class Audience(TypedDict):
1414
"""
1515
The date and time the audience was created.
1616
"""
17-
deleted: bool
18-
"""
19-
Wether the audience was deleted. Only returned on the "remove" call
20-
"""

resend/audiences/_audiences.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
99

1010
class Audiences:
1111

12+
class RemoveAudienceResponse(TypedDict):
13+
"""
14+
RemoveAudienceResponse is the type that wraps the response of the audience that was removed
15+
16+
Attributes:
17+
object (str): The object type, "audience"
18+
id (str): The ID of the removed audience
19+
deleted (bool): Whether the audience was deleted
20+
"""
21+
22+
object: str
23+
"""
24+
The object type, "audience"
25+
"""
26+
id: str
27+
"""
28+
The ID of the removed audience
29+
"""
30+
deleted: bool
31+
"""
32+
Whether the audience was deleted
33+
"""
34+
1235
class ListResponse(TypedDict):
1336
"""
1437
ListResponse type that wraps a list of audience objects
@@ -105,7 +128,7 @@ def get(cls, id: str) -> Audience:
105128
return resp
106129

107130
@classmethod
108-
def remove(cls, id: str) -> Audience:
131+
def remove(cls, id: str) -> RemoveAudienceResponse:
109132
"""
110133
Delete a single audience.
111134
see more: https://resend.com/docs/api-reference/audiences/delete-audience
@@ -114,10 +137,10 @@ def remove(cls, id: str) -> Audience:
114137
id (str): The audience ID
115138
116139
Returns:
117-
Audience: The audience object
140+
RemoveAudienceResponse: The removed audience response
118141
"""
119142
path = f"/audiences/{id}"
120-
resp = request.Request[Audience](
143+
resp = request.Request[Audiences.RemoveAudienceResponse](
121144
path=path, params={}, verb="delete"
122145
).perform_with_content()
123146
return resp

tests/audiences_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def test_audiences_remove(self) -> None:
5959
}
6060
)
6161

62-
rmed = resend.Audiences.remove("78261eea-8f8b-4381-83c6-79fa7120f1cf")
62+
rmed: resend.Audiences.RemoveAudienceResponse = resend.Audiences.remove(
63+
"78261eea-8f8b-4381-83c6-79fa7120f1cf"
64+
)
65+
assert rmed["object"] == "audience"
6366
assert rmed["id"] == "78261eea-8f8b-4381-83c6-79fa7120f1cf"
6467
assert rmed["deleted"] is True
6568

0 commit comments

Comments
 (0)