Documentation ¶
Index ¶
- Variables
- type APIError
- type BadHTTPResponseError
- type Client
- func (c *Client) CreateEvent(ctx context.Context, e *event.NewEvent, ID string, metricName string) error
- func (c *Client) CreateProfile(ctx context.Context, p *profile.NewProfile) (*profile.ExistingProfile, error)
- func (c *Client) GetEvents(ctx context.Context, params ...getprofiles.Param) ([]*event.ExistingEvent, error)
- func (c *Client) GetProfile(ctx context.Context, profileID string) (*profile.ExistingProfile, error)
- func (c *Client) GetProfiles(ctx context.Context, params ...getprofiles.Param) ([]*profile.ExistingProfile, error)
- func (c *Client) UpdateProfile(ctx context.Context, profileID string, updaters ...updater.Profile) (*profile.ExistingProfile, error)
- type ErrProfileAlreadyExists
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidAPIKey indicates that the provided Klaviyo API key is either not specified or invalid. ErrInvalidAPIKey = errors.New("klaviyo: invalid or missing API key") // ErrTooManyRequests is returned by the client method when the endpoint is retried // the maximum number of times defined by defaultRetryMax and still fails. ErrTooManyRequests = errors.New("klaviyo: too many requests for calling endpoint") // ErrProfileDoesNotExist indicates that an attempt was made to retrieve a profile // that does not exist in Klaviyo. ErrProfileDoesNotExist = errors.New("klaviyo: a profile does not exist") )
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { Id string `json:"id"` Status int `json:"status"` Code string `json:"code"` Title string `json:"title"` Detail string `json:"detail"` Source struct { Pointer string `json:"pointer"` } `json:"source"` Meta struct { DuplicateProfileID string `json:"duplicate_profile_id,omitempty"` } `json:"meta,omitempty"` }
APIError represents an error returned by the Klaviyo API.
type BadHTTPResponseError ¶
type BadHTTPResponseError struct {
// contains filtered or unexported fields
}
BadHTTPResponseError represents an error due to a bad HTTP response.
func (*BadHTTPResponseError) Body ¶
func (e *BadHTTPResponseError) Body() []byte
Body returns the body of the HTTP response.
func (*BadHTTPResponseError) Cause ¶
func (e *BadHTTPResponseError) Cause() error
Cause returns the underlying cause of the error.
func (*BadHTTPResponseError) Error ¶
func (e *BadHTTPResponseError) Error() string
Error returns a human-readable representation of the BadHTTPResponseError.
func (*BadHTTPResponseError) StatusCode ¶
func (e *BadHTTPResponseError) StatusCode() int
StatusCode returns the HTTP status code of the response.
func (*BadHTTPResponseError) Unwrap ¶
func (e *BadHTTPResponseError) Unwrap() error
Unwrap provides compatibility for Go's errors.Is() and errors.As() functions.
type Client ¶
type Client struct { APIKey string // contains filtered or unexported fields }
Client represents a Klaviyo client with methods to interact with the Klaviyo API.
func NewWithClient ¶
NewWithClient initializes a new Klaviyo client with a custom http client.
func (*Client) CreateEvent ¶ added in v0.0.5
func (c *Client) CreateEvent(ctx context.Context, e *event.NewEvent, ID string, metricName string) error
CreateEvent creates a new event in Klaviyo.
func (*Client) CreateProfile ¶
func (c *Client) CreateProfile(ctx context.Context, p *profile.NewProfile) (*profile.ExistingProfile, error)
CreateProfile creates a new profile in Klaviyo. If a profile with the same identifiers already exists, it will return ErrProfileAlreadyExists.
func (*Client) GetEvents ¶ added in v0.0.5
func (c *Client) GetEvents(ctx context.Context, params ...getprofiles.Param) ([]*event.ExistingEvent, error)
GetEvents retrieves a list of created events from Klaviyo.
func (*Client) GetProfile ¶
func (c *Client) GetProfile(ctx context.Context, profileID string) (*profile.ExistingProfile, error)
GetProfile retrieves a specific profile by its ID from Klaviyo. If the profile with the given ID does not exist, it will return ErrProfileDoesNotExist.
func (*Client) GetProfiles ¶
func (c *Client) GetProfiles(ctx context.Context, params ...getprofiles.Param) ([]*profile.ExistingProfile, error)
GetProfiles retrieves a list of created profiles from Klaviyo.
type ErrProfileAlreadyExists ¶
type ErrProfileAlreadyExists struct {
DuplicateProfileID string
}
ErrProfileAlreadyExists indicates that an attempt was made to create a profile that already exists in Klaviyo. It holds the ID of the duplicate profile.
func (*ErrProfileAlreadyExists) Error ¶ added in v0.0.2
func (e *ErrProfileAlreadyExists) Error() string
Error returns a string representation of the ErrProfileAlreadyExists error. It conforms to the error interface.