NAME

Tie::Google::Sheets::Client - Low level client used internally by Tie::Google::Sheets

VERSION

version 0.02

DESCRIPTION

This is a low level class used internally by Tie::Google::Sheets to talk to the Google Sheets API. It is not part of the public interface and may change without notice; do not use it directly.

ATTRIBUTES

spreadsheet_id

The id of the spreadsheet being accessed.

ua

The HTTP::AnyUA instance used to make requests.

access_token

The OAuth2 bearer token (or code reference) given to "new", if any.

service_account

The decoded service account key, if a service account was given to "new".

token

The most recently obtained OAuth2 access token, when authenticating via "service_account".

token_expires

The epoch time at which "token" expires.

batch_size

The maximum number of pending cell writes accumulated by "update_value" before they are automatically flushed. undef (the default) disables batching: "update_value" sends each write immediately.

backoff_retry

The maximum number of times an API request will be retried, with exponential backoff, after being rate limited by Google (HTTP status 429). undef (the default) disables retrying: a rate limited request fails immediately.

CONSTRUCTOR

new

my $client = Tie::Google::Sheets::Client->new(%options);

Constructor. %options are the same as documented in "CONSTRUCTOR" in Tie::Google::Sheets.

METHODS

sheet_titles

my $titles = $client->sheet_titles;

Returns an array reference of worksheet titles.

sheet_id_for_title

my $sheet_id = $client->sheet_id_for_title($title);

Returns the numeric sheet id for the worksheet named $title, or undef if there is no such worksheet.

get_value

my $value = $client->get_value($title, $a1);

Returns the value of the cell $a1 (for example "A1") in worksheet $title.

get_formula

my $formula = $client->get_formula($title, $a1);

Returns the formula of the cell $a1 in worksheet $title, as text (for example "=SUM(A1:A10)"), or the same as "get_value" if the cell doesn't contain a formula.

update_value

$client->update_value($title, $a1, $value);

Sets the value of the cell $a1 in worksheet $title. If "batch_size" is set, the write is queued rather than sent immediately; see "flush".

flush

$client->flush;

Sends any cell writes queued by "update_value" as a single values.batchUpdate API call. A no-op if nothing is queued. Called automatically before every other API request (so reads always see previously queued writes), when the number of queued writes reaches "batch_size", and when the client is garbage collected.

clear_value

$client->clear_value($title, $a1);

Clears the value of the cell $a1 in worksheet $title.

clear_range

$client->clear_range($title, $a1);
$client->clear_range($title);

Clears the value of the cell $a1 in worksheet $title, or, if $a1 is omitted, clears every cell in the worksheet.

get_all_values

my $rows = $client->get_all_values($title);

Returns an array reference of array references holding every value in the used range of worksheet $title.

get_all_formulas

my $rows = $client->get_all_formulas($title);

Like "get_all_values", but returns formulas (as text) instead of values, for every cell in the used range of worksheet $title that has one; cells without a formula hold the same value "get_all_values" would return.

add_sheet

$client->add_sheet($title);

Adds a new, empty worksheet named $title.

delete_sheet

$client->delete_sheet($title);

Deletes the worksheet named $title.

copy_worksheet

$client->copy_worksheet($from_title, $to_title);

Copies the worksheet named $from_title to a new worksheet named $to_title, including its formatting, data validation, and other properties, not just its cell values.

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.