types

package
v0.0.0-...-8c17a97 Latest Latest
Warning

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

Go to latest
Published: May 28, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package types defines webhook types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(t Type, a APIKey) error

Validate signature on t with a.

Types

type APIKey

type APIKey interface {
	Key() string
}

APIKey defines Key() method.

type Bounce

type Bounce struct {
	Event           `json:"event"`                   // Event name (“bounced”).
	Recipient       string                           `json:"recipient"`       // Recipient who could not be reached.
	Domain          string                           `json:"domain"`          // Domain that sent the original message.
	MessageHeaders  string                           `json:"message-headers"` // String list of all MIME headers of the original message dumped to a JSON string (order of headers preserved).
	Code            string                           `json:"code"`            // SMTP bounce error code in form (X.X.X).
	Error           string                           `json:"error"`           // SMTP bounce error string.
	Notification    string                           `json:"notification"`    // Detailed reason for bouncing (optional).
	CampaignID      string                           `json:"campaign-id"`     // The id of campaign triggering the event.
	CampaignName    string                           `json:"campaign-name"`   // The name of campaign triggering the event.
	Tag             string                           `json:"tag"`             // Message tag, if it was tagged. See Tagging.
	MailingList     string                           `json:"mailing-list"`    // The address of mailing list the original message was sent to.
	CustomVariables map[string]interface{}           `json:"-"`               // Your own custom JSON object included in the header (see Attaching Data to Messages).
	Timestamp       `json:"timestamp"`               // Number of seconds passed since January 1, 1970 (see securing webhooks).
	Token           `json:"token"`                   // Randomly generated string with length 50 (see securing webhooks).
	Signature       `json:"signature"`               // String with hexadecimal digits generate by HMAC algorithm (see securing webhooks).
	Attachments     map[*textproto.MIMEHeader][]byte `json:"-"` // attached file (‘x’ stands for number of the attachment). Attachments are included if the recipient ESP includes them in the bounce message. They are handled as file uploads, encoded as multipart/form-data.
}

func (Bounce) Bounce

func (b Bounce) Bounce() Bounce

type Click

type Click struct {
	Event           `json:"event"`         // Event name (“clicked”).
	Recipient       string                 `json:"recipient"`     // Recipient who clicked.
	Domain          string                 `json:"domain"`        // Domain that sent the original message.
	IP              string                 `json:"ip"`            // IP address the event originated from.
	Country         string                 `json:"country"`       // Two-letter country code (as specified by ISO3166) the event came from or ‘unknown’ if it couldn’t be determined.
	Region          string                 `json:"region"`        // Two-letter or two-digit region code or ‘unknown’ if it couldn’t be determined.
	City            string                 `json:"city"`          // Name of the city the event came from or ‘unknown’ if it couldn’t be determined.
	UserAgent       string                 `json:"user-agent"`    // User agent string of the client triggered the event.
	DeviceType      string                 `json:"device-type"`   // Device type the link was clicked on. Can be ‘desktop’, ‘mobile’, ‘tablet’, ‘other’ or ‘unknown’.
	ClientType      string                 `json:"client-type"`   // Type of software the link was opened in, e.g. ‘browser’, ‘mobile browser’, ‘email client’.
	ClientName      string                 `json:"client-name"`   // Name of the client software, e.g. ‘Thunderbird’, ‘Chrome’, ‘Firefox’.
	ClientOS        string                 `json:"client-os"`     // OS family running the client software, e.g. ‘Linux’, ‘Windows’, ‘OSX’.
	CampaignID      string                 `json:"campaign-id"`   // The id of campaign triggering the event.
	CampaignName    string                 `json:"campaign-name"` // The name of campaign triggering the event.
	Tag             string                 `json:"tag"`           // Message tag, if it was tagged. See Tagging.
	URL             string                 `json:"url"`           // The URL that was clicked.
	MailingList     string                 `json:"mailing-list"`  // The address of mailing list the original message was sent to.
	CustomVariables map[string]interface{} `json:"-"`             // Your own custom JSON object included in the header (see Attaching Data to Messages).
	Timestamp       `json:"timestamp"`     // Number of seconds passed since January 1, 1970 (see securing webhooks).
	Token           `json:"token"`         // Randomly generated string with length 50 (see securing webhooks).
	Signature       `json:"signature"`     // String with hexadecimal digits generate by HMAC algorithm (see securing webhooks).
}

func (Click) Click

func (c Click) Click() Click

type Complaint

