RestApi/DriveApi3/Comment.pm

filter: Statementstmt 83.9% 47 / 56 Branchbran 30.0% 3 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.8% 13 / 14 Podpod 88.8% 8 / 9 totaltotal 79.7% 71 / 89 CC 6 SCAR 11.5
CC
6
Cov
76%
replies
12.0
create
3.0
get
2.0
CRAP 3.2
« RestApi/SheetsApi4/Range/Row.pm ↑ Summary RestApi/DriveApi3/Permission.pm »
1 package Google::RestApi::DriveApi3::Comment;
2  
3 2 our $VERSION = '1.1.0';
4  
5 2 ▶use Google::RestApi::Setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use parent 'Google::RestApi::SubResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use aliased 'Google::RestApi::DriveApi3::Reply';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 16 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
12 16 my $class = shift;
13 16 state $check = signature(
14 bless => !!0,
15 named => [
16 file => HasApi,
17 id => Str, { optional => 1 },
18 ],
19 );
20 16 return bless $check->(@_), $class;
21 }
22  
23 10 ▶sub _uri_base { 'comments' }
Subroutine _uri_base: called CC=1 SCAR=0.0
24 10 ▶sub _parent_accessor { 'file' }
Subroutine _parent_accessor: called CC=1 SCAR=0.0
25  
26 6 ▶sub create {
Subroutine create: called CC=3 SCAR=11.1
Pod documented
27 6 my $self = shift;
28 6 state $check = signature(
29 bless => !!0,
30 named => [
31 content => Str,
32 anchor => Str, { optional => 1 },
33 quoted_content => Str, { optional => 1 },
34 _extra_ => slurpy HashRef,
35 ],
36 );
37 6 my $p = named_extra($check->(@_));
38  
39 my %content = (
40 content => delete $p->{content},
41 6 );
42 6 ▶ $content{anchor} = delete $p->{anchor} if defined $p->{anchor};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"anchor"} 0 6 6
43 6 ▶ $content{quotedFileContent}{value} = delete $p->{quoted_content} if defined $p->{quoted_content};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"quoted_content"} 0 6 6
44  
45 6 DEBUG(sprintf("Creating comment on file '%s'", $self->file()->file_id()));
46 6 my $result = $self->file()->api(
47 uri => 'comments',
48 method => 'post',
49 params => { fields => 'id, content, author, createdTime' },
50 content => \%content,
51 );
52 6 return ref($self)->new(file => $self->file(), id => $result->{id});
53 }
54  
55 2 ▶sub get {
Subroutine get: called CC=2 SCAR=7.0
Pod documented
56 2 my $self = shift;
57 2 state $check = signature(
58 bless => !!0,
59 named => [
60 fields => Str, { default => 'id,content,author,createdTime,modifiedTime' },
61 include_deleted => Bool, { default => 0 },
62 ],
63 );
64 2 my $p = $check->(@_);
65  
66 2 $self->require_id('get');
67  
68 my %params = (
69 fields => $p->{fields},
70 1 );
71 1 ▶ $params{includeDeleted} = $p->{include_deleted} ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$$p{'include_deleted'} ? : 0 1 1
72  
73 1 return $self->api(params => \%params);
74 }
75  
76 1 ▶sub update {
Subroutine update: called CC=1 SCAR=0.8
Pod documented
77 1 my $self = shift;
78 1 state $check = signature(
79 bless => !!0,
80 named => [
81 content => Str,
82 _extra_ => slurpy HashRef,
83 ],
84 );
85 1 my $p = named_extra($check->(@_));
86  
87 1 $self->require_id('update');
88  
89 my %content = (
90 content => delete $p->{content},
91 0 );
92  
93 0 DEBUG(sprintf("Updating comment '%s' on file '%s'", $self->{id}, $self->file()->file_id()));
94 0 return $self->api(
95 method => 'patch',
96 content => \%content,
97 );
98 }
99  
100 7 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
101 7 my $self = shift;
102  
103 7 $self->require_id('delete');
104  
105 6 DEBUG(sprintf("Deleting comment '%s' from file '%s'", $self->{id}, $self->file()->file_id()));
106 6 return $self->api(method => 'delete');
107 }
108  
109 3 ▶sub reply {
Subroutine reply: called CC=1 SCAR=0.0
Pod documented
110 3 my $self = shift;
111 3 state $check = signature(
112 bless => !!0,
113 named => [
114 id => Str, { optional => 1 },
115 ],
116 );
117 3 my $p = $check->(@_);
118  
119 3 $self->require_id('reply');
120  
121 2 return Reply->new(comment => $self, %$p);
122 }
123  
124 0 ▶sub replies {
Subroutine replies: not called CC=3 SCAR=24.8
Pod documented
125 0 my $self = shift;
126 0 state $check = signature(
127 bless => !!0,
128 named => [
129 fields => Str, { optional => 1 },
130 include_deleted => Bool, { default => 0 },
131 max_pages => Int, { default => 0 },
132 page_callback => CodeRef, { optional => 1 },
133 params => HashRef, { default => {} },
134 ],
135 );
136 0 my $p = $check->(@_);
137  
138 0 $self->require_id('replies');
139  
140 0 ▶ $p->{params}->{includeDeleted} = $p->{include_deleted} ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$$p{'include_deleted'} ? : 0 0 0
141  
142 return paginated_list(
143 api => $self,
144 uri => 'replies',
145 result_key => 'replies',
146 default_fields => 'replies(id, content, author, createdTime)',
147 max_pages => $p->{max_pages},
148 params => $p->{params},
149 0 ▶ ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
$$p{'page_callback'} ? : 0 0 0
150 );
151 }
152  
153 2 ▶sub comment_id { shift->{id}; }
Subroutine comment_id: called CC=1 SCAR=0.0
Pod documented
154 35 ▶sub file { shift->{file}; }
Subroutine file: called CC=1 SCAR=0.0
Pod documented
155  
156 2 1;
157  
158 __END__
« RestApi/SheetsApi4/Range/Row.pm ↑ Summary RestApi/DriveApi3/Permission.pm »