Skip to content

Commit

Permalink
Merge pull request #242 from khanhhongpham/master
Browse files Browse the repository at this point in the history
Add UpdateDomainDkimSelector
  • Loading branch information
thrawn01 authored Jan 19, 2021
2 parents 980ea19 + 502b086 commit 9c39a97
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,18 @@ func (mg *MailgunImpl) UpdateOpenTracking(ctx context.Context, domain, active st
return err
}

// Update the DKIM selector for a domain
func (mg *MailgunImpl) UpdateDomainDkimSelector(ctx context.Context, domain string, dkim_selector string) error {
r := newHTTPRequest(generatePublicApiUrl(mg, domainsEndpoint) + "/" + domain + "/dkim_selector")
r.setClient(mg.Client())
r.setBasicAuth(basicAuthUser, mg.APIKey())

payload := newUrlEncodedPayload()
payload.addValue("dkim_selector", dkim_selector)
_, err := makePutRequest(ctx, r, payload)
return err
}

func boolToString(b bool) string {
if b {
return "true"
Expand Down
10 changes: 10 additions & 0 deletions domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,13 @@ func TestDomainVerify(t *testing.T) {
_, err := mg.VerifyDomain(ctx, testDomain)
ensure.Nil(t, err)
}

func TestDomainDkimSelector(t *testing.T) {
mg := mailgun.NewMailgun(testDomain, testKey)
mg.SetAPIBase(server.URL())
ctx := context.Background()

// Update Domain DKIM selector
err := mg.UpdateDomainDkimSelector(ctx, testDomain, "gotest")
ensure.Nil(t, err)
}

0 comments on commit 9c39a97

Please sign in to comment.