Contacts/Role/Reader.pm

filter: Statementstmt 37.8% 14 / 37 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 5 / 10 Podpod 0.0% 0 / 1 totaltotal 25.6% 19 / 74 SCAR 43.3
CC
12
Cov
24%
_check_for_errors
20.0
_list_contactitems
20.0
retrieve
20.0
CRAP 75.9
« Calendar/Role/RetrieveWithinWindow.pm ↑ Summary Folder/Item.pm »
1 package EWS::Contacts::Role::Reader;
2 BEGIN {
3 1 ▶ $EWS::Contacts::Role::Reader::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::Contacts::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) = @_;
Subroutine _check_for_errors: not called CC=4 SCAR=30.0
19  
20 0 foreach my $msg ( $self->_list_messages($kind, $response) ) {
21 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
22 0 ▶ croak "Fault returned from Exchange Server: $code\n"
Branch: 1 branch
BranchTrueFalseTotal
if $code ne "NoError" 0 0 0
23 if $code ne 'NoError';
24 }
25 }
26  
27 sub _list_contactitems {
28 0 ▶ my ($self, $kind, $response) = @_;
Subroutine _list_contactitems: not called CC=4 SCAR=30.0
29  
30 0 return map { $_->{Contact} }
31 0 ▶ grep { defined $_->{'Contact'}->{'DisplayName'} and length $_->{'Contact'}->{'DisplayName'} }
Branch: 1 branch
BranchTrueFalseTotal
defined $_->{"Contact"}{"DisplayName"} and length $_->{"Contact"}{"DisplayName"} 0 0 0
32 0 ▶ map { @{ $_->{Items}->{cho_Item} || [] } }
Branch: 1 branch
BranchTrueFalseTotal
$_->{"Items"}{"cho_Item"} or [] 0 0 0
33 0 ▶ map { exists $_->{RootFolder} ? $_->{RootFolder} : $_ }
Branch: 1 branch
BranchTrueFalseTotal
exists $_->{'RootFolder'} ? : 0 0 0
34 0 map { $_->{"${kind}ResponseMessage"} }
35 $self->_list_messages($kind, $response);
36 }
37  
38 sub _get_contacts {
39 0 ▶ my ($self, $opts) = @_;
Subroutine _get_contacts: not called CC=3 SCAR=24.8
40  
41 return scalar $self->client->FindItem->(
42 (exists $opts->{impersonate} ? (
43 Impersonation => {
44 ConnectingSID => {
45 PrimarySmtpAddress => $opts->{impersonate},
46 }
47 },
48 ) : ()),
49 RequestVersion => {
50 Version => $self->client->server_version,
51 },
52 ItemShape => { BaseShape => 'AllProperties' },
53 ParentFolderIds => {
54 cho_FolderId => [
55 { DistinguishedFolderId =>
56 {
57 Id => 'contacts',
58 (exists $opts->{email} ? (
59 Mailbox => {
60 EmailAddress => $opts->{email},
61 },
62 0 ▶ ) : ()), # optional
Branch: 2 branches
BranchTrueFalseTotal
exists $opts->{'impersonate'} ? : 0 0 0
exists $opts->{'email'} ? : 0 0 0
63 }
64 }
65 ]
66 },
67 Traversal => 'Shallow',
68 );
69 }
70  
71 # find primarysmtp if passed an account id.
72 # then find contacts in the account.
73 sub retrieve {
74 0 ▶ my ($self, $opts) = @_;
Subroutine retrieve: not called CC=4 SCAR=30.0
Pod undocumented
75  
76 0 my $get_response = $self->_get_contacts($opts);
77  
78 0 ▶ if (exists $get_response->{'ResponseCode'} and defined $get_response->{'ResponseCode'}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $get_response->{"ResponseCode"} and defined $get_response->{"ResponseCode"} and $get_response->{"ResponseCode"} eq "ErrorNonPrimarySmtpAddress") 0 0 0
Condition0%0/6
exists $get_response->{"ResponseCode"} and defined $get_response->{"ResponseCode"} and $get_response->{"ResponseCode"} eq "ErrorNonPrimarySmtpAddress"
!ll&&!rl&&r
000
exists $get_response->{"ResponseCode"} and defined $get_response->{"ResponseCode"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $get_response->{"ResponseCode"} and defined $get_response->{"ResponseCode"} and $get_response->{"ResponseCode"} eq "ErrorNonPrimarySmtpAddress"
exists $get_response->{"ResponseCode"} defined $get_response->{"ResponseCode"} $get_response->{"ResponseCode"} eq "ErrorNonPrimarySmtpAddress"
Truth table0%0/4
A and B and C
A= exists $get_response->{"ResponseCode"}B= defined $get_response->{"ResponseCode"}C= $get_response->{"ResponseCode"} eq "ErrorNonPrimarySmtpAddress"
ABCresult
0XX0
10X0
1100
1111
79 and $get_response->{'ResponseCode'} eq 'ErrorNonPrimarySmtpAddress') {
80  
81 $self->retrieve({
82 %$opts,
83 0 email => $get_response->{'MessageXml'}->{'Value'}->{'_'},
84 });
85 }
86  
87 0 $self->_check_for_errors('FindItem', $get_response);
88  
89 0 return EWS::Contacts::ResultSet->new({
90 items => [ $self->_list_contactitems('FindItem', $get_response) ]
91 });
92 }
93  
94 1 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
95 1 1;
« Calendar/Role/RetrieveWithinWindow.pm ↑ Summary Folder/Item.pm »