resend

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package resend provides utilities for processing incoming requests from resend.com over webhook.

https://resend.com/docs/dashboard/webhooks/event-types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Click

type Click struct {
	IPAddress string `json:"ipAddress,omitempty"`
	Link      string `json:"link,omitempty"`
	Timestamp string `json:"timestamp,omitempty"`
	UserAgent string `json:"userAgent,omitempty"`
}

Click struct

type Data

type Data struct {
	// for email events
	CreatedAt string   `json:"created_at,omitempty"`
	EmailID   string   `json:"email_id,omitempty"`
	From      string   `json:"from,omitempty"`
	To        []string `json:"to,omitempty"`
	Click     *Click   `json:"click,omitempty"`
	Subject   string   `json:"subject,omitempty"`

	// for contact events
	ID           string `json:"id,omitempty"`
	AudienceID   string `json:"audience_id,omitempty"`
	UpdatedAt    string `json:"updated_at,omitempty"`
	Email        string `json:"email,omitempty"`
	FirstName    string `json:"first_name,omitempty"`
	LastName     string `json:"last_name,omitempty"`
	Unsubscribed bool   `json:"unsubscribed,omitempty"`
}

Data struct

type EventType

type EventType string

EventType represents the type of event

const (
	EmailSent            EventType = "email.sent"
	EmailDelivered       EventType = "email.delivered"
	EmailDeliveryDelayed EventType = "email.delivery_delayed"
	EmailComplained      EventType = "email.complained"
	EmailBounced         EventType = "email.bounced"
	EmailOpened          EventType = "email.opened"
	EmailClicked         EventType = "email.clicked"
	ContactCreated       EventType = "contact.created"
	ContactUpdated       EventType = "contact.updated"
	ContactDeleted       EventType = "contact.deleted"
)

all event types - email.sent - email.delivered - email.delivery_delayed - email.complained - email.bounced - email.opened - email.clicked - contact.created - contact.updated - contact.deleted

type Payload

type Payload struct {
	Type      EventType `json:"type"`
	CreatedAt string    `json:"created_at"`
	Data      Data      `json:"data"`
}

Payload struct to process the incoming request over webhook

func HandleRequest

func HandleRequest(r *http.Request, wh *svix.Webhook) (payload Payload, err error)

HandleRequest validates the incoming payload against the svix signature headers using the webhook signing secret and binds the raw data to a payload struct.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL