postmark

package
v0.0.0-...-6319034 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper function that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range.

func Int

func Int(v int) *int

Int is a helper function that allocates a new int value to store v and returns a pointer to it.

func String

func String(v string) *string

String is a helper function that allocates a new string value to store v and returns a pointer to it.

Types

type Attachment

type Attachment struct {
	Name        *string `json:"Name,omitempty"`
	Content     *string `json:"Content,omitempty"`
	ContentType *string `json:"ContentType,omitempty"`
	ContentID   *string `json:"ContentID,omitempty"`
}

func (*Attachment) MarshalJSON

func (a *Attachment) MarshalJSON() ([]byte, error)

func (*Attachment) UnmarshalJSON

func (a *Attachment) UnmarshalJSON(b []byte) error

type Client

type Client struct {

	// BaseURL for the Postmark API.
	BaseURL *url.URL

	// Secret tokens used for authenticating with the Postmark API.
	ServerToken  string
	AccountToken string

	// Services used for talking to different parts of the Postmark API.
	Email *EmailService
	// contains filtered or unexported fields
}

A Client manages communication with the Postmark API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Postmark API client. If httpClient is nil, http.DefaultClient will be used.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in path, in which case it is resolved relative to the BaseURL of the client. Relative URLs should always be specified without the preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body

type Email

type Email struct {
	From        *string      `json:"From,omitempty"`
	To          *string      `json:"To,omitempty"`
	Cc          *string      `json:"Cc,omitempty"`
	Bcc         *string      `json:"Bcc,omitempty"`
	Subject     *string      `json:"Subject,omitempty"`
	Tag         *string      `json:"Tag,omitempty"`
	HTMLBody    *string      `json:"HtmlBody,omitempty"`
	TextBody    *string      `json:"TextBody,omitempty"`
	ReplyTo     *string      `json:"ReplyTo,omitempty"`
	Headers     []Header     `json:"Headers,omitempty"`
	TrackOpens  *bool        `json:"TrackOpens,omitempty"`
	Attachments []Attachment `json:"Attachments,omitempty"`
}

type EmailResult

type EmailResult struct {
	To          string
	SubmittedAt *time.Time
	MessageID   string
}

type EmailService

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

EmailService handles communication with the Email related methods of the Postmark API.

func (*EmailService) Send

func (s *EmailService) Send(email *Email) (*EmailResult, *http.Response, error)

func (*EmailService) SendBatch

func (s *EmailService) SendBatch(emails []Email) ([]EmailResult, *http.Response, error)

type ErrorResponse

type ErrorResponse struct {
	Response  *http.Response
	ErrorCode int    `json:"ErrorCode"`
	Message   string `json:"Message"`
}

An ErrorResponse reports an error caused by an API request.

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string
type Header struct {
	Name  *string `json:"Name,omitempty"`
	Value *string `json:"Value,omitempty"`
}

Jump to

Keyboard shortcuts

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