Documentation ¶
Index ¶
- Constants
- Variables
- func NewDevice(deviceID, platform string, data map[string]interface{}) (*deviceV2, error)
- func WithHTTPClient(client *http.Client) option
- func WithRegion(r region) option
- func WithUserAgent(ua string) option
- type APIClient
- type CustomerIO
- func (c *CustomerIO) AddDevice(customerID string, deviceID string, platform string, ...) error
- func (c *CustomerIO) AddDeviceCtx(ctx context.Context, customerID string, deviceID string, platform string, ...) error
- func (c *CustomerIO) Delete(customerID string) error
- func (c *CustomerIO) DeleteCtx(ctx context.Context, customerID string) error
- func (c *CustomerIO) DeleteDevice(customerID string, deviceID string) error
- func (c *CustomerIO) DeleteDeviceCtx(ctx context.Context, customerID string, deviceID string) error
- func (c *CustomerIO) Identify(customerID string, attributes map[string]interface{}) error
- func (c *CustomerIO) IdentifyCtx(ctx context.Context, customerID string, attributes map[string]interface{}) error
- func (c *CustomerIO) MergeCustomers(primary Identifier, secondary Identifier) error
- func (c *CustomerIO) MergeCustomersCtx(ctx context.Context, primary Identifier, secondary Identifier) error
- func (c *CustomerIO) Track(customerID string, eventName string, data map[string]interface{}) error
- func (c *CustomerIO) TrackAnonymous(anonymousID, eventName string, data map[string]interface{}) error
- func (c *CustomerIO) TrackAnonymousCtx(ctx context.Context, anonymousID, eventName string, ...) error
- func (c *CustomerIO) TrackCtx(ctx context.Context, customerID string, eventName string, ...) error
- type CustomerIOError
- type Identifier
- type IdentifierType
- type ParamError
- type SendEmailRequest
- type SendEmailResponse
- type SendPushRequest
- type SendPushResponse
- type TransactionalError
- type TransactionalResponse
- type TransactionalType
Constants ¶
const ( TransactionalTypeEmail = 0 TransactionalTypePush = 1 )
const DefaultUserAgent = "Customer.io Go Client/" + Version
const Version = "3.5.0"
Variables ¶
var ( RegionUS = region{ ApiURL: "https://api.customer.io", TrackURL: "https://track.customer.io", } RegionEU = region{ ApiURL: "https://api-eu.customer.io", TrackURL: "https://track-eu.customer.io", } )
var ErrAttachmentExists = errors.New("attachment with this name already exists")
var ErrInvalidTransactionalMessageType = errors.New("unknown transactional message type")
Functions ¶
func WithHTTPClient ¶
func WithRegion ¶
func WithRegion(r region) option
func WithUserAgent ¶ added in v3.3.0
func WithUserAgent(ua string) option
Types ¶
type APIClient ¶
func NewAPIClient ¶
NewAPIClient prepares a client for use with the Customer.io API, see: https://customer.io/docs/api/#apicoreintroduction using an App API Key from https://fly.customer.io/settings/api_credentials?keyType=app
func (*APIClient) SendEmail ¶
func (c *APIClient) SendEmail(ctx context.Context, req *SendEmailRequest) (*SendEmailResponse, error)
SendEmail sends a single transactional email using the Customer.io transactional API
func (*APIClient) SendPush ¶ added in v3.5.1
func (c *APIClient) SendPush(ctx context.Context, req *SendPushRequest) (*SendPushResponse, error)
SendPush sends a single transactional push using the Customer.io transactional API
type CustomerIO ¶
type CustomerIO struct { URL string UserAgent string Client *http.Client // contains filtered or unexported fields }
CustomerIO wraps the customer.io track API, see: https://customer.io/docs/api/#apitrackintroduction
func NewCustomerIO ¶
func NewCustomerIO(siteID, apiKey string) *CustomerIO
NewCustomerIO prepares a client for use with the Customer.io track API, see: https://customer.io/docs/api/#apitrackintroduction deprecated in favour of NewTrackClient
func NewTrackClient ¶
func NewTrackClient(siteID, apiKey string, opts ...option) *CustomerIO
NewTrackClient prepares a client for use with the Customer.io track API, see: https://customer.io/docs/api/#apitrackintroduction using a Tracking Site ID and API Key pair from https://fly.customer.io/settings/api_credentials
func (*CustomerIO) AddDevice ¶
func (c *CustomerIO) AddDevice(customerID string, deviceID string, platform string, data map[string]interface{}) error
AddDevice adds a device for a customer
func (*CustomerIO) AddDeviceCtx ¶ added in v3.3.0
func (c *CustomerIO) AddDeviceCtx(ctx context.Context, customerID string, deviceID string, platform string, data map[string]interface{}) error
AddDeviceCtx adds a device for a customer
func (*CustomerIO) Delete ¶
func (c *CustomerIO) Delete(customerID string) error
Delete deletes a customer
func (*CustomerIO) DeleteCtx ¶ added in v3.3.0
func (c *CustomerIO) DeleteCtx(ctx context.Context, customerID string) error
DeleteCtx deletes a customer
func (*CustomerIO) DeleteDevice ¶
func (c *CustomerIO) DeleteDevice(customerID string, deviceID string) error
DeleteDevice deletes a device for a customer
func (*CustomerIO) DeleteDeviceCtx ¶ added in v3.3.0
DeleteDeviceCtx deletes a device for a customer
func (*CustomerIO) Identify ¶
func (c *CustomerIO) Identify(customerID string, attributes map[string]interface{}) error
Identify identifies a customer and sets their attributes
func (*CustomerIO) IdentifyCtx ¶ added in v3.3.0
func (c *CustomerIO) IdentifyCtx(ctx context.Context, customerID string, attributes map[string]interface{}) error
IdentifyCtx identifies a customer and sets their attributes
func (*CustomerIO) MergeCustomers ¶
func (c *CustomerIO) MergeCustomers(primary Identifier, secondary Identifier) error
MergeCustomers sends a request to Customer.io to merge two customer profiles together.
func (*CustomerIO) MergeCustomersCtx ¶ added in v3.3.0
func (c *CustomerIO) MergeCustomersCtx(ctx context.Context, primary Identifier, secondary Identifier) error
MergeCustomersCtx sends a request to Customer.io to merge two customer profiles together.
func (*CustomerIO) Track ¶
func (c *CustomerIO) Track(customerID string, eventName string, data map[string]interface{}) error
Track sends a single event to Customer.io for the supplied user
func (*CustomerIO) TrackAnonymous ¶
func (c *CustomerIO) TrackAnonymous(anonymousID, eventName string, data map[string]interface{}) error
TrackAnonymous sends a single event to Customer.io for the anonymous user
func (*CustomerIO) TrackAnonymousCtx ¶ added in v3.3.0
func (c *CustomerIO) TrackAnonymousCtx(ctx context.Context, anonymousID, eventName string, data map[string]interface{}) error
TrackAnonymousCtx sends a single event to Customer.io for the anonymous user
type CustomerIOError ¶
type CustomerIOError struct {
// contains filtered or unexported fields
}
CustomerIOError is returned by any method that fails at the API level
func (*CustomerIOError) Error ¶
func (e *CustomerIOError) Error() string
type Identifier ¶
type Identifier struct { Type IdentifierType Value string }
type IdentifierType ¶
type IdentifierType string
const ( IdentifierTypeID IdentifierType = "id" IdentifierTypeEmail IdentifierType = "email" IdentifierTypeCioID IdentifierType = "cio_id" )
type ParamError ¶
type ParamError struct {
Param string // Param is the name of the parameter.
}
ParamError is an error returned if a parameter to the track API is invalid.
func (ParamError) Error ¶
func (e ParamError) Error() string
type SendEmailRequest ¶
type SendEmailRequest struct { MessageData map[string]interface{} `json:"message_data,omitempty"` TransactionalMessageID string `json:"transactional_message_id,omitempty"` Identifiers map[string]string `json:"identifiers"` Headers map[string]string `json:"headers,omitempty"` From string `json:"from,omitempty"` To string `json:"to,omitempty"` ReplyTo string `json:"reply_to,omitempty"` BCC string `json:"bcc,omitempty"` Subject string `json:"subject,omitempty"` Preheader string `json:"preheader,omitempty"` Body string `json:"body,omitempty"` PlaintextBody string `json:"body_plain,omitempty"` AMPBody string `json:"body_amp,omitempty"` FakeBCC *bool `json:"fake_bcc,omitempty"` Attachments map[string]string `json:"attachments,omitempty"` DisableMessageRetention *bool `json:"disable_message_retention,omitempty"` SendToUnsubscribed *bool `json:"send_to_unsubscribed,omitempty"` EnableTracking *bool `json:"tracked,omitempty"` QueueDraft *bool `json:"queue_draft,omitempty"` DisableCSSPreprocessing *bool `json:"disable_css_preprocessing,omitempty"` SendAt *int64 `json:"send_at,omitempty"` Language *string `json:"language,omitempty"` }
type SendEmailResponse ¶
type SendEmailResponse struct {
TransactionalResponse
}
type SendPushRequest ¶ added in v3.5.1
type SendPushRequest struct { MessageData map[string]interface{} `json:"message_data,omitempty"` TransactionalMessageID string `json:"transactional_message_id,omitempty"` Identifiers map[string]string `json:"identifiers"` To string `json:"to,omitempty"` DisableMessageRetention *bool `json:"disable_message_retention,omitempty"` SendToUnsubscribed *bool `json:"send_to_unsubscribed,omitempty"` QueueDraft *bool `json:"queue_draft,omitempty"` SendAt *int64 `json:"send_at,omitempty"` Language *string `json:"language,omitempty"` Title string `json:"title,omitempty"` Message string `json:"message,omitempty"` ImageURL string `json:"image_url,omitempty"` Link string `json:"link,omitempty"` CustomData json.RawMessage `json:"custom_data,omitempty"` CustomPayload json.RawMessage `json:"custom_payload,omitempty"` Device *deviceV2 `json:"custom_device,omitempty"` Sound string `json:"sound,omitempty"` }
type SendPushResponse ¶ added in v3.5.1
type SendPushResponse struct {
TransactionalResponse
}
type TransactionalError ¶
type TransactionalError struct { // Err is a more specific error message. Err string // StatusCode is the http status code for the error. StatusCode int }
TransactionalError is returned if a transactional message fails to send.
func (*TransactionalError) Error ¶
func (e *TransactionalError) Error() string
type TransactionalResponse ¶
type TransactionalResponse struct { // DeliveryID is a unique id for the given message. DeliveryID string `json:"delivery_id"` // QueuedAt is when the message was queued. QueuedAt time.Time `json:"queued_at"` }
TransactionalResponse is a response to the send of a transactional message.
func (*TransactionalResponse) UnmarshalJSON ¶
func (t *TransactionalResponse) UnmarshalJSON(b []byte) error
type TransactionalType ¶ added in v3.5.1
type TransactionalType int