Skip to content

Commit 6a60b28

Browse files
authored
fix: use Contacts.Imports nested class for consistent type namespacing (#223)
1 parent 7519910 commit 6a60b28

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

examples/contact_imports.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
with open(csv_path, "rb") as f:
1212
file_content = f.read().replace(b"steve@example.com,Steve,Wozniak", f"steve+{ts}@example.com,Steve,Wozniak".encode())
1313

14-
create_params: resend.ContactImports.CreateParams = {
14+
create_params: resend.Contacts.Imports.CreateParams = {
1515
"file": file_content,
1616
"column_map": {
1717
"email": "Email",
@@ -34,7 +34,7 @@
3434
],
3535
}
3636

37-
import_response: resend.ContactImports.CreateContactImportResponse = (
37+
import_response: resend.Contacts.Imports.CreateContactImportResponse = (
3838
resend.Contacts.Imports.create(create_params)
3939
)
4040
print("Created contact import with ID: {}".format(import_response["id"]))
@@ -44,7 +44,7 @@
4444
print("Retrieved contact import")
4545
print(contact_import)
4646

47-
list_response: resend.ContactImports.ListContactImportsResponse = (
47+
list_response: resend.Contacts.Imports.ListContactImportsResponse = (
4848
resend.Contacts.Imports.list()
4949
)
5050
print(f"Found {len(list_response['data'])} imports")

resend/contacts/_contacts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class Contacts:
2222
# Sub-API for managing contact-segment associations
2323
Segments = ContactSegments
2424
Topics = Topics
25-
Imports = ContactImports
25+
26+
class Imports(ContactImports):
27+
pass
2628

2729
class RemoveContactResponse(BaseResponse):
2830
"""

resend/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.32.1"
1+
__version__ = "2.32.2"
22

33

44
def get_version() -> str:

tests/contact_imports_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ def test_create_contact_import(self) -> None:
1010
{"object": "contact_import", "id": "479e3145-dd38-476b-932c-529ceb705947"}
1111
)
1212

13-
params: resend.ContactImports.CreateParams = {
13+
params: resend.Contacts.Imports.CreateParams = {
1414
"file": b"email,first_name\nsteve@example.com,Steve",
1515
}
16-
resp: resend.ContactImports.CreateContactImportResponse = resend.Contacts.Imports.create(params)
16+
resp: resend.Contacts.Imports.CreateContactImportResponse = resend.Contacts.Imports.create(params)
1717
assert resp["id"] == "479e3145-dd38-476b-932c-529ceb705947"
1818
assert resp["object"] == "contact_import"
1919

@@ -22,7 +22,7 @@ def test_create_contact_import_with_options(self) -> None:
2222
{"object": "contact_import", "id": "479e3145-dd38-476b-932c-529ceb705947"}
2323
)
2424

25-
params: resend.ContactImports.CreateParams = {
25+
params: resend.Contacts.Imports.CreateParams = {
2626
"file": b"email,first_name\nsteve@example.com,Steve",
2727
"filename": "contacts.csv",
2828
"on_conflict": "upsert",
@@ -84,7 +84,7 @@ def test_list_contact_imports(self) -> None:
8484
}
8585
)
8686

87-
result: resend.ContactImports.ListContactImportsResponse = resend.Contacts.Imports.list()
87+
result: resend.Contacts.Imports.ListContactImportsResponse = resend.Contacts.Imports.list()
8888
assert result["object"] == "list"
8989
assert result["has_more"] is False
9090
assert len(result["data"]) == 1

0 commit comments

Comments
 (0)