Skip to content

Commit

Permalink
DE-1348 Missing webhook events (#339)
Browse files Browse the repository at this point in the history
fixes #337
  • Loading branch information
vtopc authored Nov 9, 2024
1 parent 78f9df9 commit b74d48f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Mailgun with Go

[![GoDoc](https://godoc.org/github.com/mailgun/mailgun-go?status.svg)](https://godoc.org/github.com/mailgun/mailgun-go/v4)
[![Build Status](https://github.com/mailgun/mailgun-go/workflows/CI/badge.svg)](https://github.com/mailgun/mailgun-go/actions/workflows/main.yml)
[![Build Status](https://github.com/mailgun/mailgun-go/workflows/CI/badge.svg)](https://github.com/mailgun/mailgun-go/actions/workflows/main.yml?query=branch%3Amaster)

Go library for interacting with the [Mailgun](https://mailgun.com/) [API](https://documentation.mailgun.com/en/latest/api_reference.html).

Expand Down
14 changes: 11 additions & 3 deletions events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ type Delivered struct {
UserVariables interface{} `json:"user-variables"`
}

// Failed - Mailgun could not deliver the email to the recipient email server.
// Use for permanent_fail and temporary_fail webhooks.
type Failed struct {
Generic

Expand All @@ -114,9 +116,15 @@ type Failed struct {
Storage Storage `json:"storage"`

DeliveryStatus DeliveryStatus `json:"delivery-status"`
Severity string `json:"severity"`
Reason string `json:"reason"`
UserVariables interface{} `json:"user-variables"`

// Severity:
//
// - permanent when a message is not delivered;
//
// - temporary when a message is temporarily rejected by an ESP.
Severity string `json:"severity"`
Reason string `json:"reason"`
UserVariables interface{} `json:"user-variables"`
}

type Stored struct {
Expand Down
5 changes: 3 additions & 2 deletions webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ func (mg *MailgunImpl) ListWebhooks(ctx context.Context) (map[string][]string, e
}

// CreateWebhook installs a new webhook for your domain.
func (mg *MailgunImpl) CreateWebhook(ctx context.Context, kind string, urls []string) error {
// List of ids - https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Webhooks/#tag/Webhooks
func (mg *MailgunImpl) CreateWebhook(ctx context.Context, id string, urls []string) error {
r := newHTTPRequest(generateDomainApiUrl(mg, webhooksEndpoint))
r.setClient(mg.Client())
r.setBasicAuth(basicAuthUser, mg.APIKey())
p := newUrlEncodedPayload()
p.addValue("id", kind)
p.addValue("id", id)
for _, url := range urls {
p.addValue("url", url)
}
Expand Down

0 comments on commit b74d48f

Please sign in to comment.