Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type Attributes
- type BadResponseError
- type Client
- func (c *Client) GetPerson(personId string) (*Person, error)
- func (c *Client) Identify(person *Person) error
- func (c *Client) IdentifySafe(person *Person, omit bool) error
- func (c *Client) InList(listId string, emails, phoneNumbers, pushTokens []string) ([]ListPerson, error)
- func (c *Client) Subscribe(listId string, emails, phoneNumbers []string) ([]ListPerson, error)
- func (c *Client) Unsubscribe(listId string, emails, phoneNumbers, pushTokens []string) error
- func (c *Client) UpdatePerson(person *Person) error
- type KFloat
- type KInt
- type ListPerson
- type Object
- type Person
Constants ¶
const ( ConsentEmail = "email" ConsentWeb = "web" ConsentSMS = "sms" ConsentDirect = "directmail" ConsentMobile = "mobile" // Use these instead of the MIME library because this is what is specified in their documentation. ContentNone = "" ContentHTML = "text/html" ContentHTMLUTF8 = "text/html; charset=utf-8" ContentJSON = "application/json" // They have multiple endpoints unfortunately. Endpoint = "https://a.klaviyo.com/api" EndpointV1 = "https://a.klaviyo.com/api/v1" EndpointV2 = "https://a.klaviyo.com/api/v2" )
Variables ¶
var ( ErrNoPublicKey = errors.New("missing public key") ErrNoPrivateKey = errors.New("missing private key") ErrNoProfileIdentifier = errors.New("there is no unique profile identifier, must have email or phone number") ErrFailed = errors.New("request successful, call failed") ErrInvalidOutArg = errors.New("out arg provided does not match datatype of response") )
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type Attributes ¶
type Attributes map[string]interface{}
func (Attributes) ParseBool ¶
func (a Attributes) ParseBool(key string) bool
type BadResponseError ¶
func (*BadResponseError) Error ¶
func (e *BadResponseError) Error() string
type Client ¶
type Client struct {
// Sometimes called "token"
PublicKey string
// Sometimes seen as "api_key"
PrivateKey string
// The amount of time an HTTP API call should run for before it times out.
DefaultTimeout time.Duration
}
func (*Client) GetPerson ¶
https://apidocs.klaviyo.com/reference/profiles#get-profile GET https://a.klaviyo.com/api/v1/person/person_id
func (*Client) Identify ¶
https://apidocs.klaviyo.com/reference/track-identify#identify GET https://a.klaviyo.com/api/identify TODO Update Identify to use POST method version as GET is outdated
func (*Client) IdentifySafe ¶
Use this if you do not want to send values that are not set. This is great for when you want to update a Person without first fetching their information. This will happen if you only have thier email and no Klaviyo Id to utilize.
func (*Client) InList ¶
func (c *Client) InList(listId string, emails, phoneNumbers, pushTokens []string) ([]ListPerson, error)
https://apidocs.klaviyo.com/reference/lists-segments#list-membership GET https://a.klaviyo.com/api/v2/list/list_id/members
func (*Client) Subscribe ¶
func (c *Client) Subscribe(listId string, emails, phoneNumbers []string) ([]ListPerson, error)
https://apidocs.klaviyo.com/reference/lists-segments#subscribe POST https://a.klaviyo.com/api/v2/list/list_id/subscribe
func (*Client) Unsubscribe ¶
https://apidocs.klaviyo.com/reference/lists-segments#unsubscribe DELETE https://a.klaviyo.com/api/v2/list/list_id/subscribe
func (*Client) UpdatePerson ¶
https://apidocs.klaviyo.com/reference/profiles#update-profile PUT https://a.klaviyo.com/api/v1/person/person_id Only works to update a persons attributes after they have been identified.
type KFloat ¶
type KFloat float64
KFloat implements the UnmarshalJSON interface to do special processing for Klaviyo. In certain instances (such as when a number field is empty), klaviyo will return the value as a string. Otherwise, it will return the value as a number.
func (*KFloat) UnmarshalJSON ¶
type KInt ¶
type KInt int
KInt implements the UnmarshalJSON interface to do special processing for Klaviyo. In certain instances (such as when a number field is empty), klaviyo will return the value as a string. Otherwise, it will return the value as a number.
func (*KInt) UnmarshalJSON ¶
type ListPerson ¶
type Object ¶
All objects in Klaviyo use this basic structure to identify what kind of object it is and how to identify it.
type Person ¶
type Person struct {
Object
// Below are special fields used by Klaviyo, they will be render in special UI for fancy-ness
// they are identified by the $ prefix in their JSON.
// Please read here for more: https://help.klaviyo.com/hc/en-us/articles/115005084927-Template-Tags-and-Variable-Syntax#klaviyo-special-properties18
//
// Any extra attributes appear in the same flat structure but we store them in Attributes below.
CustomId string `json:"$id"`
Address1 string `json:"$address1"`
Address2 string `json:"$address2"`
City string `json:"$city"`
Consent []string `json:"$consent"`
Country string `json:"$country"`
Email string `json:"$email"`
FirstName string `json:"$first_name"`
Image string `json:"$image"`
LastName string `json:"$last_name"`
Latitude KFloat `json:"$latitude"`
Longitude KFloat `json:"$longitude"`
Organization string `json:"$organization"`
PhoneNumber string `json:"$phone_number"`
Region string `json:"$region"`
Source KInt `json:"$source"`
Timezone string `json:"$timezone"`
Title string `json:"$title"`
Zip string `json:"$zip"`
// Use these to have custom attributes tied to a user that can be used to create segments for lists.
Attributes Attributes
}
func (*Person) HasProfileIdentifier ¶
A profile identifier is an email or phone number. In the case of SMS they must have a phone number.