drip

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: MIT Imports: 9 Imported by: 0

README

drip-go

Wrapper for the Drip API https://www.getdrip.com/docs/rest-api

godoc

Example

dripClient, err := drip.New("DRIP_API_KEY", "DRIP_ACCOUNT_ID")
if err != nil {
    ...
}
req := &drip.ListSubscribersReq{}
resp, err := dripClient.ListSubscribers(req)
if err != nil {
    ...
}
if len(resp.Errors) > 0 {
    ... // resp.Errors has Drip API errors. https://www.getdrip.com/docs/rest-api#errors
}

// resp.Subscribers has list of subscribers

Look at test for more examples.

Contributions

Please feel free to add a pull request for any feature not available. Pull requests should include test.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadAPIKey is returned by New if bad api key.
	ErrBadAPIKey = fmt.Errorf("bad api key")
	// ErrBadAccountID is returned by New if bad account ID.
	ErrBadAccountID = fmt.Errorf("bad drip account id")
	// ErrIDorEmailEmpty is returned if id and email are both empty.
	ErrIDorEmailEmpty = fmt.Errorf("ID and Email both cannot be empty")
	// ErrInvalidInput is returned if input is invalid.
	ErrInvalidInput = fmt.Errorf("invalid input")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTPClient *http.Client
	UserAgent  string
	// contains filtered or unexported fields
}

Client is a client to interact with the Drip API. Use https://www.getdrip.com/docs/rest-api for extra documentation.

func New

func New(apiKey, accountID string) (*Client, error)

New returns a new Client.

func (*Client) DeleteSubscriber

func (c *Client) DeleteSubscriber(idOrEmail string) (*Response, error)

DeleteSubscriber deletes a subscriber.

func (*Client) FetchSubscriber

func (c *Client) FetchSubscriber(idOrEmail string) (*SubscribersResp, error)

FetchSubscriber fetches a subscriber.

func (*Client) ListSubscribers

func (c *Client) ListSubscribers(req *ListSubscribersReq) (*SubscribersResp, error)

ListSubscribers returns a list of subscribers. Either an ID or Email can

func (Client) RecordEvent added in v0.0.6

func (c Client) RecordEvent(email, eventName string, properties map[string]interface{}) (*Response, error)

RecordEvent sends a custom event to Drip

func (*Client) RemoveSubscriberTag

func (c *Client) RemoveSubscriberTag(req *TagReq) (*Response, error)

RemoveSubscriberTag adds a tag to a subscriber.

func (*Client) TagSubscriber

func (c *Client) TagSubscriber(req *TagsReq) (*Response, error)

TagSubscriber adds a tag to a subscriber.

func (*Client) UpdateBatchSubscribers

func (c *Client) UpdateBatchSubscribers(req *UpdateBatchSubscribersReq) (*SubscribersResp, error)

UpdateBatchSubscribers creates or updates a subscribers. We recommend using this API endpoint when you need to create or update a collection of subscribers at once. Note: Since our batch APIs process requests in the background, there may be a delay between the time you submit your request and the time your data appears in user interface.

func (*Client) UpdateSubscriber

func (c *Client) UpdateSubscriber(req *UpdateSubscribersReq) (*SubscribersResp, error)

UpdateSubscriber creates or updates a subscriber. If you need to create or update a collection of subscribers at once, use our batch API instead.

type Code

type Code string

Code is an Code returned with errors from the Drip API. https://www.getdrip.com/docs/rest-api#errors

const (
	// PresenceError means the attribute is required.
	PresenceError Code = "presence_error"
	// LengthError means the length of the attribute is out of bounds.
	LengthError Code = "length_error"
	// UniquenessError means the attribute must be unique.
	UniquenessError Code = "uniqueness_error"
	// EmailError means the attribute must be a valid email address.
	EmailError Code = "email_error"
	// URLError means the attribute must be a valid URL.
	URLError Code = "url_error"
	// DomainError means the attribute must be a valid domain name.
	DomainError Code = "domain_error"
	// TimeError means the attribute must be a valid time in ISO-8601 format.
	TimeError Code = "time_error"
	// EmailAddressListError means the attribute must be a valid comma-separated list of email addresses.
	EmailAddressListError Code = "email_address_list_error"
	// DaysOfTheWeekError means the attribute must be a valid days of the week mask of the format /\A(0|1){7}\z/ (excluding 0000000).
	DaysOfTheWeekError Code = "days_of_the_week_error"
	// UnavailableError means a resource has been disabled or deleted.
	UnavailableError Code = "unavailable_error"
	// FormatError means a resource identifier or object is not formatted correctly.
	FormatError Code = "format_error"
	// RangeError means a numeric value is out of range.
	RangeError Code = "range_error"
)

type CodeError

type CodeError struct {
	Code      string `json:"code"`
	Attribute string `json:"attribute"`
	Message   string `json:"message"`
}

CodeError is a error with a code. https://www.getdrip.com/docs/rest-api#errors

func (CodeError) Error

func (e CodeError) Error() string

Error returns the error message.

type Links struct {
	Account    string   `json:"account,omitempty"`
	Forms      []string `json:"forms,omitempty"`
	Subscriber string   `json:"subscriber,omitempty"`
}

