| 1 | package Google::RestApi::CalendarApi3; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | our $VERSION = '2.2.5'; | |||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Google::RestApi::Setup; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | use aliased 'Google::RestApi::CalendarApi3::Calendar'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use aliased 'Google::RestApi::CalendarApi3::CalendarList'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use aliased 'Google::RestApi::CalendarApi3::Colors'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | ▶ | use aliased 'Google::RestApi::CalendarApi3::Settings'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 2 | Readonly our $Calendar_Endpoint => 'https://www.googleapis.com/calendar/v3'; | |||||||||
| 16 | 2 | Readonly our $Calendar_Id => '[a-zA-Z0-9._@-]+'; | |||||||||
| 17 | |||||||||||
| 18 | 31 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 19 | 31 | my $class = shift; | |||||||||
| 20 | 31 | state $check = signature( | |||||||||
| 21 | bless => !!0, | ||||||||||
| 22 | named => [ | ||||||||||
| 23 | api => HasApi, | ||||||||||
| 24 | endpoint => Str, { default => $Calendar_Endpoint }, | ||||||||||
| 25 | ], | ||||||||||
| 26 | ); | ||||||||||
| 27 | 31 | return bless $check->(@_), $class; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 20 | ▶ | sub api { | ||||||||
|
Subroutine
api: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 31 | 20 | my $self = shift; | |||||||||
| 32 | 20 | state $check = signature( | |||||||||
| 33 | bless => !!0, | ||||||||||
| 34 | named => [ | ||||||||||
| 35 | uri => Str, { optional => 1 }, | ||||||||||
| 36 | _extra_ => slurpy HashRef, | ||||||||||
| 37 | ], | ||||||||||
| 38 | ); | ||||||||||
| 39 | 20 | my $p = named_extra($check->(@_)); | |||||||||
| 40 | 20 | my $uri = "$self->{endpoint}/"; | |||||||||
| 41 | 20 | ▶ | $uri .= delete $p->{uri} if defined $p->{uri}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 20 | return $self->{api}->api(%$p, uri => $uri); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 14 | ▶ | sub calendar { | ||||||||
|
Subroutine
calendar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 46 | 14 | my $self = shift; | |||||||||
| 47 | 14 | state $check = signature( | |||||||||
| 48 | bless => !!0, | ||||||||||
| 49 | named => [ | ||||||||||
| 50 | id => Str, | ||||||||||
| 51 | ], | ||||||||||
| 52 | ); | ||||||||||
| 53 | 14 | my $p = $check->(@_); | |||||||||
| 54 | 14 | return Calendar->new(calendar_api => $self, %$p); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 2 | ▶ | sub calendar_list { | ||||||||
|
Subroutine
calendar_list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 58 | 2 | my $self = shift; | |||||||||
| 59 | 2 | state $check = signature( | |||||||||
| 60 | bless => !!0, | ||||||||||
| 61 | named => [ | ||||||||||
| 62 | id => Str, { optional => 1 }, | ||||||||||
| 63 | ], | ||||||||||
| 64 | ); | ||||||||||
| 65 | 2 | my $p = $check->(@_); | |||||||||
| 66 | 2 | return CalendarList->new(calendar_api => $self, %$p); | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 2 | ▶ | sub colors { Colors->new(calendar_api => shift); } | ||||||||
|
Subroutine
colors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 70 | |||||||||||
| 71 | 3 | ▶ | sub settings { | ||||||||
|
Subroutine
settings: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 72 | 3 | my $self = shift; | |||||||||
| 73 | 3 | state $check = signature( | |||||||||
| 74 | bless => !!0, | ||||||||||
| 75 | named => [ | ||||||||||
| 76 | id => Str, { optional => 1 }, | ||||||||||
| 77 | ], | ||||||||||
| 78 | ); | ||||||||||
| 79 | 3 | my $p = $check->(@_); | |||||||||
| 80 | 3 | return Settings->new(calendar_api => $self, %$p); | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | 1 | ▶ | sub create_calendar { | ||||||||
|
Subroutine
create_calendar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 84 | 1 | my $self = shift; | |||||||||
| 85 | 1 | state $check = signature( | |||||||||
| 86 | bless => !!0, | ||||||||||
| 87 | named => [ | ||||||||||
| 88 | summary => Str, | ||||||||||
| 89 | _extra_ => slurpy HashRef, | ||||||||||
| 90 | ], | ||||||||||
| 91 | ); | ||||||||||
| 92 | 1 | my $p = named_extra($check->(@_)); | |||||||||
| 93 | |||||||||||
| 94 | my %content = ( | ||||||||||
| 95 | summary => delete $p->{summary}, | ||||||||||
| 96 | 1 | ); | |||||||||
| 97 | |||||||||||
| 98 | 1 | DEBUG("Creating calendar '$content{summary}'"); | |||||||||
| 99 | 1 | my $result = $self->api( | |||||||||
| 100 | uri => 'calendars', | ||||||||||
| 101 | method => 'post', | ||||||||||
| 102 | content => \%content, | ||||||||||
| 103 | ); | ||||||||||
| 104 | 1 | return Calendar->new(calendar_api => $self, id => $result->{id}); | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | 2 | ▶ | sub list_calendars { | ||||||||
|
Subroutine
list_calendars: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 108 | 2 | my $self = shift; | |||||||||
| 109 | 2 | state $check = signature( | |||||||||
| 110 | bless => !!0, | ||||||||||
| 111 | named => [ | ||||||||||
| 112 | max_pages => Int, { default => 0 }, | ||||||||||
| 113 | page_callback => CodeRef, { optional => 1 }, | ||||||||||
| 114 | params => HashRef, { default => {} }, | ||||||||||
| 115 | ], | ||||||||||
| 116 | ); | ||||||||||
| 117 | 2 | my $p = $check->(@_); | |||||||||
| 118 | |||||||||||
| 119 | return paginated_list( | ||||||||||
| 120 | api => $self, | ||||||||||
| 121 | uri => 'users/me/calendarList', | ||||||||||
| 122 | result_key => 'items', | ||||||||||
| 123 | default_fields => 'items(id, summary)', | ||||||||||
| 124 | max_pages => $p->{max_pages}, | ||||||||||
| 125 | params => $p->{params}, | ||||||||||
| 126 | 2 | ▶ | ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()), | ||||||||
|
Branch: 1 branch
| |||||||||||
| 127 | ); | ||||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | 0 | ▶ | sub freebusy { | ||||||||
|
Subroutine
freebusy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 131 | 0 | my $self = shift; | |||||||||
| 132 | 0 | state $check = signature( | |||||||||
| 133 | bless => !!0, | ||||||||||
| 134 | named => [ | ||||||||||
| 135 | time_min => Str, | ||||||||||
| 136 | time_max => Str, | ||||||||||
| 137 | items => ArrayRef[HashRef], | ||||||||||
| 138 | _extra_ => slurpy HashRef, | ||||||||||
| 139 | ], | ||||||||||
| 140 | ); | ||||||||||
| 141 | 0 | my $p = named_extra($check->(@_)); | |||||||||
| 142 | |||||||||||
| 143 | my %content = ( | ||||||||||
| 144 | timeMin => delete $p->{time_min}, | ||||||||||
| 145 | timeMax => delete $p->{time_max}, | ||||||||||
| 146 | items => delete $p->{items}, | ||||||||||
| 147 | 0 | ); | |||||||||
| 148 | |||||||||||
| 149 | 0 | return $self->api( | |||||||||
| 150 | uri => 'freeBusy', | ||||||||||
| 151 | method => 'post', | ||||||||||
| 152 | content => \%content, | ||||||||||
| 153 | ); | ||||||||||
| 154 | } | ||||||||||
| 155 | |||||||||||
| 156 | 0 | ▶ | sub rest_api { shift->{api}; } | ||||||||
|
Subroutine
rest_api: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 157 | 0 | ▶ | sub transaction { shift->rest_api()->transaction(); } | ||||||||
|
Subroutine
transaction: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 158 | 0 | ▶ | sub stats { shift->rest_api()->stats(); } | ||||||||
|
Subroutine
stats: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 159 | 0 | ▶ | sub reset_stats { shift->rest_api->reset_stats(); } | ||||||||
|
Subroutine
reset_stats: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 160 | |||||||||||
| 161 | 2 | 1; | |||||||||
| 162 | |||||||||||
| 163 | __END__ | ||||||||||