line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pikeo::API::Contact; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6588
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
485
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw( Pikeo::API::Base ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
134
|
|
9
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
345
|
|
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
0
|
|
|
sub _info_fields {qw( user_id owner_id is_contact is_friend is_family )} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Pikeo::API::Contact - Abstraction of a pikeo use contact |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Provides access to a Pikeo::API::User contact details |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
You should not use this module directly. See Pikeo::API::User documentation. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 FUNCTIONS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 CONSTRUCTORS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head3 new( \%args ) |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Returns a Pikeo::API::Contact object. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Required args are: |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over 4 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * api |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Pikeo::API object |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item * from_xml |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
XML::LibXML node containing the contact details |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=back |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
sub new { |
47
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
48
|
0
|
|
|
|
|
|
my $params = shift; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new($params); |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if ( $params->{from_xml} ) { |
53
|
0
|
|
|
|
|
|
$self->_init_from_xml( $params->{from_xml} ); |
54
|
0
|
|
|
|
|
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
croak "Need an xml object"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 INSTANCE METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head3 owner() |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Pikeo::API::User that owns the contact |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub owner { |
68
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
return Pikeo::API::User->new({ id => $self->owner_id, api => $self->api }); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head3 user() |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Pikeo::API::User that is the contact |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub user { |
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
return Pikeo::API::User->new({ id => $self->user_id, api => $self->api }); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head3 user_id() |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head3 owner_id() |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head3 is_contact() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head3 is_friend() |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head3 is_family() |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _init_from_xml { |
96
|
0
|
|
|
0
|
|
|
my $self = shift; |
97
|
0
|
|
|
|
|
|
my $doc = shift; |
98
|
0
|
|
|
|
|
|
my $nodes = $doc->findnodes("./*"); |
99
|
0
|
|
|
|
|
|
for ($nodes->get_nodelist()) { |
100
|
0
|
0
|
|
|
|
|
if ( $_->to_literal eq 'null' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$self->{$_->nodeName} = undef; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
elsif ( $_->to_literal eq 'true' ) { |
104
|
0
|
|
|
|
|
|
$self->{$_->nodeName} = 1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
elsif ( $_->to_literal eq 'false' ) { |
107
|
0
|
|
|
|
|
|
$self->{$_->nodeName} = 0; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
else { |
110
|
0
|
|
|
|
|
|
$self->{$_->nodeName} = $_->to_literal; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
|
$self->{_init} = 1; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |