blib/lib/Etherpad.pm

filter: Statementstmt 5.8% 27 / 461 Branchbran 0.0% 0 / 166 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 12.0% 7 / 58 Podpod 100% 50 / 50 totaltotal 11.3% 84 / 740 CC 86 SCAR 34.5
CC
86
Cov
4%
_execute
210.0
list_names_of_authors_of_pad
42.0
append_chat_message
30.0
CRAP 31.7
↑ Summary
1 # vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
2 package Etherpad;
3 # ABSTRACT: interact with Etherpad API
4  
5 2 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Mojo::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Mojo::JSON qw(decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Mojo::IOLoop;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Carp qw(carp);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 has 'url';
13 2 has 'apikey';
14 2 has 'user';
15 2 has 'password';
16 2 has 'proxy';
17 1 ▶has 'ua' => sub { Mojo::UserAgent->new; };
Subroutine __ANON__: called CC=1 SCAR=0.0
18  
19 2 our $VERSION = '1.2.13.2';
20  
21  
22 sub _execute {
23 0 ▶ my $c = shift;
Subroutine _execute: not called CC=14 SCAR=53.5
24 0 my $args = shift;
25  
26 0 ▶ if (defined $c->proxy) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c->proxy) 0 0 0
27 0 ▶ if ($c->proxy->{detect}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->proxy->{'detect'}) { } 0 0 0
28 0 $c->ua->proxy->detect;
29 } else {
30 0 ▶ $c->ua->proxy->http($c->proxy->{http}) if defined $c->proxy->{http};
Branch: 1 branch
BranchTrueFalseTotal
if defined $c->proxy->{"http"} 0 0 0
31 0 ▶ $c->ua->proxy->http($c->proxy->{https}) if defined $c->proxy->{https};
Branch: 1 branch
BranchTrueFalseTotal
if defined $c->proxy->{"https"} 0 0 0
32 }
33 }
34  
35 0 my $url = Mojo::URL->new($c->url);
36 0 ▶ $url->userinfo($c->user.':'.$c->password) if defined $c->user && defined $c->password;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c->user and defined $c->password 0 0 0
Condition0%0/3
defined $c->user and defined $c->password
!ll&&!rl&&r
000
MC/DC0%0/2
defined $c->user and defined $c->password
defined $c->user defined $c->password
Truth table0%0/3
A and B
A= defined $c->userB= defined $c->password
ABresult
0X0
100
111
37  
38 0 my $path = $url->path;
39 0 $path =~ s#/$##;
40 0 $url->path($path.'/api/'.$args->{api}.'/'.$args->{method});
41  
42 0 $args->{args}->{apikey} = $c->apikey;
43  
44 0 my $res = $c->ua->get($url => form => $args->{args})->result;
45 0 ▶ if ($res->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_success) { } 0 0 0
46 # Can’t use $res->json when json is too large
47 0 my $json = decode_json($res->body);
48 0 ▶ if ($json->{code} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($json->{'code'} == 0) { } 0 0 0
49 0 ▶ return 1 if $args->{boolean};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"boolean"} 0 0 0
50 0 my $data;
51 0 ▶ if (defined $args->{key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{'key'}) { } 0 0 0
52 0 ▶ $data = (ref($json->{data}) eq 'HASH') ? $json->{data}->{$args->{key}} : $json->{data};
Branch: 1 branch
BranchTrueFalseTotal
ref $json->{'data'} eq 'HASH' ? : 0 0 0
53 } else {
54 0 $data = $json->{data};
55 }
56  
57 0 ▶ return (wantarray) ? @{$data}: $data if ref($data) eq 'ARRAY';
Branch: 2 branches
BranchTrueFalseTotal
if ref $data eq "ARRAY" 0 0 0
wantarray ? : 0 0 0
58 0 return $data;
59 } else {
60 0 carp $json->{message};
61 0 return undef;
62 }
63 } else {
64 0 carp Dumper $res->message;
65 0 return undef;
66 }
67 }
68  
69  
70 #################################################################
71 #################################################################
72  
73 #################### subroutine header begin ####################
74  
75  
76 #################### subroutine header end ####################
77  
78  
79 sub create_group {
80 0 ▶ my $c = shift;
Subroutine create_group: not called CC=1 SCAR=6.9
Pod documented
81  
82 0 return $c->_execute({
83 api => 1,
84 method => 'createGroup',
85 key => 'groupID'
86 });
87 }
88  
89  
90 #################### subroutine header begin ####################
91  
92  
93 #################### subroutine header end ####################
94  
95  
96 sub create_group_if_not_exists_for {
97 0 ▶ my $c = shift;
Subroutine create_group_if_not_exists_for: not called CC=2 SCAR=17.9
Pod documented
98 0 my $group_mapper = shift;
99  
100 0 ▶ unless (defined($group_mapper)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group_mapper) 0 0 0
101 0 carp 'Please provide a group id';
102 0 return undef;
103 }
104  
105 0 my $args = {
106 groupMapper => $group_mapper
107 };
108  
109 0 return $c->_execute({
110 api => 1,
111 method => 'createGroupIfNotExistsFor',
112 key => 'groupID',
113 args => $args
114 });
115 }
116  
117  
118 #################### subroutine header begin ####################
119  
120  
121 #################### subroutine header end ####################
122  
123  
124 sub delete_group {
125 0 ▶ my $c = shift;
Subroutine delete_group: not called CC=2 SCAR=17.9
Pod documented
126 0 my $group_id = shift;
127  
128 0 ▶ unless (defined($group_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group_id) 0 0 0
129 0 carp 'Please provide a group id';
130 0 return undef;
131 }
132  
133 0 my $args = {
134 groupID => $group_id
135 };
136  
137 0 return $c->_execute({
138 api => 1,
139 method => 'deleteGroup',
140 boolean => 1,
141 args => $args
142 });
143 }
144  
145  
146 #################### subroutine header begin ####################
147  
148  
149 #################### subroutine header end ####################
150  
151  
152 sub list_pads {
153 0 ▶ my $c = shift;
Subroutine list_pads: not called CC=2 SCAR=17.9
Pod documented
154 0 my $group_id = shift;
155  
156 0 ▶ unless (defined($group_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group_id) 0 0 0
157 0 carp 'Please provide a group id';
158 0 return undef;
159 }
160  
161 0 my $args = {
162 groupID => $group_id
163 };
164  
165 0 return $c->_execute({
166 api => 1,
167 method => 'listPads',
168 key => 'padIDs',
169 args => $args
170 });
171 }
172  
173  
174 #################### subroutine header begin ####################
175  
176  
177 #################### subroutine header end ####################
178  
179  
180 sub create_group_pad {
181 0 ▶ my $c = shift;
Subroutine create_group_pad: not called CC=3 SCAR=24.8
Pod documented
182 0 my $group_id = shift;
183 0 my $pad_name = shift;
184 0 my $text = shift;
185  
186 0 ▶ unless (defined($pad_name)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_name) 0 0 0
187 0 carp 'Please provide at least 2 arguments : the group id and the pad name';
188 return undef
189 0 }
190  
191 0 my $args = {
192 groupID => $group_id,
193 padName => $pad_name
194 };
195 0 ▶ $args->{text} = $text if defined $text;
Branch: 1 branch
BranchTrueFalseTotal
if defined $text 0 0 0
196  
197 0 return $c->_execute({
198 api => 1,
199 method => 'createGroupPad',
200 boolean => 1,
201 args => $args
202 });
203 }
204  
205  
206 #################### subroutine header begin ####################
207  
208  
209 #################### subroutine header end ####################
210  
211  
212 sub list_all_groups {
213 0 ▶ my $c = shift;
Subroutine list_all_groups: not called CC=1 SCAR=6.9
Pod documented
214  
215 0 return $c->_execute({
216 api => '1.1',
217 method => 'listAllGroups',
218 key => 'groupIDs'
219 });
220 }
221  
222  
223 #################################################################
224 #################################################################
225  
226 #################### subroutine header begin ####################
227  
228  
229 #################### subroutine header end ####################
230  
231  
232 sub create_author {
233 0 ▶ my $c = shift;
Subroutine create_author: not called CC=2 SCAR=17.9
Pod documented
234 0 my $name = shift;
235  
236 0 my $args = {};
237 0 ▶ $args->{name} = $name if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 0 0
238  
239 0 return $c->_execute({
240 api => 1,
241 method => 'createAuthor',
242 key => 'authorID',
243 args => $args
244 });
245 }
246  
247  
248 #################### subroutine header begin ####################
249  
250  
251 #################### subroutine header end ####################
252  
253  
254 sub create_author_if_not_exists_for {
255 0 ▶ my $c = shift;
Subroutine create_author_if_not_exists_for: not called CC=3 SCAR=24.8
Pod documented
256 0 my $author_mapper = shift;
257 0 my $name = shift;
258  
259 0 ▶ unless (defined($author_mapper)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $author_mapper) 0 0 0
260 0 carp 'Please provide your application author id';
261 0 return undef;
262 }
263  
264 0 my $args = {
265 authorMapper => $author_mapper
266 };
267 0 ▶ $args->{name} = $name if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 0 0
268  
269 0 return $c->_execute({
270 api => 1,
271 method => 'createAuthorIfNotExistsFor',
272 key => 'authorID',
273 args => $args
274 });
275 }
276  
277  
278 #################### subroutine header begin ####################
279  
280  
281 #################### subroutine header end ####################
282  
283  
284 sub list_pads_of_author {
285 0 ▶ my $c = shift;
Subroutine list_pads_of_author: not called CC=2 SCAR=17.9
Pod documented
286 0 my $author_id = shift;
287  
288 0 ▶ unless (defined($author_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $author_id) 0 0 0
289 0 carp 'Please provide an author id';
290 0 return undef;
291 }
292  
293 0 my $args = {
294 authorID => $author_id
295 };
296  
297 0 return $c->_execute({
298 api => 1,
299 method => 'listPadsOfAuthor',
300 key => 'padIDs',
301 args => $args
302 });
303 }
304  
305  
306 #################### subroutine header end ####################
307  
308  
309 sub get_author_name {
310 0 ▶ my $c = shift;
Subroutine get_author_name: not called CC=2 SCAR=17.9
Pod documented
311 0 my $author_id = shift;
312  
313 0 ▶ unless (defined($author_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $author_id) 0 0 0
314 0 carp 'Please provide an author id';
315 0 return undef;
316 }
317  
318 0 my $args = {
319 authorID => $author_id
320 };
321  
322 0 return $c->_execute({
323 api => '1.1',
324 method => 'getAuthorName',
325 key => 'authorName',
326 args => $args
327 });
328 }
329  
330  
331 #################################################################
332 #################################################################
333  
334 #################### subroutine header begin ####################
335  
336  
337 #################### subroutine header end ####################
338  
339  
340 sub create_session {
341 0 ▶ my $c = shift;
Subroutine create_session: not called CC=3 SCAR=24.8
Pod documented
342 0 my $group_id = shift;
343 0 my $author_id = shift;
344 0 my $valid_until = shift;
345  
346 0 ▶ unless (defined($valid_until)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $valid_until) 0 0 0
347 0 carp 'Please provide 3 arguments : the group id, the author id and a valid unix timestamp';
348 0 return undef;
349 }
350 0 ▶ unless ($valid_until =~ m/\d+/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($valid_until =~ /\d+/u) 0 0 0
351 0 carp 'Please provide a *valid* unix timestamp as third argument';
352 0 return undef;
353 }
354  
355 0 my $args = {
356 groupID => $group_id,
357 authorID => $author_id,
358 validUntil => $valid_until
359 };
360  
361 0 return $c->_execute({
362 api => 1,
363 method => 'createSession',
364 key => 'sessionID',
365 args => $args
366 });
367 }
368  
369  
370 #################### subroutine header begin ####################
371  
372  
373 #################### subroutine header end ####################
374  
375  
376 sub delete_session {
377 0 ▶ my $c = shift;
Subroutine delete_session: not called CC=2 SCAR=17.9
Pod documented
378 0 my $session_id = shift;
379  
380 0 ▶ unless (defined($session_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $session_id) 0 0 0
381 0 carp 'Please provide a session id';
382 0 return undef;
383 }
384  
385 0 my $args = {
386 sessionID => $session_id
387 };
388  
389 0 return $c->_execute({
390 api => 1,
391 method => 'deleteSession',
392 boolean => 1,
393 args => $args
394 });
395 }
396  
397  
398 #################### subroutine header begin ####################
399  
400  
401 #################### subroutine header end ####################
402  
403  
404 sub get_session_info {
405 0 ▶ my $c = shift;
Subroutine get_session_info: not called CC=2 SCAR=17.9
Pod documented
406 0 my $session_id = shift;
407  
408 0 ▶ unless (defined($session_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $session_id) 0 0 0
409 0 carp 'Please provide a session id';
410 0 return undef;
411 }
412  
413 0 my $args = {
414 sessionID => $session_id
415 };
416  
417 0 return $c->_execute({
418 api => 1,
419 method => 'getSessionInfo',
420 args => $args
421 });
422 }
423  
424  
425 #################### subroutine header begin ####################
426  
427  
428 #################### subroutine header end ####################
429  
430  
431 sub list_sessions_of_group {
432 0 ▶ my $c = shift;
Subroutine list_sessions_of_group: not called CC=2 SCAR=17.9
Pod documented
433 0 my $group_id = shift;
434  
435 0 ▶ unless (defined($group_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group_id) 0 0 0
436 0 carp 'Please provide a group id';
437 0 return undef;
438 }
439  
440 0 my $args = {
441 groupID => $group_id
442 };
443  
444 0 return $c->_execute({
445 api => 1,
446 method => 'listSessionsOfGroup',
447 args => $args
448 });
449 }
450  
451  
452 #################### subroutine header begin ####################
453  
454  
455 #################### subroutine header end ####################
456  
457  
458 sub list_sessions_of_author {
459 0 ▶ my $c = shift;
Subroutine list_sessions_of_author: not called CC=2 SCAR=17.9
Pod documented
460 0 my $author_id = shift;
461  
462 0 ▶ unless (defined($author_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $author_id) 0 0 0
463 0 carp 'Please provide an author id';
464 0 return undef;
465 }
466  
467 0 my $args = {
468 authorID => $author_id
469 };
470  
471 0 return $c->_execute({
472 api => 1,
473 method => 'listSessionsOfAuthor',
474 args => $args
475 });
476 }
477  
478  
479 #################################################################
480 #################################################################
481  
482 #################### subroutine header begin ####################
483  
484  
485 #################### subroutine header end ####################
486  
487  
488 sub get_text {
489 0 ▶ my $c = shift;
Subroutine get_text: not called CC=3 SCAR=24.8
Pod documented
490 0 my $pad_id = shift;
491 0 my $rev = shift;
492  
493 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
494 0 carp 'Please provide at least a pad id';
495 0 return undef;
496 }
497  
498 0 my $args = {
499 padID => $pad_id
500 };
501 0 ▶ $args->{rev} = $rev if defined $rev;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rev 0 0 0
502  
503 0 return $c->_execute({
504 api => 1,
505 method => 'getText',
506 key => 'text',
507 args => $args
508 });
509 }
510  
511  
512 #################### subroutine header begin ####################
513  
514  
515 #################### subroutine header end ####################
516  
517  
518 sub set_text {
519 0 ▶ my $c = shift;
Subroutine set_text: not called CC=2 SCAR=17.9
Pod documented
520 0 my $pad_id = shift;
521 0 my $text = shift;
522  
523 0 ▶ unless (defined($text)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $text) 0 0 0
524 0 carp 'Please provide 2 arguments : a pad id and a text';
525 0 return undef;
526 }
527  
528 0 my $args = {
529 padID => $pad_id,
530 text => $text
531 };
532  
533 0 return $c->_execute({
534 api => 1,
535 method => 'setText',
536 boolean => 1,
537 args => $args
538 });
539 }
540  
541  
542 #################### subroutine header begin ####################
543  
544  
545 #################### subroutine header end ####################
546  
547  
548 sub append_text {
549 0 ▶ my $c = shift;
Subroutine append_text: not called CC=2 SCAR=17.9
Pod documented
550 0 my $pad_id = shift;
551 0 my $text = shift;
552  
553 0 ▶ unless (defined($text)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $text) 0 0 0
554 0 carp 'Please provide 2 arguments : a pad id and a text';
555 0 return undef;
556 }
557  
558 0 my $args = {
559 padID => $pad_id,
560 text => $text
561 };
562  
563 0 return $c->_execute({
564 api => '1.2.13',
565 method => 'appendText',
566 boolean => 1,
567 args => $args
568 });
569 }
570  
571  
572 #################### subroutine header begin ####################
573  
574  
575 #################### subroutine header end ####################
576  
577  
578 sub get_html {
579 0 ▶ my $c = shift;
Subroutine get_html: not called CC=3 SCAR=24.8
Pod documented
580 0 my $pad_id = shift;
581 0 my $rev = shift;
582  
583 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
584 0 carp 'Please provide at least a pad id';
585 0 return undef;
586 }
587  
588 0 my $args = {
589 padID => $pad_id
590 };
591 0 ▶ $args->{rev} = $rev if defined $rev;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rev 0 0 0
592  
593 0 return $c->_execute({
594 api => 1,
595 method => 'getHTML',
596 key => 'html',
597 args => $args
598 });
599 }
600  
601  
602 #################### subroutine header begin ####################
603  
604  
605 #################### subroutine header end ####################
606  
607  
608 sub set_html {
609 0 ▶ my $c = shift;
Subroutine set_html: not called CC=2 SCAR=17.9
Pod documented
610 0 my $pad_id = shift;
611 0 my $html = shift;
612  
613 0 ▶ unless (defined($html)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $html) 0 0 0
614 0 carp 'Please provide 2 arguments : a pad id and a HTML code';
615 0 return undef;
616 }
617  
618 0 my $args = {
619 padID => $pad_id,
620 html => $html
621 };
622  
623 0 return $c->_execute({
624 api => 1,
625 method => 'setHTML',
626 boolean => 1,
627 args => $args
628 });
629 }
630  
631  
632 #################### subroutine header begin ####################
633  
634  
635 #################### subroutine header end ####################
636  
637  
638 sub get_attribute_pool {
639 0 ▶ my $c = shift;
Subroutine get_attribute_pool: not called CC=2 SCAR=17.9
Pod documented
640 0 my $pad_id = shift;
641  
642 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
643 0 carp 'Please provide a pad id';
644 0 return undef;
645 }
646  
647 0 my $args = {
648 padID => $pad_id
649 };
650  
651 0 return $c->_execute({
652 api => '1.2.8',
653 method => 'getAttributePool',
654 key => 'pool',
655 args => $args
656 });
657 }
658  
659  
660 #################### subroutine header begin ####################
661  
662  
663 #################### subroutine header end ####################
664  
665  
666 sub get_revision_changeset {
667 0 ▶ my $c = shift;
Subroutine get_revision_changeset: not called CC=3 SCAR=24.8
Pod documented
668 0 my $pad_id = shift;
669 0 my $rev = shift;
670  
671 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
672 0 carp 'Please provide at least a pad id';
673 0 return undef;
674 }
675  
676 0 my $args = {
677 padID => $pad_id
678 };
679 0 ▶ $args->{rev} = $rev if defined $rev;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rev 0 0 0
680  
681 0 return $c->_execute({
682 api => '1.2.8',
683 method => 'getRevisionChangeset',
684 args => $args
685 });
686 }
687  
688  
689 #################### subroutine header begin ####################
690  
691  
692 #################### subroutine header end ####################
693  
694  
695 sub create_diff_html {
696 0 ▶ my $c = shift;
Subroutine create_diff_html: not called CC=4 SCAR=30.0
Pod documented
697 0 my $pad_id = shift;
698 0 my $start_rev = shift;
699 0 my $end_rev = shift;
700  
701 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
702 0 carp 'Please provide a pad id, a start_rev and an end_rev';
703 0 return undef;
704 }
705  
706 0 ▶ unless (defined($start_rev)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $start_rev) 0 0 0
707 0 carp 'Please provide a start_rev and an end_rev';
708 0 return undef;
709 }
710  
711 0 ▶ unless (defined($end_rev)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $end_rev) 0 0 0
712 0 carp 'Please provide an end_rev';
713 0 return undef;
714 }
715  
716 0 my $args = {
717 padID => $pad_id,
718 startRev => $start_rev,
719 endRev => $end_rev
720 };
721  
722 0 return $c->_execute({
723 api => '1.2.7',
724 method => 'createDiffHTML',
725 args => $args
726 });
727 }
728  
729  
730 #################### subroutine header begin ####################
731  
732  
733 #################### subroutine header end ####################
734  
735  
736 sub restore_revision {
737 0 ▶ my $c = shift;
Subroutine restore_revision: not called CC=3 SCAR=24.8
Pod documented
738 0 my $pad_id = shift;
739 0 my $rev = shift;
740  
741 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
742 0 carp 'Please provide a pad id, a start_rev and an end_rev';
743 0 return undef;
744 }
745  
746 0 ▶ unless (defined($rev)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rev) 0 0 0
747 0 carp 'Please provide a revision number';
748 0 return undef;
749 }
750  
751 0 my $args = {
752 padID => $pad_id,
753 rev => $rev
754 };
755  
756 0 return $c->_execute({
757 api => '1.2.11',
758 method => 'restoreRevision',
759 boolean => 1,
760 args => $args
761 });
762 }
763  
764  
765 #################################################################
766 #################################################################
767  
768 #################### subroutine header begin ####################
769  
770  
771 #################### subroutine header end ####################
772  
773  
774 sub get_chat_history {
775 0 ▶ my $c = shift;
Subroutine get_chat_history: not called CC=4 SCAR=30.0
Pod documented
776 0 my $pad_id = shift;
777 0 my $start = shift;
778 0 my $end = shift;
779  
780 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
781 0 carp 'Please provide at least a pad id';
782 0 return undef;
783 }
784  
785 0 my $args = {
786 padID => $pad_id
787 };
788 0 ▶ $args->{start} = $start if defined $start;
Branch: 1 branch
BranchTrueFalseTotal
if defined $start 0 0 0
789 0 ▶ $args->{end} = $end if defined $end;
Branch: 1 branch
BranchTrueFalseTotal
if defined $end 0 0 0
790  
791 0 return $c->_execute({
792 api => '1.2.7',
793 method => 'getChatHistory',
794 key => 'messages',
795 args => $args
796 });
797 }
798  
799  
800 #################### subroutine header begin ####################
801  
802  
803 #################### subroutine header end ####################
804  
805  
806 sub get_chat_head {
807 0 ▶ my $c = shift;
Subroutine get_chat_head: not called CC=2 SCAR=17.9
Pod documented
808 0 my $pad_id = shift;
809  
810 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
811 0 carp 'Please provide a pad id';
812 0 return undef;
813 }
814  
815 0 my $args = {
816 padID => $pad_id
817 };
818  
819 0 return $c->_execute({
820 api => '1.2.7',
821 method => 'getChatHead',
822 key => 'chatHead',
823 args => $args
824 });
825 }
826  
827  
828 #################### subroutine header begin ####################
829  
830  
831 #################### subroutine header end ####################
832  
833  
834 sub append_chat_message {
835 0 ▶ my $c = shift;
Subroutine append_chat_message: not called CC=5 SCAR=34.0
Pod documented
836 0 my $pad_id = shift;
837 0 my $text = shift;
838 0 my $author_id = shift;
839 0 my $timestamp = shift;
840  
841 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
842 0 carp 'Please provide a pad id, a text, an authorID and a timestamp';
843 0 return undef;
844 }
845  
846 0 ▶ unless (defined($text)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $text) 0 0 0
847 0 carp 'Please provide a text, an authorID and a timestamp';
848 0 return undef;
849 }
850  
851 0 ▶ unless (defined($author_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $author_id) 0 0 0
852 0 carp 'Please provide an authorID and a timestamp';
853 0 return undef;
854 }
855  
856 0 ▶ unless (defined($timestamp)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $timestamp) 0 0 0
857 0 carp 'Please provide a timestamp';
858 0 return undef;
859 }
860  
861 0 my $args = {
862 padID => $pad_id,
863 text => $text,
864 authorID => $author_id,
865 time => $timestamp
866 };
867  
868 0 return $c->_execute({
869 api => '1.2.12',
870 method => 'appendChatMessage',
871 boolean => 1,
872 args => $args
873 });
874 }
875  
876  
877 #################################################################
878 #################################################################
879  
880 #################### subroutine header begin ####################
881  
882  
883 #################### subroutine header end ####################
884  
885  
886 sub create_pad {
887 0 ▶ my $c = shift;
Subroutine create_pad: not called CC=3 SCAR=24.8
Pod documented
888 0 my $pad_id = shift;
889 0 my $text = shift;
890  
891 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
892 0 carp 'Please provide at least a pad id';
893 0 return undef;
894 }
895  
896 0 my $args = {
897 padID => $pad_id
898 };
899 0 ▶ $args->{text} = $text if defined $text;
Branch: 1 branch
BranchTrueFalseTotal
if defined $text 0 0 0
900  
901 0 return $c->_execute({
902 api => 1,
903 method => 'createPad',
904 boolean => 1,
905 args => $args
906 });
907 }
908  
909  
910 #################### subroutine header begin ####################
911  
912  
913 #################### subroutine header end ####################
914  
915  
916 sub get_revisions_count {
917 0 ▶ my $c = shift;
Subroutine get_revisions_count: not called CC=2 SCAR=17.9
Pod documented
918 0 my $pad_id = shift;
919  
920 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
921 0 carp 'Please provide a pad id';
922 0 return undef;
923 }
924  
925 0 my $args = {
926 padID => $pad_id
927 };
928  
929 0 return $c->_execute({
930 api => 1,
931 method => 'getRevisionsCount',
932 key => 'revisions',
933 args => $args
934 });
935 }
936  
937  
938 #################### subroutine header begin ####################
939  
940  
941 #################### subroutine header end ####################
942  
943  
944 sub get_saved_revisions_count {
945 0 ▶ my $c = shift;
Subroutine get_saved_revisions_count: not called CC=2 SCAR=17.9
Pod documented
946 0 my $pad_id = shift;
947  
948 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
949 0 carp 'Please provide a pad id';
950 0 return undef;
951 }
952  
953 0 my $args = {
954 padID => $pad_id
955 };
956  
957 0 return $c->_execute({
958 api => '1.2.11',
959 method => 'getSavedRevisionsCount',
960 key => 'savedRevisions',
961 args => $args
962 });
963 }
964  
965  
966 #################### subroutine header begin ####################
967  
968  
969 #################### subroutine header end ####################
970  
971  
972 sub list_saved_revisions {
973 0 ▶ my $c = shift;
Subroutine list_saved_revisions: not called CC=2 SCAR=17.9
Pod documented
974 0 my $pad_id = shift;
975  
976 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
977 0 carp 'Please provide a pad id';
978 0 return undef;
979 }
980  
981 0 my $args = {
982 padID => $pad_id
983 };
984  
985 0 return $c->_execute({
986 api => '1.2.11',
987 method => 'listSavedRevisions',
988 key => 'savedRevisions',
989 args => $args
990 });
991 }
992  
993  
994 #################### subroutine header begin ####################
995  
996  
997 #################### subroutine header end ####################
998  
999  
1000 sub save_revision {
1001 0 ▶ my $c = shift;
Subroutine save_revision: not called CC=3 SCAR=24.8
Pod documented
1002 0 my $pad_id = shift;
1003 0 my $rev = shift;
1004  
1005 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1006 0 carp 'Please provide a pad id';
1007 0 return undef;
1008 }
1009  
1010 0 my $args = {
1011 padID => $pad_id
1012 };
1013 0 ▶ $args->{rev} = $rev if defined $rev;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rev 0 0 0
1014  
1015 0 return $c->_execute({
1016 api => '1.2.11',
1017 method => 'saveRevision',
1018 boolean => 1,
1019 args => $args
1020 });
1021 }
1022  
1023  
1024 #################### subroutine header begin ####################
1025  
1026  
1027 #################### subroutine header end ####################
1028  
1029  
1030 sub get_users_count {
1031 0 ▶ my $c = shift;
Subroutine get_users_count: not called CC=1 SCAR=6.9
Pod documented
1032 0 my $pad_id = shift;
1033  
1034 0 return $c->pad_users_count($pad_id);
1035 }
1036  
1037 sub pad_users_count {
1038 0 ▶ my $c = shift;
Subroutine pad_users_count: not called CC=2 SCAR=17.9
Pod documented
1039 0 my $pad_id = shift;
1040  
1041 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1042 0 carp 'Please provide a pad id';
1043 0 return undef;
1044 }
1045  
1046 0 my $args = {
1047 padID => $pad_id
1048 };
1049  
1050 0 return $c->_execute({
1051 api => 1,
1052 method => 'padUsersCount',
1053 key => 'padUsersCount',
1054 args => $args
1055 });
1056 }
1057  
1058  
1059 #################### subroutine header begin ####################
1060  
1061  
1062 #################### subroutine header end ####################
1063  
1064  
1065 sub pad_users {
1066 0 ▶ my $c = shift;
Subroutine pad_users: not called CC=2 SCAR=17.9
Pod documented
1067 0 my $pad_id = shift;
1068  
1069 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1070 0 carp 'Please provide a pad id';
1071 0 return undef;
1072 }
1073  
1074 0 my $args = {
1075 padID => $pad_id
1076 };
1077  
1078 0 return $c->_execute({
1079 api => '1.1',
1080 method => 'padUsers',
1081 key => 'padUsers',
1082 args => $args
1083 });
1084 }
1085  
1086  
1087 #################### subroutine header begin ####################
1088  
1089  
1090 #################### subroutine header end ####################
1091  
1092  
1093 sub delete_pad {
1094 0 ▶ my $c = shift;
Subroutine delete_pad: not called CC=2 SCAR=17.9
Pod documented
1095 0 my $pad_id = shift;
1096  
1097 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1098 0 carp 'Please provide a pad id';
1099 0 return undef;
1100 }
1101  
1102 0 my $args = {
1103 padID => $pad_id
1104 };
1105  
1106 0 return $c->_execute({
1107 api => 1,
1108 method => 'deletePad',
1109 boolean => 1,
1110 args => $args
1111 });
1112 }
1113  
1114  
1115 #################### subroutine header begin ####################
1116  
1117  
1118 #################### subroutine header end ####################
1119  
1120  
1121 sub copy_pad {
1122 0 ▶ my $c = shift;
Subroutine copy_pad: not called CC=5 SCAR=34.0
Pod documented
1123 0 my $source_id = shift;
1124 0 my $destination_id = shift;
1125 0 my $force = shift;
1126  
1127 0 ▶ unless (defined($source_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $source_id) 0 0 0
1128 0 carp 'Please provide a source pad id and a destination pad id';
1129 0 return undef;
1130 }
1131  
1132 0 ▶ unless (defined($destination_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $destination_id) 0 0 0
1133 0 carp 'Please provide a destination pad id';
1134 0 return undef;
1135 }
1136  
1137 0 $source_id =~ s/ /_/g;
1138 0 $destination_id =~ s/ /_/g;
1139  
1140 0 my $args = {
1141 sourceID => $source_id,
1142 destinationID => $destination_id,
1143 };
1144 0 ▶ $args->{force} = ($force) ? 'true' : 'false' if defined $force;
Branch: 2 branches
BranchTrueFalseTotal
if defined $force 0 0 0
$force ? : 0 0 0
1145  
1146 0 return $c->_execute({
1147 api => '1.2.9',
1148 method => 'copyPad',
1149 boolean => 1,
1150 args => $args
1151 });
1152 }
1153  
1154  
1155 #################### subroutine header begin ####################
1156  
1157  
1158 #################### subroutine header end ####################
1159  
1160  
1161 sub move_pad {
1162 0 ▶ my $c = shift;
Subroutine move_pad: not called CC=5 SCAR=34.0
Pod documented
1163 0 my $source_id = shift;
1164 0 my $destination_id = shift;
1165 0 my $force = shift;
1166  
1167 0 ▶ unless (defined($source_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $source_id) 0 0 0
1168 0 carp 'Please provide a source pad id and a destination pad id';
1169 0 return undef;
1170 }
1171  
1172 0 ▶ unless (defined($destination_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $destination_id) 0 0 0
1173 0 carp 'Please provide a destination pad id';
1174 0 return undef;
1175 }
1176  
1177 0 $source_id =~ s/ /_/g;
1178 0 $destination_id =~ s/ /_/g;
1179  
1180 0 my $args = {
1181 sourceID => $source_id,
1182 destinationID => $destination_id,
1183 };
1184 0 ▶ $args->{force} = ($force) ? 'true' : 'false' if defined $force;
Branch: 2 branches
BranchTrueFalseTotal
if defined $force 0 0 0
$force ? : 0 0 0
1185  
1186 0 return $c->_execute({
1187 api => '1.2.9',
1188 method => 'movePad',
1189 boolean => 1,
1190 args => $args
1191 });
1192 }
1193  
1194  
1195 #################### subroutine header begin ####################
1196  
1197  
1198 #################### subroutine header end ####################
1199  
1200  
1201 sub get_read_only_id {
1202 0 ▶ my $c = shift;
Subroutine get_read_only_id: not called CC=2 SCAR=17.9
Pod documented
1203 0 my $pad_id = shift;
1204  
1205 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1206 0 carp 'Please provide a pad id';
1207 0 return undef;
1208 }
1209  
1210 0 my $args = {
1211 padID => $pad_id
1212 };
1213  
1214 0 return $c->_execute({
1215 api => 1,
1216 method => 'getReadOnlyID',
1217 key => 'readOnlyID',
1218 args => $args
1219 });
1220 }
1221  
1222  
1223 #################### subroutine header begin ####################
1224  
1225  
1226 #################### subroutine header end ####################
1227  
1228  
1229 sub get_pad_id {
1230 0 ▶ my $c = shift;
Subroutine get_pad_id: not called CC=2 SCAR=17.9
Pod documented
1231 0 my $read_only_id = shift;
1232  
1233 0 ▶ unless (defined($read_only_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $read_only_id) 0 0 0
1234 0 carp 'Please provide a read only id';
1235 0 return undef;
1236 }
1237  
1238 0 my $args = {
1239 padID => $read_only_id
1240 };
1241  
1242 0 return $c->_execute({
1243 api => '1.2.10',
1244 method => 'getPadID',
1245 key => 'padID',
1246 args => $args
1247 });
1248 }
1249  
1250  
1251 #################### subroutine header begin ####################
1252  
1253  
1254 #################### subroutine header end ####################
1255  
1256  
1257 sub set_public_status {
1258 0 ▶ my $c = shift;
Subroutine set_public_status: not called CC=3 SCAR=24.8
Pod documented
1259 0 my $pad_id = shift;
1260 0 my $public_status = shift;
1261  
1262 0 ▶ unless (defined($public_status)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $public_status) 0 0 0
1263 0 carp 'Please provide 2 arguments : a pad id and a public status (1 or 0)';
1264 0 return undef;
1265 }
1266  
1267 0 ▶ my $args = {
Branch: 1 branch
BranchTrueFalseTotal
$public_status ? : 0 0 0
1268 padID => $pad_id,
1269 publicStatus => ($public_status) ? 'true' : 'false'
1270 };
1271  
1272 0 return $c->_execute({
1273 api => 1,
1274 method => 'setPublicStatus',
1275 boolean => 1,
1276 args => $args
1277 });
1278 }
1279  
1280  
1281 #################### subroutine header begin ####################
1282  
1283  
1284 #################### subroutine header end ####################
1285  
1286  
1287 sub get_public_status {
1288 0 ▶ my $c = shift;
Subroutine get_public_status: not called CC=2 SCAR=17.9
Pod documented
1289 0 my $pad_id = shift;
1290  
1291 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1292 0 carp 'Please provide a pad id';
1293 0 return undef;
1294 }
1295  
1296 0 my $args = {
1297 padID => $pad_id
1298 };
1299  
1300 0 return $c->_execute({
1301 api => 1,
1302 method => 'getPublicStatus',
1303 key => 'publicStatus',
1304 args => $args
1305 });
1306 }
1307  
1308  
1309 #################### subroutine header begin ####################
1310  
1311  
1312 #################### subroutine header end ####################
1313  
1314  
1315 sub set_password {
1316 0 ▶ my $c = shift;
Subroutine set_password: not called CC=2 SCAR=17.9
Pod documented
1317 0 my $pad_id = shift;
1318 0 my $password = shift;
1319  
1320 0 ▶ unless (defined($password)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $password) 0 0 0
1321 0 carp 'Please provide 2 arguments : a pad id and a password';
1322 0 return undef;
1323 }
1324  
1325 0 my $args = {
1326 padID => $pad_id,
1327 password => $password
1328 };
1329  
1330 0 return $c->_execute({
1331 api => 1,
1332 method => 'setPassword',
1333 boolean => 1,
1334 args => $args
1335 });
1336 }
1337  
1338  
1339 #################### subroutine header begin ####################
1340  
1341  
1342 #################### subroutine header end ####################
1343  
1344  
1345 sub is_password_protected {
1346 0 ▶ my $c = shift;
Subroutine is_password_protected: not called CC=2 SCAR=17.9
Pod documented
1347 0 my $pad_id = shift;
1348  
1349 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1350 0 carp 'Please provide a pad id';
1351 0 return undef;
1352 }
1353  
1354 0 my $args = {
1355 padID => $pad_id
1356 };
1357  
1358 0 return $c->_execute({
1359 api => 1,
1360 method => 'isPasswordProtected',
1361 key => 'isPasswordProtected',
1362 args => $args
1363 });
1364 }
1365  
1366  
1367 #################### subroutine header begin ####################
1368  
1369  
1370 #################### subroutine header end ####################
1371  
1372  
1373 sub list_authors_of_pad {
1374 0 ▶ my $c = shift;
Subroutine list_authors_of_pad: not called CC=2 SCAR=17.9
Pod documented
1375 0 my $pad_id = shift;
1376  
1377 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1378 0 carp 'Please provide a pad id';
1379 0 return undef;
1380 }
1381  
1382 0 my $args = {
1383 padID => $pad_id
1384 };
1385  
1386 0 return $c->_execute({
1387 api => 1,
1388 method => 'listAuthorsOfPad',
1389 key => 'authorIDs',
1390 args => $args
1391 });
1392 }
1393  
1394  
1395 #################### subroutine header begin ####################
1396  
1397  
1398 #################### subroutine header end ####################
1399  
1400  
1401 sub list_names_of_authors_of_pad {
1402 0 ▶ my $c = shift;
Subroutine list_names_of_authors_of_pad: not called CC=6 SCAR=37.4
Pod documented
1403 0 my $pad_id = shift;
1404  
1405 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1406 0 carp 'Please provide a pad id';
1407 0 return undef;
1408 }
1409  
1410 0 my @names;
1411 0 my $anonymous = 0;
1412  
1413 0 my @authors = $c->list_authors_of_pad($pad_id);
1414 0 for my $author (@authors) {
1415 0 my $name = $c->get_author_name($author);
1416 0 ▶ if (defined($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) { } 0 0 0
1417 0 push @names, $name;
1418 } else {
1419 0 $anonymous++;
1420 }
1421 }
1422 0 @names = sort(@names);
1423 0 ▶ push @names, $anonymous . ' anonymous' if ($anonymous);
Branch: 1 branch
BranchTrueFalseTotal
if $anonymous 0 0 0
1424  
1425 0 ▶ return (wantarray) ? @names : \@names;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1426 }
1427  
1428  
1429 #################### subroutine header begin ####################
1430  
1431  
1432 #################### subroutine header end ####################
1433  
1434  
1435 sub get_last_edited {
1436 0 ▶ my $c = shift;
Subroutine get_last_edited: not called CC=2 SCAR=17.9
Pod documented
1437 0 my $pad_id = shift;
1438  
1439 0 ▶ unless (defined($pad_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pad_id) 0 0 0
1440 0 carp 'Please provide at least a pad id';
1441 0 return undef;
1442 }
1443  
1444 0 my $args = {
1445 padID => $pad_id
1446 };
1447  
1448 0 return $c->_execute({
1449 api => 1,
1450 method => 'getLastEdited',
1451 key => 'lastEdited',
1452 args => $args
1453 });
1454 }
1455  
1456  
1457 #################### subroutine header begin ####################
1458  
1459  
1460 #################### subroutine header end ####################
1461  
1462  
1463 sub send_clients_message {
1464 0 ▶ my $c = shift;
Subroutine send_clients_message: not called CC=2 SCAR=17.9
Pod documented
1465 0 my $pad_id = shift;
1466 0 my $msg = shift;
1467  
1468 0 ▶ unless (defined($msg)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $msg) 0 0 0
1469 0 carp "Please provide 2 arguments : the pad id and a message";
1470 0 return undef;
1471 }
1472  
1473 0 my $args = {
1474 padID => $pad_id,
1475 msg => $msg
1476 };
1477  
1478 0 return $c->_execute({
1479 api => '1.1',
1480 method => 'sendClientsMessage',
1481 boolean => 1,
1482 args => $args
1483 });
1484 }
1485  
1486  
1487 #################### subroutine header begin ####################
1488  
1489  
1490 #################### subroutine header end ####################
1491  
1492  
1493 sub check_token {
1494 0 ▶ my $c = shift;
Subroutine check_token: not called CC=1 SCAR=6.9
Pod documented
1495  
1496 0 my $args = {};
1497  
1498 0 return $c->_execute({
1499 api => '1.2',
1500 method => 'checkToken',
1501 boolean => 1,
1502 args => $args
1503 });
1504 }
1505  
1506  
1507 #################################################################
1508 #################################################################
1509  
1510 #################### subroutine header begin ####################
1511  
1512  
1513  
1514 sub list_all_pads {
1515 0 ▶ my $c = shift;
Subroutine list_all_pads: not called CC=1 SCAR=6.9
Pod documented
1516  
1517 0 my $args = {};
1518  
1519 0 return $c->_execute({
1520 api => '1.2.1',
1521 method => 'listAllPads',
1522 key => 'padIDs',
1523 args => $args
1524 });
1525 }
1526  
1527 #################### footer pod documentation begin ###################
1528 #################### footer pod documentation end ###################
1529  
1530 2 1;
1531  
1532 __END__
↑ Summary