type Complaint struct {
	Event           `json:"event"`                   // Event name (“complained”).
	Recipient       string                           `json:"recipient"`       // Recipient who clicked spam.
	Domain          string                           `json:"domain"`          // Domain that sent the original message.
	MessageHeaders  string                           `json:"message-headers"` // String list of all MIME headers of the original message dumped to a JSON string (order of headers preserved).
	CampaignID      string                           `json:"campaign-id"`     // The id of campaign triggering the event.
	CampaignName    string                           `json:"campaign-name"`   // The name of campaign triggering the event.
	Tag             string                           `json:"tag"`             // Message tag, if it was tagged. See Tagging.
	MailingList     string                           `json:"mailing-list"`    // The address of mailing list the original message was sent to.
	CustomVariables map[string]interface{}           `json:"-"`               // Your own custom JSON object included in the header (see Attaching Data to Messages).
	Timestamp       `json:"timestamp"`               // Number of seconds passed since January 1, 1970 (see securing webhooks).
	Token           `json:"token"`                   // Randomly generated string with length 50 (see securing webhooks).
	Signature       `json:"signature"`               // String with hexadecimal digits generate by HMAC algorithm (see securing webhooks).
	Attachments     map[*textproto.MIMEHeader][]byte `json:"-"` // attached file (‘x’ stands for number of the attachment). Attachments are included if the recipient ESP includes them in the bounce message. They are handled as file uploads, encoded as multipart/form-data.
}

func (Complaint) Complaint

func (c Complaint) Complaint() Complaint

type Delivered

type Delivered struct {
	Event           `json:"event"`         // Event name (“delivered”).
	Recipient       string                 `json:"recipient"`       // Intended recipient.
	Domain          string                 `json:"domain"`          // Domain that sent the original message.
	MessageHeaders  string                 `json:"message-headers"` // String list of all MIME headers dumped to a JSON string (order of headers preserved).
	MessageID       string                 `json:"Message-Id"`      // String id of the original message delivered to the recipient.
	CustomVariables map[string]interface{} `json:"-"`               // Your own custom JSON object included in the header of the original message (see Attaching Data to Messages).
	Timestamp       `json:"timestamp"`     // Number of seconds passed since January 1, 1970 (see securing webhooks).
	Token           `json:"token"`         // Randomly generated string with length 50 (see securing webhooks).
	Signature       `json:"signature"`     // String with hexadecimal digits generate by HMAC algorithm (see securing webhooks).
}

func (Delivered) Delivered

func (d Delivered) Delivered() Delivered

type Drop

type Drop struct {
	Event           `json:"event"`                   // Event name (“dropped”).
	Recipient       string                           `json:"recipient"`       // Intended recipient.
	Domain          string                           `json:"domain"`          // Domain that sent the original message.
	MessageHeaders  string                           `json:"message-headers"` // String list of all MIME headers of the original message dumped to a JSON string (order of headers preserved).
	Reason          string                           `json:"reason"`          // Reason for failure. Can be one either “hardfail” or “old”. See below.
	Code            string                           `json:"code"`            // ESP response code, e.g. if the message was blocked as a spam (optional).
	Description     string                           `json:"description"`     // Detailed explanation of why the messages was dropped
	CustomVariables map[string]interface{}           `json:"-"`               // Your own custom JSON object included in the header (see Attaching Data to Messages).
	Timestamp       `json:"timestamp"`               // Number of seconds passed since January 1, 1970 (see securing webhooks).
	Token           `json:"token"`                   // Randomly generated string with length 50 (see securing webhooks).
	Signature       `json:"signature"`               // String with hexadecimal digits generate by HMAC algorithm (see securing webhooks).
	Attachments     map[*textproto.MIMEHeader][]byte `json:"-"` // attached file (‘x’ stands for number of the attachment). Attachments are included if the recipient ESP includes them in the bounce message. They are handled as file uploads, encoded as multipart/form-data.
}

func (Drop) Drop

func (d Drop) Drop() Drop

type Event

type Event string

Event is shared by all webhook types.

func (Event) Type

func (e Event) Type() string

Type implements Type.

type IBounce

type IBounce interface{ Bounce() Bounce }

type IClick

type IClick interface{ Click() Click }

type IComplaint

type IComplaint interface{ Complaint() Complaint }

type IDelivered

type IDelivered interface{ Delivered() Delivered }

type IDrop

type IDrop interface{ Drop() Drop }

type IOpen

type IOpen interface{ Open() Open }

type IUnsubscribe

type IUnsubscribe interface{ Unsubscribe() Unsubscribe }

type Open

