Google-RestApi
view release on metacpan or search on metacpan
lib/Google/RestApi/CalendarApi3.pm view on Meta::CPAN
package Google::RestApi::CalendarApi3;
our $VERSION = '2.2.3';
use Google::RestApi::Setup;
use Readonly;
use URI;
use aliased 'Google::RestApi::CalendarApi3::Calendar';
use aliased 'Google::RestApi::CalendarApi3::CalendarList';
use aliased 'Google::RestApi::CalendarApi3::Colors';
use aliased 'Google::RestApi::CalendarApi3::Settings';
Readonly our $Calendar_Endpoint => 'https://www.googleapis.com/calendar/v3';
Readonly our $Calendar_Id => '[a-zA-Z0-9._@-]+';
sub new {
my $class = shift;
state $check = signature(
bless => !!0,
named => [
api => HasApi,
endpoint => Str, { default => $Calendar_Endpoint },
],
);
return bless $check->(@_), $class;
}
sub api {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
uri => Str, { optional => 1 },
_extra_ => slurpy HashRef,
],
);
my $p = named_extra($check->(@_));
my $uri = "$self->{endpoint}/";
$uri .= delete $p->{uri} if defined $p->{uri};
return $self->{api}->api(%$p, uri => $uri);
}
sub calendar {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
id => Str,
],
);
my $p = $check->(@_);
return Calendar->new(calendar_api => $self, %$p);
}
sub calendar_list {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
id => Str, { optional => 1 },
],
);
my $p = $check->(@_);
return CalendarList->new(calendar_api => $self, %$p);
}
sub colors { Colors->new(calendar_api => shift); }
sub settings {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
id => Str, { optional => 1 },
],
);
my $p = $check->(@_);
return Settings->new(calendar_api => $self, %$p);
}
sub create_calendar {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
summary => Str,
_extra_ => slurpy HashRef,
],
);
my $p = named_extra($check->(@_));
my %content = (
summary => delete $p->{summary},
);
DEBUG("Creating calendar '$content{summary}'");
my $result = $self->api(
uri => 'calendars',
lib/Google/RestApi/CalendarApi3.pm view on Meta::CPAN
=item * Calendar list management (user's view of calendars)
=item * Colors and settings (read-only)
=item * Free/busy queries
=back
It is assumed that you are familiar with the Google Calendar API:
L<https://developers.google.com/calendar/api/v3/reference>
=head2 Architecture
The API uses a hierarchical object model where child objects delegate API calls
to their parent:
CalendarApi3 (top-level)
|-- calendar(id => ...) -> Calendar
| |-- event(id => ...) -> Event
| |-- acl(id => ...) -> Acl
|-- calendar_list(id => ...) -> CalendarList
|-- colors() -> Colors
|-- settings(id => ...) -> Settings
Each object provides CRUD operations appropriate to its resource type.
=head1 NAVIGATION
=over
=item * L<Google::RestApi::CalendarApi3> - This module (top-level Calendar API)
=item * L<Google::RestApi::CalendarApi3::Calendar> - Calendar operations
=item * L<Google::RestApi::CalendarApi3::Event> - Event management
=item * L<Google::RestApi::CalendarApi3::Acl> - Access control rules
=item * L<Google::RestApi::CalendarApi3::CalendarList> - Calendar list management
=item * L<Google::RestApi::CalendarApi3::Colors> - Available colors
=item * L<Google::RestApi::CalendarApi3::Settings> - User settings
=back
=head1 SUBROUTINES
=head2 new(%args)
Creates a new CalendarApi3 instance.
my $cal_api = Google::RestApi::CalendarApi3->new(api => $rest_api);
%args consists of:
=over
=item * C<api> L<Google::RestApi>: Required. A configured RestApi instance.
=item * C<endpoint> <string>: Optional. Override the default Calendar API endpoint.
=back
=head2 api(%args)
Low-level method to make API calls. You would not normally call this directly
unless making a Google API call not currently supported by this framework.
%args consists of:
=over
=item * C<uri> <string>: Path segments to append to the Calendar endpoint.
=item * C<%args>: Additional arguments passed to L<Google::RestApi>'s api() (content, params, method, etc).
=back
Returns the response hash from the Google API.
=head2 calendar(%args)
Returns a Calendar object for the given calendar ID.
my $cal = $cal_api->calendar(id => 'primary');
my $cal = $cal_api->calendar(id => 'user@gmail.com');
%args consists of:
=over
=item * C<id> <string>: Required. The calendar ID (e.g. 'primary' or an email address).
=back
=head2 calendar_list(%args)
Returns a CalendarList object for managing the user's view of calendars.
my $cl = $cal_api->calendar_list(id => 'primary');
%args consists of:
=over
=item * C<id> <string>: Optional. The calendar ID. Required for get/update/delete.
=back
=head2 colors()
Returns a Colors object for querying available calendar and event colors.
my $colors = $cal_api->colors();
my $all = $colors->get();
=head2 settings(%args)
Returns a Settings object for querying user settings.
my $setting = $cal_api->settings(id => 'timezone');
my $value = $setting->value();
%args consists of:
=over
=item * C<id> <string>: Optional. The setting ID. Required for get/value.
=back
=head2 create_calendar(%args)
( run in 0.716 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )