gochimp

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 8 Imported by: 1

README

gochimp

A Go library for interacting with the Mailchimp API.

Includes support for Mandrill.

Note: This is very much a work in progress! Currently only the features needed immediately by Ussie are implemented. Anything may change in the future. Use at your own risk!

Contributions, criticism and suggestions welcome.

Will also do our best to add features upon request. The goal is to evolve this into a full-fledged client.

Documentation

Index

Constants

View Source
const (
	Checkboxes CategoryType = "checkboxes"
	Dropdown                = "dropdown"
	Radio                   = "radio"
	Hidden                  = "hidden"
)
View Source
const (
	Subscribed          SubscriptionStatus = "subscribed"
	Unsubscribed                           = "unsubscribed"
	SubscriptionCleaned                    = "cleaned"
	SubscriptionPending                    = "pending"
)
View Source
const ENDPOINT string = "https://%s.api.mailchimp.com/3.0/%s"

Variables

This section is empty.

Functions

func EmailToHash

func EmailToHash(email string) string

Types

type Category

type Category struct {
	Id           string       `json:"id"`
	ListId       string       `json:"list_id"`
	Title        string       `json:"title"`
	DisplayOrder uint         `json:"display_order"`
	Type         CategoryType `json:"type"`
}

type CategoryType

type CategoryType string

type Client

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

func NewClient

func NewClient(key string) *Client

func (*Client) AddInterest

func (c *Client) AddInterest(listId, categoryId, interest *Interest) (*Interest, error)

func (*Client) AddMember

func (c *Client) AddMember(listId string, member *Member) (*Member, error)

func (*Client) Call

func (c *Client) Call(method string, endpoint string, data interface{}, results interface{}) error

func (*Client) CreateInterestCategory

func (c *Client) CreateInterestCategory(listId string, category *Category) (*Category, error)

func (*Client) CreateList

func (c *Client) CreateList(list *List) (List, error)

func (*Client) DeleteInterest

func (c *Client) DeleteInterest(listId, categoryId, id string) error

func (*Client) DeleteInterestCategory

func (c *Client) DeleteInterestCategory(listId, categoryId string) error

func (*Client) DeleteList

func (c *Client) DeleteList(listId string) error

func (*Client) DeleteMember

func (c *Client) DeleteMember(listId, emailHash string) error

func (*Client) Details

func (c *Client) Details() (Detail, error)

func (*Client) Interest

func (c *Client) Interest(listId, categoryId, id string) (Interest, error)

func (*Client) InterestCategories

func (c *Client) InterestCategories(listId string) ([]Category, error)

func (*Client) InterestCategory

func (c *Client) InterestCategory(listId, categoryId string) (Category, error)

func (*Client) Interests

func (c *Client) Interests(listId, categoryId string) ([]Interest, error)

func (*Client) List

func (c *Client) List(listId string) (List, error)

func (*Client) Lists

func (c *Client) Lists() ([]List, error)

func (*Client) Member

func (c *Client) Member(listId, emailHash string) (*Member, error)

func (*Client) Members

func (c *Client) Members(listId string) ([]*Member, error)

func (*Client) UpdateInterest

func (c *Client) UpdateInterest(listId, categoryId, interest *Interest) (*Interest, error)

func (*Client) UpdateInterestCategory

func (c *Client) UpdateInterestCategory(listId, categoryId string, category *Category) (*Category, error)

func (*Client) UpdateList

func (c *Client) UpdateList(list *List) (List, error)

func (*Client) UpdateMember

func (c *Client) UpdateMember(listId string, member *Member) (*Member, error)

func (*Client) UpsertMember

func (c *Client) UpsertMember(listId string, member *Member) (*Member, error)

type Contact

type Contact struct {
	Company  string `json:"company"`
	Address1 string `json:"address1"`
	Address2 string `json:"address2,omitempty"`
	City     string `json:"city"`
	State    string `json:"state"`
	Zip      string `json:"zip"`
	Country  string `json:"country"`
	Phone    string `json:"phone,omitempty"`
}

type Detail

type Detail struct {
	AccountId        string  `json:"account_id"`
	AccountName      string  `json:"account_name"`
	Contact          Contact `json:"contact"`
	LastLogin        string  `json:"last_login"`
	TotalSubscribers int64   `json:"total_subscribers"`
}

type EmailType

type EmailType string
const (
	HtmlEmail EmailType = "html"
	TextEmail           = "text"
)

type Interest

type Interest struct {
	Id           string `json:"id"`
	ListId       string `json:"list_id"`
	CategoryId   string `json:"category_id"`
	Name         string `json:"name"`
	DisplayOrder uint   `json:"display_order"`
}

type List

