Documentation
¶
Index ¶
- Variables
- func CleanParams(values url.Values)
- func ValidateParams(values url.Values, required []string) error
- type ActionParams
- type Brand
- type Client
- func (c *Client) Call(endpoint string, params url.Values, required []string) (*http.Response, error)
- func (c *Client) CreateCampaign(p CreateCampaignParams) (string, error)
- func (c *Client) DeleteSubscriber(p ActionParams) error
- func (c *Client) GetBrands() ([]Brand, error)
- func (c *Client) GetLists(p GetListsParams) ([]List, error)
- func (c *Client) SetClient(newClient httpClient)
- func (c *Client) Subscribe(p SusbcribeParams) error
- func (c *Client) SubscriberCount(p ActionParams) (string, error)
- func (c *Client) SubscriptionStatus(p ActionParams) (string, error)
- func (c *Client) Unsubscribe(p UnsusbcribeParams) error
- type CreateCampaignParams
- type GetListsParams
- type List
- type SusbcribeParams
- type UnsusbcribeParams
Constants ¶
This section is empty.
Variables ¶
ErrAPIResponse APIError generic error type
ErrParamsMissing is raised when the required params are missing
Functions ¶
Types ¶
type ActionParams ¶
ActionParams is aimed to perform actions over already registered email like subscription_status, delete and subscriber_count
Email: user's email List: the list id you want to subscribe a user to
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines the API host, API Key and the http Client to use, by default it is a http.Client instance, but you can change it using the SetDefault method
func NewClient ¶
NewClient return a new Client "instance"
func (*Client) Call ¶
func (c *Client) Call(endpoint string, params url.Values, required []string) (*http.Response, error)
Call is a simple wrapper for client logic. It is used internally by all the endpoint func and get the request params and return a http.Response or an error. The params are: endpoind: API endpoint params: a url.Values map of the EP params required: a string slice with the required params for this EP
func (*Client) CreateCampaign ¶
func (c *Client) CreateCampaign(p CreateCampaignParams) (string, error)
CreateCampaign endpoint. If succes it returns a string describing the action. It might be `Campaign created`, `Campaign created and now sending` or `Campaign scheduled`. Otherwise it returns an error. It reicives as params a CreateCampaignParams struct. The following fields are required FromName, FromEmail, ReplyTo, Title, Subject, HTMLText, TraskOpens, TrackClicks, ScheduleDateTime, ScheduleTimeZone.
func (*Client) DeleteSubscriber ¶
func (c *Client) DeleteSubscriber(p ActionParams) error
DeleteSubscriber endpoint. It returns an error or nil if the request was sucessful It reicives as params a ActionParams struct where Email and List are required.
func (*Client) GetBrands ¶
GetBrands endpoint. If succeed returns a slice of Brand Otherwhise it returns an error
func (*Client) GetLists ¶
func (c *Client) GetLists(p GetListsParams) ([]List, error)
GetLists endpoint. If succeed returns an slice of List Otherwhise it returns an error
Params BrandID: the id of the brand you want to get the list of lists from. IncludeHidden (optional): if you want to retrieve lists that are hidden as well, set this to yes. Default is no.
func (*Client) SetClient ¶
func (c *Client) SetClient(newClient httpClient)
SetClient changes the http Client used for sending requests to the API Changing this might be useful for test purposes or using a proxy. By default it is an instance of http.Client. The new client must fulfill the `httpClient` interface that implements a PostForm func
func (*Client) Subscribe ¶
func (c *Client) Subscribe(p SusbcribeParams) error
Subscribe endpoint. It returns an error or nil if the request was sucessful It reicives as params a SubscribeParam struct where Email and List are required. Optional fields are: Name, Country, IPAddress, Referrer, Silent, GDPR and HP
func (*Client) SubscriberCount ¶
func (c *Client) SubscriberCount(p ActionParams) (string, error)
SubscriberCount endpoint. If success it returns a string describing the subscriber number, otherwise an error. It reicives as params a ActionParams struct where List is required
func (*Client) SubscriptionStatus ¶
func (c *Client) SubscriptionStatus(p ActionParams) (string, error)
SubscriptionStatus endpoint. If success it returns a string describing the status, otherwise an error. Status might be `Subscribed`, `Unsubscribed`, `Unconfirmed`, `Bounced`, `Soft bounced` or `Complained` It reicives as params a ActionParams struct where Email and List are required.
func (*Client) Unsubscribe ¶
func (c *Client) Unsubscribe(p UnsusbcribeParams) error
Unsubscribe endpoint. It returns an error or nil if the request was sucessful It reicives as params a UnsusbcribeParams struct where Email and List are required.
type CreateCampaignParams ¶
type CreateCampaignParams struct { FromName string FromEmail string ReplyTo string Title string Subject string PlainText string HTMLText string ListIDS string BrandID string QueryString string SendCampaign int64 SegmentIDS string ExcludeListIDS string ExcludeSegmentsIDS string TrackOpens int64 TrackClicks int64 ScheduleDateTime string ScheduleTimeZone string }
CreateCampaignParams ...
FormName: the 'From name' of your campaign FromEmail: the 'From email' of your campaign ReplyTo: the 'Reply to' of your campaign Title: the 'Title' of your campaign Subject: the 'Subject' of your campaign PlainText: the 'Plain text version' of your campaign (optional) HTMLText: the 'HTML version' of your campaign ListIDS: Required only if you set SendCampaign to 1 and no SegmentIDS are passed in. List IDs should be single or comma-separated. SegmentIDS: Required only if you set send_campaign to 1 and no list_ids are passed in. Segment IDs should be single or comma-separated. ExcludeList: ids Lists to exclude from your campaign. List IDs should be single or comma-separated.(optional) ExcludeSegmentsIDS: Segments to exclude from your campaign. Segment IDs should be single or comma-separated. (optional) BrandID: Required only if you are creating a 'Draft' campaign QueryString: eg. Google Analytics tags (optional) TrackOpens: Set to 0 to disable, 1 to enable and 2 for anonymous opens tracking. TrackClicks: Set to 0 to disable, 1 to enable and 2 for anonymous clicks tracking. SendCampaign: Set to 1 if you want to send the campaign as well and not just create a draft. Default is 0. ScheduleDateTime: Campaign will be scheduled if a valid date/time is passed. Date/time format. eg. June 15, 2021 6:05pm. ScheduleTimeZone: Eg. 'America/New_York'.
type GetListsParams ¶
GetListsParams ...
BrandID: the id of the brand you want to get the list of lists from. IncludeHidden: if you want to retrieve lists that are hidden as well, set this to yes. Default is no.
type SusbcribeParams ¶
type SusbcribeParams struct { List string Email string Name string Country string IPAddress string Referrer string Silent bool GDPR bool HP string }
SusbcribeParams ...
Email: user's email List: the list id you want to subscribe a user to Name: user's name (optional) Country: user's 2 letter country code (optional) IPAddress: user's IP address (optional) Referrer: the URL where the user signed up from (optional) GDPR: if you're signing up EU users in a GDPR compliant manner, set this to "true" (optional) Silent: set to true if your list is 'Double opt-in' but you want to bypass that and signup the user to the list as 'Single Opt-in instead' (optional) HP: include this 'honeypot' field to prevent spambots from signing up via this API call. (optional)