Google-RestApi
view release on metacpan or search on metacpan
lib/Google/RestApi/CalendarApi3/Calendar.pm view on Meta::CPAN
package Google::RestApi::CalendarApi3::Calendar;
our $VERSION = '2.2.3';
use Google::RestApi::Setup;
use parent 'Google::RestApi::SubResource';
use aliased 'Google::RestApi::CalendarApi3::Event';
use aliased 'Google::RestApi::CalendarApi3::Acl';
sub new {
my $class = shift;
state $check = signature(
bless => !!0,
named => [
calendar_api => HasApi,
id => Str,
],
);
return bless $check->(@_), $class;
}
sub _uri_base { 'calendars' }
sub _parent_accessor { 'calendar_api' }
sub get {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
fields => Str, { optional => 1 },
params => HashRef, { default => {} },
],
);
my $p = $check->(@_);
my $params = $p->{params};
$params->{fields} = $p->{fields} if defined $p->{fields};
return $self->api(params => $params);
}
sub update {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
summary => Str, { optional => 1 },
description => Str, { optional => 1 },
location => Str, { optional => 1 },
time_zone => Str, { optional => 1 },
_extra_ => slurpy HashRef,
],
);
my $p = named_extra($check->(@_));
my %content;
$content{summary} = delete $p->{summary} if defined $p->{summary};
$content{description} = delete $p->{description} if defined $p->{description};
$content{location} = delete $p->{location} if defined $p->{location};
$content{timeZone} = delete $p->{time_zone} if defined $p->{time_zone};
DEBUG(sprintf("Updating calendar '%s'", $self->{id}));
return $self->api(
method => 'put',
content => \%content,
);
}
sub delete {
my $self = shift;
DEBUG(sprintf("Deleting calendar '%s'", $self->{id}));
return $self->api(method => 'delete');
}
sub clear {
my $self = shift;
DEBUG(sprintf("Clearing calendar '%s'", $self->{id}));
return $self->api(uri => 'clear', method => 'post');
}
sub event {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
id => Str, { optional => 1 },
],
);
my $p = $check->(@_);
return Event->new(calendar => $self, %$p);
}
sub events {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
fields => Str, { optional => 1 },
max_pages => Int, { default => 0 },
page_callback => CodeRef, { optional => 1 },
params => HashRef, { default => {} },
],
( run in 1.343 second using v1.01-cache-2.11-cpan-b16cb0d3907 )