Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use enum style TLS config #35

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import (
"net/http"
)

type TlsOption = string

const (
Enforced TlsOption = "enforced"
Opportunistic TlsOption = "opportunistic"
)

type DomainsSvc interface {
CreateWithContext(ctx context.Context, params *CreateDomainRequest) (CreateDomainResponse, error)
Create(params *CreateDomainRequest) (CreateDomainResponse, error)
Expand Down Expand Up @@ -46,9 +53,9 @@ type ListDomainsResponse struct {
}

type UpdateDomainRequest struct {
OpenTracking bool `json:"open_tracking,omitempty"`
ClickTracking bool `json:"click_tracking,omitempty"`
Tls string `json:"tls,omitempty"`
OpenTracking bool `json:"open_tracking,omitempty"`
ClickTracking bool `json:"click_tracking,omitempty"`
Tls TlsOption `json:"tls,omitempty"`
}

type Domain struct {
Expand Down
2 changes: 1 addition & 1 deletion domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func TestUpdateDomain(t *testing.T) {

params := &UpdateDomainRequest{
OpenTracking: true,
Tls: "opportunistic",
Tls: Opportunistic,
}
updated, err := client.Domains.Update("d91cd9bd-1176-453e-8fc1-35364d380206", params)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions examples/domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/resend/resend-go/v2"
)

func domainsExample() {
func domainExample() {
ctx := context.TODO()
apiKey := os.Getenv("RESEND_API_KEY")

Expand Down Expand Up @@ -40,7 +40,7 @@ func domainsExample() {
updateDomainParams := &resend.UpdateDomainRequest{
OpenTracking: true,
ClickTracking: true,
Tls: "opportunistic",
Tls: resend.Enforced,
}

updated, err := client.Domains.UpdateWithContext(ctx, domain.Id, updateDomainParams)
Expand Down
Loading