events

package
v0.0.0-...-6217e70 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package events defines a struct for each type of event and provides various other helper functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
)

Functions

func ECLog

func ECLog(e Event) string

func ValidEventType

func ValidEventType(eventType string) bool

ValidEventType returns true if the event name parameter is valid.

Types

type Bounce

type Bounce struct {
	EventCommon
	Binding         string            `json:"binding"`
	BindingGroup    string            `json:"binding_group"`
	BounceClass     string            `json:"bounce_class"`
	CampaignID      string            `json:"campaign_id"`
	CustomerID      string            `json:"customer_id"`
	DeliveryMethod  string            `json:"delv_method"`
	DeviceToken     string            `json:"device_token"`
	ErrorCode       string            `json:"error_code"`
	IPAddress       string            `json:"ip_address"`
	MessageID       string            `json:"message_id"`
	MessageFrom     string            `json:"msg_from"`
	MessageSize     string            `json:"msg_size"`
	Retries         string            `json:"num_retries"`
	Metadata        map[string]string `json:"rcpt_meta"`
	Tags            []string          `json:"rcpt_tags"`
	Recipient       string            `json:"rcpt_to"`
	RecipientType   string            `json:"rcpt_type"`
	RawReason       string            `json:"raw_reason"`
	Reason          string            `json:"reason"`
	ReceiveProtocol string            `json:"recv_method"`
	RoutingDomain   string            `json:"routing_domain"`
	Subject         string            `json:"subject"`
	TemplateID      string            `json:"template_id"`
	TemplateVersion string            `json:"template_version"`
	Timestamp       Timestamp         `json:"timestamp"`
	TransmissionID  string            `json:"transmission_id"`
}

func (*Bounce) ECLog

func (b *Bounce) ECLog() string

ECLog emits a Bounce in the same format that it would be logged to bouncelog.ec: https://support.messagesystems.com/docs/web-ref/log_formats.version_3.php

func (*Bounce) String

func (b *Bounce) String() string

String returns a brief summary of a Bounce event

type Click

type Click struct {
	EventCommon
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	DeliveryMethod  string      `json:"delv_method"`
	GeoIP           *GeoIP      `json:"geo_ip"`
	IPAddress       string      `json:"ip_address"`
	MessageID       string      `json:"message_id"`
	Metadata        interface{} `json:"rcpt_meta"`
	Tags            []string    `json:"rcpt_tags"`
	Recipient       string      `json:"rcpt_to"`
	RecipientType   string      `json:"rcpt_type"`
	TargetLinkName  string      `json:"target_link_name"`
	TargetLinkURL   string      `json:"target_link_url"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
	UserAgent       string      `json:"user_agent"`
}

func (*Click) String

func (c *Click) String() string

String returns a brief summary of a Click event

type Creation

type Creation struct {
	EventCommon
	Accepted        string      `json:"accepted_rcpts"`
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	InjectionMethod string      `json:"inj_method"`
	NodeName        string      `json:"node_name"`
	Metadata        interface{} `json:"rcpt_meta"`
	Tags            []string    `json:"rcpt_tags"`
	Submitted       string      `json:"submitted_rcpts"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
	UserID          string      `json:"user_id"`
}

func (*Creation) String

func (c *Creation) String() string

type Delay

