RestApi/DriveApi3/File.pm

filter: Statementstmt 70.1% 68 / 97 Branchbran 25.0% 6 / 24 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 82.6% 19 / 23 Podpod 80.0% 12 / 15 totaltotal 67.0% 110 / 164 CC 14 SCAR 22.4
CC
14
Cov
62%
update
42.0
comments
12.0
watch
6.0
CRAP 9.4
« RestApi/SheetsApi4/Range/Iterator.pm ↑ Summary RestApi/SheetsApi4/Request/Spreadsheet/Worksheet.pm »
1 package Google::RestApi::DriveApi3::File;
2  
3 2 our $VERSION = '2.2.5';
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';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use aliased 'Google::RestApi::DriveApi3::Permission';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use aliased 'Google::RestApi::DriveApi3::Revision';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use aliased 'Google::RestApi::DriveApi3::Comment';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 71 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15 71 my $class = shift;
16 71 my $qr_id = $Google::RestApi::DriveApi3::Drive_File_Id;
17 71 state $check = signature(
18 bless => !!0,
19 named => [
20 drive => HasApi,
21 id => StrMatch[qr/$qr_id/],
22 ],
23 );
24 71 return bless $check->(@_), $class;
25 }
26  
27 64 ▶sub _uri_base { 'files' }
Subroutine _uri_base: called CC=1 SCAR=0.0
28 64 ▶sub _parent_accessor { 'drive' }
Subroutine _parent_accessor: called CC=1 SCAR=0.0
29  
30 8 ▶sub copy {
Subroutine copy: called CC=3 SCAR=11.0
Pod documented
31 8 my $self = shift;
32  
33 8 state $check = signature(
34 bless => !!0,
35 named => [
36 name => Str, { optional => 1 },
37 title => Str, { optional => 1 },
38 _extra_ => slurpy HashRef,
39 ],
40 );
41 8 my $p = named_extra($check->(@_));
42 8 ▶ $p->{name} //= $p->{title};
Condition100%3/3
$$p{"name"} //= $$p{"title"}
l!l&&r!l&&!r
323
MC/DC100%2/2
$$p{"name"} //= $$p{"title"}
$$p{"name"} $$p{"title"}
Truth table100%3/3
A //= B
A= $$p{"name"}B= $$p{"title"}
ABresult
1X1
011
000
43 8 ▶ $p->{content}->{name} = $p->{name} if defined $p->{name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"name"} 5 3 8
44 8 delete @$p{qw(name title)};
45  
46 8 $p->{uri} = 'copy';
47 8 $p->{method} = 'post';
48  
49 8 my $copy = $self->api(%$p);
50 8 DEBUG(sprintf("Copied file '%s' to '%s'", $self->file_id(), $copy->{id}));
51 return ref($self)->new(
52 drive => $self->drive(),
53 id => $copy->{id},
54 8 );
55 }
56  
57 33 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
58 33 my $self = shift;
59 33 DEBUG(sprintf("Deleting file '%s'", $self->file_id()));
60 33 return $self->api(method => 'delete');
61 }
62  
63 2 ▶sub get {
Subroutine get: called CC=2 SCAR=6.9
Pod documented
64 2 my $self = shift;
65 2 state $check = signature(
66 bless => !!0,
67 named => [
68 fields => Str, { optional => 1 },
69 params => HashRef, { default => {} },
70 ],
71 );
72 2 my $p = $check->(@_);
73  
74 2 my $params = $p->{params};
75 2 ▶ $params->{fields} = $p->{fields} if defined $p->{fields};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"fields"} 1 1 2
76  
77 2 return $self->api(params => $params);
78 }
79  
80 0 ▶sub update {
Subroutine update: not called CC=6 SCAR=37.4
Pod documented
81 0 my $self = shift;
82 0 state $check = signature(
83 bless => !!0,
84 named => [
85 name => Str, { optional => 1 },
86 description => Str, { optional => 1 },
87 mime_type => Str, { optional => 1 },
88 add_parents => Str, { optional => 1 },
89 remove_parents => Str, { optional => 1 },
90 _extra_ => slurpy HashRef,
91 ],
92 );
93 0 my $p = named_extra($check->(@_));
94  
95 0 my %params;
96 0 ▶ $params{addParents} = delete $p->{add_parents} if defined $p->{add_parents};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"add_parents"} 0 0 0
97 0 ▶ $params{removeParents} = delete $p->{remove_parents} if defined $p->{remove_parents};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"remove_parents"} 0 0 0
98  
99 0 my %content;
100 0 ▶ $content{name} = delete $p->{name} if defined $p->{name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"name"} 0 0 0
101 0 ▶ $content{description} = delete $p->{description} if defined $p->{description};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"description"} 0 0 0
102 0 ▶ $content{mimeType} = delete $p->{mime_type} if defined $p->{mime_type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"mime_type"} 0 0 0
103  
104 0 DEBUG(sprintf("Updating file '%s'", $self->file_id()));
105 0 return $self->api(
106 method => 'patch',
107 params => \%params,
108 content => \%content,
109 );
110 }
111  
112 0 ▶sub export {
Subroutine export: not called CC=1 SCAR=6.9
Pod documented
113 0 my $self = shift;
114 0 state $check = signature(
115 bless => !!0,
116 named => [
117 mime_type => Str,
118 ],
119 );
120 0 my $p = $check->(@_);
121  
122 0 DEBUG(sprintf("Exporting file '%s' as '%s'", $self->file_id(), $p->{mime_type}));
123 return $self->api(
124 uri => 'export',
125 params => { mimeType => $p->{mime_type} },
126 0 );
127 }
128  
129 0 ▶sub watch {
Subroutine watch: not called CC=2 SCAR=17.9
Pod documented
130 0 my $self = shift;
131 0 state $check = signature(
132 bless => !!0,
133 named => [
134 id => Str,
135 type => Str, { default => 'web_hook' },
136 address => Str,
137 expiration => Int, { optional => 1 },
138 _extra_ => slurpy HashRef,
139 ],
140 );
141 0 my $p = named_extra($check->(@_));
142  
143 my $content = {
144 id => delete $p->{id},
145 type => delete $p->{type},
146 address => delete $p->{address},
147 0 };
148 0 ▶ $content->{expiration} = delete $p->{expiration} if defined $p->{expiration};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"expiration"} 0 0 0
149  
150 0 DEBUG(sprintf("Setting watch on file '%s'", $self->file_id()));
151 0 return $self->api(
152 uri => 'watch',
153 method => 'post',
154 content => $content,
155 );
156 }
157  
158 2 ▶sub permission {
Subroutine permission: called CC=1 SCAR=0.0
Pod documented
159 2 my $self = shift;
160 2 state $check = signature(
161 bless => !!0,
162 named => [
163 id => Str, { optional => 1 },
164 ],
165 );
166 2 my $p = $check->(@_);
167 2 return Permission->new(file => $self, %$p);
168 }
169  
170 1 ▶sub permissions {
Subroutine permissions: called CC=2 SCAR=7.0
Pod documented
171 1 my $self = shift;
172 1 state $check = signature(
173 bless => !!0,
174 named => [
175 fields => Str, { optional => 1 },
176 max_pages => Int, { default => 0 },
177 page_callback => CodeRef, { optional => 1 },
178 params => HashRef, { default => {} },
179 ],
180 );
181 1 my $p = $check->(@_);
182  
183 return paginated_list(
184 api => $self,
185 uri => 'permissions',
186 result_key => 'permissions',
187 default_fields => 'permissions(id, role, type, emailAddress)',
188 max_pages => $p->{max_pages},
189 params => $p->{params},
190 1 ▶ ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
$$p{'page_callback'} ? : 0 1 1
191 );
192 }
193  
194 1 ▶sub revision {
Subroutine revision: called CC=1 SCAR=0.0
Pod documented
195 1 my $self = shift;
196 1 state $check = signature(
197 bless => !!0,
198 named => [
199 id => Str, { optional => 1 },
200 ],
201 );
202 1 my $p = $check->(@_);
203 1 return Revision->new(file => $self, %$p);
204 }
205  
206 1 ▶sub revisions {
Subroutine revisions: called CC=2 SCAR=7.0
Pod documented
207 1 my $self = shift;
208 1 state $check = signature(
209 bless => !!0,
210 named => [
211 fields => Str, { optional => 1 },
212 max_pages => Int, { default => 0 },
213 page_callback => CodeRef, { optional => 1 },
214 params => HashRef, { default => {} },
215 ],
216 );
217 1 my $p = $check->(@_);
218  
219 return paginated_list(
220 api => $self,
221 uri => 'revisions',
222 result_key => 'revisions',
223 default_fields => 'revisions(id, modifiedTime, keepForever)',
224 max_pages => $p->{max_pages},
225 params => $p->{params},
226 1 ▶ ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
$$p{'page_callback'} ? : 0 1 1
227 );
228 }
229  
230 7 ▶sub comment {
Subroutine comment: called CC=1 SCAR=0.0
Pod documented
231 7 my $self = shift;
232 7 state $check = signature(
233 bless => !!0,
234 named => [
235 id => Str, { optional => 1 },
236 ],
237 );
238 7 my $p = $check->(@_);
239 7 return Comment->new(file => $self, %$p);
240 }
241  
242 0 ▶sub comments {
Subroutine comments: not called CC=3 SCAR=24.8
Pod documented
243 0 my $self = shift;
244 0 state $check = signature(
245 bless => !!0,
246 named => [
247 fields => Str, { optional => 1 },
248 include_deleted => Bool, { default => 0 },
249 max_pages => Int, { default => 0 },
250 page_callback => CodeRef, { optional => 1 },
251 params => HashRef, { default => {} },
252 ],
253 );
254 0 my $p = $check->(@_);
255  
256 0 ▶ $p->{params}->{includeDeleted} = $p->{include_deleted} ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$$p{'include_deleted'} ? : 0 0 0
257  
258 return paginated_list(
259 api => $self,
260 uri => 'comments',
261 result_key => 'comments',
262 default_fields => 'comments(id, content, author, createdTime)',
263 max_pages => $p->{max_pages},
264 params => $p->{params},
265 0 ▶ ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
$$p{'page_callback'} ? : 0 0 0
266 );
267 }
268  
269 67 ▶sub file_id { shift->{id}; }
Subroutine file_id: called CC=1 SCAR=0.0
Pod undocumented
270 72 ▶sub drive { shift->{drive}; }
Subroutine drive: called CC=1 SCAR=0.0
Pod undocumented
271  
272 2 1;
273  
274 __END__
« RestApi/SheetsApi4/Range/Iterator.pm ↑ Summary RestApi/SheetsApi4/Request/Spreadsheet/Worksheet.pm »