Documentation
¶
Overview ¶
Package sendtern calls the Sendtern transactional email API.
Index ¶
- type APIError
- type BatchResult
- type BatchValidationError
- type Client
- func (c *Client) Capture(ctx context.Context, message any, idempotencyKey string) (EmailID, error)
- func (c *Client) Download(ctx context.Context, path string) ([]byte, error)
- func (c *Client) Get(ctx context.Context, id string) (map[string]any, error)
- func (c *Client) GetEmail(ctx context.Context, id string) (Email, error)
- func (Client) GoString() string
- func (c *Client) List(ctx context.Context, options ListOptions) (EmailList, error)
- func (c *Client) Request(ctx context.Context, method, path string, body any, idempotencyKey string, ...) error
- func (c *Client) Send(ctx context.Context, message any, idempotencyKey string) (EmailID, error)
- func (c *Client) SendBatch(ctx context.Context, messages any, idempotencyKey string) (BatchResult, error)
- func (c *Client) SendBatchPermissive(ctx context.Context, messages any, idempotencyKey string) (PermissiveBatchResult, error)
- func (Client) String() string
- type Email
- type EmailEvent
- type EmailID
- type EmailList
- type EmailTag
- type ListOptions
- type PermissiveBatchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError describes an HTTP response outside the 2xx status range. RetryAfter preserves the original header value when one was supplied.
type BatchResult ¶
type BatchResult struct {
Data []EmailID `json:"data"`
}
BatchResult contains the IDs accepted by SendBatch.
type BatchValidationError ¶
BatchValidationError identifies a rejected message by its zero-based input index.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is safe for concurrent use. Create one with New and reuse it.
func New ¶
New creates a client for baseURL. An empty baseURL uses https://sendtern.com. Requests have a 10-second timeout and the client does not follow redirects.
func (*Client) Capture ¶
Capture stores a JSON-encodable message in Email Playground without sending it.
func (*Client) Download ¶ added in v0.3.0
Download returns the original bytes from a documented native binary endpoint.
func (Client) GoString ¶
GoString returns a description without client configuration or credentials.
func (*Client) Request ¶ added in v0.3.0
func (c *Client) Request(ctx context.Context, method, path string, body any, idempotencyKey string, result any) error
Request calls a documented native JSON endpoint and decodes into result. Pass nil for result to discard the response, including for HTTP 204.
func (*Client) Send ¶
Send submits a JSON-encodable message for asynchronous delivery. Pass the same idempotency key and payload for each retry of a logical email.
func (*Client) SendBatch ¶
func (c *Client) SendBatch(ctx context.Context, messages any, idempotencyKey string) (BatchResult, error)
SendBatch submits an array of 1 to 100 JSON-encodable messages in strict mode.
func (*Client) SendBatchPermissive ¶
func (c *Client) SendBatchPermissive(ctx context.Context, messages any, idempotencyKey string) (PermissiveBatchResult, error)
SendBatchPermissive submits 1 to 100 messages and reports individual validation failures. If all messages are invalid or the request fails, it returns an API error.
type Email ¶
type Email struct {
Object string `json:"object"`
ID string `json:"id"`
From string `json:"from"`
To []string `json:"to"`
CC []string `json:"cc"`
BCC []string `json:"bcc"`
ReplyTo []string `json:"reply_to"`
Subject string `json:"subject"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastEvent string `json:"last_event"`
Mode string `json:"mode"`
Tags []EmailTag `json:"tags"`
Text *string `json:"text"`
HTML *string `json:"html"`
Error *string `json:"error"`
Events []EmailEvent `json:"events"`
}
Email is the email and delivery timeline returned by GetEmail.
type EmailEvent ¶
type EmailEvent struct {
Kind string `json:"kind"`
CreatedAt time.Time `json:"created_at"`
Detail *string `json:"detail"`
}
EmailEvent represents a delivery event in the email timeline.
type EmailID ¶
type EmailID struct {
ID string `json:"id"`
}
EmailID identifies an accepted email or Email Playground capture.
type EmailList ¶ added in v0.3.0
type EmailList struct {
Object string `json:"object"`
Data []Email `json:"data"`
HasMore bool `json:"has_more"`
}
EmailList is a page of email summaries. Detail fields are available from GetEmail.
type ListOptions ¶ added in v0.3.0
ListOptions specifies filters for List. Zero values use the server defaults.
type PermissiveBatchResult ¶
type PermissiveBatchResult struct {
Data []EmailID `json:"data"`
Errors []BatchValidationError `json:"errors,omitempty"`
}
PermissiveBatchResult includes the accepted IDs and per-message validation errors.