Skip to content

Commit

Permalink
feat: Use enum style TLS config (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
drish authored Jun 11, 2024
1 parent a0d2854 commit 65a0cd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
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

0 comments on commit 65a0cd6

Please sign in to comment.