File Coverage

blib/lib/WWW/LogicBoxes/Contact/CA.pm
Criterion Covered Total %
statement 21 49 42.8
branch 0 12 0.0
condition 0 6 0.0
subroutine 7 10 70.0
pod 2 3 66.6
total 30 80 37.5


line stmt bran cond sub pod time code
1             package WWW::LogicBoxes::Contact::CA;
2              
3 45     45   405861 use strict;
  45         112  
  45         1561  
4 45     45   280 use warnings;
  45         99  
  45         1426  
5              
6 45     45   729 use Moose;
  45         142323  
  45         392  
7 45     45   303696 use MooseX::StrictConstructor;
  45         24832  
  45         405  
8 45     45   146036 use namespace::autoclean;
  45         132  
  45         470  
9              
10 45     45   4830 use WWW::LogicBoxes::Types qw( CPR CPRIndividual CPRNonIndividual Str );
  45         113  
  45         474  
11              
12 45     45   460089 use Carp;
  45         135  
  45         21618  
13              
14             extends 'WWW::LogicBoxes::Contact';
15              
16             our $VERSION = '1.10.0'; # VERSION
17             # ABSTRACT: Contact for .CA Registrations
18              
19             has '+type' => (
20             default => 'CaContact',
21             );
22              
23             has 'cpr' => (
24             is => 'ro',
25             isa => CPR,
26             required => 1,
27             );
28              
29             has 'agreement_version' => (
30             is => 'ro',
31             isa => Str,
32             required => 0,
33             predicate => 'has_agreement_version',
34             );
35              
36             sub BUILD {
37 0     0 0   my $self = shift;
38              
39 0 0         if( $self->type ne 'CaContact' ) {
40 0           croak 'CA Contacts must have a type of CaContact';
41             }
42              
43 0 0 0       if( !$self->has_id && !$self->has_agreement_version ) {
44 0           croak 'An agreement_version must be provided for new CA Contacts';
45             }
46              
47 0 0 0       if( grep { $_ eq $self->cpr } @{ CPRNonIndividual->values } && $self->company ne 'N/A' ) {
  0            
48 0           croak 'For Non Individual CA Contacts the company must be "N/A"';
49             }
50              
51 0           return $self;
52             }
53              
54             sub construct_creation_request {
55 0     0 1   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 0         if( $self->has_agreement_version ) {
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             sub construct_from_response {
74 0     0 1   my $self = shift;
75 0           my $response = shift;
76              
77 0 0         if( !defined $response ) {
78 0           return;
79             }
80              
81 0           my $contact = WWW::LogicBoxes::Contact->construct_from_response( $response );
82              
83 0 0         if( !defined $contact ) {
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             __PACKAGE__->meta->make_immutable;
95             1;
96              
97             __END__
98             =pod
99              
100             =head1 NAME
101              
102             WWW::LogicBoxes::Contact::CA - Representation of Domain Contact for .ca Domains
103              
104             =head1 SYNOPSIS
105              
106             use strict;
107             use warnings;
108              
109             use WWW::LogicBoxes;
110             use WWW::LogicBoxes::Customer;
111             use WWW::LogicBoxes::Contact::CA;
112             use WWW::LogicBoxes::Contact::CA::Agreement;
113              
114             my $api = WWW::LogicBoxes->new( ... );
115             my $agreement = $api->get_ca_registrant_contact();
116              
117             my $customer = WWW::LogicBoxes::Customer->new( ... ); # Valid LogicBoxes Customer
118              
119             my $contact = WWW::LogicBoxes::Contact::CA->new(
120             id => 42,
121             name => 'Edsger Dijkstra',
122             company => 'University of Texas at Austin',
123             email => 'depth.first@search.com',
124             address1 => 'University of Texas',
125             address2 => '42 Main St',
126             city => 'Austin',
127             state => 'Texas',
128             country => 'US',
129             zipcode => '78713',
130             phone_number => '18005551212',
131             fax_number => '18005551212',
132             customer_id => $customer->id,
133              
134             cpr => 'RES',
135             agreement_version => $agreement->version,
136             );
137              
138             =head1 EXTENDS
139              
140             L<WWW::LogicBoxes::Contact>
141              
142             =head1 DESCRIPTION
143              
144             Representation of a L<LogicBoxes|http://www.logicboxes.com> domain contact for .ca TLD domains. The .ca TLD is special in that specific CPR and Agreement data must be provided. For details on the agreement that customers must accept please see L<WWW::LogicBoxes::Contact::CA::Agreement>.
145              
146             =head1 ATTRIBUTES
147              
148             =head2 B<name>
149              
150             The name has special restrictions based on if the CPR provided is for Individuals or Non Individuals. Please see L<http://manage.logicboxes.com/kb/sites/default/files/Valid%20Contact%20Names.pdf> for a full listing of key words that must or must not be present.
151              
152             Also, the name of a CA Contact can not be changed! If you really need to change it, you'll have to create a whole new L<WWW::LogicBoxes::Contact::CA> with the desired information, replace it on any domain that uses the old contact, and then delete the old contact.
153              
154             =head2 B<cpr>
155              
156             Similiar to nexus_data for .us domains, the CPR is a specialized code that describes the registrant contact. It must take on one of the following values (original source L<http://manage.logicboxes.com/kb/answer/790>):
157              
158             =head3 CPR For Individuals
159              
160             =over 4
161              
162             =item ABO - Aboriginal Peoples (individuals or groups) indigenous to Canada
163              
164             =item CCT - Canadian citizen
165              
166             =item LGR - Legal Representative of a Canadian Citizen or Permanent Resident
167              
168             =item RES - Permanent Resident of Canada
169              
170             =back
171              
172             =head3 CPR For Non Individuals
173              
174             B<NOTE> For Non Individual CPRs the company name MUST be "N/A".
175              
176             =over 4
177              
178             =item ASS Canadian Unincorporated Association
179              
180             =item CCO Corporation (Canada or Canadian province or territory)
181              
182             =item EDU Canadian Educational institution
183              
184             =item GOV Government or government entity in Canada
185              
186             =item HOP Canadian Hospital
187              
188             =item INB Indian Band recognized by the Indian Act of Canada
189              
190             =item LAM Canadian Library, Archive or Museum
191              
192             =item MAJ Her Majesty the Queen
193              
194             =item OMK Official mark registered in Canada
195              
196             =item PLT Canadian Political Party
197              
198             =item PRT Partnership Registered in Canada
199              
200             =item TDM Trade-mark registered in Canada (by a non-Canadian owner)
201              
202             =item TRD Canadian Trade Union
203              
204             =item TRS Trust established in Canada
205              
206             =back
207              
208             The cpr B<can not be changed> once the contact is created.
209              
210             =head2 agreement_version
211              
212             The version of the CA Registrant Agreement the customer is accepting (retrieved via L<WWW::LogicBoxes::Role::Command::Contact/get_ca_registrant_agreement> which returns a L<WWW::LogicBoxes::Contact::CA::Agreement>). This value must be specified when creating a new contact but is never returned by the API.
213              
214             Offers a predicate of has_agreement_version.
215              
216             =cut