RestApi/DocsApi1/Document.pm

filter: Statementstmt 97.9% 144 / 147 Branchbran 90.6% 29 / 32 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 90.0% 27 / 30 Podpod 89.2% 25 / 28 totaltotal 93.4% 229 / 245 CC 19 SCAR 8.6
CC
19
Cov
96%
insert_inline_image
6.1
submit_requests
3.0
insert_text
3.0
CRAP 2.4
« RestApi/SheetsApi4/RangeGroup/Iterator.pm ↑ Summary RestApi/SubResource.pm »
1 package Google::RestApi::DocsApi1::Document;
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::Request";
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 39 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
10 39 my $class = shift;
11  
12 39 state $check = signature(
13 bless => !!0,
14 named => [
15 docs_api => HasApi,
16 id => Str,
17 ],
18 );
19 39 my $self = $check->(@_);
20  
21 38 return bless $self, $class;
22 }
23  
24 3 ▶sub api {
Subroutine api: called CC=2 SCAR=6.9
Pod documented
25 3 my $self = shift;
26 3 state $check = signature(
27 bless => !!0,
28 named => [
29 uri => Str, { default => '' },
30 _extra_ => slurpy HashRef,
31 ],
32 );
33 3 my $p = named_extra($check->(@_));
34 3 ▶ $p->{uri} = $self->{id} . ($p->{uri} ? "/$p->{uri}" : '');
Branch: 1 branch
BranchTrueFalseTotal
$$p{'uri'} ? : 1 2 3
35 3 return $self->docs_api()->api(%$p);
36 }
37  
38 1 ▶sub document_id { shift->{id}; }
Subroutine document_id: called CC=1 SCAR=0.0
Pod documented
39  
40 2 ▶sub get {
Subroutine get: called CC=3 SCAR=11.0
Pod documented
41 2 my $self = shift;
42 2 state $check = signature(
43 bless => !!0,
44 named => [
45 fields => Str, { optional => 1 },
46 _extra_ => slurpy HashRef,
47 ],
48 );
49 2 my $p = named_extra($check->(@_));
50 2 my %params;
51 2 ▶ $params{fields} = delete $p->{fields} if $p->{fields};
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"fields"} 1 1 2
52 2 ▶ return $self->api(
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 1 1 2
53 %$p,
54 (%params ? (params => \%params) : ()),
55 );
56 }
57  
58 2 ▶sub submit_requests {
Subroutine submit_requests: called CC=3 SCAR=11.0
Pod documented
59 2 my $self = shift;
60  
61 2 my @requests = $self->batch_requests();
62 2 ▶ return if !@requests;
Branch: 1 branch
BranchTrueFalseTotal
unless @requests 1 1 2
63  
64 1 my $result = $self->api(
65 uri => ':batchUpdate',
66 method => 'post',
67 content => { requests => \@requests },
68 );
69  
70 1 ▶ my $replies = $result->{replies} || [];
Condition50%1/2
$$result{'replies'} || []
l!l
10
MC/DC0%0/1
$$result{'replies'} || []
$$result{'replies'}
Truth table50%1/2
A
A= $$result{'replies'}
Aresult
11
00
71 1 $self->requests_response_from_api($replies);
72  
73 1 return $result;
74 }
75  
76 # Request builder methods. Each queues a request hash and returns $self for chaining.
77  
78 8 ▶sub insert_text {
Subroutine insert_text: called CC=3 SCAR=11.0
Pod documented
79 8 my $self = shift;
80 8 state $check = signature(
81 bless => !!0,
82 named => [
83 text => Str,
84 index => Int, { optional => 1 },
85 segment_id => Str, { optional => 1 },
86 ],
87 );
88 8 my $p = $check->(@_);
89  
90 8 my %location;
91 8 ▶ $location{index} = $p->{index} if defined $p->{index};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"index"} 8 0 8
92 8 ▶ $location{segmentId} = $p->{segment_id} if defined $p->{segment_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"segment_id"} 1 7 8
93  
94 $self->batch_requests(
95 insertText => {
96 text => $p->{text},
97 8 location => \%location,
98 },
99 );
100 8 return $self;
101 }
102  
103 1 ▶sub delete_content {
Subroutine delete_content: called CC=1 SCAR=0.0
Pod documented
104 1 my $self = shift;
105 1 state $check = signature(
106 bless => !!0,
107 named => [
108 range => HashRef,
109 ],
110 );
111 1 my $p = $check->(@_);
112  
113 $self->batch_requests(
114 deleteContentRange => {
115 range => $p->{range},
116 },
117 1 );
118 1 return $self;
119 }
120  
121 2 ▶sub replace_all_text {
Subroutine replace_all_text: called CC=2 SCAR=6.9
Pod documented
122 2 my $self = shift;
123 2 state $check = signature(
124 bless => !!0,
125 named => [
126 find => Str,
127 replacement => Str,
128 match_case => Bool, { default => 1 },
129 ],
130 );
131 2 my $p = $check->(@_);
132  
133 $self->batch_requests(
134 replaceAllText => {
135 containsText => {
136 text => $p->{find},
137 matchCase => $p->{match_case} ? JSON::MaybeXS::true() : JSON::MaybeXS::false(),
138 },
139 replaceText => $p->{replacement},
140 },
141 2 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$$p{'match_case'} ? : 1 1 2
142 2 return $self;
143 }
144  
145 1 ▶sub update_text_style {
Subroutine update_text_style: called CC=1 SCAR=0.0
Pod documented
146 1 my $self = shift;
147 1 state $check = signature(
148 bless => !!0,
149 named => [
150 range => HashRef,
151 style => HashRef,
152 fields => Str,
153 ],
154 );
155 1 my $p = $check->(@_);
156  
157 $self->batch_requests(
158 updateTextStyle => {
159 range => $p->{range},
160 textStyle => $p->{style},
161 fields => $p->{fields},
162 },
163 1 );
164 1 return $self;
165 }
166  
167 1 ▶sub update_paragraph_style {
Subroutine update_paragraph_style: called CC=1 SCAR=0.0
Pod documented
168 1 my $self = shift;
169 1 state $check = signature(
170 bless => !!0,
171 named => [
172 range => HashRef,
173 style => HashRef,
174 fields => Str,
175 ],
176 );
177 1 my $p = $check->(@_);
178  
179 $self->batch_requests(
180 updateParagraphStyle => {
181 range => $p->{range},
182 paragraphStyle => $p->{style},
183 fields => $p->{fields},
184 },
185 1 );
186 1 return $self;
187 }
188  
189 2 ▶sub insert_table {
Subroutine insert_table: called CC=2 SCAR=6.9
Pod documented
190 2 my $self = shift;
191 2 state $check = signature(
192 bless => !!0,
193 named => [
194 index => Int,
195 rows => Int,
196 columns => Int,
197 segment_id => Str, { optional => 1 },
198 ],
199 );
200 2 my $p = $check->(@_);
201  
202 2 my %location = (index => $p->{index});
203 2 ▶ $location{segmentId} = $p->{segment_id} if defined $p->{segment_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"segment_id"} 1 1 2
204  
205 $self->batch_requests(
206 insertTable => {
207 rows => $p->{rows},
208 columns => $p->{columns},
209 2 location => \%location,
210 },
211 );
212 2 return $self;
213 }
214  
215 3 ▶sub insert_inline_image {
Subroutine insert_inline_image: called CC=6 SCAR=18.0
Pod documented
216 3 my $self = shift;
217 3 state $check = signature(
218 bless => !!0,
219 named => [
220 index => Int,
221 uri => Str,
222 width => HashRef, { optional => 1 },
223 height => HashRef, { optional => 1 },
224 segment_id => Str, { optional => 1 },
225 ],
226 );
227 3 my $p = $check->(@_);
228  
229 3 my %location = (index => $p->{index});
230 3 ▶ $location{segmentId} = $p->{segment_id} if defined $p->{segment_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"segment_id"} 1 2 3
231  
232 my %request = (
233 uri => $p->{uri},
234 3 location => \%location,
235 );
236 3 ▶ if ($p->{width} || $p->{height}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$p{"width"} or $$p{"height"}) 1 2 3
Condition66%2/3
$$p{"width"} or $$p{"height"}
l!l&&r!l&&!r
102
MC/DC50%1/2
$$p{"width"} or $$p{"height"}
$$p{"width"} $$p{"height"}
Truth table66%2/3
A or B
A= $$p{"width"}B= $$p{"height"}
ABresult
1X1
011
000
237 1 my %size;
238 1 ▶ $size{width} = $p->{width} if $p->{width};
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"width"} 1 0 1
239 1 ▶ $size{height} = $p->{height} if $p->{height};
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"height"} 1 0 1
240 1 $request{objectSize} = \%size;
241 }
242  
243 3 $self->batch_requests(insertInlineImage => \%request);
244 3 return $self;
245 }
246  
247 1 ▶sub create_paragraph_bullets {
Subroutine create_paragraph_bullets: called CC=1 SCAR=0.0
Pod documented
248 1 my $self = shift;
249 1 state $check = signature(
250 bless => !!0,
251 named => [
252 range => HashRef,
253 bullet_preset => Str,
254 ],
255 );
256 1 my $p = $check->(@_);
257  
258 $self->batch_requests(
259 createParagraphBullets => {
260 range => $p->{range},
261 bulletPreset => $p->{bullet_preset},
262 },
263 1 );
264 1 return $self;
265 }
266  
267 1 ▶sub delete_paragraph_bullets {
Subroutine delete_paragraph_bullets: called CC=1 SCAR=0.0
Pod documented
268 1 my $self = shift;
269 1 state $check = signature(
270 bless => !!0,
271 named => [
272 range => HashRef,
273 ],
274 );
275 1 my $p = $check->(@_);
276  
277 $self->batch_requests(
278 deleteParagraphBullets => {
279 range => $p->{range},
280 },
281 1 );
282 1 return $self;
283 }
284  
285 1 ▶sub create_named_range {
Subroutine create_named_range: called CC=1 SCAR=0.0
Pod documented
286 1 my $self = shift;
287 1 state $check = signature(
288 bless => !!0,
289 named => [
290 name => Str,
291 range => HashRef,
292 ],
293 );
294 1 my $p = $check->(@_);
295  
296 $self->batch_requests(
297 createNamedRange => {
298 name => $p->{name},
299 range => $p->{range},
300 },
301 1 );
302 1 return $self;
303 }
304  
305 1 ▶sub delete_named_range {
Subroutine delete_named_range: called CC=1 SCAR=0.0
Pod documented
306 1 my $self = shift;
307 1 state $check = signature(positional => [Str]);
308 1 my ($named_range_id) = $check->(@_);
309  
310 1 $self->batch_requests(
311 deleteNamedRange => {
312 namedRangeId => $named_range_id,
313 },
314 );
315 1 return $self;
316 }
317  
318 2 ▶sub create_header {
Subroutine create_header: called CC=2 SCAR=6.9
Pod documented
319 2 my $self = shift;
320 2 state $check = signature(
321 bless => !!0,
322 named => [
323 type => Str,
324 section_break_location => HashRef, { optional => 1 },
325 ],
326 );
327 2 my $p = $check->(@_);
328  
329 2 my %request = (type => $p->{type});
330 $request{sectionBreakLocation} = $p->{section_break_location}
331 2 ▶ if $p->{section_break_location};
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"section_break_location"} 1 1 2
332  
333 2 $self->batch_requests(createHeader => \%request);
334 2 return $self;
335 }
336  
337 2 ▶sub create_footer {
Subroutine create_footer: called CC=2 SCAR=6.9
Pod documented
338 2 my $self = shift;
339 2 state $check = signature(
340 bless => !!0,
341 named => [
342 type => Str,
343 section_break_location => HashRef, { optional => 1 },
344 ],
345 );
346 2 my $p = $check->(@_);
347  
348 2 my %request = (type => $p->{type});
349 $request{sectionBreakLocation} = $p->{section_break_location}
350 2 ▶ if $p->{section_break_location};
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"section_break_location"} 1 1 2
351  
352 2 $self->batch_requests(createFooter => \%request);
353 2 return $self;
354 }
355  
356 1 ▶sub delete_header {
Subroutine delete_header: called CC=1 SCAR=0.0
Pod documented
357 1 my $self = shift;
358 1 state $check = signature(positional => [Str]);
359 1 my ($header_id) = $check->(@_);
360 1 $self->batch_requests(deleteHeader => { headerId => $header_id });
361 1 return $self;
362 }
363  
364 1 ▶sub delete_footer {
Subroutine delete_footer: called CC=1 SCAR=0.0
Pod documented
365 1 my $self = shift;
366 1 state $check = signature(positional => [Str]);
367 1 my ($footer_id) = $check->(@_);
368 1 $self->batch_requests(deleteFooter => { footerId => $footer_id });
369 1 return $self;
370 }
371  
372 2 ▶sub insert_page_break {
Subroutine insert_page_break: called CC=2 SCAR=6.9
Pod documented
373 2 my $self = shift;
374 2 state $check = signature(
375 bless => !!0,
376 named => [
377 index => Int,
378 segment_id => Str, { optional => 1 },
379 ],
380 );
381 2 my $p = $check->(@_);
382  
383 2 my %location = (index => $p->{index});
384 2 ▶ $location{segmentId} = $p->{segment_id} if defined $p->{segment_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"segment_id"} 1 1 2
385  
386 2 $self->batch_requests(
387 insertPageBreak => {
388 location => \%location,
389 },
390 );
391 2 return $self;
392 }
393  
394 2 ▶sub insert_section_break {
Subroutine insert_section_break: called CC=2 SCAR=6.9
Pod documented
395 2 my $self = shift;
396 2 state $check = signature(
397 bless => !!0,
398 named => [
399 index => Int,
400 type => Str,
401 segment_id => Str, { optional => 1 },
402 ],
403 );
404 2 my $p = $check->(@_);
405  
406 2 my %location = (index => $p->{index});
407 2 ▶ $location{segmentId} = $p->{segment_id} if defined $p->{segment_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"segment_id"} 1 1 2
408  
409 $self->batch_requests(
410 insertSectionBreak => {
411 sectionType => $p->{type},
412 2 location => \%location,
413 },
414 );
415 2 return $self;
416 }
417  
418 1 ▶sub update_document_style {
Subroutine update_document_style: called CC=1 SCAR=0.0
Pod documented
419 1 my $self = shift;
420 1 state $check = signature(
421 bless => !!0,
422 named => [
423 style => HashRef,
424 fields => Str,
425 ],
426 );
427 1 my $p = $check->(@_);
428  
429 $self->batch_requests(
430 updateDocumentStyle => {
431 documentStyle => $p->{style},
432 fields => $p->{fields},
433 },
434 1 );
435 1 return $self;
436 }
437  
438 5 ▶sub docs_api { shift->{docs_api}; }
Subroutine docs_api: called CC=1 SCAR=0.0
Pod documented
439 1 ▶sub rest_api { shift->docs_api()->rest_api(); }
Subroutine rest_api: called CC=1 SCAR=0.0
Pod documented
440 0 ▶sub transaction { shift->docs_api()->transaction(); }
Subroutine transaction: not called CC=1 SCAR=6.9
Pod undocumented
441 0 ▶sub stats { shift->docs_api()->stats(); }
Subroutine stats: not called CC=1 SCAR=6.9
Pod undocumented
442 0 ▶sub reset_stats { shift->docs_api()->reset_stats(); }
Subroutine reset_stats: not called CC=1 SCAR=6.9
Pod undocumented
443  
444 2 1;
445  
446 __END__
« RestApi/SheetsApi4/RangeGroup/Iterator.pm ↑ Summary RestApi/SubResource.pm »