File Coverage

lib/Google/RestApi/SheetsApi4/Request/Spreadsheet/Worksheet.pm
Criterion Covered Total %
statement 21 52 40.3
branch 1 4 25.0
condition 1 7 14.2
subroutine 9 29 31.0
pod 0 23 0.0
total 32 115 27.8


line stmt bran cond sub pod time code
1              
2             our $VERSION = '1.0.2';
3              
4             use Google::RestApi::Setup;
5 1     1   438  
  1         2  
  1         6  
6             use aliased "Google::RestApi::SheetsApi4::Request";
7 1     1   19098  
  1         2  
  1         6  
8             use parent "Google::RestApi::SheetsApi4::Request::Spreadsheet";
9 1     1   95  
  1         3  
  1         8  
10              
11 0     0 0 0  
12              
13 1     1 0 59 my $self = shift;
14 1     1 0 949  
15 1     1 0 1005 my $dim = shift;
16 0     0 0 0 state $check = compile(PositiveOrZeroInt, { default => 0 });
17 4     4 0 1823 my ($count) = $check->(@_);
18 2 50   2 0 1937  
19             # "frozenColumnCount" or "frozenRowCount".
20 0   0 0   0 my $frozen = "frozen" . ($dim eq 'col' ? "Column" : "Row") . "Count";
21 0     0 0 0  
22 0     0 0 0 return $self->update_worksheet_properties(
23 0     0 0 0 properties => { gridProperties => { $frozen => $count }, },
24 0     0 0 0 fields => "gridProperties.$frozen",
25 0     0 0 0 );
26 0     0 0 0 }
27 0     0 0 0  
28             my $self = shift;
29 0     0 0 0  
30 0     0 0 0 state $check = compile_named(
31 0     0 0 0 properties => HashRef,
32 0     0 0 0 fields => Str, { optional => 1 },
33             );
34 0     0   0 my $p = $check->(@_);
35              
36 0         0 my $properties = $p->{properties};
37 0         0 my $fields = $p->{fields} || join(',', sort keys %$properties);
38 0         0  
39             $self->batch_requests(
40             updateSheetProperties => {
41 0 0       0 properties => {
42             sheetId => $self->worksheet_id(),
43 0         0 %$properties,
44             },
45             fields => $fields,
46             },
47             );
48              
49             return $self;
50 7     7 0 19 }
51              
52 7         22 my $self = shift;
53              
54             my $fields = shift;
55             my $range = shift || { sheetId => $self->worksheet_id() };
56 7         1599 $self->batch_requests(
57             updateCells => {
58 7         202 range => $range,
59 7   33     79 fields => $fields,
60             },
61 7         41 );
62              
63             return $self;
64             }
65              
66              
67             my $self = shift;
68             $self->batch_requests(
69             deleteSheet => { sheetId => $self->worksheet_id() }
70             );
71 7         46 return $self;
72             }
73              
74 0     0 0   1;
75 0     0 0    
76              
77 0     0     =head1 NAME
78              
79 0           Google::RestApi::SheetsApi4::Request::Spreadsheet::Worksheet - Build Google API's batchRequests for a Worksheet.
80 0   0        
81 0           =head1 DESCRIPTION
82              
83             Deriving from the Request::Spreadsheet object, this adds the ability to create
84             requests that have to do with worksheet properties.
85              
86             See the description and synopsis at Google::RestApi::SheetsApi4::Request.
87             and Google::RestApi::SheetsApi4.
88 0            
89             =head1 AUTHORS
90              
91 0     0 0   =over
92              
93             =item
94 0     0 0    
95 0           Robin Murray mvsjes@cpan.org
96              
97             =back
98 0            
99             =head1 COPYRIGHT
100              
101             Copyright (c) 2021, Robin Murray. All rights reserved.
102              
103             This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.