type Delay struct {
	EventCommon
	Binding         string      `json:"binding"`
	BindingGroup    string      `json:"binding_group"`
	BounceClass     string      `json:"bounce_class"`
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	DeliveryMethod  string      `json:"delv_method"`
	DeviceToken     string      `json:"device_token"`
	ErrorCode       string      `json:"error_code"`
	IPAddress       string      `json:"ip_address"`
	MessageID       string      `json:"message_id"`
	MessageFrom     string      `json:"msg_from"`
	MessageSize     string      `json:"msg_size"`
	Retries         string      `json:"num_retries"`
	QueueTime       string      `json:"queue_time"`
	Metadata        interface{} `json:"rcpt_meta"`
	Tags            []string    `json:"rcpt_tags"`
	Recipient       string      `json:"rcpt_to"`
	RecipientType   string      `json:"rcpt_type"`
	RawReason       string      `json:"raw_reason"`
	Reason          string      `json:"reason"`
	RoutingDomain   string      `json:"routing_domain"`
	Subject         string      `json:"subject"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
}

func (*Delay) ECLog

func (d *Delay) ECLog() string

ECLog emits a Delay in the same format that it would be logged to bouncelog.ec: https://support.messagesystems.com/docs/web-ref/log_formats.version_3.php

func (*Delay) String

func (d *Delay) String() string

String returns a brief summary of a Delay event

type Delivery

type Delivery struct {
	EventCommon
	Binding         string      `json:"binding"`
	BindingGroup    string      `json:"binding_group"`
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	DeliveryMethod  string      `json:"delv_method"`
	DeviceToken     string      `json:"device_token"`
	IPAddress       string      `json:"ip_address"`
	MessageID       string      `json:"message_id"`
	MessageFrom     string      `json:"msg_from"`
	MessageSize     string      `json:"msg_size"`
	Retries         string      `json:"num_retries"`
	QueueTime       string      `json:"queue_time"`
	Metadata        interface{} `json:"rcpt_meta"`
	Tags            []string    `json:"rcpt_tags"`
	Recipient       string      `json:"rcpt_to"`
	RecipientType   string      `json:"rcpt_type"`
	ReceiveProtocol string      `json:"recv_method"`
	RoutingDomain   string      `json:"routing_domain"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
}

func (*Delivery) ECLog

func (d *Delivery) ECLog() string

ECLog emits a Delivery in the same format that it would be logged to mainlog.ec: https://support.messagesystems.com/docs/web-ref/log_formats.version_3.php

func (*Delivery) String

func (d *Delivery) String() string

String returns a brief summary of a Delivery event

type ECLogger

type ECLogger interface {
	ECLog() string
}

type Event

type Event interface {
	EventType() string
}

Event is a generic event.

func EventForName

func EventForName(eventType string) Event

EventForName returns a struct matching the passed-in type.

func ParseRawJSONEvents

func ParseRawJSONEvents(rawEvents []json.RawMessage) ([]Event, error)

type EventCommon

type EventCommon struct {
	Type string `json:"type"`
}

EventCommon contains fields common to all types of Event objects

func (EventCommon) EventType

func (e EventCommon) EventType() string

type Events

type Events []Event

Events is a list of generic events. Useful for decoding events from API webhooks.

func (*Events) UnmarshalJSON

func (events *Events) UnmarshalJSON(data []byte) error

type GenerationFailure

type GenerationFailure struct {
	EventCommon
	Binding          string      `json:"binding"`
	BindingGroup     string      `json:"binding_group"`
	CampaignID       string      `json:"campaign_id"`
	CustomerID       string      `json:"customer_id"`
	ErrorCode        string      `json:"error_code"`
	Metadata         interface{} `json:"rcpt_meta"`
	SubstitutionData interface{} `json:"rcpt_subs"`
	Tags             []string    `json:"rcpt_tags"`
	Recipient        string      `json:"rcpt_to"`
	RawReason        string      `json:"raw_reason"`
	Reason           string      `json:"reason"`
	ReceiveProtocol  string      `json:"recv_method"`
	RoutingDomain    string      `json:"routing_domain"`
	TemplateID       string      `json:"template_id"`
	TemplateVersion  string      `json:"template_version"`
	Timestamp        Timestamp   `json:"timestamp"`
	TransmissionID   string      `json:"transmission_id"`
}

func (*GenerationFailure) String

func (g *GenerationFailure) String() string

String returns a brief summary of a GenerationFailure event

type GenerationRejection

type GenerationRejection GenerationFailure

func (*GenerationRejection) String

func (g *GenerationRejection) String() string

String returns a brief summary of a GenerationFailure event

type GeoIP

type GeoIP struct {
	Country   string  `json:"country"`
	Region    string  `json:"region"`
	City      string  `json:"city"`
	Latitude  LatLong `json:"latitude"`
	Longitude LatLong `json:"longitude"`
}

type Injection

