package contact

import "git.sr.ht/~shulhan/pakakeh.go/lib/contact"

Package contact provide a library to import contact from Google, Microsoft, and Yahoo.

Index

Constants

const (
	KindIndividual = "individual"
	KindGroup      = "group"
	KindOrg        = "org"
	KindLocation   = "location"
)

List of Kind values.

const (
	TypeAnniversary = "anniversary"
	TypeHome        = "home"
	TypeMain        = "main"
	TypeMobile      = "mobile"
	TypeOther       = "other"
	TypeWork        = "work"
)

List of known TYPE values.

Types

type Address

type Address struct {
	Type        string `json:"type,omitempty"`
	POBox       string `json:"pobox,omitempty"`
	Ext         string `json:"extension,omitempty"`
	Street      string `json:"street,omitempty"`
	City        string `json:"city,omitempty"`
	StateOrProv string `json:"stateOrProvince,omitempty"`
	PostalCode  string `json:"postalCode,omitempty"`
	Country     string `json:"country,omitempty"`
}

Address define contact's address.

type Date

type Date struct {
	Day   string `json:"day"`
	Month string `json:"month"`
	Year  string `json:"year"`
}

Date define contact's with type "birthday" and "anniversary".

func (*Date) String

func (date *Date) String() (r string)

String will return the string representation of date object in `YYYY-MM-DD` format.

func (*Date) VCardString

func (date *Date) VCardString() (r string)

VCardString will return the string representation of date object in VCard format: `YYYYMMDD` or "--MMDD" if year is empty.

type Email

type Email struct {
	Type    string
	Address string
}

Email contains, yes, electronic mail address.

type Name

type Name struct {
	Given       string `json:"givenName"`
	Middle      string `json:"middleName"`
	Family      string `json:"familyName"`
	Prefix      string `json:"prefix"`
	Suffix      string `json:"suffix"`
	GivenSound  string `json:"givenNameSound"`
	FamilySound string `json:"familyNameSound"`
}

Name define contact's name.

type Phone

type Phone struct {
	Type   string
	Number string
}

Phone define contact phone number and their type.

type Record

type Record struct {
	Name Name

	Birthday    *Date
	Anniversary *Date

	Company  string
	JobTitle string

	Addresses []Address
	Emails    []Email
	Phones    []Phone
	Links     []string
	Notes     []string
}

Record define a single contact entity with sane format.

func (*Record) SetAnniversary

func (contact *Record) SetAnniversary(dateStr string)

SetAnniversary will set contact annivery from string format "YYYY-MM-DD".

func (*Record) SetBirthday

func (contact *Record) SetBirthday(dateStr string)

SetBirthday will set contact birthday from string format "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SSZ".

Source Files

address.go const.go contact.go date.go email.go name.go phone.go

Directories

PathSynopsis
lib/contact/googlePackage google implement Google's contact API v3.
lib/contact/microsoftPackage microsoft implement Microsoft's Live contact API v1.0.
lib/contact/vcardPackage vcard implement RFC6350 for encoding and decoding VCard formatted data.
lib/contact/yahooPackage yahoo implement user's contacts import using Yahoo API.
Version
v0.60.0 (latest)
Published
Feb 1, 2025
Platform
linux/amd64
Imports
1 packages
Last checked
9 hours ago

Tools for package owners.