| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WWW::LogicBoxes::Contact::Factory; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 44 |  |  | 44 |  | 597915 | use strict; | 
|  | 44 |  |  |  |  | 153 |  | 
|  | 44 |  |  |  |  | 1454 |  | 
| 4 | 44 |  |  | 44 |  | 226 | use warnings; | 
|  | 44 |  |  |  |  | 94 |  | 
|  | 44 |  |  |  |  | 1396 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 44 |  |  | 44 |  | 3163 | use MooseX::Params::Validate; | 
|  | 44 |  |  |  |  | 3321359 |  | 
|  | 44 |  |  |  |  | 455 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 44 |  |  | 44 |  | 28663 | use WWW::LogicBoxes::Types qw( HashRef ); | 
|  | 44 |  |  |  |  | 117 |  | 
|  | 44 |  |  |  |  | 485 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 44 |  |  | 44 |  | 483206 | use WWW::LogicBoxes::Contact; | 
|  | 44 |  |  |  |  | 205 |  | 
|  | 44 |  |  |  |  | 2124 |  | 
| 11 | 44 |  |  | 44 |  | 26583 | use WWW::LogicBoxes::Contact::CA; | 
|  | 44 |  |  |  |  | 190 |  | 
|  | 44 |  |  |  |  | 2004 |  | 
| 12 | 44 |  |  | 44 |  | 25650 | use WWW::LogicBoxes::Contact::US; | 
|  | 44 |  |  |  |  | 205 |  | 
|  | 44 |  |  |  |  | 2053 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 44 |  |  | 44 |  | 426 | use Carp; | 
|  | 44 |  |  |  |  | 105 |  | 
|  | 44 |  |  |  |  | 10130 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | our $VERSION = '1.10.1'; # VERSION | 
| 17 |  |  |  |  |  |  | # ABSTRACT: Abstract Factory For Construction of Contacts | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | sub construct_from_response { | 
| 20 | 7 |  |  | 7 | 1 | 13706 | my $self         = shift; | 
| 21 | 7 |  |  |  |  | 50 | my ( $response ) = pos_validated_list( \@_, { isa => HashRef } ); | 
| 22 |  |  |  |  |  |  |  | 
| 23 | 7 | 50 | 100 |  |  | 15643 | if( $response->{type} eq 'CaContact' ) { | 
|  |  | 100 | 66 |  |  |  |  | 
| 24 | 0 |  |  |  |  | 0 | return WWW::LogicBoxes::Contact::CA->construct_from_response( $response ); | 
| 25 |  |  |  |  |  |  | } | 
| 26 | 6 |  |  |  |  | 54 | elsif( ( grep { $_ eq 'domus' } @{ $response->{contacttype} } ) | 
|  | 7 |  |  |  |  | 33 |  | 
| 27 |  |  |  |  |  |  | && exists $response->{ApplicationPurpose} && exists $response->{NexusCategory} ) { | 
| 28 | 1 |  |  |  |  | 10 | return WWW::LogicBoxes::Contact::US->construct_from_response($response); | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  | else { | 
| 31 | 6 |  |  |  |  | 107 | return WWW::LogicBoxes::Contact->construct_from_response($response); | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | 1; | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | __END__ | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =pod | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | =head1 NAME | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | WWW::LogicBoxes::Contact::Factory - Factory for Construction of Contact Objects | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | use WWW::LogicBoxes; | 
| 48 |  |  |  |  |  |  | use WWW::LogicBoxes::Contact::Factory; | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | my $api = WWW::LogicBoxes->new( ... ); | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | my $response = $api->submit({ | 
| 53 |  |  |  |  |  |  | method => 'contacts__details', | 
| 54 |  |  |  |  |  |  | params => { | 
| 55 |  |  |  |  |  |  | 'contact-id' => 42, | 
| 56 |  |  |  |  |  |  | }, | 
| 57 |  |  |  |  |  |  | }); | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | my $contact = WWW::LogicBoxes::Contact::Factory->construct_from_response( $response ); | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | Abstract Factory that accepts the raw response from L<LogicBoxes|http://www.logicboxes.com> and returns a fully formed L<WWW::LogicBoxes::Contact> or one of it's subclasses. | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | =head1 METHODS | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | =head2 construct_from_response | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | my $response = $api->submit({ | 
| 70 |  |  |  |  |  |  | method => 'contacts__details', | 
| 71 |  |  |  |  |  |  | params => { | 
| 72 |  |  |  |  |  |  | 'contact-id' => 42, | 
| 73 |  |  |  |  |  |  | }, | 
| 74 |  |  |  |  |  |  | }); | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | my $contact = WWW::LogicBoxes::Contact::Factory->construct_from_response( $response ); | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | Given a HashRef that is the JSON response from LogicBoxes when retrieving contact details, returns an instance of L<WWW::LogicBoxes::Contact> or one of it's subclasses. |