converter

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	AddressItem `json:"address"`
}

Address is a SparkPost address

type AddressItem

type AddressItem struct {
	Email string `json:"email" validate:"required,email"`
}

AddressItem is a SparkPost Address item

type Content

type Content struct {
	EmailRFC822 string `json:"email_rfc822"`
}

Content is the transmission content

type Converter

type Converter interface {
	ID() ID
	Convert(data io.ReadSeeker) (*Message, error)
}

Converter converts an input to a ConvertedMessage

func NewRFC5322

func NewRFC5322() Converter

NewRFC5322 returns a new message converter for RFC 5322 format

func NewSparkPost

func NewSparkPost() Converter

NewSparkPost returns a new SparkPost transmission converter

type ID

type ID string

ID is a converter ID type

const RFC5322ID ID = "rfc5322"

RFC5322ID is the ID for RFC5322 converter

const SparkPostID ID = "sparkpost"

SparkPostID is the ID for SparkPost converter

const StubConverterID ID = "stub"

StubConverterID is the Stub converter ID

type Message

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

Message represents an email message

func NewMessage

func NewMessage(from string, to, cc, bcc []string, raw io.Reader) *Message

NewMessage returns a new Message instance

func (*Message) Bcc

func (m *Message) Bcc() []string

Bcc returns the Bcc: recipient(s)

func (*Message) Cc

func (m *Message) Cc() []string

Cc returns the Cc: recipient(s)

func (*Message) From

func (m *Message) From() string

From returns the message's From: value

func (*Message) HasRecipients

func (m *Message) HasRecipients() bool

HasRecipients returns true if the message contains as least one recipient amongst To, Cc and Bcc.

func (*Message) Raw

func (m *Message) Raw() ([]byte, error)

Raw returns the raw message (with its headers) as a byte stream

func (*Message) To

func (m *Message) To() []string

To returns the To: recipient(s)

type Provider

type Provider interface {
	IDs() []ID
	Get(cid ID) (Converter, error)
}

Provider exposes the provider methods

func NewProvider

func NewProvider(converters ...Converter) Provider

NewProvider returns a new and initialized provider with given converters

type RecipientProvider

type RecipientProvider func(*Message) []string

RecipientProvider is the common func type for To(), Cc() and Bcc()

type SparkPostTransmission

type SparkPostTransmission struct {
	Recipients []Address `json:"recipients" validate:"required,min=1,dive,required"`
	Content    Content   `json:"content" validate:"required"`
}

SparkPostTransmission represents a SparkPost transmission See: https://developers.sparkpost.com/api/transmissions/#transmissions-create-a-transmission

type Stub

type Stub struct {
	StubID  ID
	Message *Message
	Err     error
}

Stub is the stub converter used for testing purposes

func (*Stub) Convert

func (s *Stub) Convert(data io.ReadSeeker) (*Message, error)

Convert implements the Converter interface. It returns the stub message and error.

func (*Stub) ID

func (s *Stub) ID() ID

ID implements the Converter interface. It returns a stub ID if provided or returns the default StubConverterID otherwise

Jump to

Keyboard shortcuts

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