Links are links send in responses.

type ListSubscribersReq

type ListSubscribersReq struct {
	Status           string     `url:"status,omitempty"`
	Tags             []string   `url:"tags,omitempty"`
	SubscribedBefore *time.Time `url:"subscribed_before,omitempty"`
	SubscribedAfter  *time.Time `url:"subscribed_after,omitempty"`
	Page             *int       `url:"page,omitempty"`
	PerPage          *int       `url:"per_page,omitempty"`
}

ListSubscribersReq is a request for ListSubscribers.

type Meta

type Meta struct {
	Page       int `json:"page,omitempty"`
	Count      int `json:"count,omitempty"`
	TotalPages int `json:"total_pages,omitempty"`
	TotalCount int `json:"total_count,omitempty"`
}

Meta is data related to pagination. https://www.getdrip.com/docs/rest-api#pagination

type Response

type Response struct {
	StatusCode int         `json:"status_code,omitempty"`
	Errors     []CodeError `json:"errors,omitempty"`
}

Response is a basic response recieved.

type Subscriber

type Subscriber struct {
	ID               string            `json:"id,omitempty"`
	Status           string            `json:"status,omitempty"`
	Email            string            `json:"email,omitempty"`
	TimeZone         string            `json:"time_zone,omitempty"`
	UTCOffset        int               `json:"utc_offset,omitempty"`
	VisitorUUID      string            `json:"visitor_uuid,omitempty"`
	CustomFields     map[string]string `json:"custom_fields,omitempty"`
	Tags             []string          `json:"tags,omitempty"`
	IPAddress        string            `json:"ip_address,omitempty"`
	UserAgent        string            `json:"user_agent,omitempty"`
	OriginalReferrer string            `json:"original_referrer,omitempty"`
	LandingURL       string            `json:"landing_url,omitempty"`
	Prospect         bool              `json:"prospect,omitempty"`
	LeadScore        int               `json:"lead_score,omitempty"`
	LifetimeValue    int               `json:"lifetime_value,omitempty"`
	CreatedAt        time.Time         `json:"created_at,omitempty"`
	HREF             string            `json:"href,omitempty"`
	UserID           string            `json:"user_id,omitempty"`
	BaseLeadScore    int               `json:"base_lead_score,omitempty"`
	Links            Links             `json:"links,omitempty"`
}

Subscriber is a subscriber.

type SubscribersBatch

type SubscribersBatch struct {
	Subscribers []UpdateSubscriber `json:"subscribers,omitempty"`
}

SubscribersBatch is a request for UpdateBatchSubscribers.

type SubscribersResp

type SubscribersResp struct {
	StatusCode  int           `json:"status_code,omitempty"`
	Links       Links         `json:"links,omitempty"`
	Meta        Meta          `json:"meta,omitempty"`
	Subscribers []*Subscriber `json:"subscribers,omitempty"`
	Errors      []CodeError   `json:"errors,omitempty"`
}

SubscribersResp is a response recieved with subscribers in it. List functions have Meta for pagination. StatusCode is included in resp.

type TagReq

type TagReq struct {
	Email string `json:"email,omitempty"`
	Tag   string `json:"tag,omitempty"`
}

TagReq is a part of a TagsReq.

type TagsReq

type TagsReq struct {
	Tags []TagReq `json:"tags,omitempty"`
}

TagsReq is a request for TagSubscription.

type UpdateBatchSubscribersReq

type UpdateBatchSubscribersReq struct {
	Batches []SubscribersBatch `json:"batches,omitempty"`
}

UpdateBatchSubscribersReq is a request for UpdateBatchSubscribers.

type UpdateSubscriber

type UpdateSubscriber struct {
	Email         string            `json:"email,omitempty"`
	Name          string            `json:"name,omitempty"`
	FirstName     string            `json:"first_name,omitempty"`
	LastName      string            `json:"last_name,omitempty"`
	ID            string            `json:"id,omitempty"`
	NewEmail      string            `json:"new_email,omitempty"`
	UserID        string            `json:"user_id,omitempty"`
	TimeZone      string            `json:"time_zone,omitempty"`
	LifetimeValue *float32          `json:"lifetime_value,omitempty"`
	IPAddress     string            `json:"ip_address,omitempty"`
	Country       string            `json:"country,omitempty"`
	City          string            `json:"city,omitempty"`
	State         string            `json:"state,omitempty"`
	Zip           string            `json:"zip,omitempty"`
	CustomFields  map[string]string `json:"custom_fields,omitempty"`
	Tags          []string          `json:"tags,omitempty"`
	RemoveTags    []string          `json:"remove_tags,omitempty"`
	Prospect      *bool             `json:"prospect,omitempty"`
	BaseLeadScore *int              `json:"base_lead_score,omitempty"`
}

UpdateSubscriber is the info available to update or create a subscriber.

type UpdateSubscribersReq

type UpdateSubscribersReq struct {
	Subscribers []UpdateSubscriber `json:"subscribers,omitempty"`
}

UpdateSubscribersReq is a request for UpdateSubscriber.

Jump to

Keyboard shortcuts

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