File Coverage

lib/Google/RestApi/SheetsApi4/Request/Spreadsheet.pm
Criterion Covered Total %
statement 6 24 25.0
branch 0 12 0.0
condition n/a
subroutine 2 5 40.0
pod 0 3 0.0
total 8 44 18.1


line stmt bran cond sub pod time code
1             package Google::RestApi::SheetsApi4::Request::Spreadsheet;
2              
3             our $VERSION = '1.0.3';
4              
5 1     1   508 use Google::RestApi::Setup;
  1         4  
  1         7  
6              
7 1     1   13484 use parent "Google::RestApi::SheetsApi4::Request";
  1         3  
  1         7  
8              
9 0     0 0   sub spreadsheet_id { LOGDIE "Pure virtual function 'spreadsheet_id' must be overridden"; }
10              
11             sub delete_protected_range {
12 0     0 0   my $self = shift;
13              
14 0           state $check = compile(Str);
15 0           my ($id) = $check->(@_);
16              
17 0           $self->batch_requests(
18             deleteProtectedRange => {
19             protectedRangeId => $id,
20             },
21             );
22              
23 0           return $self;
24             }
25              
26             sub add_worksheet {
27 0     0 0   my $self = shift;
28              
29 0           state $check = compile_named(
30             name => Optional[Str],
31             title => Optional[Str],
32             grid_properties => Optional[Dict[ rows => Optional[Int], cols => Optional[Int] ]],
33             tab_color => Optional[Dict[ red => Optional[Num], blue => Optional[Num], green => Optional[Num] ]],
34             );
35 0           my $p = $check->(@_);
36              
37 0           my %properties;
38 0 0         $properties{title} = $p->{title} if $p->{title};
39 0 0         $properties{title} = $p->{name} if $p->{name};
40 0 0         $properties{tabColor} = $p->{tab_color} if $p->{tab_color};
41            
42 0 0         $p->{grid_properties}->{rowCount} = delete $p->{grid_properties}->{rows} if $p->{grid_properties}->{rows};
43 0 0         $p->{grid_properties}->{columnCount} = delete $p->{grid_properties}->{cols} if $p->{grid_properties}->{cols};
44 0 0         $properties{gridProperties} = $p->{grid_properties} if $p->{grid_properties};
45            
46 0           $self->batch_requests(addSheet => { properties => \%properties });
47              
48 0           return $self;
49             }
50              
51             1;
52              
53             __END__
54              
55             =head1 NAME
56              
57             Google::RestApi::SheetsApi4::Request::Spreadsheet - Build Google API's batchRequests for a Spreadsheet.
58              
59             =head1 DESCRIPTION
60              
61             Deriving from the Request object, this adds the ability to create
62             requests that have to do with spreadsheet properties.
63              
64             See the description and synopsis at Google::RestApi::SheetsApi4::Request.
65             and Google::RestApi::SheetsApi4.
66              
67             =head1 AUTHORS
68              
69             =over
70              
71             =item
72              
73             Robin Murray mvsjes@cpan.org
74              
75             =back
76              
77             =head1 COPYRIGHT
78              
79             Copyright (c) 2021, Robin Murray. All rights reserved.
80              
81             This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.