Google-RestApi
view release on metacpan or search on metacpan
lib/Google/RestApi/DriveApi3/Revision.pm view on Meta::CPAN
package Google::RestApi::DriveApi3::Revision;
our $VERSION = '1.1.0';
use Google::RestApi::Setup;
use parent 'Google::RestApi::SubResource';
sub new {
my $class = shift;
state $check = signature(
bless => !!0,
named => [
file => HasApi,
id => Str, { optional => 1 },
],
);
return bless $check->(@_), $class;
}
sub _uri_base { 'revisions' }
sub _parent_accessor { 'file' }
sub get {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
fields => Str, { optional => 1 },
acknowledge_abuse => Bool, { default => 0 },
],
);
my $p = $check->(@_);
$self->require_id('get');
my %params;
$params{fields} = $p->{fields} if defined $p->{fields};
$params{acknowledgeAbuse} = 'true' if $p->{acknowledge_abuse};
return $self->api(params => \%params);
}
sub update {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
keep_forever => Bool, { optional => 1 },
publish_auto => Bool, { optional => 1 },
published => Bool, { optional => 1 },
published_outside_domain => Bool, { optional => 1 },
_extra_ => slurpy HashRef,
],
);
my $p = named_extra($check->(@_));
$self->require_id('update');
my %content;
$content{keepForever} = $p->{keep_forever} ? \1 : \0 if defined $p->{keep_forever};
$content{publishAuto} = $p->{publish_auto} ? \1 : \0 if defined $p->{publish_auto};
$content{published} = $p->{published} ? \1 : \0 if defined $p->{published};
$content{publishedOutsideDomain} = $p->{published_outside_domain} ? \1 : \0
if defined $p->{published_outside_domain};
DEBUG(sprintf("Updating revision '%s' on file '%s'", $self->{id}, $self->file()->file_id()));
return $self->api(
method => 'patch',
content => \%content,
);
}
sub delete {
my $self = shift;
$self->require_id('delete');
DEBUG(sprintf("Deleting revision '%s' from file '%s'", $self->{id}, $self->file()->file_id()));
return $self->api(method => 'delete');
}
sub revision_id { shift->{id}; }
sub file { shift->{file}; }
1;
__END__
=head1 NAME
Google::RestApi::DriveApi3::Revision - Revision object for Google Drive files.
=head1 SYNOPSIS
# List all revisions
my @revisions = $file->revisions();
# Get a specific revision
my $rev = $file->revision(id => 'revision_id');
my $details = $rev->get();
# Update revision settings
$rev->update(keep_forever => 1);
( run in 1.115 second using v1.01-cache-2.11-cpan-ceb78f64989 )