line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pikeo::API::Comment; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5296
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw( Pikeo::API::Base ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
109
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
77
|
|
9
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
377
|
|
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
0
|
|
|
sub _info_fields {qw( owner_id owner_username date picture_id parent_id text )} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Pikeo::API::Comment - Abstraction of a pikeo user comment |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Provides access to a comment details |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
You should not use this module directly. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 FUNCTIONS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 CONSTRUCTORS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head3 new( \%args ) |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Returns a Pikeo::API::Comment 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
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub new { |
48
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
49
|
0
|
|
|
|
|
|
my $params = shift; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new($params); |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if ( $params->{from_xml} ) { |
54
|
0
|
|
|
|
|
|
$self->_init_from_xml( $params->{from_xml} ); |
55
|
0
|
|
|
|
|
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
croak "Need an xml object"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head3 id() |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The id of the comment |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
0
|
|
|
0
|
1
|
|
sub id { return shift->{id} } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head3 update(\%args) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Updates the text of the comment. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
You must be owner |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Required args are: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over 4 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * text |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
The text to update |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=back |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
sub update { |
85
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
86
|
0
|
|
|
|
|
|
my $params = shift; |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
croak "missing required param 'text'" unless $params->{text}; |
89
|
0
|
|
|
|
|
|
$self->api->request_parsed( 'pikeo.comments.updateComment', |
90
|
|
|
|
|
|
|
{ comment_id => $self->id, |
91
|
|
|
|
|
|
|
text => $params->{text}, |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
); |
94
|
0
|
|
|
|
|
|
return 1; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head3 delete() |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Deletes the comment. You must be owner |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
sub delete { |
103
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
104
|
0
|
|
|
|
|
|
my $params = shift; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$self->api->request_parsed( 'pikeo.comments.deleteComment', |
107
|
|
|
|
|
|
|
{ comment_id => $self->id } |
108
|
|
|
|
|
|
|
); |
109
|
0
|
|
|
|
|
|
return 1; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head3 owner_id |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head3 owner_username |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head3 date |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head3 picture_id |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head3 parent_id |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head3 text |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _init_from_xml { |
127
|
0
|
|
|
0
|
|
|
my $self = shift; |
128
|
0
|
|
|
|
|
|
my $doc = shift; |
129
|
0
|
|
|
|
|
|
my $nodes = $doc->findnodes("./*"); |
130
|
0
|
|
|
|
|
|
for ($nodes->get_nodelist()) { |
131
|
0
|
0
|
|
|
|
|
$self->{$_->nodeName} = ( $_->to_literal eq 'null' ? undef : $_->to_literal ); |
132
|
|
|
|
|
|
|
} |
133
|
0
|
0
|
|
|
|
|
croak "could not init from XML, missing id" unless $self->{id}; |
134
|
0
|
|
|
|
|
|
$self->{_init} = 1; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |