vcard

package module
v0.0.0-...-b19f4ea Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

vcard

Golang library for creating vcards

Documentation

Index

Constants

View Source
const (
	// TelHome is a telephone number associated with a residence
	TelHome = "home"

	// TelMsg indicates that the telephone number has voice messaging support
	TelMsg = "msg"

	// TelWork indicates a telephone number associated with a place of work
	TelWork = "work"

	// TelPref indicates a preferred-use telephone number
	TelPref = "pref"

	// TelVoice indicates a voice telephone number
	TelVoice = "voice"

	// TelFax indicates a facsimile telephone number
	TelFax = "fax"

	// TelCell indicates a cellular phone number
	TelCell = "cell"

	// TelVideo indicates video calling support
	TelVideo = "video"

	// TelPager indicates a paging device telephone number
	TelPager = "pager"

	// TelBBS indicates a buletin board system telephone number
	TelBBS = "bbs"

	// TelModem indicates a moden telephone number
	TelModem = "modem"

	// TelCar indicates a car-phone telephone
	TelCar = "car"

	// TelISDN indicates an ISDN service telephone number
	TelISDN = "isdn"

	// TelPCS indicates a personal communication service telephone number
	TelPCS = "pcs"
)
View Source
const (
	// AdrDom indicates a domestic address.
	AdrDom = "dom"

	// AdrIntl indicates an international address.
	AdrIntl = "intl"

	// AdrPostal indicates a postal address.
	AdrPostal = "postal"

	// AdrParcel indicates a parcel delivery address.
	AdrParcel = "parcel"

	// AdrHome indicates a home delivery address.
	AdrHome = "home"

	// AdrWork indicates a delivery address for a place of work.
	AdrWork = "work"

	// AdrPref indicates a preferred address for when more addresses are supplied.
	AdrPref = "pref"
)
View Source
const (
	// EmailInternet indicates an internet addressing type.
	EmailInternet = "internet"

	// EmailX400 indicates a X.400 addressing type.
	EmailX400 = "x400"

	// EmailPref indicates a preferred address for when more addresses are supplied
	EmailPref = "pref"
)

Variables

View Source
var ErrVersion = errors.New("unsupported verson")

ErrVersion is used by FieldFormatters when a request is made for an unsupported vcard version

Functions

This section is empty.

Types

type Adr

type Adr struct {
	Types           []string
	PostOfficeBox   string
	ExtendedAddress string
	StreetAddress   string
	Locality        string
	Region          string
	PostalCode      string
	CountryName     string
}

Adr type definition to specify the components of the delivery address for the vCard object.

func (Adr) Format

func (f Adr) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Agent

type Agent struct {
	VCard *VCard
	Text  string
}

Agent type definition to specify information about another person who will act on behalf of the individual or resource associated with the vCard. Can contain a VCard of the agent or a string.

func (Agent) Format

func (f Agent) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Anniversary

type Anniversary struct {
	Date       time.Time
	TimeFormat string
}

Anniversary type definition to specify a person's anniversary/

func (Anniversary) Format

func (f Anniversary) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Bday

type Bday struct {
	Timestamp  time.Time
	TimeFormat string
}

Bday type definition to specify the date of birth of the individual associated with the vCard.

func (Bday) Format

func (f Bday) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Email

type Email struct {
	Types []string
	Email string
}

Email type definition to specify the formatted text corresponding to the name of the object the vCard represents.

func (Email) Format

func (f Email) Format(v string) (string, error)

Format implements the FieldFormatter interface

type FN

type FN struct {
	FormattedName string
}

FN type definition to specify the formatted text corresponding to the name of the object the vCard represents.

func (FN) Format

func (f FN) Format(v string) (string, error)

Format implements the FieldFormatter interface

type FbURL

type FbURL struct {
	*url.URL
}

FbURL type definition to specify a URL that shows when the person is "free" or "busy" on their calendar.

func (FbURL) Format

func (f FbURL) Format(v string) (string, error)

