Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrApiEndpoint = errors.New("API endpoint cannot be empty")
var ErrClientCode = errors.New("Client code cannot be empty")
var ErrEventData = errors.New("Event data cannot be nil")
var ErrEventType = errors.New("Event type cannot be empty")
var ErrMaxBatchSize = errors.New("Max batch size cannot bet set to 0 seconds")
var ErrMaxRetryInterval = errors.New("Max retry interval cannot exceed 300 seconds")
var ErrRetryInterval = errors.New("Retry interval cannot bet set to 0 seconds")
var ErrSecretKey = errors.New("Secret key cannot be empty")
var ErrTrackingId = errors.New("Tracking id cannot be empty")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an Revolt API client. It can be configured in NewClient via ClientConfig fun
func NewClient ¶
func NewClient(trackingId, appCode, secret string, opts ...ClientConfig) (*Client, error)
NewClient returns an Revolt Client for use communicating with a Revolt service API configured with the given ClientConfig.
func (*Client) NewEvent ¶
NewEvent is a clients method wrapper around NewEvent function. It creates a new Event instance.
func (*Client) ServiceResponseFromHTTP ¶
func (c *Client) ServiceResponseFromHTTP(response *http.Response) (*ServiceResponse, error)
ServiceResponseFromHTTP is a clients method wrapper around ServiceResponseFromHTTP function. It extracts Revolt service response from an http response.
type ClientConfig ¶
type ClientConfig func(c *Client)
func WithCustomClient ¶
func WithCustomClient(httpClient *http.Client) ClientConfig
Specifies Client used to communication with Revolt service.
func WithEndpoint ¶
func WithEndpoint(endpoint string) ClientConfig
Specifies endpoint on which communication with Revolt service should take place.
type Event ¶
type Event struct { Meta Meta `json:"meta"` Data interface{} `json:"data"` }
Event is a representation of a message sent to Revolt API
type Meta ¶
type Meta struct { ID string `json:"id"` Type string `json:"type"` Timestamp int64 `json:"timestamp"` }
Meta is a representation of Meta tags
type ServiceResponse ¶
type ServiceResponse struct { EventsAccepted int `json:"eventsAccepted"` EventError *struct { EventOffset int `json:"eventOffset"` EventId interface{} `json:"eventId"` ErrorCode int `json:"errorCode"` ErrorMessage string `json:"errorMessage"` } `json:"eventError"` }
ServiceResponse represents a response from Revolt service
func ServiceResponseFromHTTP ¶
func ServiceResponseFromHTTP(response *http.Response) (*ServiceResponse, error)
ServiceResponseFromHTTP extracts Revolt service struct response from an http response.