Documentation ¶
Overview ¶
Package contactbuilder converts astorg types into digium contacts.
This package is experimental and is subject to breaking changes.
Index ¶
- type Builder
- func (builder *Builder) Add(contacts ...digium.Contact)
- func (builder *Builder) AddCustomPerson(f PersonFunc, people ...astorg.Person)
- func (builder *Builder) AddCustomPhoneRole(f PhoneRoleFunc, roles ...astorg.PhoneRole)
- func (builder *Builder) AddPerson(people ...astorg.Person)
- func (builder *Builder) AddPhoneRole(roles ...astorg.PhoneRole)
- func (builder *Builder) Group(name, id string) digium.ContactGroup
- func (builder *Builder) Reset()
- type PersonFunc
- type PhoneRoleFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs a slice of digium contact entries.
An empty contact builder is ready for use.
func (*Builder) AddCustomPerson ¶
func (builder *Builder) AddCustomPerson(f PersonFunc, people ...astorg.Person)
AddCustomPerson adds a contact entry for each person to the builder.
The function f will be used to convert people into contacts.
func (*Builder) AddCustomPhoneRole ¶
func (builder *Builder) AddCustomPhoneRole(f PhoneRoleFunc, roles ...astorg.PhoneRole)
AddCustomPhoneRole adds a contact entry for each phone role to the builder.
The function f will be used to convert phone roles into contacts.
func (*Builder) AddPerson ¶
AddPerson adds a contact entry for each person to the builder.
The PersonFactory function will be used to convert people into contacts.
func (*Builder) AddPhoneRole ¶
AddPhoneRole adds a contact entry for each person to the builder.
The PhoneRoleFactory function will be used to convert people into contacts.
type PersonFunc ¶
PersonFunc is a function that converts people into contacts.
var PersonFactory PersonFunc = func(person *astorg.Person, contact *digium.Contact) { contact.ID = person.Username contact.Type = "sip" contact.FirstName = person.FirstName contact.LastName = person.LastName contact.Organization = person.Organization contact.JobTitle = person.Title contact.Location = person.Location contact.SubscriptionURI = "auto_hint_" + person.Username contact.AccountID = person.Extension contact.Actions = append(contact.Actions, digium.ContactAction{ ID: "primary", Label: "Desk Phone", Name: "Desk Phone", Dial: person.Extension, }) for _, number := range person.ContactNumbers { contact.Actions = append(contact.Actions, digium.ContactAction{ ID: sanitize(number.Label, "_"), Label: number.Label, Name: number.Label, Dial: number.Dial, DialPrefix: number.DialPrefix, }) } if person.VoicemailExtension != "" { contact.Actions = append(contact.Actions, digium.ContactAction{ ID: "send_to_vm", Label: "Voicemail", Name: "Voicemail", Dial: person.VoicemailExtension, Headers: []digium.ContactHeader{ digium.ContactHeader{ Key: "X-Digium-Call-Feature", Value: "feature_send_to_vm", }, digium.ContactHeader{ Key: "Diversion", Value: `<sip:%_ACCOUNT_USERNAME_%@%_ACCOUNT_SERVER_%:%_ACCOUNT_PORT_%>;reason="send_to_vm"`, }, }, }) } for _, email := range person.EmailAddresses { contact.Emails = append(contact.Emails, digium.ContactEmail{ Address: email.Address, Label: email.Label, Primary: email.Primary, }) } }
PersonFactory converts people into contacts.
func (PersonFunc) PersonContact ¶
func (f PersonFunc) PersonContact(from *astorg.Person, to *digium.Contact)
PersonContact applies f to from and to.
func (PersonFunc) Then ¶
func (f PersonFunc) Then(series ...PersonFunc) PersonFunc
Then returns a new function that will execute f followed by each member of series.
type PhoneRoleFunc ¶
PhoneRoleFunc is a function that converts phone roles into contacts.
var PhoneRoleFactory PhoneRoleFunc = func(role *astorg.PhoneRole, contact *digium.Contact) { contact.ID = role.Username contact.Type = "sip" contact.FirstName = role.DisplayName contact.Location = role.Location contact.SubscriptionURI = "auto_hint_" + role.Username contact.AccountID = role.Extension contact.Actions = append(contact.Actions, digium.ContactAction{ ID: "primary", Label: "Desk Phone", Name: "Desk Phone", Dial: role.Extension, }) }
PhoneRoleFactory converts phone roles into contacts.
func (PhoneRoleFunc) Then ¶
func (f PhoneRoleFunc) Then(series ...PhoneRoleFunc) PhoneRoleFunc
Then returns a new function that will execute f followed by each member of series.