Format implements the FieldFormatter interface

type FieldFormatter

type FieldFormatter interface {
	Format(string) (string, error)
}

FieldFormatter is an interface containing the minimal behaviour of any VCard field formatter Receives the version as a string, returns a formatted string and an error Current versions to support are 2.1, 3.0 and 4,0

type Gender

type Gender struct {
	Val string
}

Gender type definition to specify a person's gender.

func (Gender) Format

func (f Gender) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Geo

type Geo struct {
	Lat  float64
	Long float64
}

Geo type definition to specify a latitude and longitude. For vcard version 4.0

func (Geo) Format

func (f Geo) Format(v string) (string, error)

Format implements the FieldFormatter interface

type IMPP

type IMPP struct {
	Platform string
	Handle   string
}

IMPP type definition to specify instant messenger handle.

func (IMPP) Format

func (f IMPP) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Key

type Key struct {
	Type   string
	URI    *url.URL
	Data   string
	Binary bool
}

Key type definition to specify a key associated with the vCard object. It may point to an external URL, may be plain text, or may be embedded in the vCard as a Base64 encoded block of text.

func (Key) Format

func (f Key) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Kind

type Kind struct {
	Text string
}

Kind type definition to specify the the type of entity that this vCard represents: 'application', 'individual', 'group', 'location' or 'organization'; 'x-*' values may be used for experimental purposes.

func (Kind) Format

func (f Kind) Format(v string) (string, error)

Format implements the FieldFormatter interface

type N

type N struct {
	FamilyName        string
	GivenName         string
	AdditionalNames   string
	HonorificPrefixes string
	HonorificSuffixes string
}

N type definition to specify the components of the name of the object the vCard represents

func (N) Format

func (f N) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Org

type Org struct {
	Name  string
	Units []string
}

Org type definition to specify the organizational name and units associated with the vCard.

func (Org) Format

func (f Org) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Photo

type Photo struct {
	Type       string
	URI        *url.URL
	Base64Data string
}

Photo type definition to specify an image or photograph information that annotates some aspect of the object the vCard represents.

func (Photo) Format

func (f Photo) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Rev

type Rev struct {
	Timestamp  time.Time
	TimeFormat string
}

Rev type definition to specify revision information about the current vCard.

func (Rev) Format

func (f Rev) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Role

type Role struct {
	Role string
}

Role type definition to specify information concerning the role, occupation, or business category of the object the vCard represents.

func (Role) Format

func (f Role) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Tel

type Tel struct {
	Types  []string
	Number string
}

Tel type definition to the telephone number for telephony communication with the object the vCard represents.

func (Tel) Format

func (f Tel) Format(v string) (string, error)

Format implements the FieldFormatter interface

type Title

type Title struct {
	Title string
}

Title type definition to specify the job title, functional position or function of the object the vCard represents.

func (Title) Format

func (f Title) Format(v string) (string, error)

Format implements the FieldFormatter interface

type VCard

type VCard struct {
	Version string
	Fields  []FieldFormatter
}

VCard represents a formattable vcard

func New

func New(v string, fields ...FieldFormatter) (*VCard, error)

New returns a new VCard based upon the provided version and fields, returns an error if an invalid version is provided or if validation of the vcard fails

func (*VCard) Generate

func (v *VCard) Generate() (string, error)

Generate will generate the vcard string

func (*VCard) QR

func (v *VCard) QR(x, y int) (barcode.Barcode, error)

QR creates a QR code of the VCard

func (*VCard) QRPng

func (v *VCard) QRPng(x, y int, filename string) error

QRPng creates a png file containing a QR code of the VCard

func (*VCard) Validate

func (v *VCard) Validate() error

Validate checks whether a VCard is valid by checking if all required fields are set for the version and if provided fields are supported by the required version

type VersionError

type VersionError struct{}

VersionError is used to to return an error when the user has selected a wrong version

func (*VersionError) Error

func (err *VersionError) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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