Google-RestApi

 view release on metacpan or  search on metacpan

lib/Google/RestApi/CalendarApi3.pm  view on Meta::CPAN

    api            => $self,
    uri            => 'users/me/calendarList',
    result_key     => 'items',
    default_fields => 'items(id, summary)',
    max_pages      => $p->{max_pages},
    params         => $p->{params},
    ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()),
  );
}

sub freebusy {
  my $self = shift;
  state $check = signature(
    bless => !!0,
    named => [
      time_min => Str,
      time_max => Str,
      items    => ArrayRef[HashRef],
      _extra_  => slurpy HashRef,
    ],
  );

lib/Google/RestApi/CalendarApi3.pm  view on Meta::CPAN

=item * Calendar CRUD operations (create, get, update, delete)

=item * Event management (create, get, update, delete, quick add)

=item * Access control (ACL) management

=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:

lib/Google/RestApi/CalendarApi3.pm  view on Meta::CPAN

Lists all calendars visible to the user.

 my @calendars = $cal_api->list_calendars();
 my @calendars = $cal_api->list_calendars(max_pages => 2);

C<max_pages> limits the number of pages fetched (default 0 = unlimited).
Supports C<page_callback>, see L<Google::RestApi/PAGE CALLBACKS>.

Returns a list of calendar hashrefs with id and summary.

=head2 freebusy(%args)

Queries free/busy information for a set of calendars.

 my $result = $cal_api->freebusy(
   time_min => '2026-03-01T00:00:00Z',
   time_max => '2026-03-02T00:00:00Z',
   items    => [{ id => 'primary' }],
 );

%args consists of:

=over

=item * C<time_min> <string>: Required. Start of the time range (RFC3339).

t/unit/Test/Google/RestApi/CalendarApi3.pm  view on Meta::CPAN

sub _constructor : Tests(4) {
  my $self = shift;

  throws_ok sub { CalendarApi3->new() },
    qr/api/i,
    'Constructor without api should throw';

  ok my $cal = CalendarApi3->new(api => mock_rest_api()), 'Constructor should succeed';
  isa_ok $cal, CalendarApi3, 'Constructor returns';
  can_ok $cal, qw(api calendar calendar_list colors settings
                  create_calendar list_calendars freebusy);

  return;
}

sub calendar_factory : Tests(3) {
  my $self = shift;

  my $cal_api = mock_calendar_api();
  ok my $cal = $cal_api->calendar(id => 'primary'), 'Calendar factory should succeed';
  isa_ok $cal, Calendar, 'Calendar factory returns';



( run in 0.530 second using v1.01-cache-2.11-cpan-39bf76dae61 )