contacts

package
v1.0.47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package contacts provides a client for the Google People API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	FormattedValue string `json:"formattedValue,omitempty"`
	Type           string `json:"type,omitempty"`
	City           string `json:"city,omitempty"`
	Region         string `json:"region,omitempty"`
	PostalCode     string `json:"postalCode,omitempty"`
	Country        string `json:"country,omitempty"`
}

Address represents a physical address

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the Google People API service for contacts

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new Contacts client with OAuth2 authentication

func (*Client) AddToGroup added in v1.0.38

func (c *Client) AddToGroup(ctx context.Context, groupResourceName string, contactResourceNames []string) error

AddToGroup adds contacts to a contact group

func (*Client) GetContact

func (c *Client) GetContact(ctx context.Context, resourceName string) (*people.Person, error)

GetContact retrieves a specific contact by resource name

func (*Client) ListContactGroups

func (c *Client) ListContactGroups(ctx context.Context, pageToken string, pageSize int64) (*people.ListContactGroupsResponse, error)

ListContactGroups retrieves all contact groups

func (*Client) ListContacts

func (c *Client) ListContacts(ctx context.Context, pageToken string, pageSize int64) (*people.ListConnectionsResponse, error)

ListContacts retrieves contacts from the user's account

func (*Client) RemoveFromGroup added in v1.0.38

func (c *Client) RemoveFromGroup(ctx context.Context, groupResourceName string, contactResourceNames []string) error

RemoveFromGroup removes contacts from a contact group

func (*Client) ResolveGroupName added in v1.0.38

func (c *Client) ResolveGroupName(ctx context.Context, name string) (string, error)

ResolveGroupName finds a contact group by name and returns its resource name

func (*Client) SearchContactIDs added in v1.0.38

func (c *Client) SearchContactIDs(ctx context.Context, query string, pageSize int64) ([]string, error)

SearchContactIDs searches contacts and returns only resource names. pageSize of 0 defaults to 100 (the People API maximum for search).

func (*Client) SearchContacts

func (c *Client) SearchContacts(ctx context.Context, query string, pageSize int64) (*people.SearchResponse, error)

SearchContacts searches for contacts matching a query

type Contact

type Contact struct {
	ResourceName  string         `json:"resourceName"`
	DisplayName   string         `json:"displayName,omitempty"`
	Names         []Name         `json:"names,omitempty"`
	Emails        []Email        `json:"emails,omitempty"`
	Phones        []Phone        `json:"phones,omitempty"`
	Organizations []Organization `json:"organizations,omitempty"`
	Addresses     []Address      `json:"addresses,omitempty"`
	URLs          []URL          `json:"urls,omitempty"`
	Biography     string         `json:"biography,omitempty"`
	Birthday      string         `json:"birthday,omitempty"`
	PhotoURL      string         `json:"photoUrl,omitempty"`
}

Contact represents a simplified contact for output

func ParseContact

func ParseContact(p *people.Person) *Contact

ParseContact converts a People API Person to our Contact type

func (*Contact) GetDisplayName

func (c *Contact) GetDisplayName() string

GetDisplayName returns the best display name for a contact

func (*Contact) GetOrganization

func (c *Contact) GetOrganization() string

GetOrganization returns the first organization name

func (*Contact) GetPrimaryEmail

func (c *Contact) GetPrimaryEmail() string

GetPrimaryEmail returns the primary email or first email

func (*Contact) GetPrimaryPhone

func (c *Contact) GetPrimaryPhone() string

GetPrimaryPhone returns the first phone number

type ContactGroup

type ContactGroup struct {
	ResourceName string `json:"resourceName"`
	Name         string `json:"name"`
	GroupType    string `json:"groupType,omitempty"`
	MemberCount  int64  `json:"memberCount"`
}

ContactGroup represents a contact group/label

func ParseContactGroup

func ParseContactGroup(g *people.ContactGroup) *ContactGroup

ParseContactGroup converts a People API ContactGroup to our ContactGroup type

type Email

type Email struct {
	Value       string `json:"value"`
	Type        string `json:"type,omitempty"`
	DisplayName string `json:"displayName,omitempty"`
	Primary     bool   `json:"primary,omitempty"`
}

Email represents an email address

type Name

type Name struct {
	DisplayName      string `json:"displayName,omitempty"`
	GivenName        string `json:"givenName,omitempty"`
	FamilyName       string `json:"familyName,omitempty"`
	MiddleName       string `json:"middleName,omitempty"`
	HonorificPrefix  string `json:"honorificPrefix,omitempty"`
	HonorificSuffix  string `json:"honorificSuffix,omitempty"`
	PhoneticFullName string `json:"phoneticFullName,omitempty"`
}

Name represents a contact name

type Organization

type Organization struct {
	Name       string `json:"name,omitempty"`
	Title      string `json:"title,omitempty"`
	Department string `json:"department,omitempty"`
	Type       string `json:"type,omitempty"`
}

Organization represents a company/organization

type Phone

type Phone struct {
	Value string `json:"value"`
	Type  string `json:"type,omitempty"`
}

Phone represents a phone number

type URL

type URL struct {
	Value string `json:"value"`
	Type  string `json:"type,omitempty"`
}

URL represents a website or link

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL