Calendar/Role/RetrieveWithinWindow.pm

filter: Statementstmt 35.0% 14 / 40 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 1 totaltotal 27.5% 19 / 69 CC 11 SCAR 28.9
CC
11
Cov
24%
_check_for_errors
30.0
retrieve_within_window
30.0
_list_calendaritems
12.0
CRAP 18.1
« Client.pm ↑ Summary Contacts/Role/Reader.pm »
1 package EWS::Calendar::Role::RetrieveWithinWindow;
2 BEGIN {
3 1 ▶ $EWS::Calendar::Role::RetrieveWithinWindow::VERSION = '1.143070';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use EWS::Calendar::ResultSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub _list_messages {
11 0 ▶ my ($self, $kind, $response) = @_;
Subroutine _list_messages: not called CC=1 SCAR=6.9
12 0 return @{ $response->{"${kind}Result"}
13 ->{ResponseMessages}
14 0 ->{cho_CreateItemResponseMessage} };
15 }
16  
17 sub _check_for_errors {
18 0 ▶ my ($self, $kind, $response, $opts) = @_;
Subroutine _check_for_errors: not called CC=5 SCAR=34.0
19  
20 croak "Fault returned from Exchange Server: ($opts->{impersonate}) $response->{Fault}->{faultstring}\n"
21 0 ▶ if ( exists $response->{Fault} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $response->{"Fault"} 0 0 0
22 0 foreach my $msg ( $self->_list_messages($kind, $response) ) {
23 0 ▶ my $code = $msg->{"${kind}ResponseMessage"}->{ResponseCode} || '';
Condition0%0/2
$$msg{"${kind}ResponseMessage"}{'ResponseCode'} || ''
l!l
00
MC/DC0%0/1
$$msg{"${kind}ResponseMessage"}{'ResponseCode'} || ''
$$msg{"${kind}ResponseMessage"}{'ResponseCode'}
Truth table0%0/2
A
A= $$msg{"${kind}ResponseMessage"}{'ResponseCode'}
Aresult
11
00
24 0 ▶ croak "Fault returned from Exchange Server: ($opts->{impersonate}) $code\n"
Branch: 1 branch
BranchTrueFalseTotal
if $code ne "NoError" 0 0 0
25 if $code ne 'NoError';
26 }
27 }
28  
29 sub _list_calendaritems {
30 0 ▶ my ($self, $kind, $response) = @_;
Subroutine _list_calendaritems: not called CC=3 SCAR=24.8
31  
32 0 return map { $_->{CalendarItem} }
33 0 ▶ map { @{ $_->{Items}->{cho_Item} || [] } }
Branch: 1 branch
BranchTrueFalseTotal
$_->{"Items"}{"cho_Item"} or [] 0 0 0
34 0 ▶ map { exists $_->{RootFolder} ? $_->{RootFolder} : $_ }
Branch: 1 branch
BranchTrueFalseTotal
exists $_->{'RootFolder'} ? : 0 0 0
35 0 map { $_->{"${kind}ResponseMessage"} }
36 $self->_list_messages($kind, $response);
37 }
38  
39 # Find list of items within the view, then Get details for each one
40 # (item:Body is only available this way, it's not returned by FindItem)
41 sub retrieve_within_window {
42 0 ▶ my ($self, $opts) = @_;
Subroutine retrieve_within_window: not called CC=5 SCAR=34.0
Pod undocumented
43  
44 my $find_response = scalar $self->client->FindItem->(
45 (exists $opts->{impersonate} ? (
46 Impersonation => {
47 ConnectingSID => {
48 PrimarySmtpAddress => $opts->{impersonate},
49 }
50 },
51 ) : ()),
52 RequestVersion => {
53 Version => $self->client->server_version,
54 },
55 Traversal => 'Shallow',
56 ItemShape => {
57 BaseShape => 'IdOnly',
58 },
59 ParentFolderIds => {
60 cho_FolderId => [
61 { DistinguishedFolderId =>
62 {
63 Id => "calendar",
64 (exists $opts->{email} ? (
65 Mailbox => {
66 EmailAddress => $opts->{email},
67 },
68 ) : ()), # optional
69 },
70 },
71 ],
72 },
73 CalendarView => {
74 StartDate => $opts->{window}->start->iso8601,
75 EndDate => $opts->{window}->end->iso8601,
76 },
77 0 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
exists $opts->{'impersonate'} ? : 0 0 0
exists $opts->{'email'} ? : 0 0 0
78  
79 0 $self->_check_for_errors('FindItem', $find_response, $opts);
80  
81 0 my @ids = map { $_->{ItemId}->{Id} }
82 $self->_list_calendaritems('FindItem', $find_response);
83  
84 0 ▶ return return EWS::Calendar::ResultSet->new({items => []})
Branch: 1 branch
BranchTrueFalseTotal
if scalar @ids == 0 0 0 0
85 if scalar @ids == 0;
86  
87 my $get_response = scalar $self->client->GetItem->(
88 (exists $opts->{impersonate} ? (
89 Impersonation => {
90 ConnectingSID => {
91 PrimarySmtpAddress => $opts->{impersonate},
92 }
93 },
94 ) : ()),
95 RequestVersion => {
96 Version => $self->client->server_version,
97 },
98 ItemShape => {
99 BaseShape => 'IdOnly',
100 AdditionalProperties => {
101 cho_Path => [
102 map {{
103 0 FieldURI => {
104 FieldURI => $_,
105 },
106 }} qw/
107 calendar:Start
108 calendar:End
109 item:Subject
110 calendar:Location
111 calendar:CalendarItemType
112 calendar:Organizer
113 item:Sensitivity
114 item:DisplayTo
115 calendar:AppointmentState
116 calendar:IsAllDayEvent
117 calendar:LegacyFreeBusyStatus
118 item:IsDraft
119 item:Body
120 calendar:OptionalAttendees
121 calendar:RequiredAttendees
122 calendar:Duration
123 calendar:UID
124 /,
125 ],
126 },
127 },
128 ItemIds => {
129 cho_ItemId => [
130 0 ▶ map {{
Branch: 1 branch
BranchTrueFalseTotal
exists $opts->{'impersonate'} ? : 0 0 0
131 0 ItemId => { Id => $_ },
132 }} @ids
133 ],
134 },
135 );
136  
137 0 $self->_check_for_errors('GetItem', $get_response, $opts);
138  
139 0 return EWS::Calendar::ResultSet->new({
140 items => [ $self->_list_calendaritems('GetItem', $get_response) ]
141 });
142 }
143  
144 1 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
145 1 1;
146  
« Client.pm ↑ Summary Contacts/Role/Reader.pm »