Documentation ¶
Index ¶
- Constants
- type Emailer
- type ListMember
- type ListMemberManager
- type MailchimpAPI
- func (m *MailchimpAPI) GetListMember(listID string, email string) (*ListMember, error)
- func (m *MailchimpAPI) IsSubscribedToList(listID string, email string) (bool, error)
- func (m *MailchimpAPI) ServiceName() string
- func (m *MailchimpAPI) SubscribeToList(listID string, email string, params *SubscriptionParams) error
- func (m *MailchimpAPI) UnsubscribeFromList(listID string, email string, delete bool) error
- type MailchimpTag
- type Member
- type MemberTag
- type NewMemberParams
- type SendEmailRequest
- type SendTemplateEmailRequest
- type Status
- type SubscriptionParams
- type Tag
- type TemplateData
Constants ¶
const ( // StatusSubscribed means a member is subscribed StatusSubscribed Status = "subscribed" // StatusUnsubscribed means a member is unsubscribed StatusUnsubscribed = "unsubscribed" // StatusInvalid means a member's status is invalid StatusInvalid = "invalid" // StatusPending means a member is pending or waiting of opt in StatusPending = "pending" )
const ( // ErrTitleResourceNotFound is the error response from Mailchimp ErrTitleResourceNotFound = "resource not found" // ErrTitleMemberExists is the error response from Mailchimp ErrTitleMemberExists = "member exists" )
const (
// ServiceNameMailchimp is the service name for Mailchimp
ServiceNameMailchimp = "mailchimp"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Emailer ¶
type Emailer struct {
// contains filtered or unexported fields
}
Emailer is a struct that wraps around an Email provider and makes it a little easier to use.
func NewEmailer ¶
NewEmailer is a convenience function that returns a new Emailer struct with the given apiKey
func NewEmailerWithSandbox ¶
NewEmailerWithSandbox is a convenience function that returns a new Emailer struct with the given apiKey for use with the Sendgrid sandbox. FOR TESTING PURPOSES, use NewEmailer for production code.
func (*Emailer) SendEmail ¶
func (e *Emailer) SendEmail(req *SendEmailRequest) error
SendEmail sends a basic email via the Email provider
func (*Emailer) SendTemplateEmail ¶
func (e *Emailer) SendTemplateEmail(req *SendTemplateEmailRequest) error
SendTemplateEmail sends an email based on a template in the email provider.
type ListMember ¶
type ListMember struct { ServiceID string EmailAddress string Status Status SignupDate time.Time LastUpdatedDate time.Time Tags []Tag }
ListMember represents some basic data about a member of a list.
type ListMemberManager ¶
type ListMemberManager interface { // ServiceName returns the underlying mailing list service (sendgrid, mailchimp, etc.) ServiceName() string // GetListMember returns this member of the given list GetListMember(listID string, email string) (*ListMember, error) // IsSubscribedToList checks if email is subscribed to the given list IsSubscribedToList(listID string, email string) (bool, error) // SubscribeToList subscribes the email to a given list using the params SubscribeToList(listID string, email string, params *SubscriptionParams) error // UnsubscribeFromList unsubscribes the email from the given list. If delete // flag is true, will permanently delete from list. UnsubscribeFromList(listID string, email string, delete bool) error }
ListMemberManager is an interface that represents a service that manages email lists consisting of members. This
type MailchimpAPI ¶
type MailchimpAPI struct {
// contains filtered or unexported fields
}
MailchimpAPI is a wrapper around the MailChimp API. Uses the gochimp lib.
func NewMailchimpAPI ¶
func NewMailchimpAPI(apiKey string) *MailchimpAPI
NewMailchimpAPI is a convenience function to instantiate a new MailChimpAPI struct
func (*MailchimpAPI) GetListMember ¶
func (m *MailchimpAPI) GetListMember(listID string, email string) (*ListMember, error)
GetListMember returns a Mailchimp mailing list member
func (*MailchimpAPI) IsSubscribedToList ¶
func (m *MailchimpAPI) IsSubscribedToList(listID string, email string) (bool, error)
IsSubscribedToList returns true if an email is subscribed on a specified list
func (*MailchimpAPI) ServiceName ¶
func (m *MailchimpAPI) ServiceName() string
ServiceName returns the underlying mailing list service
func (*MailchimpAPI) SubscribeToList ¶
func (m *MailchimpAPI) SubscribeToList(listID string, email string, params *SubscriptionParams) error
SubscribeToList adds an email address to a specified list. Only adds tags on creation, not re-subscribes
func (*MailchimpAPI) UnsubscribeFromList ¶
func (m *MailchimpAPI) UnsubscribeFromList(listID string, email string, delete bool) error
UnsubscribeFromList unsubscribes an email address from a specified list. The delete flag will completely delete it from a list.
type Member ¶
type Member struct { ID string `json:"id"` EmailAddress string `json:"email_address"` UniqueEmailID string `json:"unique_email_id"` EmailType members.EmailType `json:"email_type,omitempty"` Status members.Status `json:"status"` MergeFields map[string]interface{} `json:"merge_fields,omitempty"` Interests map[string]bool `json:"interests,omitempty"` Stats *members.Stats `json:"stats,omitempty"` IPSignup string `json:"ip_signup,omitempty"` TimestampSignup time.Time `json:"timestamp_signup,omitempty"` IPOpt string `json:"ip_opt,omitempty"` TimestampOpt time.Time `json:"timestamp_opt,omitempty"` MemberRating uint8 `json:"member_rating,omitempty"` LastChanged time.Time `json:"last_changed,omitempty"` Language string `json:"language,omitempty"` VIP bool `json:"vip,omitempty"` EmailClient string `json:"email_client,omitempty"` Location *members.Location `json:"location,omitempty"` LastNote *members.Note `json:"last_note,omitempty"` ListID string `json:"list_id"` Tags []*MemberTag `json:"tags,omitempty"` }
Member defines a single member within a list that adds a field for tags
type NewMemberParams ¶
type NewMemberParams struct { EmailType members.EmailType `json:"email_type,omitempty"` Status members.Status `json:"status"` MergeFields map[string]interface{} `json:"merge_fields,omitempty"` Interests map[string]bool `json:"interests,omitempty"` Language string `json:"language,omitempty"` VIP bool `json:"vip,omitempty"` Location *members.Location `json:"location,omitempty"` IPSignup string `json:"ip_signup,omitempty"` TimestampSignup time.Time `json:"timestamp_signup,omitempty"` IPOpt string `json:"ip_opt,omitempty"` TimestampOpt time.Time `json:"timestamp_opt,omitempty"` EmailAddress string `json:"email_address"` Tags []MailchimpTag `json:"tags,omitempty"` }
NewMemberParams is a version of NewParams that adds a tags field
func (*NewMemberParams) MarshalJSON ¶
func (np *NewMemberParams) MarshalJSON() ([]byte, error)
MarshalJSON handles custom JSON marshalling for the NewMembersParams object. Added here to correct the invalid timestamp format issue.
type SendEmailRequest ¶
type SendEmailRequest struct { ToName string ToEmail string FromName string FromEmail string Subject string Text string HTML string }
SendEmailRequest provides all the parameters to SendEmail to deliver an email.
type SendTemplateEmailRequest ¶
type SendTemplateEmailRequest struct { ToName string ToEmail string FromName string FromEmail string TemplateID string TemplateData TemplateData AsmGroupID int }
SendTemplateEmailRequest provides all the parameters to SendTemplateEmail to deliver an templated email.
type SubscriptionParams ¶
type SubscriptionParams struct {
Tags []Tag
}
SubscriptionParams is any data can be passed along for a subscription
type TemplateData ¶
type TemplateData map[string]interface{}
TemplateData represents the key-value data for the template