elasticemail

package module
v0.0.0-...-751306d Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2018 License: MIT Imports: 14 Imported by: 0

README

About

Go library for interacting with the ElasticEmail API.

Supported methods

  • Email:

    Send your emails and see their statuses

    • GetStatus
    • Send
    • Status
    • View
  • Template:

    Managing and editing templates of your emails

    • GetList
  • List:

    API methods for managing your Lists

    • list
  • Contact:

    Methods used to manage your Contacts.

    • Add

Usage

        ee := elasticemail.NewElasticEmail("api-key")
        
        //send email
	to := make([]string, 1)
	to[0] = "abc@gmail.com"
	sendEmail, err := ee.Send(elasticemail.SendParams{To: to, BodyHtml: "<b>Hello!</b>", Subject: "Hello", From: "noreply@eeee.eee"})
	if err!= nil {
		log.Fatal(err.Error())
	}
	
	// get status:
    	status, err := ee.GetEmailStatus(elasticemail.GetEmailStatusParams{TransactionID: sendEmail.TransactionID})
    	if err != nil {
    		log.Fatal(err.Error())
    	}


Documentation

Index

Constants

View Source
const (
	ApiBase = "https://api.elasticemail.com/v2"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddContactParams

type AddContactParams struct {
	Email               string   `json:"email" url:"email"`
	PublicAccountID     string   `json:"publicaccountid" url:"publicaccountid"`
	ActivationReturnUrl string   `json:"activationreturnurl" url:"activationreturnurl"`
	ActivationTemplate  string   `json:"activationtemplate" url:"activationtemplate"`
	AlreadyActiveUrl    string   `json:"alreadyactiveurl" url:"alreadyactiveurl"`
	ConsentDate         string   `json:"consentdate" url:"consentdate"`
	ConsentIP           string   `json:"consentip" url:"consentip"`
	ConsentTracking     int      `json:"consenttracking" url:"consenttracking"` // ConsentTracking Enumeration
	Field               []string `json:"field" url:"field"`
	FirstName           string   `json:"firstname" url:"firstname"`
	LastName            string   `json:"lastname" url:"lastname"`
	ListName            []string `json:"listname" url:"listname"`
	NotifyEmail         string   `json:"notifyemail" url:"notifyemail"`
	PublicListID        []string `json:"publiclistid" url:"publiclistid"`
	ReturnUrl           string   `json:"returnurl" url:"returnurl"`
	SendActivation      bool     `json:"sendactivation" url:"sendactivation"`
	Source              int      `json:"source" url:"source"` // ContactSource Enumeration
	SourceUrl           string   `json:"sourceurl" url:"sourceurl"`
}

type ElasticEmail

type ElasticEmail interface {
	APIBase() string
	APIKey() string
	Client() *http.Client
	SetClient(client *http.Client)
	GetEmailStatusParams(params GetEmailStatusParams)
}

type ElasticEmailImpl

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

func NewElasticEmail

func NewElasticEmail(apiKey string) *ElasticEmailImpl

func NewElasticEmailFromEnv

func NewElasticEmailFromEnv() *ElasticEmailImpl

func (*ElasticEmailImpl) APIBase

func (m *ElasticEmailImpl) APIBase() string

ApiBase returns the API Base URL configured for this client.

func (*ElasticEmailImpl) AddContact

func (m *ElasticEmailImpl) AddContact(params AddContactParams) (err error)

Add a new contact and optionally to one of your lists. Note that your API KEY is not required for this call. return nil if success

func (*ElasticEmailImpl) Client

func (m *ElasticEmailImpl) Client() *http.Client

Client returns the HTTP client configured for this client.

func (*ElasticEmailImpl) GetEmailStatus

func (m *ElasticEmailImpl) GetEmailStatus(params GetEmailStatusParams) (status *EmailJobStatus, err error)

Get email batch status Access Level required: ViewReports

func (*ElasticEmailImpl) GetList

func (m *ElasticEmailImpl) GetList(params TemplateGetListParams) (lists *TemplateList, err error)

Lists your templates Access Level required: ViewTemplates

func (*ElasticEmailImpl) List

func (m *ElasticEmailImpl) List(params ListParams) (lists *[]List, err error)

Shows all your existing lists Access Level required: ViewContacts

func (*ElasticEmailImpl) Send

func (m *ElasticEmailImpl) Send(params SendParams) (status *EmailSend, err error)

Submit emails. The HTTP POST request is suggested. The default, maximum (accepted by us) size of an email is 10 MB in total, with or without attachments included. For suggested implementations please refer to https://elasticemail.com/support/http-api/ Access Level required: SendHttp

func (*ElasticEmailImpl) SetAPIBase

func (m *ElasticEmailImpl) SetAPIBase(address string)

SetAPIBase updates the API Base URL for this client.

func (*ElasticEmailImpl) SetClient

func (m *ElasticEmailImpl) SetClient(c *http.Client)

SetClient updates the HTTP client for this client.

func (*ElasticEmailImpl) Status

func (m *ElasticEmailImpl) Status(params StatusParams) (status *EmailStatus, err error)

Detailed status of a unique email sent through your account. Returns a 'Email has expired and the status is unknown.' error, if the email has not been fully processed yet. Access Level required: ViewReports

func (*ElasticEmailImpl) View

func (m *ElasticEmailImpl) View(params ViewParams) (status *EmailView, err error)

View email Access Level required: ViewReports

type EmailJobFailedStatus

type EmailJobFailedStatus struct {
	Address   string `json:"address"`
	Category  string `json:"dategory"`
	Error     string `json:"error"`
	ErrorCode int    `json:"errorcode"`
}

type EmailJobStatus

type EmailJobStatus struct {
	AbuseReports      *[]string               `json:"abusereports"`
	AbuseReportsCount int                     `json:"abusereportscount"`
	Clicked           *[]string               `json:"clicked"`
	ClickedCount      int                     `json:"clickedcount"`
	Delivered         *[]string               `json:"delivered"`
	DeliveredCount    int                     `json:"deliveredcount"`
	Failed            *[]EmailJobFailedStatus `json:"failed"`
	FailedCount       int                     `json:"failedcount"`
	ID                string                  `json:"id"`
	MessageIDs        *[]string               `json:"messageids"`
	Opened            *[]string               `json:"opened"`
	OpenedCount       int                     `json:"openedcount"`
	Pending           *[]string               `json:"pending"`
	PendingCount      int                     `json:"pendingcount"`
	RecipientsCount   int                     `json:"recipientscount"`
	Sent              *[]string               `json:"sent"`
	SentCount         int                     `json:"sentcount"`
	Status            string                  `json:"status"`
	Unsubscribed      *[]string               `json:"unsubscribed"`
	UnsubscribedCount int                     `json:"unsubscribedcount"`
}

type EmailSend

type EmailSend struct {
	MessageID     string `json:"messageid"`
	TransactionID string `json:"transactionid"`
}

type EmailStatus

type EmailStatus struct {
	Date             string  `json:"date"`
	DateClicked      *string `json:"dateclicked"`
	DateOpened       *string `json:"dateopened"`
	DateSent         *string `json:"datesent"`
	ErrorMessage     string  `json:"errormessage"`
	From             string  `json:"from"`
	Status           uint8   `json:"status"` // value from LogJobStatus Enumeration
	StatusChangeDate string  `json:"statuschangedate"`
	StatusName       string  `json:"statusname"`
	To               string  `json:"to"`
	TransactionID    string  `json:"transactionid"`
}

type EmailView

type EmailView struct {
	Body    string `json:"body"`
	From    string `json:"from"`
	Subject string `json:"subject"`
}

type GetEmailStatusParams

type GetEmailStatusParams struct {
	TransactionID    string `json:"transactionID" url:"transactionID"`
	ShowAbuse        bool   `json:"showAbuse" url:"showAbuse"`
	ShowClicked      bool   `json:"showClicked" url:"showClicked"`
	ShowDelivered    bool   `json:"showDelivered" url:"showDelivered"`
	ShowErrors       bool   `json:"showErrors" url:"showErrors"`
	ShowFailed       bool   `json:"showFailed" url:"showFailed"`
	ShowMessageIDs   bool   `json:"showMessageIDs" url:"showMessageIDs"`
	ShowOpened       bool   `json:"showOpened" url:"showOpened"`
	ShowPending      bool   `json:"showPending" url:"showPending"`
	ShowSent         bool   `json:"showSent" url:"showSent"`
	ShowUnsubscribed bool   `json:"showUnsubscribed" url:"showUnsubscribed"`
}

type List

type List struct {
	AllowUnsubscribe bool   `json:"allowunsubscribe"`
	Count            int    `json:"count"`
	DateAdded        string `json:"dateadded"`
	ListID           int    `json:"listid"`
	ListName         string `json:"listname"`
	PublicListID     string `json:"publiclistid"`
	Rule             string `json:"rule"`
}

type ListParams

type ListParams struct {
	From string `json:"from" url:"from"` // Starting date for search in YYYY-MM-DDThh:mm:ss format.
	To   string `json:"to" url:"to"`     // Ending date for search in YYYY-MM-DDThh:mm:ss format.
}

type SendParams

type SendParams struct {
	Attachments         []string `json:"attachments"`
	BodyHtml            string   `json:"bodyhtml"`
	BodyText            string   `json:"bodytext"`
	To                  []string `json:"to"`
	Channel             string   `json:"channel"`
	Charset             string   `json:"charset"`
	CharsetBodyHtml     string   `json:"charsetbodyhtml"`
	CharsetBodyText     string   `json:"charsetbodytext"`
	DataSource          string   `json:"datasource"`
	EncodingType        int8     `json:"encodingtype"` // EncodingType Enumeration
	From                string   `json:"from"`
	FromName            string   `json:"fromname"`
	Headers             []string `json:"headers"` // example: headers_xmailer = xmailer: header-value1  Whitespace required!
	IsTransactional     bool     `json:"istransactional"`
	Lists               []string `json:"lists"`
	Merge               string   `json:"merge"` // example: merge_firstname=John, ....
	MergeSourceFilename string   `json:"mergesourcefilename"`
	MsgBcc              []string `json:"msgbcc"`
	MsgCC               []string `json:"msgcc"`
	MsgFrom             string   `json:"msgfrom"`
	MsgFromName         string   `json:"msgfromname"`
	MsgTo               []string `json:"msgto"`
	PoolName            string   `json:"poolname"`
	PostBack            string   `json:"postback"`
	ReplyTo             string   `json:"replyto"`
	ReplyToName         string   `json:"replytoname"`
	Segments            []string `json:"sefments"`
	Sender              string   `json:"sender"`
	SenderName          string   `json:"sendername"`
	Subject             string   `json:"subject"`
	Template            string   `json:"template"`
	TimeOffSetMinutes   string   `json:"timeoffsetminutes"`
	TrackClicks         bool     `json:"trackclicks"`
	TrackOpens          bool     `json:"trackopens"`
}

type StatusParams

type StatusParams struct {
	MessageID string `json:"messageID" url:"messageID"` // Unique identifier for this email.
}

type Template

type Template struct {
	BodyHtm            string `json:"bodyhtml"`
	BodyText           string `json:"bodytext"`
	Css                string `json:"css"`
	DateAdded          string `json:"dateadded"`
	FromEmail          string `json:"fromemail"`
	FromName           string `json:"fromname"`
	Name               string `json:"name"`
	OriginalTemplateID int    `json:"originaltemplateid"`
	Subject            string `json:"subject"`
	TemplateID         int    `json:"templateid"`
	TemplateScope      int    `json:"templatescope"`
	TemplateType       int    `json:"templatetype"`
}

type TemplateGetListParams

type TemplateGetListParams struct {
	Limit  int `json:"limit" url:"limit"`   // Maximum of loaded items.
	Offset int `json:"offset" url:"offset"` // How many items should be loaded ahead.
}

type TemplateList

type TemplateList struct {
	DraftTemplate []Template `json:"drafttemplate"`
	Templates     []Template `json:"templates"`
}

type ViewParams

type ViewParams struct {
	MessageID string `json:"messageID" url:"messageID"` // Unique identifier for this email.
}

Jump to

Keyboard shortcuts

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