type List struct {
	Id                 string  `json:"id,omitempty"`
	Name               string  `json:"name"`
	Contact            Contact `json:"contact"`
	PermissionReminder string  `json:"permission_reminder"`
	UseArchiveBar      bool    `json:"use_archive_bar,omitempty"`
	CampaignDefaults   struct {
		FromName  string `json:"from_name"`
		FromEmail string `json:"from_email"`
		Subject   string `json:"subject"`
		Language  string `json:"language"`
	} `json:"campaign_defaults"`
	NotifyOnSubscribe   string           `json:"notify_on_subscribe,omitempty"`
	NotifyOnUnsubscribe string           `json:"notify_on_unsubscribe,omitempty"`
	DateCreated         string           `json:"date_created,omitempty"`
	ListRating          uint             `json:"list_rating,omitempty"`
	EmailTypeOption     bool             `json:"email_type_option"`
	SubscribeUrlShort   string           `json:"subscribe_url_short,omitempty"`
	SubscribeUrlLong    string           `json:"subscribe_url_long,omitempty"`
	BeamerAddress       string           `json:"beamer_address,omitempty"`
	Visibility          VisibilityStatus `json:"visibility,omitempty"`
	Modules             []string         `json:"modules,omitempty"`
	Stats               struct {
		MemberCount               uint64 `json:"member_count"`
		UnsubscribeCount          uint64 `json:"unsubscribe_count"`
		CleanedCount              uint64 `json:"cleaned_count"`
		MemberCountSinceSend      uint64 `json:"member_count_since_send"`
		UnsubscribeCountSinceSend uint64 `json:"unsubscribe_count_since_send"`
		CleanedCountSinceSend     uint64 `json:"cleaned_count_since_send"`
		CampaignCount             uint64 `json:"campaign_count"`

		CampaignLastSent string `json:"campaign_last_sent,omitempty"`

		MergeFieldCount int `json:"merge_field_count"`

		AvgSubRate    float32 `json:"avg_sub_rate"`
		AvgUnsubRate  float32 `json:"avg_unsub_rate"`
		TargetSubRate float32 `json:"target_sub_rate"`
		OpenRate      float32 `json:"open_rate"`
		ClickRate     float32 `json:"click_rate"`

		LastSubDate   string `json:"last_sub_date,omitempty"`
		LastUnsubDate string `json:"last_unsub_date,omitempty"`
	} `json:"stats,omitempty"`
}

type Member

type Member struct {
	Id            string                 `json:"id,omitempty"`
	EmailAddress  string                 `json:"email_address"`
	UniqueEmailId string                 `json:"unique_email_id,omitempty"`
	EmailType     EmailType              `json:"email_type,omitempty"`
	Status        SubscriptionStatus     `json:"status,omitempty"`
	StatusIfNew   SubscriptionStatus     `json:"status_if_new,omitempty"`
	MergeFields   map[string]interface{} `json:"merge_fields,omitempty"`
	Interests     map[string]bool        `json:"interests,omitempty"`
	Stats         struct {
		AvgOpenRate  float32 `json:"avg_open_rate,omitempty"`
		AvgClickRate float32 `json:"avg_click_rate,omitempty"`
	} `json:"stats,omitempty"`
	IpSignup        string `json:"ip_signup,omitempty"`
	TimestampSignup string `json:"timestamp_signup,omitempty"`
	IpOpt           string `json:"ip_opt,omitempty"`
	TimestampOpt    string `json:"timestamp_opt,omitempty"`
	MemberRating    uint   `json:"member_rating,omitempty"`
	LastChanged     string `json:"last_changed,omitempty"`
	Language        string `json:"language,omitempty"`
	Vip             bool   `json:"vip,omitempty"`
	EmailClient     string `json:"email_client,omitempty"`
	Location        struct {
		Lat         float64 `json:"latitude,omitempty"`
		Lon         float64 `json:"longitude,omitempty"`
		Gmtoff      int     `json:"gmtoff,omitempty"`
		Dstoff      int     `json:"dstoff,omitempty"`
		CountryCode string  `json:"country_code,omitempty"`
		Timezone    string  `json:"timezone,omitempty"`
	} `json:"location,omitempty"`
	LastNote struct {
		Id        string `json:"note_id,omitempty"`
		CreatedAt string `json:"created_at,omitempty"`
		CreatedBy string `json:"created_by,omitempty"`
		Note      string `json:"note,omitempty"`
	} `json:"last_note,omitempty"`
	ListId string `json:"list_id,omitempty"`
}

func NewMember

func NewMember(email string) *Member

func (*Member) SetInterest

func (m *Member) SetInterest(key string, val bool) *Member

func (*Member) SetMergeField

func (m *Member) SetMergeField(key string, val interface{}) *Member

type Message

type Message struct {
	FromName  string `json:"from_name"`
	FromEmail string `json:"from_email"`
	Subject   string `json:"subject"`
	Language  string `json:"language"`
}

FIXME merge with Mandrill Message

type SubscriptionStatus

type SubscriptionStatus string

type VisibilityStatus

type VisibilityStatus string
const (
	PublicVisibility  VisibilityStatus = "pub"
	PrivateVisibility                  = "prv"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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