Documentation
¶
Index ¶
- Constants
- Variables
- func BuildUrl(path string) string
- func GetAPIUrl() string
- func NewTracker(clientId string) (skalinTracker, error)
- type API
- type Agreement
- type Contact
- type CustomAttributes
- type CustomLog
- func (logger *CustomLog) AddSkalinApplicationField() *logrus.Entry
- func (logger *CustomLog) Errorf(format string, args ...interface{})
- func (logger *CustomLog) Fatalf(format string, args ...interface{})
- func (logger *CustomLog) Infof(format string, args ...interface{})
- func (logger *CustomLog) Panicf(format string, args ...interface{})
- func (logger *CustomLog) Printf(format string, args ...interface{})
- func (logger *CustomLog) Warnf(format string, args ...interface{})
- func (logger *CustomLog) Warningf(format string, args ...interface{})
- type Customer
- type CustomerResponse
- type EntitiesGeneric
- type EntitySlice
- type GenericResponse
- type GetParams
- type HitAction
- type HitEvent
- type HitIdentity
- type HitTrack
- type MockAPI
- func (m *MockAPI) DeleteData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (m *MockAPI) GetClientID() *string
- func (m *MockAPI) GetData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (m *MockAPI) GetLogger() *CustomLog
- func (m *MockAPI) PatchData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (m *MockAPI) PostData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (m *MockAPI) PutData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (m *MockAPI) SetLogger(l logrus.FieldLogger)
- func (m *MockAPI) WithToken(_ string) API
- type PaginationMetadata
- type ResponseMetadata
- type Skalin
- type SkalinAPI
- func (a SkalinAPI) DeleteData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (a *SkalinAPI) GetClientID() *string
- func (a SkalinAPI) GetData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (a *SkalinAPI) GetLogger() *CustomLog
- func (a SkalinAPI) PatchData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (a SkalinAPI) PostData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (a SkalinAPI) PutData(url, contentType string, extraHeaders map[string][]string, body []byte, ...) (*http.Response, []byte, error)
- func (a *SkalinAPI) SetLogger(logger logrus.FieldLogger)
- func (a *SkalinAPI) WithClientID(clientID string) API
- func (a *SkalinAPI) WithToken(token string) API
- type SkalinDate
- type SkalinResponseError
- type SkalinTracking
- type Tag
Constants ¶
View Source
const ( SAVE_AGREEMENT_PATH = "/agreements" UPDATE_AGREEMENT_PATH = "/agreements/%v" CREATE_CUSTOMER_AGREEMENT_PATH = "/customers/%v/agreements" )
View Source
const ( SKALIN_API_URL = "https://api.skalin.io/v1" SKALIN_AUTH_URL = "https://auth.skalin.io/oauth/token" SKALIN_HIT_URL = "https://collect.skalin.io/hit" )
View Source
const ( SAVE_CONTACT_PATH = "/contacts" UPDATE_CONTACT_PATH = "/contacts/%v" CREATE_CUSTOMER_CONTACT_PATH = "/customers/%v/contacts" )
View Source
const ( GET_TAGS = "/tags" GET_TAG_BY_ID = "/tags/%v" )
View Source
const (
SAVE_CUSTOMER_PATH = "/customers"
)
Variables ¶
View Source
var ( ErrUndefined = errors.New("undefined error") ErrAuthorization = errors.New("No authorization token was found") )
View Source
var Log = NewLogger()
Functions ¶
func NewTracker ¶ added in v1.4.0
Types ¶
type API ¶
type API interface {
PutData(url, contentType string, extraHeaders map[string][]string, body []byte, queryParams *url.Values, expectedStatusCode int) (*http.Response, []byte, error)
PostData(url, contentType string, extraHeaders map[string][]string, body []byte, queryParams *url.Values, expectedStatusCode int) (*http.Response, []byte, error)
PatchData(url, contentType string, extraHeaders map[string][]string, body []byte, queryParams *url.Values, expectedStatusCode int) (*http.Response, []byte, error)
GetData(url, contentType string, extraHeaders map[string][]string, body []byte, queryParams *url.Values, expectedStatusCode int) (*http.Response, []byte, error)
DeleteData(url, contentType string, extraHeaders map[string][]string, body []byte, queryParams *url.Values, expectedStatusCode int) (*http.Response, []byte, error)
WithToken(token string) API
GetLogger() *CustomLog
GetClientID() *string
SetLogger(logrus.FieldLogger)
// contains filtered or unexported methods
}
type Agreement ¶
type Agreement struct {
Id string `json:"id,omitempty"`
CustomerId *string `json:"customerId,omitempty"` // correspond to the customer Id
Customer *string `json:"customer,omitempty"` // correspond to the customer refId
RefId string `json:"refId,omitempty"`
StartDate *SkalinDate `json:"startDate,omitempty"` // need to be at format `YYYY-MM-DD`
EndDate *SkalinDate `json:"endDate,omitempty"` // need to be at format `YYYY-MM-DD`
RenewalDate *SkalinDate `json:"renewalDate,omitempty"` // need to be at format `YYYY-MM-DD`
AutoRenew bool `json:"autoRenew,omitempty"`
Engagement *int `json:"engagement,omitempty"` // need pointer because engagement value can be 0
EngagementPeriod string `json:"engagementPeriod,omitempty"`
Notice *int `json:"notice,omitempty"` // need pointer because engagement value can be 0
NoticePeriod string `json:"noticePeriod,omitempty"`
Plan string `json:"plan,omitempty"`
Type string `json:"type,omitempty"`
Mrr *int `json:"mrr,omitempty"`
Fee *int `json:"fee,omitempty"`
}
type Contact ¶
type Contact struct {
Id string `json:"id,omitempty"`
CustomerId *string `json:"customerId,omitempty"` // correspond to the customer Id
Customer *string `json:"customer,omitempty"` // correspond to the customer refId
RefId string `json:"refId,omitempty"`
Email string `json:"email,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Phone string `json:"phone,omitempty"`
NpsScore *int `json:"npsScore,omitempty"`
Tags []string `json:"tags,omitempty"`
LastActivityTs *time.Time `json:"lastActivityTs,omitempty"`
CustomAttributes CustomAttributes `json:"-"`
}
func (Contact) MarshalJSON ¶
need custom MarshalJSON to merge custom attributes with contact see the doc of skalin for now, no need to create a custom UnmarshalJson because skalin API does not return custom attributes
type CustomAttributes ¶
type CustomAttributes map[string]interface{}
type CustomLog ¶
type CustomLog struct {
logrus.FieldLogger
}
func (*CustomLog) AddSkalinApplicationField ¶
type Customer ¶
type Customer struct {
Id string `json:"id,omitempty"`
RefId string `json:"refId,omitempty"`
Name string `json:"name,omitempty"`
Stage string `json:"stage,omitempty"`
Tags []string `json:"tags,omitempty"`
LastActivityTs *time.Time `json:"lastActivityTs,omitempty"`
CustomAttributes CustomAttributes `json:"-"`
}
func (Customer) MarshalJSON ¶
need custom MarshalJSON to merge custom attributes with contact see the doc of skalin for now, no need to create a custom UnmarshalJson because skalin API does not return custom attributes
type CustomerResponse ¶
type EntitiesGeneric ¶ added in v1.3.0
type EntitySlice ¶ added in v1.3.0
type EntitySlice[T EntitiesGeneric] interface { ~[]T // permit to define a core type to use `make` and `append` on generic (https://go.dev/ref/spec#Core_types) }
type GenericResponse ¶
type GenericResponse[T EntitySlice[V] | EntitiesGeneric, V EntitiesGeneric, U ResponseMetadata] struct { Status string `json:"status"` Data T `json:"data"` Metadata U `json:"metadata,omitempty"` }
type HitAction ¶ added in v1.4.0
type HitAction string
const HitActionEvent HitAction = "ev"
const HitActionUserIdendity HitAction = "ui"
type HitIdentity ¶ added in v1.4.0
type HitTrack ¶ added in v1.4.0
type HitTrack struct {
Action HitAction `validate:"required"`
VisitorID string `validate:"required,len=16"`
VisitID string `validate:"required,len=16"`
Identity HitIdentity `validate:"required"`
Event *HitEvent `validate:"required_if=Action ev"` // mandatory if action is event
EventID *string `validate:"omitempty,len=16"`
CustomerID *string
Ts *time.Time
URL *string
CIP *string // client ip
CustomHeaders map[string][]string
}
type MockAPI ¶
func (*MockAPI) DeleteData ¶ added in v1.8.0
func (*MockAPI) GetClientID ¶ added in v1.4.0
func (*MockAPI) SetLogger ¶
func (m *MockAPI) SetLogger(l logrus.FieldLogger)
type PaginationMetadata ¶ added in v1.3.0
type ResponseMetadata ¶ added in v1.3.0
type ResponseMetadata interface {
PaginationMetadata
}
type Skalin ¶
type Skalin interface {
GetContacts(*GetParams) ([]Contact, error)
SaveContact(Contact) (*Contact, error)
UpdateContact(Contact) (*Contact, error)
CreateContactForCustomer(Contact, string) (*Contact, error)
DeleteContact(Contact) error
GetCustomers(*GetParams) ([]Customer, error)
SaveCustomer(Customer) (*Customer, error)
GetAgreements(*GetParams) ([]Agreement, error)
SaveAgreement(Agreement) (*Agreement, error)
UpdateAgreement(Agreement) (*Agreement, error)
CreateAgreementForCustomer(Agreement, string) (*Agreement, error)
DeleteAgreement(Agreement) error
GetTags(*GetParams) ([]Tag, error)
GetTagByID(id string) (*Tag, error)
SetLogger(logger logrus.FieldLogger)
}
type SkalinAPI ¶
type SkalinAPI struct {
// contains filtered or unexported fields
}
func (SkalinAPI) DeleteData ¶ added in v1.8.0
func (*SkalinAPI) GetClientID ¶ added in v1.4.0
func (*SkalinAPI) SetLogger ¶
func (a *SkalinAPI) SetLogger(logger logrus.FieldLogger)
func (*SkalinAPI) WithClientID ¶
type SkalinDate ¶
need SkalinDate to unmarshal date from skalin API because format is "YYYY-MM-DD"
func (SkalinDate) MarshalJSON ¶
func (s SkalinDate) MarshalJSON() ([]byte, error)
func (*SkalinDate) UnmarshalJSON ¶
func (s *SkalinDate) UnmarshalJSON(b []byte) error
type SkalinResponseError ¶
type SkalinTracking ¶ added in v1.4.0
Click to show internal directories.
Click to hide internal directories.