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

DE-1348 Missing webhook events #339

Merged
merged 4 commits into from
Nov 9, 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
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