Skip to content

togo-framework/contacts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

togo

togo-framework/contacts

marketplace pkg.go.dev MIT

Part of the togo framework.

Install

togo install togo-framework/contacts

contacts — togo contacts plugin

The contacts base plugin for togo. It defines a normalized Contact model and a ContactsProvider driver interface so you can import/sync contacts from anywhere — Google, a CRM, … — behind one API.

togo install togo-framework/contacts
togo install togo-framework/contacts-google   # a provider

Select the provider with CONTACTS_DRIVER (default null — no contacts):

CONTACTS_DRIVER=google

Use it

import "github.com/togo-framework/contacts"

svc, _ := contacts.FromKernel(k)
all, err := svc.Sync(ctx)        // pull every contact from the provider
c, err  := svc.Get(ctx, id)      // one contact by provider id

Write a provider

A provider is a tiny module that registers a driver in init():

func init() {
    contacts.RegisterDriver("mycrm", func(k *togo.Kernel) (contacts.ContactsProvider, error) {
        return &provider{/* read env */}, nil
    })
}

It implements List(ctx, pageToken) ([]Contact, next, err) and Get(ctx, id). contacts-google is the reference provider (Google People API); the same shape works for any CRM.

MIT


Premium sponsors

ID8 Media  ·  One Studio

Support togo — become a sponsor.

Sponsor this project

 

Packages

 
 
 

Contributors

Languages