google

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package google implement Google's contact API v3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportFromJSON

func ImportFromJSON(jsonb []byte) (contacts []*contact.Record, err error)

ImportFromJSON will parse JSON input and return Contacts object on success.

On fail it will return nil and error.

func ImportWithOAuth

func ImportWithOAuth(client *http.Client) (contacts []*contact.Record, err error)

ImportWithOAuth get Google contact API using OAuth HTTP client.

func ParseRel

func ParseRel(in string) string

ParseRel will parse Google "rel" value and return the type.

Types

type Address

type Address struct {
	Rel         string `json:"rel,omitempty"`
	Full        GD     `json:"gd$formattedAddress,omitempty"`
	POBox       GD     `json:"gd$pobox,omitempty"`
	Street      GD     `json:"gd$street,omitempty"`
	City        GD     `json:"gd$city,omitempty"`
	StateOrProv GD     `json:"gd$region,omitempty"`
	PostalCode  GD     `json:"gd$postcode,omitempty"`
	Country     GD     `json:"gd$country,omitempty"`
}

Address format.

type Author

type Author struct {
	Name  GD `json:"name,omitempty"`
	Email GD `json:"email,omitempty"`
}

Author define Google contacts author.

type Birthday

type Birthday struct {
	When string `json:"when,omitempty"`
}

Birthday format.

type Category

type Category struct {
	Scheme string `json:"scheme,omitempty"`
	Term   string `json:"term,omitempty"`
}

Category format.

type Contact

type Contact struct {
	Name      Name      `json:"gd$name,omitempty"`
	Birthday  Birthday  `json:"gContact$birthday,omitempty"`
	Orgs      []Org     `json:"gd$organization,omitempty"`
	Emails    []Email   `json:"gd$email,omitempty"`
	Phones    []Phone   `json:"gd$phoneNumber,omitempty"`
	Addresses []Address `json:"gd$structuredPostalAddress,omitempty"`
	Events    []Event   `json:"gContact$event,omitempty"`
	Websites  []Link    `json:"gContact$website,omitempty"`
}

Contact define a single Google contact data.

Some of the fields are disabled for speed.

func (*Contact) Decode

func (gc *Contact) Decode() (to *contact.Record)

Decode will convert Google's Contact to our Contact format.

type Email

type Email struct {
	Rel     string `json:"rel,omitempty"`
	Address string `json:"address,omitempty"`
	Primary string `json:"primary,omitempty"`
}

Email format.

type Event

type Event struct {
	Rel  string    `json:"rel,omitempty"`
	When EventTime `json:"gd$when,omitempty"`
}

Event format.

type EventTime

type EventTime struct {
	Start string `json:"startTime,omitempty"`
}

EventTime format.

type Feed

type Feed struct {
	TotalResult GD        `json:"openSearch$totalResults,omitempty"`
	Contacts    []Contact `json:"entry,omitempty"`
}

Feed define content of Google contacts feed metadata.

Some of the fields are disabled for speed.

type GD

type GD struct {
	Value string `json:"$t,omitempty"`
}

GD is Google Data.

type Generator

type Generator struct {
	Version string `json:"version,omitempty"`
	URI     string `json:"uri,omitempty"`
	Value   string `json:"$t,omitempty"`
}

Generator define Google contact generator.

type Link struct {
	Rel  string `json:"rel,omitempty"`
	Type string `json:"type,omitempty"`
	HRef string `json:"href,omitempty"`
}

Link define Google contact link type.

type Name

type Name struct {
	Prefix GD `json:"gd$namePrefix,omitempty"`
	First  GD `json:"gd$givenName,omitempty"`
	Middle GD `json:"gd$additionalName,omitempty"`
	Last   GD `json:"gd$familyName,omitempty"`
	Suffix GD `json:"gd$nameSuffix,omitempty"`
	Full   GD `json:"gd$fullName,omitempty"`
}

Name define Google contact name format.

type Org

type Org struct {
	Type     string `json:"rel,omitempty"`
	Name     GD     `json:"gd$orgName,omitempty"`
	JobTitle GD     `json:"gd$orgTitle,omitempty"`
}

Org as organisation.

type Phone

type Phone struct {
	Rel    string `json:"rel,omitempty"`
	Number string `json:"$t,omitempty"`
}

Phone format.

type Root

type Root struct {
	Version  string `json:"version,omitempty"`
	Encoding string `json:"encoding,omitempty"`
	Feed     Feed   `json:"feed,omitempty"`
}

Root define the root of Google's contact in JSON.

Jump to

Keyboard shortcuts

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