| 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
| |||||||||||||||
| 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'} || ''
MC/DC0%0/1
$$msg{"${kind}ResponseMessage"}{'ResponseCode'} || ''
$$msg{"${kind}ResponseMessage"}{'ResponseCode'}
Truth table0%0/2
A
A= $$msg{"${kind}ResponseMessage"}{'ResponseCode'}
| |||||||||||||||
| 24 | 0 | ▶ | croak "Fault returned from Exchange Server: ($opts->{impersonate}) $code\n" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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
| |||||||||||||||
| 34 | 0 | ▶ | map { exists $_->{RootFolder} ? $_->{RootFolder} : $_ } | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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=6 SCAR=37.4
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
| |||||||||||||||
| 78 | |||||||||||||||
| 79 | 0 | ▶ | return EWS::Calendar::ResultSet->new({items => []}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 80 | if !defined $find_response; | ||||||||||||||
| 81 | |||||||||||||||
| 82 | 0 | $self->_check_for_errors('FindItem', $find_response, $opts); | |||||||||||||
| 83 | |||||||||||||||
| 84 | 0 | my @ids = map { $_->{ItemId}->{Id} } | |||||||||||||
| 85 | $self->_list_calendaritems('FindItem', $find_response); | ||||||||||||||
| 86 | |||||||||||||||
| 87 | 0 | ▶ | return EWS::Calendar::ResultSet->new({items => []}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 88 | if scalar @ids == 0; | ||||||||||||||
| 89 | |||||||||||||||
| 90 | my $get_response = scalar $self->client->GetItem->( | ||||||||||||||
| 91 | (exists $opts->{impersonate} ? ( | ||||||||||||||
| 92 | Impersonation => { | ||||||||||||||
| 93 | ConnectingSID => { | ||||||||||||||
| 94 | PrimarySmtpAddress => $opts->{impersonate}, | ||||||||||||||
| 95 | } | ||||||||||||||
| 96 | }, | ||||||||||||||
| 97 | ) : ()), | ||||||||||||||
| 98 | RequestVersion => { | ||||||||||||||
| 99 | Version => $self->client->server_version, | ||||||||||||||
| 100 | }, | ||||||||||||||
| 101 | ItemShape => { | ||||||||||||||
| 102 | BaseShape => 'IdOnly', | ||||||||||||||
| 103 | AdditionalProperties => { | ||||||||||||||
| 104 | cho_Path => [ | ||||||||||||||
| 105 | map {{ | ||||||||||||||
| 106 | 0 | FieldURI => { | |||||||||||||
| 107 | FieldURI => $_, | ||||||||||||||
| 108 | }, | ||||||||||||||
| 109 | }} qw/ | ||||||||||||||
| 110 | calendar:Start | ||||||||||||||
| 111 | calendar:End | ||||||||||||||
| 112 | item:Subject | ||||||||||||||
| 113 | calendar:Location | ||||||||||||||
| 114 | calendar:CalendarItemType | ||||||||||||||
| 115 | calendar:Organizer | ||||||||||||||
| 116 | item:Sensitivity | ||||||||||||||
| 117 | item:DisplayTo | ||||||||||||||
| 118 | calendar:AppointmentState | ||||||||||||||
| 119 | calendar:IsAllDayEvent | ||||||||||||||
| 120 | calendar:LegacyFreeBusyStatus | ||||||||||||||
| 121 | item:IsDraft | ||||||||||||||
| 122 | item:Body | ||||||||||||||
| 123 | calendar:OptionalAttendees | ||||||||||||||
| 124 | calendar:RequiredAttendees | ||||||||||||||
| 125 | calendar:Duration | ||||||||||||||
| 126 | calendar:UID | ||||||||||||||
| 127 | /, | ||||||||||||||
| 128 | ], | ||||||||||||||
| 129 | }, | ||||||||||||||
| 130 | }, | ||||||||||||||
| 131 | ItemIds => { | ||||||||||||||
| 132 | cho_ItemId => [ | ||||||||||||||
| 133 | 0 | ▶ | map {{ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 134 | 0 | ItemId => { Id => $_ }, | |||||||||||||
| 135 | }} @ids | ||||||||||||||
| 136 | ], | ||||||||||||||
| 137 | }, | ||||||||||||||
| 138 | ); | ||||||||||||||
| 139 | |||||||||||||||
| 140 | 0 | $self->_check_for_errors('GetItem', $get_response, $opts); | |||||||||||||
| 141 | |||||||||||||||
| 142 | 0 | return EWS::Calendar::ResultSet->new({ | |||||||||||||
| 143 | items => [ $self->_list_calendaritems('GetItem', $get_response) ] | ||||||||||||||
| 144 | }); | ||||||||||||||
| 145 | } | ||||||||||||||
| 146 | |||||||||||||||
| 147 | 1 | ▶ | no Moose::Role; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 148 | 1 | 1; | |||||||||||||
| 149 | |||||||||||||||