Documentation
¶
Overview ¶
Package contacts is the togo contacts base plugin. It defines a normalized Contact model + a ContactsProvider driver interface; provider plugins (e.g. contacts-google) call contacts.RegisterDriver and depend on this package.
Blank-import a provider and set CONTACTS_DRIVER to select it. The default "null" driver returns no contacts (safe for dev/tests).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDriver ¶
func RegisterDriver(name string, f DriverFactory)
RegisterDriver registers a contacts driver by name (call from a plugin's init()).
Types ¶
type Contact ¶
type Contact struct {
ID string `json:"id"`
Name string `json:"name"`
Emails []string `json:"emails,omitempty"`
Phones []string `json:"phones,omitempty"`
Photo string `json:"photo,omitempty"`
Org string `json:"org,omitempty"`
Source string `json:"source,omitempty"`
Extra map[string]string `json:"extra,omitempty"`
}
Contact is a normalized contact record (provider-agnostic).
type ContactsProvider ¶
type ContactsProvider interface {
// List returns a page of contacts. pageToken "" starts at the beginning; the
// returned next token is "" when there are no more pages.
List(ctx context.Context, pageToken string) (contacts []Contact, next string, err error)
// Get returns one contact by its provider id.
Get(ctx context.Context, id string) (*Contact, error)
}
ContactsProvider imports contacts from an external source (Google, a CRM, …).
type DriverFactory ¶
type DriverFactory func(k *togo.Kernel) (ContactsProvider, error)
DriverFactory builds a provider from the kernel (env/config).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the contacts runtime stored on the kernel (k.Get("contacts")).
func FromKernel ¶
FromKernel fetches the contacts service from the kernel container.
func (*Service) Provider ¶
func (s *Service) Provider() ContactsProvider
Provider returns the active driver implementation.