provider

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package provider defines the email-transport boundary used by application services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	VerifyWebhook([]byte, WebhookHeaders) error
	GetReceived(context.Context, string) (ReceivedEmail, error)
	GetReceivedAttachment(context.Context, string, string) (ReceivedAttachment, error)
	Download(context.Context, string) (io.ReadCloser, int64, error)
	Send(context.Context, SendRequest) (string, error)
}

Client isolates Resend SDK models from the mailbox domain.

type Error

type Error struct {
	Kind      string
	Message   string
	Temporary bool
	Cause     error
}

Error classifies provider failures for retry behavior and safe UI messages.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type OutboundAttachment

type OutboundAttachment struct {
	Filename    string
	ContentType string
	ContentID   string
	Content     []byte
}

OutboundAttachment is bounded content prepared for a provider SDK.

type ReceivedAttachment

type ReceivedAttachment struct {
	ID                 string
	Filename           string
	ContentType        string
	ContentDisposition string
	ContentID          string
	DownloadURL        string
	Size               int64
}

ReceivedAttachment is inbound attachment metadata plus a temporary URL.

type ReceivedEmail

type ReceivedEmail struct {
	ID          string
	To          []string
	From        string
	CreatedAt   time.Time
	Subject     string
	HTML        string
	Text        string
	BCC         []string
	CC          []string
	ReplyTo     []string
	Headers     map[string]string
	MessageID   string
	RawURL      string
	Attachments []ReceivedAttachment
}

ReceivedEmail is a provider-neutral retrieved inbound message.

type Resend

type Resend struct {
	// contains filtered or unexported fields
}

Resend implements Client using the official Go SDK and bounded HTTP downloads.

func NewResend

func NewResend(apiKey, webhookSecret string) *Resend

NewResend creates a long-lived Resend adapter.

func NewResendForTest

func NewResendForTest(apiKey, webhookSecret string, httpClient *http.Client, baseURL *url.URL) *Resend

NewResendForTest creates an adapter with an injectable API endpoint and HTTP client.

func (*Resend) Download

func (r *Resend) Download(ctx context.Context, rawURL string) (io.ReadCloser, int64, error)

Download opens a temporary provider URL for streaming into private storage.

func (*Resend) GetReceived

func (r *Resend) GetReceived(ctx context.Context, id string) (ReceivedEmail, error)

GetReceived retrieves normalized content and attachment metadata.

func (*Resend) GetReceivedAttachment

func (r *Resend) GetReceivedAttachment(ctx context.Context, emailID, attachmentID string) (ReceivedAttachment, error)

GetReceivedAttachment refreshes the provider's temporary attachment URL.

func (*Resend) Send

func (r *Resend) Send(ctx context.Context, request SendRequest) (string, error)

Send submits a bounded outbound message with a stable idempotency key.

func (*Resend) UpdateCredentials added in v0.3.1

func (r *Resend) UpdateCredentials(apiKey, webhookSecret string)

UpdateCredentials replaces provider credentials for subsequent requests.

func (*Resend) VerifyWebhook

func (r *Resend) VerifyWebhook(raw []byte, headers WebhookHeaders) error

VerifyWebhook delegates raw-body signature verification to the official SDK.

type SendRequest

type SendRequest struct {
	From           model.Address
	To             []model.Address
	CC             []model.Address
	BCC            []model.Address
	Subject        string
	Text           string
	Headers        map[string]string
	Attachments    []OutboundAttachment
	IdempotencyKey string
}

SendRequest is one logical provider submission.

type WebhookHeaders

type WebhookHeaders struct {
	ID        string
	Timestamp string
	Signature string
}

WebhookHeaders contains the three Svix signature headers.

Jump to

Keyboard shortcuts

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