type Open struct {
	Event           `json:"event"`         // Event name (“opened”).
	Recipient       string                 `json:"recipient"`     // Recipient who opened.
	Domain          string                 `json:"domain"`        // Domain that sent the original message.
	IP              string                 `json:"ip"`            // IP address the event originated from.
	Country         string                 `json:"country"`       // Two-letter country code (as specified by ISO3166) the event came from or ‘unknown’ if it couldn’t be determined.
	Region          string                 `json:"region"`        // Two-letter or two-digit region code or ‘unknown’ if it couldn’t be determined.
	City            string                 `json:"city"`          // Name of the city the event came from or ‘unknown’ if it couldn’t be determined.
	UserAgent       string                 `json:"user-agent"`    // User agent string of the client triggered the event.
	DeviceType      string                 `json:"device-type"`   // Device type the email was opened on. Can be ‘desktop’, ‘mobile’, ‘tablet’, ‘other’ or ‘unknown’.
	ClientType      string                 `json:"client-type"`   // Type of software the email was opened in, e.g. ‘browser’, ‘mobile browser’, ‘email client’.
	ClientName      string                 `json:"client-name"`   // Name of the client software, e.g. ‘Thunderbird’, ‘Chrome’, ‘Firefox’.
	ClientOS        string                 `json:"client-os"`     // OS family running the client software, e.g. ‘Linux’, ‘Windows’, ‘OSX’.
	CampaignID      string                 `json:"campaign-id"`   // The id of campaign triggering the event.
	CampaignName    string                 `json:"campaign-name"` // The name of campaign triggering the event.
	Tag             string                 `json:"tag"`           // Message tag, if message was tagged. See Tagging
	MailingList     string                 `json:"mailing-list"`  // The address of mailing list the original message was sent to.
	CustomVariables map[string]interface{} `json:"-"`             // Your own custom JSON object included in the header (see Attaching Data to Messages).
	Timestamp       `json:"timestamp"`     // Number of seconds passed since January 1, 1970 (see securing webhooks).
	Token           `json:"token"`         // Randomly generated string with length 50 (see securing webhooks).
	Signature       `json:"signature"`     // String with hexadecimal digits generate by HMAC algorithm (see securing webhooks).
}

func (Open) Open

func (o Open) Open() Open

type Signature

type Signature string

Signature is shared by all webhook types.

func (Signature) Sig

func (s Signature) Sig() string

Sig implements Type.

type Timestamp

type Timestamp string

Timestamp is shared by all webhook types.

func (Timestamp) TS

func (t Timestamp) TS() string

TS implements Type.

type Token

type Token string

Token is shared by all webhook types.

func (Token) Tok

func (t Token) Tok() string

Tok implements Type.

type Type

type Type interface {
	Type() string
	Sig() string
	TS() string
	Tok() string
}

Type is the event interface.

func Decode

func Decode(reader io.Reader, boundary string) (Type, error)

Decode decodes webhook payload from reader. If boundary is empty, guesses if x-form-urlencoded or multipart.

type Unsubscribe

type Unsubscribe struct {
	Event           `json:"event"`         // Event name (“unsubscribed”).
	Recipient       string                 `json:"recipient"`     // Recipient who unsubscribed.
	Domain          string                 `json:"domain"`        // Domain that sent the original message.
	IP              string                 `json:"ip"`            // IP address the event originated from.
	Country         string                 `json:"country"`       // Two-letter country code (as specified by ISO3166) the event came from or ‘unknown’ if it couldn’t be determined.
	Region          string                 `json:"region"`        // Two-letter or two-digit region code or ‘unknown’ if it couldn’t be determined.
	City            string                 `json:"city"`          // Name of the city the event came from or ‘unknown’ if it couldn’t be determined.
	UserAgent       string                 `json:"user-agent"`    // User agent string of the client triggered the event.
	DeviceType      string                 `json:"device-type"`   // Device type the person unsubscribed on. Can be ‘desktop’, ‘mobile’, ‘tablet’, ‘other’ or ‘unknown’.
	ClientType      string                 `json:"client-type"`   // Type of software the unsubscribe link was clicked in, e.g. ‘browser’, ‘mobile browser’, ‘email client’.
	ClientName      string                 `json:"client-name"`   // Name of the client software, e.g. ‘Thunderbird’, ‘Chrome’, ‘Firefox’.
	ClientOS        string                 `json:"client-os"`     // OS family running the client software, e.g. ‘Linux’, ‘Windows’, ‘OSX’.
	CampaignID      string                 `json:"campaign-id"`   // The id of the campaign that recipient has unsubscribed from.
	CampaignName    string                 `json:"campaign-name"` // The name of campaign triggering the event.
	Tag             string                 `json:"tag"`           // Message tag, if it was tagged. See Tagging.
	MailingList     string                 `json:"mailing-list"`  // The address of mailing list the original message was sent to.
	CustomVariables map[string]interface{} `json:"-"`             // Your own custom JSON object included in the header (see Attaching Data to Messages).
	Timestamp       `json:"timestamp"`     // Number of seconds passed since January 1, 1970 (see securing webhooks).
	Token           `json:"token"`         // Randomly generated string with length 50 (see securing webhooks).
	Signature       `json:"signature"`     // String with hexadecimal digits generate by HMAC algorithm (see securing webhooks).
}

func (Unsubscribe) Unsubscribe

func (u Unsubscribe) Unsubscribe() Unsubscribe

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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