Skip to content

Commit

Permalink
feat: support for domain TLS option (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
drish committed Jun 10, 2024
1 parent 1367cfd commit b93986c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions examples/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
print(domain)

retrieved: resend.Domain = resend.Domains.get(domain_id=domain["id"])
print(retrieved)

if retrieved["records"] is not None:
for record in retrieved["records"]:
print(record)
Expand All @@ -25,6 +23,7 @@
"id": domain["id"],
"open_tracking": True,
"click_tracking": True,
"tls": "enforced",
}

updated_domain: resend.Domain = resend.Domains.update(update_params)
Expand Down
15 changes: 14 additions & 1 deletion resend/domains/_domains.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import Any, Dict, List, cast

from typing_extensions import NotRequired, TypedDict
from typing_extensions import Literal, NotRequired, TypedDict

from resend import request
from resend.domains._domain import Domain

TlsOptions = Literal["enforced", "opportunistic"]


class _ListResponse(TypedDict):
data: List[Domain]
Expand Down Expand Up @@ -36,6 +38,17 @@ class UpdateParams(TypedDict):
"""
Track the open rate of each email.
"""
tls: NotRequired[TlsOptions]
"""
default: "opportunistic"
opportunistic: Opportunistic TLS means that it always attempts to make a
secure connection to the receiving mail server.
If it can't establish a secure connection, it sends the message unencrypted.
enforced: Enforced TLS on the other hand, requires that the email
communication must use TLS no matter what.
If the receiving server does not support TLS, the email will not be sent.
"""

class CreateParams(TypedDict):
name: str
Expand Down
2 changes: 1 addition & 1 deletion resend/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0.0"
__version__ = "2.1.0"


def get_version() -> str:
Expand Down
1 change: 1 addition & 0 deletions tests/domains_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def test_domains_update(self) -> None:
"id": "479e3145-dd38-476b-932c-529ceb705947",
"open_tracking": True,
"click_tracking": True,
"tls": "opportunistic",
}
domain = resend.Domains.update(params)
assert domain["id"] == "479e3145-dd38-476b-932c-529ceb705947"
Expand Down

0 comments on commit b93986c

Please sign in to comment.