RestApi/CalendarApi3/Event.pm

filter: Statementstmt 68.6% 46 / 67 Branchbran 18.1% 4 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 12 / 14 Podpod 90.0% 9 / 10 totaltotal 62.8% 71 / 113 CC 12 SCAR 24.7
CC
12
Cov
56%
update
36.0
instances
6.0
create
4.1
CRAP 11.8
« RestApi/DriveApi3/Drive.pm ↑ Summary RestApi/SheetsApi4/Range/Iterator.pm »
1 package Google::RestApi::CalendarApi3::Event;
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 parent 'Google::RestApi::SubResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10 8 my $class = shift;
11 8 state $check = signature(
12 bless => !!0,
13 named => [
14 calendar => HasApi,
15 id => Str, { optional => 1 },
16 ],
17 );
18 8 return bless $check->(@_), $class;
19 }
20  
21 3 ▶sub _uri_base { 'events' }
Subroutine _uri_base: called CC=1 SCAR=0.0
22 3 ▶sub _parent_accessor { 'calendar' }
Subroutine _parent_accessor: called CC=1 SCAR=0.0
23  
24 1 ▶sub create {
Subroutine create: called CC=4 SCAR=14.1
Pod documented
25 1 my $self = shift;
26 1 state $check = signature(
27 bless => !!0,
28 named => [
29 summary => Str,
30 start => HashRef,
31 end => HashRef,
32 description => Str, { optional => 1 },
33 location => Str, { optional => 1 },
34 attendees => ArrayRef[HashRef], { optional => 1 },
35 _extra_ => slurpy HashRef,
36 ],
37 );
38 1 my $p = named_extra($check->(@_));
39  
40 my %content = (
41 summary => delete $p->{summary},
42 start => delete $p->{start},
43 end => delete $p->{end},
44 1 );
45 1 ▶ $content{description} = delete $p->{description} if defined $p->{description};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"description"} 0 1 1
46 1 ▶ $content{location} = delete $p->{location} if defined $p->{location};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"location"} 0 1 1
47 1 ▶ $content{attendees} = delete $p->{attendees} if defined $p->{attendees};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"attendees"} 0 1 1
48  
49 1 DEBUG(sprintf("Creating event '%s' on calendar '%s'", $content{summary}, $self->calendar()->calendar_id()));
50 1 my $result = $self->calendar()->api(
51 uri => 'events',
52 method => 'post',
53 content => \%content,
54 );
55 1 return ref($self)->new(calendar => $self->calendar(), id => $result->{id});
56 }
57  
58 2 ▶sub get {
Subroutine get: called CC=2 SCAR=7.0
Pod documented
59 2 my $self = shift;
60 2 state $check = signature(
61 bless => !!0,
62 named => [
63 fields => Str, { optional => 1 },
64 ],
65 );
66 2 my $p = $check->(@_);
67  
68 2 $self->require_id('get');
69  
70 1 my %params;
71 1 ▶ $params{fields} = $p->{fields} if defined $p->{fields};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"fields"} 0 1 1
72  
73 1 return $self->api(params => \%params);
74 }
75  
76 1 ▶sub update {
Subroutine update: called CC=7 SCAR=35.8
Pod documented
77 1 my $self = shift;
78 1 state $check = signature(
79 bless => !!0,
80 named => [
81 summary => Str, { optional => 1 },
82 description => Str, { optional => 1 },
83 location => Str, { optional => 1 },
84 start => HashRef, { optional => 1 },
85 end => HashRef, { optional => 1 },
86 attendees => ArrayRef[HashRef], { optional => 1 },
87 _extra_ => slurpy HashRef,
88 ],
89 );
90 1 my $p = named_extra($check->(@_));
91  
92 1 $self->require_id('update');
93  
94 0 my %content;
95 0 ▶ $content{summary} = delete $p->{summary} if defined $p->{summary};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"summary"} 0 0 0
96 0 ▶ $content{description} = delete $p->{description} if defined $p->{description};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"description"} 0 0 0
97 0 ▶ $content{location} = delete $p->{location} if defined $p->{location};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"location"} 0 0 0
98 0 ▶ $content{start} = delete $p->{start} if defined $p->{start};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"start"} 0 0 0
99 0 ▶ $content{end} = delete $p->{end} if defined $p->{end};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"end"} 0 0 0
100 0 ▶ $content{attendees} = delete $p->{attendees} if defined $p->{attendees};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"attendees"} 0 0 0
101  
102 0 DEBUG(sprintf("Updating event '%s'", $self->{id}));
103 0 return $self->api(
104 method => 'patch',
105 content => \%content,
106 );
107 }
108  
109 3 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
110 3 my $self = shift;
111  
112 3 $self->require_id('delete');
113  
114 2 DEBUG(sprintf("Deleting event '%s'", $self->{id}));
115 2 return $self->api(method => 'delete');
116 }
117  
118 1 ▶sub quick_add {
Subroutine quick_add: called CC=1 SCAR=0.0
Pod documented
119 1 my $self = shift;
120 1 state $check = signature(
121 bless => !!0,
122 named => [
123 text => Str,
124 ],
125 );
126 1 my $p = $check->(@_);
127  
128 1 DEBUG(sprintf("Quick adding event on calendar '%s': %s", $self->calendar()->calendar_id(), $p->{text}));
129 my $result = $self->calendar()->api(
130 uri => 'events/quickAdd',
131 method => 'post',
132 params => { text => $p->{text} },
133 1 );
134 1 return ref($self)->new(calendar => $self->calendar(), id => $result->{id});
135 }
136  
137 0 ▶sub instances {
Subroutine instances: not called CC=2 SCAR=17.9
Pod documented
138 0 my $self = shift;
139 0 state $check = signature(
140 bless => !!0,
141 named => [
142 fields => Str, { optional => 1 },
143 max_pages => Int, { default => 0 },
144 page_callback => CodeRef, { optional => 1 },
145 params => HashRef, { default => {} },
146 ],
147 );
148 0 my $p = $check->(@_);
149  
150 0 $self->require_id('instances');
151  
152 return paginated_list(
153 api => $self,
154 uri => 'instances',
155 result_key => 'items',
156 default_fields => 'items(id, summary, start, end)',
157 max_pages => $p->{max_pages},
158 params => $p->{params},
159 0 ▶ ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
$$p{'page_callback'} ? : 0 0 0
160 );
161 }
162  
163 0 ▶sub move {
Subroutine move: not called CC=1 SCAR=6.9
Pod documented
164 0 my $self = shift;
165 0 state $check = signature(
166 bless => !!0,
167 named => [
168 destination => Str,
169 ],
170 );
171 0 my $p = $check->(@_);
172  
173 0 $self->require_id('move');
174  
175 0 DEBUG(sprintf("Moving event '%s' to calendar '%s'", $self->{id}, $p->{destination}));
176 my $result = $self->api(
177 uri => 'move',
178 method => 'post',
179 params => { destination => $p->{destination} },
180 0 );
181 0 return $result;
182 }
183  
184 2 ▶sub event_id { shift->{id}; }
Subroutine event_id: called CC=1 SCAR=0.0
Pod documented
185 9 ▶sub calendar { shift->{calendar}; }
Subroutine calendar: called CC=1 SCAR=0.0
Pod documented
186  
187 2 1;
188  
189 __END__
« RestApi/DriveApi3/Drive.pm ↑ Summary RestApi/SheetsApi4/Range/Iterator.pm »