type Injection struct {
	EventCommon
	Binding         string      `json:"binding"`
	BindingGroup    string      `json:"binding_group"`
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	MessageID       string      `json:"message_id"`
	MessageFrom     string      `json:"msg_from"`
	MessageSize     string      `json:"msg_size"`
	Metadata        interface{} `json:"rcpt_meta"`
	Pathway         string      `json:"pathway"`
	PathwayGroup    string      `json:"pathway_group"`
	Tags            []string    `json:"rcpt_tags"`
	Recipient       string      `json:"rcpt_to"`
	RecipientType   string      `json:"rcpt_type"`
	ReceiveProtocol string      `json:"recv_method"`
	RoutingDomain   string      `json:"routing_domain"`
	Subject         string      `json:"subject"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
}

func (*Injection) ECLog

func (i *Injection) ECLog() string

ECLog emits an Injection in the same format that it would be logged to mainlog.ec: https://support.messagesystems.com/docs/web-ref/log_formats.version_3.php

func (*Injection) String

func (i *Injection) String() string

String returns a brief summary of a GenerationFailure event

type LatLong

type LatLong float32

The API inconsistently returns float or string. We need a custom unmarshaller.

func (*LatLong) MarshalJSON

func (v *LatLong) MarshalJSON() ([]byte, error)

func (*LatLong) UnmarshalJSON

func (v *LatLong) UnmarshalJSON(data []byte) error

type LinkUnsubscribe

type LinkUnsubscribe struct {
	EventCommon
	ListUnsubscribe
	UserAgent string `json:"user_agent"`
}

func (*LinkUnsubscribe) String

func (l *LinkUnsubscribe) String() string

String returns a brief summary of a ListUnsubscribe event

type ListUnsubscribe

type ListUnsubscribe struct {
	EventCommon
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	MessageFrom     string      `json:"mailfrom"`
	MessageID       string      `json:"message_id"`
	Metadata        interface{} `json:"rcpt_meta"`
	Tags            []string    `json:"rcpt_tags"`
	Recipient       string      `json:"rcpt_to"`
	RecipientType   string      `json:"rcpt_type"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
}

func (*ListUnsubscribe) String

func (l *ListUnsubscribe) String() string

String returns a brief summary of a ListUnsubscribe event

type Open

type Open struct {
	EventCommon
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	DeliveryMethod  string      `json:"delv_method"`
	GeoIP           *GeoIP      `json:"geo_ip"`
	IPAddress       string      `json:"ip_address"`
	MessageID       string      `json:"message_id"`
	Metadata        interface{} `json:"rcpt_meta"`
	Tags            []string    `json:"rcpt_tags"`
	Recipient       string      `json:"rcpt_to"`
	RecipientType   string      `json:"rcpt_type"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
	UserAgent       string      `json:"user_agent"`
}

func (*Open) String

func (o *Open) String() string

String returns a brief summary of an Open event

type OutOfBand

type OutOfBand struct {
	EventCommon
	Binding         string    `json:"binding"`
	BindingGroup    string    `json:"binding_group"`
	BounceClass     string    `json:"bounce_class"`
	CampaignID      string    `json:"campaign_id"`
	CustomerID      string    `json:"customer_id"`
	DeliveryMethod  string    `json:"delv_method"`
	DeviceToken     string    `json:"device_token"`
	ErrorCode       string    `json:"error_code"`
	MessageID       string    `json:"message_id"`
	MessageFrom     string    `json:"msg_from"`
	Recipient       string    `json:"rcpt_to"`
	RawReason       string    `json:"raw_reason"`
	Reason          string    `json:"reason"`
	ReceiveProtocol string    `json:"recv_method"`
	RoutingDomain   string    `json:"routing_domain"`
	TemplateID      string    `json:"template_id"`
	TemplateVersion string    `json:"template_version"`
	Timestamp       Timestamp `json:"timestamp"`
}

func (*OutOfBand) ECLog

func (b *OutOfBand) ECLog() string

ECLog emits an OutOfBand in the same format that it would be logged to bouncelog.ec: https://support.messagesystems.com/docs/web-ref/log_formats.version_3.php

func (*OutOfBand) String

func (b *OutOfBand) String() string

String returns a brief summary of a Bounce event

type PolicyRejection

type PolicyRejection struct {
	EventCommon
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	ErrorCode       string      `json:"error_code"`
	MessageID       string      `json:"message_id"`
	MessageFrom     string      `json:"msg_from"`
	Metadata        interface{} `json:"rcpt_meta"`
	Pathway         string      `json:"pathway"`
	PathwayGroup    string      `json:"pathway_group"`
	Tags            []string    `json:"rcpt_tags"`
	RawReason       string      `json:"raw_reason"`
	Reason          string      `json:"reason"`
	Recipient       string      `json:"rcpt_to"`
	RecipientType   string      `json:"rcpt_type"`
	ReceiveProtocol string      `json:"recv_method"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
}

func (*PolicyRejection) String

func (p *PolicyRejection) String() string

String returns a brief summary of a PolicyRejection event

type RelayContent

type RelayContent struct {
	HTML    string              `json:"html"`
	Text    string              `json:"text"`
	Subject string              `json:"subject"`
	To      []string            `json:"to"`
	Cc      []string            `json:"cc"`
	Headers []map[string]string `json:"headers"`
	Email   string              `json:"email_rfc822"`
	Base64  bool                `json:email_rfc822_is_base64"`
}

type RelayDelivery

type RelayDelivery struct {
	EventCommon
	Binding         string    `json:"binding"`
	BindingGroup    string    `json:"binding_group"`
	CustomerID      string    `json:"customer_id"`
	DeliveryMethod  string    `json:"delv_method"`
	MessageFrom     string    `json:"msg_from"`
	Pathway         string    `json:"pathway"`
	PathwayGroup    string    `json:"pathway_group"`
	QueueTime       string    `json:"queue_time"`
	ReceiveProtocol string    `json:"recv_method"`
	RelayID         string    `json:"relay_id"`
	Retries         string    `json:"num_retries"`
	RoutingDomain   string    `json:"routing_domain"`
	Timestamp       Timestamp `json:"timestamp"`
}

func (*RelayDelivery) String

func (d *RelayDelivery) String() string

String returns a brief summary of a RelayDelivery event

type RelayInjection

type RelayInjection struct {
	EventCommon
	Binding         string    `json:"binding"`
	BindingGroup    string    `json:"binding_group"`
	CustomerID      string    `json:"customer_id"`
	MessageFrom     string    `json:"msg_from"`
	MessageSize     string    `json:"msg_size"`
	Pathway         string    `json:"pathway"`
	PathwayGroup    string    `json:"pathway_group"`
	Recipient       string    `json:"rcpt_to"`
	ReceiveProtocol string    `json:"recv_method"`
	RelayID         string    `json:"relay_id"`
	RoutingDomain   string    `json:"routing_domain"`
	Timestamp       Timestamp `json:"timestamp"`
}

func (*RelayInjection) String

func (i *RelayInjection) String() string

String returns a brief summary of a RelayInjection event

type RelayMessage

type RelayMessage struct {
	EventCommon
	Content      RelayContent `json:"content"`
	FriendlyFrom string       `json:"friendly_from"`
	From         string       `json:"msg_from"`
	To           string       `json:"rcpt_to"`
	WebhookID    string       `json:"webhook_id"`
}

func (*RelayMessage) String

func (m *RelayMessage) String() string

type RelayPermfail

type RelayPermfail RelayTempfail

func (*RelayPermfail) String

func (p *RelayPermfail) String() string

String returns a brief summary of a RelayInjection event

type RelayRejection

type RelayRejection struct {
	EventCommon
	CustomerID      string    `json:"customer_id"`
	ErrorCode       string    `json:"error_code"`
	MessageFrom     string    `json:"msg_from"`
	Pathway         string    `json:"pathway"`
	PathwayGroup    string    `json:"pathway_group"`
	RawReason       string    `json:"raw_reason"`
	Reason          string    `json:"reason"`
	Recipient       string    `json:"rcpt_to"`
	ReceiveProtocol string    `json:"recv_method"`
	RelayID         string    `json:"relay_id"`
	RemoteAddress   string    `json:"remote_addr"`
	Timestamp       Timestamp `json:"timestamp"`
}

func (*RelayRejection) String

func (r *RelayRejection) String() string

String returns a brief summary of a RelayInjection event

type RelayTempfail

type RelayTempfail struct {
	EventCommon
	Binding         string    `json:"binding"`
	BindingGroup    string    `json:"binding_group"`
	CustomerID      string    `json:"customer_id"`
	DeliveryMethod  string    `json:"delv_method"`
	ErrorCode       string    `json:"error_code"`
	MessageFrom     string    `json:"msg_from"`
	Retries         string    `json:"num_retries"`
	QueueTime       string    `json:"queue_time"`
	Pathway         string    `json:"pathway"`
	PathwayGroup    string    `json:"pathway_group"`
	RawReason       string    `json:"raw_reason"`
	Reason          string    `json:"reason"`
	ReceiveProtocol string    `json:"recv_method"`
	RelayID         string    `json:"relay_id"`
	RoutingDomain   string    `json:"routing_domain"`
	Timestamp       Timestamp `json:"timestamp"`
}

func (*RelayTempfail) String

func (t *RelayTempfail) String() string

String returns a brief summary of a RelayTempfail event

type SMSStatus

type SMSStatus struct {
	EventCommon
	CustomerID     string `json:"customer_id"`
	DeliveryMethod string `json:"delv_method"`
	// TODO: `json:"dr_latency"`
	IPAddress      string   `json:"ip_address"`
	RawReason      string   `json:"raw_reason"`
	Reason         string   `json:"reason"`
	RoutingDomain  string   `json:"routing_domain"`
	Destination    string   `json:"sms_dst"`
	DestinationNPI string   `json:"sms_dst_npi"`
	DestinationTON string   `json:"sms_dst_ton"`
	RemoteIDs      []string `json:"sms_remoteids"`
	Source         string   `json:"sms_src"`
	SourceNPI      string   `json:"sms_src_npi"`
	SourceTON      string   `json:"sms_src_ton"`
	Text           string   `json:"sms_text"`
	StatusType     string   `json:"stat_type"`
	StatusState    string   `json:"stat_state"`
	// TODO: SubAccountID string `json:"subaccount_id"`
	Timestamp Timestamp `json:"timestamp"`
}

func (*SMSStatus) String

func (e *SMSStatus) String() string

String returns a brief summary of a Delay event

type SpamComplaint

type SpamComplaint struct {
	EventCommon
	Binding         string      `json:"binding"`
	BindingGroup    string      `json:"binding_group"`
	CampaignID      string      `json:"campaign_id"`
	CustomerID      string      `json:"customer_id"`
	DeliveryMethod  string      `json:"delv_method"`
	FeedbackType    string      `json:"fbtype"`
	FriendlyFrom    string      `json:"friendly_from"`
	MessageID       string      `json:"message_id"`
	Metadata        interface{} `json:"rcpt_meta"`
	Tags            []string    `json:"rcpt_tags"`
	Recipient       string      `json:"rcpt_to"`
	RecipientType   string      `json:"rcpt_type"`
	ReportedBy      string      `json:"report_by"`
	ReportedTo      string      `json:"report_to"`
	Subject         string      `json:"subject"`
	TemplateID      string      `json:"template_id"`
	TemplateVersion string      `json:"template_version"`
	Timestamp       Timestamp   `json:"timestamp"`
	TransmissionID  string      `json:"transmission_id"`
	UserString      string      `json:"user_str"`
}

func (*SpamComplaint) String

func (p *SpamComplaint) String() string

String returns a brief summary of a SpamComplaint event

type Timestamp

type Timestamp time.Time

func (*Timestamp) MarshalJSON

func (t *Timestamp) MarshalJSON() ([]byte, error)

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

type Unknown

type Unknown struct {
	EventCommon
	RawJSON json.RawMessage
	Error   error
}

func (*Unknown) EventType

func (e *Unknown) EventType() string

func (*Unknown) String

func (e *Unknown) String() string

func (*Unknown) UnmarshalJSON

func (e *Unknown) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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