blib/lib/WWW/eNom/DomainRequest/Registration.pm

filter: Statementstmt 80.3% 45 / 56 Branchbran 18.1% 4 / 22 Conditioncond 33.3% 2 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 88.8% 8 / 9 Podpod n/a totaltotal 61.8% 60 / 97 CC 14 SCAR 34.2
CC
14
Cov
61%
construct_request
72.0
BUILD
12.4
BEGIN
1.0
CRAP 30.4
« blib/lib/WWW/eNom/Role/Command/Domain/Availability.pm ↑ Summary blib/lib/WWW/eNom/Role/Command/Domain/PrivateNameServer.pm »
1 package WWW::eNom::DomainRequest::Registration;
2  
3 46 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 46 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 46 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 46 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 46 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 46 ▶use WWW::eNom::Types qw( Bool Contact DomainName DomainNames Int NexusCategory NexusPurpose );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 46 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 46 our $VERSION = 'v2.0.0'; # VERSION
15 # ABSTRACT: Domain Registration Request
16  
17 46 has 'name' => (
18 is => 'ro',
19 isa => DomainName,
20 required => 1,
21 );
22  
23 46 has 'ns' => (
24 is => 'ro',
25 isa => DomainNames,
26 predicate => 'has_ns',
27 );
28  
29 46 has 'is_ns_fail_fatal' => (
30 is => 'ro',
31 isa => Bool,
32 default => 0,
33 );
34  
35 46 has 'is_locked' => (
36 is => 'ro',
37 isa => Bool,
38 default => 1,
39 );
40  
41 46 has 'is_private' => (
42 is => 'ro',
43 isa => Bool,
44 default => 0,
45 );
46  
47 46 has 'is_auto_renew' => (
48 is => 'ro',
49 isa => Bool,
50 default => 0,
51 );
52  
53 46 has 'is_queueable' => (
54 is => 'ro',
55 isa => Bool,
56 default => 0,
57 );
58  
59 46 has 'years' => (
60 is => 'ro',
61 isa => Int,
62 required => 1,
63 );
64  
65 46 has 'registrant_contact' => (
66 is => 'ro',
67 isa => Contact,
68 required => 1,
69 );
70  
71 46 has 'admin_contact' => (
72 is => 'ro',
73 isa => Contact,
74 required => 1,
75 );
76  
77 46 has 'technical_contact' => (
78 is => 'ro',
79 isa => Contact,
80 required => 1,
81 );
82  
83 46 has 'billing_contact' => (
84 is => 'ro',
85 isa => Contact,
86 required => 1,
87 );
88  
89 46 has 'nexus_purpose' => (
90 is => 'ro',
91 isa => NexusPurpose,
92 predicate => 'has_nexus_purpose',
93 );
94  
95 46 has 'nexus_category' => (
96 is => 'ro',
97 isa => NexusCategory,
98 predicate => 'has_nexus_category',
99 );
100  
101 46 with 'WWW::eNom::Role::ParseDomain';
102  
103 sub BUILD {
104 2 ▶ my $self = shift;
Subroutine BUILD: called CC=7 SCAR=25.1
105  
106 2 ▶ if( $self->public_suffix eq 'us' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->public_suffix eq 'us') { } 2 0 2
107 2 ▶ if( !$self->has_nexus_purpose || !$self->has_nexus_category ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_nexus_purpose and $self->has_nexus_category) 1 1 2
Condition66%2/3
$self->has_nexus_purpose and $self->has_nexus_category
!ll&&!rl&&r
101
MC/DC50%1/2
$self->has_nexus_purpose and $self->has_nexus_category
$self->has_nexus_purpose $self->has_nexus_category
Truth table66%2/3
A and B
A= $self->has_nexus_purposeB= $self->has_nexus_category
ABresult
0X0
100
111
108 1 croak '.us domain registration require a nexus_purpose and a nexus_category';
109 }
110  
111 1 ▶ if( $self->is_private ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_private) 1 0 1
112 1 croak 'Domain Privacy is not available for .us domains';
113 }
114 }
115 else {
116 0 ▶ if( $self->has_nexus_purpose || $self->has_nexus_category ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_nexus_purpose or $self->has_nexus_category) 0 0 0
Condition0%0/3
$self->has_nexus_purpose or $self->has_nexus_category
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->has_nexus_purpose or $self->has_nexus_category
$self->has_nexus_purpose $self->has_nexus_category
Truth table0%0/3
A or B
A= $self->has_nexus_purposeB= $self->has_nexus_category
ABresult
1X1
011
000
117 0 croak 'nexus values should only be provided for .us domains';
118 }
119 }
120  
121 0 return;
122 }
123  
124 sub construct_request {
125 0 ▶ my $self = shift;
Subroutine construct_request: not called CC=8 SCAR=42.8
126  
127 return {
128 SLD => $self->sld,
129 TLD => $self->tld,
130 !$self->has_ns
131 ? ( UseDNS => 'default' )
132 0 ▶ : ( map { 'NS' . ( $_ + 1 ) => $self->ns->[ $_ ] } 0 .. ( scalar (@{ $self->ns }) - 1) ),
Branch: 6 branches
BranchTrueFalseTotal
$self->is_ns_fail_fatal ? : 0 0 0
$self->is_locked ? : 0 0 0
$self->is_auto_renew ? : 0 0 0
$self->is_queueable ? : 0 0 0
$self->has_nexus_purpose ? : 0 0 0
$self->has_nexus_category ? : 0 0 0
133 IgnoreNSFail => ( $self->is_ns_fail_fatal ? 'No' : 'Yes' ),
134 UnLockRegistrar => ( $self->is_locked ? 0 : 1 ),
135 RenewName => ( $self->is_auto_renew ? 1 : 0 ),
136 AllowQueueing => ( $self->is_queueable ? 1 : 0 ),
137 NumYears => $self->years,
138 $self->has_nexus_purpose ? ( us_purpose => $self->nexus_purpose ) : ( ),
139 $self->has_nexus_category ? ( us_nexus => $self->nexus_category ) : ( ),
140 0 %{ $self->registrant_contact->construct_creation_request('Registrant') },
141 0 %{ $self->admin_contact->construct_creation_request('Admin') },
142 0 %{ $self->technical_contact->construct_creation_request('Tech') },
143 0 ▶ %{ $self->billing_contact->construct_creation_request('AuxBilling') },
Branch: 1 branch
BranchTrueFalseTotal
!$self->has_ns ? : 0 0 0
144 };
145 }
146  
147 46 __PACKAGE__->meta->make_immutable;
148 46 1;
149  
150 __END__
151  
152 =pod
153  
154 =head1 NAME
155  
156 WWW::eNom::DomainRequest::Registration - Domain Registration Request
157  
158 =head1 SYNOPSIS
159  
160 use WWW::eNom;
161 use WWW::eNom::Contact;
162 use WWW::eNom::DomainRequest::Registration;
163  
164 my $api = WWW::eNom->new( ... );
165 my $contact = WWW::eNom::Contact->new( ... );
166  
167 # Register a New Domain
168 my $registration_request = WWW::eNom::DomainRequest::Registration->new(
169 name => 'drzigman.com',
170 ns => [ 'ns1.enom.com', 'ns2.enom.com' ],
171 is_ns_fail_fatal => 0, # Optional, defaults to false
172 is_locked => 1, # Optional, defaults to true
173 is_private => 1, # Optional, defaults to false
174 is_auto_renew => 0, # Optional, defaults to false
175 is_queueable => 0, # Optional, defaults to false
176 years => 1,
177 nexus_purpose => 'P1', # Only for .us domains
178 nexus_category => 'C11', # Only for .us domains
179 registrant_contact => $contact,
180 technical_contact => $contact,
181 admin_contact => $contact,
182 billing_contact => $contact,
183 );
184  
185 # Real way of using this module to register a domain
186 my $domain = $api->register_domain( request => $registration_request );
187  
188  
189 # Example showing construct_request, contrived! Use register_domain in real life!
190 my $response = $api->submit({
191 method => 'Purchase',
192 params => $registration_request->construct_request(),
193 });
194  
195 =head1 WITH
196  
197 =over 4
198  
199 =item L<WWW::eNom::Role::ParseDomain>
200  
201 =back
202  
203 =head1 DESCRIPTION
204  
205 WWW::eNom::DomainRequest::Registration is a representation of all the data needed in order to complete a domain registration. It is used when requesting a new registration from L<eNom|https://www.enom.com>.
206  
207 =head1 ATTRIBUTES
208  
209 =head2 B<name>
210  
211 The FQDN to register.
212  
213 =head2 ns
214  
215 ArrayRef of Domain Names that are to be authoritative nameservers for this domain.
216  
217 Predicate of has_ns. If not specified, L<eNom|https://www.enom.com>'s nameservers (or whatever you specially configured in your L<eNom Reseller Panel|https://www.enom.com/login.aspx>) will be used.
218  
219 =head2 is_ns_fail_fatal
220  
221 Boolean that defaults to false. If set to true, the provided ns values must resolve otherwise the domain registration request will fail.
222  
223 =head2 is_locked
224  
225 Boolean that defaults to true. Indicates if the domain should be locked, preventing transfers.
226  
227 =head2 is_private
228  
229 Boolean that defaults to false. If true, the L<WPPS Service|https://www.enom.com/api/Value%20Added%20Topics/ID%20Protect.htm> (what eNom calls Privacy Protection) will automatically be purchased and enabled.
230  
231 It's worth noting that not all domains permit domain privacy. If you attempt to purchase a domain with privacy for one of these domains (such as a .us registration) construction of the request will croak.
232  
233 =head2 is_auto_renew
234  
235 Boolean that defaults to false. If true, this domain will be automatically renewed by eNom before it expires.
236  
237 =head2 is_queueable
238  
239 Boolean that defaults to false. If true, eNom will "queue" domain registration requests that it can not be complete in real time (example: the registry connectivity is down).
240  
241 =head2 B<years>
242  
243 The number of years to register the domain for. Keep in mind there are limits (based on the Public Suffix) but generally this is a Positive Integer between 1 and 10.
244  
245 =head2 nexus_purpose
246  
247 This is the B<Domain Name Application Purpose Code>, the reason this domain was registered and a bit about it's intended usage. This should be populated B<ONLY> for .us domain registrations. The descriptions come from L<http://www.whois.us/whois-gui/US/faqs.html>.
248  
249 Must be one of the following I<2 character> values:
250  
251 =over 4
252  
253 =item P1 - Business use for profit.
254  
255 =item P2 - Non-profit business, club, association, religious organization, etc.
256  
257 =item P3 - Personal use.
258  
259 =item P4 - Education purposes.
260  
261 =item P5 - Government purposes
262  
263 =back
264  
265 =head2 B<nexus_category>
266  
267 This is the B<Nexus Code>, it contains information about the contact and their relationship with respect to US residency. This should be populated B<ONLY> for .us domain registrations. The descriptions come from L<http://www.whois.us/whois-gui/US/faqs.html>.
268  
269 Must be one of the following I<2 character> values:
270  
271 =over 4
272  
273 =item C11 - A natural person who is a United States citizen.
274  
275 =item C12 - A natural person who is a permanent resident of the United States of America, or any of its possessions or territories.
276  
277 =item C21 - A US-based organization or company (A US-based organization or company formed within one of the fifty (50) U.S. states, the District of Columbia, or any of the United States possessions or territories, or organized or otherwise constituted under the laws of a state of the United States of America, the District of Columbia or any of its possessions or territories or a U.S. federal, state, or local government entity or a political subdivision thereof).
278  
279 =item C31 - A foreign entity or organization (A foreign entity or organization that has a bona fide presence in the United States of America or any of its possessions or territories who regularly engages in lawful activities (sales of goods or services or other business, commercial or non-commercial, including not-for-profit relations in the United States)).
280  
281 =item C32 - Entity has an office or other facility in the United States.
282  
283 =back
284  
285 =head2 B<registrant_contact>
286  
287 A L<WWW::eNom::Contact> for the Registrant Contact.
288  
289 =head2 B<admin_contact>
290  
291 A L<WWW::eNom::Contact> for the Admin Contact.
292  
293 =head2 B<technical_contact>
294  
295 A L<WWW::eNom::Contact> for the Technical Contact.
296  
297 =head2 B<billing_contact>
298  
299 A L<WWW::eNom::Contact> for the Billing Contact.
300  
301 B<NOTE> L<eNom|https://www.eNom.com> actually calls this the B<AuxBilling> contact since the primary billing contact is the reseller's information.
302  
303 =head1 METHODS
304  
305 =head2 construct_request
306  
307 my $registration_request = WWW::eNom::DomainRequest::Registration->new( ... );
308  
309 my $response = $api->submit({
310 method => 'Purchase',
311 params => $registration_request->construct_request(),
312 });
313  
314 Converts $self into a HashRef suitable for the L<Purchase|https://www.enom.com/api/API%20topics/api_Purchase.htm> of a Domain Name.
315  
316 =cut
« blib/lib/WWW/eNom/Role/Command/Domain/Availability.pm ↑ Summary blib/lib/WWW/eNom/Role/Command/Domain/PrivateNameServer.pm »