blib/lib/WWW/eNom/Domain.pm

filter: Statementstmt 81.5% 62 / 76 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 82.3% 14 / 17 Podpod n/a totaltotal 73.0% 76 / 104 CC 6 SCAR 25.1
CC
6
Cov
72%
__ANON__
42.0
construct_from_response
2.0
__ANON__
2.0
CRAP 12.3
« blib/lib/WWW/eNom/DomainTransfer.pm ↑ Summary blib/lib/WWW/eNom/Role/Command/Domain/Transfer.pm »
1 package WWW::eNom::Domain;
2  
3 48 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 48 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 48 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 48 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 48 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 48 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 48 ▶use WWW::eNom::Types qw( Bool Contact DateTime DomainName DomainNames HashRef IRTPDetail PositiveInt Str PrivateNameServers );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 48 ▶use WWW::eNom::Contact;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 48 ▶use WWW::eNom::IRTPDetail;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 48 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 48 ▶use DateTime::Format::DateParse;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 48 ▶use Mozilla::PublicSuffix qw( public_suffix );
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 48 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 48 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 48 our $VERSION = 'v2.6.0'; # VERSION
24 # ABSTRACT: Representation of Registered eNom Domain
25  
26 48 has 'id' => (
27 is => 'ro',
28 isa => PositiveInt,
29 required => 1,
30 );
31  
32 48 has 'name' => (
33 is => 'ro',
34 isa => DomainName,
35 required => 1,
36 );
37  
38 48 has 'status' => (
39 is => 'ro',
40 isa => Str,
41 required => 1,
42 );
43  
44 48 has 'verification_status' => (
45 is => 'ro',
46 isa => Str,
47 required => 1,
48 );
49  
50 48 has 'is_auto_renew' => (
51 is => 'ro',
52 isa => Bool,
53 required => 1,
54 );
55  
56 48 has 'is_locked' => (
57 is => 'ro',
58 isa => Bool,
59 required => 1,
60 );
61  
62 48 has 'is_private' => (
63 is => 'ro',
64 isa => Bool,
65 required => 1,
66 );
67  
68 48 has 'created_date' => (
69 is => 'ro',
70 isa => DateTime,
71 required => 1,
72 );
73  
74 48 has 'expiration_date' => (
75 is => 'ro',
76 isa => DateTime,
77 required => 1,
78 );
79  
80 48 has 'ns' => (
81 is => 'ro',
82 isa => DomainNames,
83 required => 1,
84 );
85  
86 48 has 'registrant_contact' => (
87 is => 'ro',
88 isa => Contact,
89 required => 1,
90 );
91  
92 48 has 'admin_contact' => (
93 is => 'ro',
94 isa => Contact,
95 required => 1,
96 );
97  
98 48 has 'technical_contact' => (
99 is => 'ro',
100 isa => Contact,
101 required => 1,
102 );
103  
104 48 has 'billing_contact' => (
105 is => 'ro',
106 isa => Contact,
107 required => 1,
108 );
109  
110 48 has 'private_nameservers' => (
111 is => 'ro',
112 isa => PrivateNameServers,
113 predicate => 'has_private_nameservers',
114 );
115  
116 48 has 'irtp_detail' => (
117 is => 'ro',
118 isa => IRTPDetail,
119 predicate => 'has_irtp_detail',
120 );
121  
122 48 with 'WWW::eNom::Role::ParseDomain';
123  
124 sub construct_from_response {
125 0 ▶ my $self = shift;
Subroutine construct_from_response: not called CC=1 SCAR=6.9
126 0 my ( %args ) = validated_hash(
127 \@_,
128 domain_info => { isa => HashRef },
129 is_auto_renew => { isa => Bool },
130 is_locked => { isa => Bool },
131 name_servers => { isa => DomainNames },
132 private_nameservers => { isa => PrivateNameServers, optional => 1 },
133 contacts => { isa => HashRef },
134 created_date => { isa => DateTime },
135 );
136  
137 return try {
138 0 ▶ my ( $verification_status, $is_private );
Subroutine __ANON__: not called CC=6 SCAR=37.4
139 0 ▶ if( public_suffix( $args{domain_info}{domainname}{content} ) eq 'us' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (public_suffix($args{'domain_info'}{'domainname'}{'content'}) eq 'us') { } 0 0 0
140 0 $verification_status = 'Verification Not Needed';
141 0 $is_private = 0;
142 }
143 else {
144 # On verified domains the raasettings response is empty, if the value is missing, just call it verified.
145 0 ▶ $verification_status = $args{domain_info}{services}{entry}{raasettings}{raasetting}{verificationstatus} // 'Verified';
Condition0%0/2
$args{"domain_info"}{"services"}{"entry"}{"raasettings"}{"raasetting"}{"verificationstatus"} // "Verified"
l!l
00
MC/DC0%0/1
$args{"domain_info"}{"services"}{"entry"}{"raasettings"}{"raasetting"}{"verificationstatus"} // "Verified"
$args{"domain_info"}{"services"}{"entry"}{"raasettings"}{"raasetting"}{"verificationstatus"}
Truth table0%0/2
A
A= $args{"domain_info"}{"services"}{"entry"}{"raasettings"}{"raasetting"}{"verificationstatus"}
Aresult
11
00
146 0 $is_private = ( $args{domain_info}{services}{entry}{wpps}{service}{content} == 1120 );
147 }
148  
149 0 my $irtp_detail;
150 0 ▶ if( $args{contacts}{is_pending_irtp} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"contacts"}{"is_pending_irtp"}) 0 0 0
151 $irtp_detail = WWW::eNom::IRTPDetail->construct_from_response(
152 $args{domain_info}{services}{entry}{irtpsettings}{irtpsetting}
153 0 );
154 }
155  
156 return $self->new({
157 id => $args{domain_info}{domainname}{domainnameid},
158 name => $args{domain_info}{domainname}{content},
159 status => $args{domain_info}{status}{registrationstatus},
160 verification_status => $verification_status,
161 is_auto_renew => $args{is_auto_renew},
162 is_locked => $args{is_locked},
163 is_private => $is_private,
164 created_date => $args{created_date},
165 expiration_date => DateTime::Format::DateParse->parse_datetime( $args{domain_info}{status}{expiration} ),
166 ns => $args{name_servers},
167 registrant_contact => $args{contacts}{registrant_contact},
168 admin_contact => $args{contacts}{admin_contact},
169 technical_contact => $args{contacts}{technical_contact},
170 billing_contact => $args{contacts}{billing_contact},
171 defined $irtp_detail ? ( irtp_detail => $irtp_detail ) : ( ),
172 0 ▶ $args{private_nameservers} ? ( private_nameservers => $args{private_nameservers} ) : ( ),
Branch: 2 branches
BranchTrueFalseTotal
defined $irtp_detail ? : 0 0 0
$args{'private_nameservers'} ? : 0 0 0
173 });
174 }
175 catch {
176 0 ▶ croak "Error constructing domain from response: $_";
Subroutine __ANON__: not called CC=1 SCAR=6.9
177 0 };
178 }
179  
180 48 __PACKAGE__->meta->make_immutable;
181 48 1;
182  
183 __END__
184  
185 =pod
186  
187 =head1 NAME
188  
189 WWW::eNom::Domain - Representation of Registered eNom Domain
190  
191 =head1 SYNOPSIS
192  
193 use strict;
194 use warnings;
195  
196 use WWW::eNom;
197 use WWW::eNom::Contact;
198 use WWW::eNom::Domain;
199  
200 my $api = WWW::eNom->new( ... );
201  
202 # Create New Domain Object, note that domain registration is handled by
203 # WWW::eNom::DomainRequest::Registration.
204 my $contact = WWW::eNom::Contact->new( ... );
205 my $private_name_servers = [ WWW::eNom::PrivateNameServer->new( ... ) ];
206  
207 my $domain = WWW::eNom::Domain->new(
208 id => 42,
209 name => 'drzigman.com',
210 status => 'Paid',
211 verification_status => 'Pending Suspension',
212 is_auto_renew => 0,
213 is_locked => 1,
214 is_private => 0,
215 created_date => DateTime->...,
216 expiration_date => DateTime->...,
217 ns => [ 'ns1.enom.com', 'ns2.enom.com' ],
218 registrant_contact => $contact,
219 admin_contact => $contact,
220 technical_contact => $contact,
221 billing_contact => $contact,
222 private_name_servers => $private_name_servers, # Optional
223 );
224  
225 # Construct From eNom Response
226 my $response = $api->submit({
227 method => 'GetDomainInfo',
228 params => {
229 Domain => 'drzigman.com',
230 }
231 });
232  
233 my $domain = WWW::eNom::Domain->construct_from_response(
234 domain_info => $response->{GetDomainInfo},
235 is_auto_renew => $api->get_is_domain_auto_renew_by_name( 'drzigman.com' ),
236 is_locked => $api->get_is_domain_locked_by_name( 'drzigman.com' ),
237 name_servers => $api->get_domain_name_servers_by_name( 'drzigman.com' ),
238 contacts => $api->get_contacts_by_domain_name( 'drzigman.com' ),
239 created_date => $api->get_domain_created_date_by_name( 'drzigman.com' ),
240 );
241  
242  
243 =head1 WITH
244  
245 =over 4
246  
247 =item L<WWW::eNom::Role::ParseDomain>
248  
249 =back
250  
251 =head1 DESCRIPTION
252  
253 Represents L<eNom|https://www.enom.com> domains, containing all related information. For most operations this will be the base object that is used to represent the data.
254  
255 =head1 attributes
256  
257 =head2 B<id>
258  
259 The domain id of the domain in L<eNom|https://www.enom.com>'s system.
260  
261 =head2 B<name>
262  
263 The FQDN this domain object represents
264  
265 =head2 B<status>
266  
267 Current status of the domain, related more so to if it's been paid or if it has been deleted or expired.
268  
269 =head2 B<verification_status>
270  
271 According to ICANN rules, all new gTLD domains that were registered after January 1st, 2014 must be verified. verification_status describes the current state of this verification and begins in 'Pending Suspension' until the domain is either verified or is suspended due to a lack of verification.
272  
273 For details on the ICANN policy please see the riveting ICANN Registrar Agreement L<https://www.icann.org/resources/pages/approved-with-specs-2013-09-17-en>.
274  
275 =head2 B<is_auto_renew>
276  
277 Boolean that indicates if eNom should automagically renew this domain.
278  
279 =head2 B<is_locked>
280  
281 Boolean indicating if the domain is currently locked, preventing transfer.
282  
283 =head2 B<is_private>
284  
285 Boolean indicating if this domain uses WHOIS Privacy.
286  
287 =head2 B<created_date>
288  
289 Date this domain registration was created.
290  
291 =head2 B<expiration_date>
292  
293 Date this domain registration expires.
294  
295 =head2 B<ns>
296  
297 ArrayRef of Domain Names that are authoritative nameservers for this domain.
298  
299 =head2 B<registrant_contact>
300  
301 A L<WWW::eNom::Contact> for the Registrant Contact.
302  
303 =head2 B<admin_contact>
304  
305 A L<WWW::eNom::Contact> for the Admin Contact.
306  
307 =head2 B<technical_contact>
308  
309 A L<WWW::eNom::Contact> for the Technical Contact.
310  
311 =head2 B<billing_contact>
312  
313 A L<WWW::eNom::Contact> for the Billing Contact.
314  
315 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.
316  
317 =head2 B<private_nameservers>
318  
319 An ArrayRef of L<WWW::eNom::PrivateNameServer> objects that comprise the private nameservers for this domain, provides a predicate of has_private_nameservers.
320  
321 B<NOTE> Due to limitations of L<eNom|https://www.enom.com>'s API, all private nameservers B<*MUST*> be used as authoritative nameservers (i.e., they must also appear in the L</ns> attribute). See L<WWW::eNom::Role::Command::Domain::PrivateNameServer/LIMITATIONS> for more information about this and other limitations.
322  
323 =head2 irtp_detail
324  
325 In the event of a recent change in registrant contact, the irtp_detail attribute will be populated with an instance of L<WWW::eNom::IRTPDetail> that contains additional IRTP related information about this domain. If there is no recent registrant contact change then no value will be provided for the irtp_detail. Offers a predicate of has_irtp_detail.
326  
327 =head1 METHODS
328  
329 =head2 construct_from_response
330  
331 my $api = WWW::eNom->new( ... );
332  
333 my $response = $api->submit({
334 method => 'GetDomainInfo',
335 params => {
336 Domain => 'drzigman.com',
337 }
338 });
339  
340 my $domain = WWW::eNom::Domain->construct_from_response(
341 domain_info => $response->{GetDomainInfo},
342 is_auto_renew => $api->get_is_domain_auto_renew_by_name( $domain_name ),
343 is_locked => $api->get_is_domain_locked_by_name( $domain_name ),
344 name_servers => $api->get_domain_name_servers_by_name( $domain_name ),
345 private_name_servers => $private_name_servers, # Optional
346 contacts => $api->get_contacts_by_domain_name( $domain_name ),
347 created_date => $api->get_domain_created_date_by_name( $domain_name ),
348 );
349  
350 Creates an instance of $self given several parameters:
351  
352 =over 4
353  
354 =item domain_info
355  
356 HashRef response to L<eNom's GetDomainInfo|https://www.enom.com/api/API%20topics/api_GetDomainInfo.htm>. This, unfortunately, does not contain all of the needed data so several other parameters are required.
357  
358 =item is_auto_renew
359  
360 Boolean, indicating if L<eNom|https://www.enom.com> will auto renew this domain.
361  
362 =item is_locked
363  
364 Boolean, indicating if this domain is locked to prevent transfer.
365  
366 =item name_servers
367  
368 ArrayRef of Domain Names that are the authoritative nameservers for this domain.
369  
370 =item contacts
371  
372 HashRef with the keys being:
373  
374 =over 4
375  
376 =item registrant_contact
377  
378 =item admin_contact
379  
380 =item technical_contact
381  
382 =item billing_contact
383  
384 =back
385  
386 And the values being instances of L<WWW::eNom::Contact> that correspond to the key's contact type.
387  
388 =item created_date
389  
390 DateTime that this domain was first created/registered.
391  
392 =back
393  
394 =cut
« blib/lib/WWW/eNom/DomainTransfer.pm ↑ Summary blib/lib/WWW/eNom/Role/Command/Domain/Transfer.pm »