| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package EWS::Contacts::Item; | 
| 2 |  |  |  |  |  |  | BEGIN { | 
| 3 | 1 |  |  | 1 |  | 23 | $EWS::Contacts::Item::VERSION = '1.143070'; | 
| 4 |  |  |  |  |  |  | } | 
| 5 | 1 |  |  | 1 |  | 4 | use Moose; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 |  |  | 1 |  | 7448 | use Encode; | 
|  | 1 |  |  |  |  | 11096 |  | 
|  | 1 |  |  |  |  | 768 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | has DisplayName => ( | 
| 10 |  |  |  |  |  |  | is => 'ro', | 
| 11 |  |  |  |  |  |  | isa => 'Str', | 
| 12 |  |  |  |  |  |  | required => 1, | 
| 13 |  |  |  |  |  |  | ); | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | has JobTitle => ( | 
| 16 |  |  |  |  |  |  | is => 'ro', | 
| 17 |  |  |  |  |  |  | isa => 'Str', | 
| 18 |  |  |  |  |  |  | ); | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | has CompanyName => ( | 
| 21 |  |  |  |  |  |  | is => 'ro', | 
| 22 |  |  |  |  |  |  | isa => 'Str', | 
| 23 |  |  |  |  |  |  | ); | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | has BusinessHomePage => ( | 
| 26 |  |  |  |  |  |  | is => 'ro', | 
| 27 |  |  |  |  |  |  | isa => 'Str', | 
| 28 |  |  |  |  |  |  | ); | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | has PhoneNumbers => ( | 
| 31 |  |  |  |  |  |  | is => 'ro', | 
| 32 |  |  |  |  |  |  | isa => 'HashRef[ArrayRef]', | 
| 33 |  |  |  |  |  |  | default => sub { {} }, | 
| 34 |  |  |  |  |  |  | ); | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | has EmailAddresses => ( | 
| 37 |  |  |  |  |  |  | is => 'ro', | 
| 38 |  |  |  |  |  |  | isa => 'HashRef[ArrayRef]', | 
| 39 |  |  |  |  |  |  | default => sub { {} }, | 
| 40 |  |  |  |  |  |  | ); | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | has PhysicalAddresses => ( | 
| 43 |  |  |  |  |  |  | is => 'ro', | 
| 44 |  |  |  |  |  |  | isa => 'HashRef[ArrayRef]', | 
| 45 |  |  |  |  |  |  | default => sub { {} }, | 
| 46 |  |  |  |  |  |  | ); | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | sub BUILDARGS { | 
| 49 | 0 |  |  | 0 | 1 |  | my ($class, @rest) = @_; | 
| 50 | 0 | 0 |  |  |  |  | my $params = (scalar @rest == 1 ? $rest[0] : {@rest}); | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 0 |  |  |  |  |  | $params->{'PhoneNumbers'} = _build_Contact_Hashes($params->{'PhoneNumbers'}); | 
| 53 | 0 |  |  |  |  |  | $params->{'EmailAddresses'} = _build_Contact_Hashes($params->{'EmailAddresses'}); | 
| 54 | 0 |  |  |  |  |  | $params->{'PhysicalAddresses'} = _build_Biz_Hashes($params->{'PhysicalAddresses'}); | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 0 |  |  |  |  |  | foreach my $key (keys %$params) { | 
| 57 | 0 | 0 |  |  |  |  | if (not ref $params->{$key}) { | 
| 58 | 0 |  |  |  |  |  | $params->{$key} = Encode::encode('utf8', $params->{$key}); | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 0 |  |  |  |  |  | return $params; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | sub _build_Contact_Hashes { | 
| 66 | 0 |  |  | 0 |  |  | my $values = shift; | 
| 67 | 0 |  |  |  |  |  | my $entries = {}; | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | return {} if !exists $values->{'Entry'} | 
| 70 |  |  |  |  |  |  | or ref $values->{'Entry'} ne 'ARRAY' | 
| 71 | 0 | 0 | 0 |  |  |  | or scalar @{ $values->{'Entry'} } == 0; | 
|  | 0 |  | 0 |  |  |  |  | 
| 72 |  |  |  |  |  |  |  | 
| 73 | 0 |  |  |  |  |  | foreach my $entry (@{ $values->{'Entry'} }) { | 
|  | 0 |  |  |  |  |  |  | 
| 74 | 0 | 0 |  |  |  |  | next if !defined $entry->{'Key'}; | 
| 75 |  |  |  |  |  |  | #or $entry->{'Key'} =~ m/(?:Fax|Callback|Isdn|Pager|Telex|TtyTdd)/i; | 
| 76 |  |  |  |  |  |  |  | 
| 77 | 0 |  |  |  |  |  | my $type = $entry->{'Key'}; | 
| 78 | 0 |  |  |  |  |  | $type =~ s/(\w)([A-Z0-9])/$1 $2/g; # BusinessPhone -> Business Phone | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | # get numbers and set mapping to this name, but skip blanks | 
| 81 | 0 | 0 |  |  |  |  | next unless $entry->{'_'}; | 
| 82 | 0 |  |  |  |  |  | push @{ $entries->{$type} }, $entry->{'_'}; | 
|  | 0 |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  |  | 
| 85 | 0 |  |  |  |  |  | return $entries; | 
| 86 |  |  |  |  |  |  | } | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | sub _build_Biz_Hashes { | 
| 89 | 0 |  |  | 0 |  |  | my $values = shift; | 
| 90 | 0 |  |  |  |  |  | my $entries = {}; | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | return {} if !exists $values->{'Entry'} | 
| 93 |  |  |  |  |  |  | or ref $values->{'Entry'} ne 'ARRAY' | 
| 94 | 0 | 0 | 0 |  |  |  | or scalar @{ $values->{'Entry'} } == 0; | 
|  | 0 |  | 0 |  |  |  |  | 
| 95 |  |  |  |  |  |  |  | 
| 96 | 0 |  |  |  |  |  | foreach my $entry (@{ $values->{'Entry'} }) { | 
|  | 0 |  |  |  |  |  |  | 
| 97 | 0 | 0 |  |  |  |  | next if !defined $entry->{'Key'}; | 
| 98 | 0 |  |  |  |  |  | my $type = $entry->{'Key'}; | 
| 99 |  |  |  |  |  |  |  | 
| 100 | 0 |  |  |  |  |  | while( my ($fieldname, $fieldvalue) = each %$entry ) { | 
| 101 | 0 |  |  |  |  |  | $fieldname =~ s/(\w)([A-Z0-9])/$1 $2/g; | 
| 102 | 0 | 0 | 0 |  |  |  | next unless $fieldvalue and $fieldname ne 'Key'; | 
| 103 | 0 |  |  |  |  |  | push @{ $entries->{"$type $fieldname"} }, $fieldvalue; | 
|  | 0 |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | } | 
| 105 |  |  |  |  |  |  | } | 
| 106 |  |  |  |  |  |  |  | 
| 107 | 0 |  |  |  |  |  | return $entries; | 
| 108 |  |  |  |  |  |  | } | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; | 
| 111 | 1 |  |  | 1 |  | 6 | no Moose; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 10 |  | 
| 112 |  |  |  |  |  |  | 1; |