Google-RestApi
view release on metacpan or search on metacpan
lib/Google/RestApi/Request.pm view on Meta::CPAN
Google::RestApi::Request - A base class for building Google API batchUpdate requests.
=head1 DESCRIPTION
A Request is a lightweight base class that provides generic batch
request queuing and response infrastructure. It is used by both
Google Sheets (via SheetsApi4::Request) and Google Docs (via
DocsApi1::Document) to collect requests and distribute responses.
Batch requests are formulated and queued up to be submitted later
via 'submit_requests'. Derived classes must override submit_requests
to implement the actual API call.
The default merge_request returns false (no merging). Sheets overrides
this with its own merge logic for combining compatible requests.
=head1 SUBROUTINES
=over
lib/Google/RestApi/SheetsApi4.pm view on Meta::CPAN
Shorthand for move_dimension.
=back
=head3 Copy/Paste
=over
=item copy_paste(destination => $range, type => $type, orientation => $orient)
Copy and paste. C<type>: 'normal', 'values', 'format', 'no_borders', 'formula', 'data_validation', 'conditional_formatting'. C<orientation>: 'normal', 'transpose'.
=item cut_paste(destination => $range, type => $type)
Cut and paste.
=back
=head3 Named Ranges
=over
lib/Google/RestApi/SheetsApi4.pm view on Meta::CPAN
=item paste_data(data => $data, delimiter => $delim, type => $type, html => $bool)
Paste delimited or HTML data.
=item text_to_columns(delimiter => $delim, delimiter_type => $type)
Split text in column to multiple columns.
=item find_replace(%args)
Find and replace. Args: C<find> (required), C<replacement>, C<match_case>, C<match_entire_cell>, C<search_by_regex>, C<include_formulas>.
=back
=head3 Data Validation
=over
=item set_data_validation(rule => \%rule)
Set data validation rule.
lib/Google/RestApi/SheetsApi4/Range.pm view on Meta::CPAN
# - - Fred
# if a range is included it's a flag that the dim and values are present from
# the returned api call.
sub _cache_range_values {
my $self = shift;
my %p = @_;
# if a range is included, assume this cache is coming from the api as a reply.
# this is to store the values for this range when includeValuesInResponse is
# added to the url or content on the original values call. you can replace the
# original values using the valueRenderOption to replace, say, formulas with their
# calculated value.
if ($p{range}) {
state $check = signature(
bless => !!0,
named => [
majorDimension => DimColRow,
range => StrMatch[qr/.+!/],
values => ArrayRef, { optional => 1 } # will not exist if values aren't set in the ss.
],
);
lib/Google/RestApi/SheetsApi4/Request/Spreadsheet/Worksheet/Range.pm view on Meta::CPAN
my $self = shift;
state $check = signature(
bless => !!0,
named => [
find => Str,
replacement => Str, { default => '' },
match_case => Bool, { default => 0 },
match_entire_cell => Bool, { default => 0 },
search_by_regex => Bool, { default => 0 },
include_formulas => Bool, { default => 0 },
],
);
my $p = $check->(@_);
$self->batch_requests(
findReplace => {
range => $self->range_to_index(),
find => $p->{find},
replacement => $p->{replacement},
matchCase => bool($p->{match_case}),
matchEntireCell => bool($p->{match_entire_cell}),
searchByRegex => bool($p->{search_by_regex}),
includeFormulas => bool($p->{include_formulas}),
},
);
return $self;
}
sub set_data_validation {
my $self = shift;
state $check = signature(
tutorial/sheets/20_worksheet.pl view on Meta::CPAN
end("'Payroll' worksheet headings should now be formatted.");
# a column could start at the second row and still be called a column.
start("Now we will bold the IDs column.");
$ws0->range_col("A2:A")->bold()->submit_requests();
end("IDs should now be bolded.");
# do a batch update and formatting request via a range group.
# range groups can be used to format each range in the range group.
# ranges can be specified in very flexible ways.
start("Now we will set a couple of formulas via batch.");
my $tax = $ws0->range_cell([ 3, 5 ]); # same as "C5"
my $salary = $ws0->range_cell({ row => 5, col => "D" }); # same as "D5"
$tax->batch_values(values => "=SUM(C2:C4)");
$salary->batch_values(values => "=SUM(D2:D4)");
my $rg = $ss->range_group($tax, $salary);
$rg->submit_values();
$rg->bold()->italic()->bd_solid()->bd_thick('bottom')->submit_requests();
end("Totals should now be set with formulas.");
message('green', "\nProceed to 25_worksheet.pl.\n");
message('blue', "We are done, here are some api stats:\n", Dump($ss->stats()));
( run in 1.887 second using v1.01-cache-2.11-cpan-fe3c2283af0 )