NAME
Polycom::Contact - Contact in a Polycom VoIP phone's local contact directory.
SYNOPSIS
use Polycom::Contact;
# Create a new contact
my $contact = Polycom::Contact->new(
first_name => 'Bob',
last_name => 'Smith',
contact => '1234',
);
# The contact can be interpolated in strings
# Prints: "The contact is: Bob Smith at 1234"
print "The contact is: $contact\n";
# The contact can also be compared with other contacts
my $otherContact = Polycom::Contact->new(first_name => 'Jimmy', contact => '5678');
if ($otherContact != $contact)
{
print "$otherContact is not the same as $contact\n";
}
# Or, of course, you can simply query the contact's fields
my $first_name = $contact->first_name;
my $last_name = $contact->last_name;
DESCRIPTION
The Polycom::Contact
class represents a contact in a Polycom SoundPoint IP, SoundStation IP, or VVX phone's local contact directory. This class is intended to be used with Polycom::Contact::Directory
, which parses entire contact directory files, extracting the contacts, and enabling you to read or modify them.
CONSTRUCTOR
new ( %fields )
use Polycom::Contact;
my $contact = Polycom::Contact->new(first_name => 'Bob', contact => 1234);
Returns a newly created Polycom::Contact
object.
In all, each Polycom::Contact
object can have the following fields:
first_name - first name
last_name - last name
contact - phone number or URL (required)
speed_index - speed dial index (1 - 9999)
label - label to show on speed dial keys
ring_type - distinctive incoming ring tone (1 - 22)
divert - phone number or URL to divert incoming calls to
auto_reject - automatically reject calls from this contact (0 = no, 1 = yes)
auto_divert - automatically divert calls from this contact (0 = no, 1 = yes)
buddy_watching - include in the list of watched phones (0 = no, 1 = yes)
buddy_block - block from watching this phone (0 = no, 1 = yes)
user_photo - index of a user photo/icon set by the icons.x parameter.
Of those fields, the contact
field is the only required field; without a unique contact
field, the phone will not load the contact.
ACCESSORS
first_name
my $fn = $contact->first_name;
$contact->first_name('Bob'); # Set the first_name to "Bob"
last_name
my $ln = $contact->last_name;
$contact->last_name('Smith'); # Set the last_name to "Smith"
contact
The phone number, extension, or URL of the contact. This field must be present (i.e. not blank) and must be unique.
my $num = $contact->contact;
$contact->contact('1234'); # Set the contact number to 1234
speed_index
The speed dial index for the contact (1 - 9999).
my $sd = $contact->speed_index;
$contact->speed_index(5); # Set the speed index to 5
Contacts that have a speed dial index specified are listed in the phone's speed dial menu and are mapped to unused line keys for quick access.
label
The label to show on speed dial keys (e.g. "Manager").
my $lb = $contact->label;
$contact->label('Sales'); # Set the label to "Sales"
ring_type
The distinctive incoming ring tone for this contact (1 - 22).
my $rt = $contact->ring_type;
$contact->ring_type(2); # Set the ring type to 2
The ring type number must correspond to a ring type listed in the Settings > Basic > Ring Type menu on the phone. When an incoming call is received from the contact, the specified ring tone will play instead of the default ring tone.
divert
The phone number or URL to divert incoming calls to.
my $divert = $contact->divert;
$contact->divert(2345); # Set the divert phone number to 2345
auto_reject
Specifies whether to automatically reject calls from this contact (0 = no, 1 = yes).
print "Calls from $contact will be automatically rejected" if ($contact->auto_reject);
$contact->auto_reject(1); # Enable auto reject
auto_divert
Specifies whether to automatically divert calls from this contact (0 = no, 1 = yes).
print "Calls from $contact will be automatically diverted" if ($contact->auto_divert);
$contact->auto_divert(1); # Enable auto divert
buddy_watching
Specifies whether to include this contact in the list of watched phones (0 = no, 1 = yes).
print "$contact is in the watched list" if ($contact->buddy_watching);
$contact->buddy_watching(1); # Add this contact to the buddy list
buddy_block
Specifies whether to block this contact from watching this phone (0 = no, 1 = yes).
print "$contact is blocked from watching" if ($contact->buddy_block);
$contact->buddy_block(1); # Prevent this contact from watching this phone
user_photo
The index of an optional user photo that has been specified in the configuration using the icons.x parameter.
# Copy a photo to the provisioning server (e.g. bob.png) and add the following to the phone's configuration:
# <icons icons.1="bob.png" />
$contact->user_photo(1); # Show the image "bob.png" for this contact on Trio and CCX phones
=head1 METHODS
is_valid
if (!$contact->is_valid)
{
print "$contact is invalid.\n";
}
Returns undef if the contact is invalid (i.e. it has no contact
value specified), or 1 otherwise.
delete
my @contacts = $dir->search({first_name => 'Bob'});
$contacts[0]->delete;
Removes the contact from the directory it belongs to (see Polycom::Contact::Directory
). If the Polycom::Contact
object was created from scratch, rather than from an existing contact directory object, then calling delete
has no effect.
diff ( $contact2 )
my @differences = $contact1->diff($contact2);
Returns an array of contact field names that do not match (e.g. "First Name", "Speed Dial").
SEE ALSO
Polycom::Contact::Directory
- A closely related module that parses the XML-based local contact directory file used by Polycom SoundPoint IP, SoundStation IP, VVX, Trio and CCX VoIP phones, and can be used to read, modify, or create contacts in the file.
AUTHOR
Zachary Blair, <zblair@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2010 by Polycom Canada
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.