| 1 | package WWW::LogicBoxes::Contact::CA; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 51 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 51 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 51 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 51 | ▶ | use MooseX::StrictConstructor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 51 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 51 | ▶ | use WWW::LogicBoxes::Types qw( CPR CPRIndividual CPRNonIndividual Str ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 51 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 51 | extends 'WWW::LogicBoxes::Contact'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 51 | our $VERSION = '1.11.0'; # VERSION | |||||||||||||||||||||||||||
| 17 | # ABSTRACT: Contact for .CA Registrations | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 51 | has '+type' => ( | |||||||||||||||||||||||||||
| 20 | default => 'CaContact', | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 51 | has 'cpr' => ( | |||||||||||||||||||||||||||
| 24 | is => 'ro', | ||||||||||||||||||||||||||||
| 25 | isa => CPR, | ||||||||||||||||||||||||||||
| 26 | required => 1, | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 51 | has 'agreement_version' => ( | |||||||||||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||||||||||
| 31 | isa => Str, | ||||||||||||||||||||||||||||
| 32 | required => 0, | ||||||||||||||||||||||||||||
| 33 | predicate => 'has_agreement_version', | ||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if( $self->type ne 'CaContact' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | croak 'CA Contacts must have a type of CaContact'; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if( !$self->has_id && !$self->has_agreement_version ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->has_id or $self->has_agreement_version
MC/DC0%0/2
$self->has_id or $self->has_agreement_version
$self->has_id
$self->has_agreement_version
Truth table0%0/3
A or B
A= $self->has_idB= $self->has_agreement_version
| |||||||||||||||||||||||||||||
| 44 | 0 | croak 'An agreement_version must be provided for new CA Contacts'; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if( grep { $_ eq $self->cpr } @{ CPRNonIndividual->values } && $self->company ne 'N/A' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{CPRNonIndividual()->values;} && $self->company ne 'N/A'
MC/DC0%0/2
@{CPRNonIndividual()->values;} && $self->company ne 'N/A'
@{CPRNonIndividual()->values;}
$self->company ne 'N/A'
Truth table0%0/3
A && B
A= @{CPRNonIndividual()->values;}B= $self->company ne 'N/A'
| |||||||||||||||||||||||||||||
| 48 | 0 | croak 'For Non Individual CA Contacts the company must be "N/A"'; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | return $self; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub construct_creation_request { | ||||||||||||||||||||||||||
|
Subroutine
construct_creation_request: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | my $request = $self->SUPER::construct_creation_request(); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | $request->{'attr-name1'} = 'CPR'; | |||||||||||||||||||||||||||
| 60 | 0 | $request->{'attr-value1'} = $self->cpr; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if( $self->has_agreement_version ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | $request->{'attr-name2'} = 'AgreementVersion'; | |||||||||||||||||||||||||||
| 64 | 0 | $request->{'attr-value2'} = $self->agreement_version; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | $request->{'attr-name3'} = 'AgreementValue'; | |||||||||||||||||||||||||||
| 67 | 0 | $request->{'attr-value3'} = 'y'; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | return $request; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub construct_from_response { | ||||||||||||||||||||||||||
|
Subroutine
construct_from_response: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 75 | 0 | my $response = shift; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if( !defined $response ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | return; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | my $contact = WWW::LogicBoxes::Contact->construct_from_response( $response ); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if( !defined $contact ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 0 | return; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | $self->meta->rebless_instance( $contact, | ||||||||||||||||||||||||||||
| 88 | cpr => $response->{CPR}, | ||||||||||||||||||||||||||||
| 89 | 0 | ); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | return $contact; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 51 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 95 | 51 | 1; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | __END__ | ||||||||||||||||||||||||||||