blib/lib/WWW/eNom/Role/Command/Domain.pm

filter: Statementstmt 18.6% 36 / 193 Branchbran 0.0% 0 / 68 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 26.1% 11 / 42 Podpod 100% 11 / 11 totaltotal 18.1% 58 / 319 CC 37 SCAR 29.4
CC
37
Cov
14%
__ANON__
42.0
__ANON__
42.0
__ANON__
30.0
CRAP 18.8
« blib/lib/WWW/eNom/Role/Command/Raw.pm ↑ Summary blib/lib/WWW/eNom/Role/Command/Service.pm »
1 package WWW::eNom::Role::Command::Domain;
2  
3 44 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 44 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 44 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 44 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 44 ▶use WWW::eNom::Types qw( Bool DomainName DomainNames PositiveInt );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 44 ▶use WWW::eNom::Domain;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 44 ▶use Data::Util qw( is_array_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 44 ▶use DateTime::Format::DateParse;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 44 ▶use Mozilla::PublicSuffix qw( public_suffix );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 44 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 44 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 44 requires 'submit', 'get_contacts_by_domain_name', 'delete_private_nameserver';
20  
21 44 our $VERSION = 'v2.0.0'; # VERSION
22 # ABSTRACT: Domain Related Operations
23  
24 sub get_domain_by_name {
25 0 ▶ my $self = shift;
Subroutine get_domain_by_name: not called CC=1 SCAR=6.9
Pod documented
26 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
27  
28 return try {
29 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=5 SCAR=34.0
30 method => 'GetDomainInfo',
31 params => {
32 Domain => $domain_name,
33 }
34 });
35  
36 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
37 0 ▶ if( grep { $_ eq 'Domain name not found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Domain name not found";} @{$$response{"errors"};}) 0 0 0
38 0 croak 'Domain not found in your account';
39 }
40  
41 0 croak 'Unknown error';
42 }
43  
44 0 ▶ if( !exists $response->{GetDomainInfo} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $response->{"GetDomainInfo"}) 0 0 0
45 0 croak 'Response did not contain domain info';
46 }
47  
48 # There is no way to ask eNom what the private nameservers are so we use
49 # the fact that they must have the same root domain in order to differentiate
50 # between private and "regular" nameservers
51 0 my $nameservers = $self->get_domain_name_servers_by_name( $domain_name );
52 my @private_nameservers = map {
53 0 $self->retrieve_private_nameserver_by_name( $_ )
54 0 } grep { $_ =~ m/\Q$domain_name/ } @{ $nameservers };
55  
56 return WWW::eNom::Domain->construct_from_response(
57 domain_info => $response->{GetDomainInfo},
58 0 ▶ is_auto_renew => $self->get_is_domain_auto_renew_by_name( $domain_name ),
Branch: 1 branch
BranchTrueFalseTotal
scalar @private_nameservers ? : 0 0 0
59 is_locked => $self->get_is_domain_locked_by_name( $domain_name ),
60 name_servers => $nameservers,
61 scalar @private_nameservers ? ( private_nameservers => \@private_nameservers ) : ( ),
62 contacts => $self->get_contacts_by_domain_name( $domain_name ),
63 created_date => $self->get_domain_created_date_by_name( $domain_name ),
64 );
65 }
66 catch {
67 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 0 };
69 }
70  
71 sub get_is_domain_locked_by_name {
72 0 ▶ my $self = shift;
Subroutine get_is_domain_locked_by_name: not called CC=1 SCAR=6.9
Pod documented
73 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
74  
75 return try {
76 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=5 SCAR=34.0
77 method => 'GetRegLock',
78 params => {
79 Domain => $domain_name,
80 }
81 });
82  
83 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
84 0 ▶ if( $response->{RRPText} =~ m/Command blocked/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"RRPText"} =~ /Command blocked/) 0 0 0
85 0 croak 'Domain owned by someone else';
86 }
87  
88 0 ▶ if( $response->{RRPText} =~ m/Object does not exist/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"RRPText"} =~ /Object does not exist/) 0 0 0
89 0 croak 'Domain is not registered';
90 }
91  
92 0 croak $response->{RRPText};
93 }
94  
95 0 ▶ if( !exists $response->{'reg-lock'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $response->{"reg-lock"}) 0 0 0
96 0 croak 'Response did not contain lock data';
97 }
98  
99 0 return !!$response->{'reg-lock'};
100 }
101 catch {
102 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
103 0 };
104 }
105  
106 sub enable_domain_lock_by_name {
107 0 ▶ my $self = shift;
Subroutine enable_domain_lock_by_name: not called CC=1 SCAR=6.9
Pod documented
108 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
109  
110 0 return $self->_set_domain_locking(
111 domain_name => $domain_name,
112 is_locked => 1,
113 );
114 }
115  
116 sub disable_domain_lock_by_name {
117 0 ▶ my $self = shift;
Subroutine disable_domain_lock_by_name: not called CC=1 SCAR=6.9
Pod documented
118 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
119  
120 0 return $self->_set_domain_locking(
121 domain_name => $domain_name,
122 is_locked => 0,
123 );
124 }
125  
126 sub _set_domain_locking {
127 0 ▶ my $self = shift;
Subroutine _set_domain_locking: not called CC=1 SCAR=6.9
128 0 my ( %args ) = validated_hash(
129 \@_,
130 domain_name => { isa => DomainName },
131 is_locked => { isa => Bool },
132 );
133  
134 return try {
135 my $response = $self->submit({
136 method => 'SetRegLock',
137 params => {
138 Domain => $args{domain_name},
139 0 ▶ UnlockRegistrar => ( !$args{is_locked} ? 1 : 0 ),
Subroutine __ANON__: not called CC=5 SCAR=34.0
Branch: 1 branch
BranchTrueFalseTotal
!$args{'is_locked'} ? : 0 0 0
140 }
141 });
142  
143 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
144 0 ▶ if( grep { $_ eq 'Domain name not found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Domain name not found";} @{$$response{"errors"};}) 0 0 0
145 0 croak 'Domain not found in your account';
146 }
147  
148 0 ▶ if( grep { $_ =~ m/domain is already/ } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ =~ /domain is already/;} @{$$response{"errors"};}) 0 0 0
149 # NO OP, what I asked for is already done
150 }
151 }
152  
153 0 return $self->get_domain_by_name( $args{domain_name} );
154 }
155 catch {
156 0 ▶ croak "$_";
Subroutine __ANON__: not called CC=1 SCAR=6.9
157 0 };
158 }
159  
160 sub get_domain_name_servers_by_name {
161 0 ▶ my $self = shift;
Subroutine get_domain_name_servers_by_name: not called CC=1 SCAR=6.9
Pod documented
162 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
163  
164 return try {
165 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=5 SCAR=34.0
166 method => 'GetDNS',
167 params => {
168 Domain => $domain_name,
169 }
170 });
171  
172 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
173 0 ▶ if( grep { $_ eq 'Domain name not found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Domain name not found";} @{$$response{"errors"};}) 0 0 0
174 0 croak 'Domain not found in your account';
175 }
176  
177 0 croak 'Unknown error';
178 }
179  
180 0 ▶ if( !exists $response->{dns} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $response->{"dns"}) 0 0 0
181 0 croak 'Response did not contain nameserver data';
182 }
183  
184 # If there is only one NS convert the scalar to an arrayref
185 0 ▶ return is_array_ref( $response->{dns} ) ? $response->{dns} : [ $response->{dns} ];
Branch: 1 branch
BranchTrueFalseTotal
is_array_ref($response->{'dns'}) ? : 0 0 0
186 }
187 catch {
188 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
189 0 };
190 }
191  
192 sub update_nameservers_for_domain_name {
193 0 ▶ my $self = shift;
Subroutine update_nameservers_for_domain_name: not called CC=1 SCAR=6.9
Pod documented
194 0 my ( %args ) = validated_hash(
195 \@_,
196 domain_name => { isa => DomainName },
197 ns => { isa => DomainNames },
198 );
199  
200 try {
201 my @initial_private_nameserver_names = grep {
202 0 $_ =~ m/\Q$args{domain_name}/
203 0 ▶ } @{ $self->get_domain_name_servers_by_name( $args{domain_name} ) };
Subroutine __ANON__: not called CC=6 SCAR=37.4
204  
205 my $response = $self->submit({
206 method => 'ModifyNS',
207 params => {
208 Domain => $args{domain_name},
209 0 map { 'NS' . ( $_ + 1 ) => $args{ns}->[ $_ ] } 0 .. ( scalar (@{ $args{ns} }) - 1)
210 }
211 });
212  
213 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
214 0 ▶ if( grep { $_ eq 'Domain name not found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Domain name not found";} @{$$response{"errors"};}) 0 0 0
215 0 croak 'Domain not found in your account';
216 }
217  
218 0 ▶ if( grep { $_ =~ m/could not be registered/ } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ =~ /could not be registered/;} @{$$response{"errors"};}) 0 0 0
219 0 croak 'Invalid Nameserver provided';
220 }
221  
222 0 croak 'Unknown error';
223 }
224  
225 # Delete private nameservers that are no longer being used as authoritative
226 0 for my $private_nameserver_name ( @initial_private_nameserver_names ) {
227 0 ▶ if( grep { $_ eq $private_nameserver_name } @{ $args{ns} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $private_nameserver_name;} @{$args{"ns"};}) 0 0 0
228 0 next;
229 }
230  
231 $self->delete_private_nameserver(
232 domain_name => $args{domain_name},
233 0 private_nameserver_name => $private_nameserver_name,
234 );
235 }
236 }
237 catch {
238 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
239 0 };
240  
241  
242 0 return $self->get_domain_by_name( $args{domain_name} );
243 }
244  
245 sub get_is_domain_auto_renew_by_name {
246 0 ▶ my $self = shift;
Subroutine get_is_domain_auto_renew_by_name: not called CC=1 SCAR=6.9
Pod documented
247 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
248  
249 return try {
250 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=4 SCAR=30.0
251 method => 'GetRenew',
252 params => {
253 Domain => $domain_name,
254 }
255 });
256  
257 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
258 0 ▶ if( grep { $_ eq 'Domain name not found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Domain name not found";} @{$$response{"errors"};}) 0 0 0
259 0 croak 'Domain not found in your account';
260 }
261  
262 0 croak 'Unknown error';
263 }
264  
265 0 ▶ if( !exists $response->{'auto-renew'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $response->{"auto-renew"}) 0 0 0
266 0 croak 'Response did not contain renewal data';
267 }
268  
269 0 return !!$response->{'auto-renew'};
270 }
271 catch {
272 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
273 0 };
274 }
275  
276 sub enable_domain_auto_renew_by_name {
277 0 ▶ my $self = shift;
Subroutine enable_domain_auto_renew_by_name: not called CC=1 SCAR=6.9
Pod documented
278 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
279  
280 0 return $self->_set_domain_auto_renew({
281 domain_name => $domain_name,
282 is_auto_renew => 1,
283 });
284 }
285  
286 sub disable_domain_auto_renew_by_name {
287 0 ▶ my $self = shift;
Subroutine disable_domain_auto_renew_by_name: not called CC=1 SCAR=6.9
Pod documented
288 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
289  
290 0 return $self->_set_domain_auto_renew({
291 domain_name => $domain_name,
292 is_auto_renew => 0,
293 });
294 }
295  
296 sub _set_domain_auto_renew {
297 0 ▶ my $self = shift;
Subroutine _set_domain_auto_renew: not called CC=1 SCAR=6.9
298 0 my ( %args ) = validated_hash(
299 \@_,
300 domain_name => { isa => DomainName },
301 is_auto_renew => { isa => Bool },
302 privacy_is_auto_renew => { isa => Bool, optional => 1 },
303 );
304  
305 return try {
306 my $response = $self->submit({
307 method => 'SetRenew',
308 params => {
309 Domain => $args{domain_name},
310 RenewFlag => ( $args{is_auto_renew} ? 1 : 0 ),
311 0 ▶ defined $args{privacy_is_auto_renew} ? ( WPPSRenew => ( $args{privacy_is_auto_renew} ? 1 : 0 ) ) : ( ),
Subroutine __ANON__: not called CC=6 SCAR=37.4
Branch: 3 branches
BranchTrueFalseTotal
$args{'is_auto_renew'} ? : 0 0 0
defined $args{'privacy_is_auto_renew'} ? : 0 0 0
$args{'privacy_is_auto_renew'} ? : 0 0 0
312 }
313 });
314  
315 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
316 0 ▶ if( grep { $_ eq 'Domain name not found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Domain name not found";} @{$$response{"errors"};}) 0 0 0
317 0 croak 'Domain not found in your account';
318 }
319 }
320  
321 0 return $self->get_domain_by_name( $args{domain_name} );
322 }
323 catch {
324 0 ▶ croak "$_";
Subroutine __ANON__: not called CC=1 SCAR=6.9
325 0 };
326  
327 }
328  
329 sub get_domain_created_date_by_name {
330 0 ▶ my $self = shift;
Subroutine get_domain_created_date_by_name: not called CC=1 SCAR=6.9
Pod documented
331 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
332  
333 return try {
334 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=4 SCAR=30.0
335 method => 'GetWhoisContact',
336 params => {
337 Domain => $domain_name,
338 }
339 });
340  
341 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
342 0 ▶ if( grep { $_ eq 'No results found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "No results found";} @{$$response{"errors"};}) 0 0 0
343 0 croak 'Domain not found in your account';
344 }
345  
346 0 croak 'Unknown error';
347 }
348  
349 0 ▶ if( !exists $response->{GetWhoisContacts}{'rrp-info'}{'created-date'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $response->{"GetWhoisContacts"}{"rrp-info"}{"created-date"}) 0 0 0
350 0 croak 'Response did not contain creation data';
351 }
352  
353 0 return DateTime::Format::DateParse->parse_datetime( $response->{GetWhoisContacts}{'rrp-info'}{'created-date'}, 'UTC' );
354  
355 }
356 catch {
357 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
358 0 };
359  
360 }
361  
362 sub renew_domain {
363 0 ▶ my $self = shift;
Subroutine renew_domain: not called CC=1 SCAR=6.9
Pod documented
364 0 my ( %args ) = validated_hash(
365 \@_,
366 domain_name => { isa => DomainName },
367 years => { isa => PositiveInt },
368 );
369  
370 return try {
371 my $response = $self->submit({
372 method => 'Extend',
373 params => {
374 Domain => $args{domain_name},
375 NumYears => $args{years},
376 }
377 0 ▶ });
Subroutine __ANON__: not called CC=5 SCAR=34.0
378  
379 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
380 0 ▶ if( grep { $_ eq 'Domain name not found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Domain name not found";} @{$$response{"errors"};}) 0 0 0
381 0 croak 'Domain not found in your account';
382 }
383  
384 0 ▶ if( ( grep { $_ =~ qr/The number of years cannot/ } @{ $response->{errors} } )
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ =~ qr/The number of years cannot/;} @{$$response{"errors"};} or grep {$_ =~ qr/cannot be extended/;} @{$$response{"errors"};}) 0 0 0
Condition0%0/3
grep {$_ =~ qr/The number of years cannot/;} @{$$response{"errors"};} or grep {$_ =~ qr/cannot be extended/;} @{$$response{"errors"};}
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {$_ =~ qr/The number of years cannot/;} @{$$response{"errors"};} or grep {$_ =~ qr/cannot be extended/;} @{$$response{"errors"};}
grep {$_ =~ qr/The number of years cannot/;} @{$$response{"errors"};} grep {$_ =~ qr/cannot be extended/;} @{$$response{"errors"};}
Truth table0%0/3
A or B
A= grep {$_ =~ qr/The number of years cannot/;} @{$$response{"errors"};}B= grep {$_ =~ qr/cannot be extended/;} @{$$response{"errors"};}
ABresult
1X1
011
000
385 0 || ( grep { $_ =~ qr/cannot be extended/ } @{ $response->{errors} } ) ) {
386 0 croak 'Requested renewal too long';
387 }
388  
389 0 croak 'Unknown error';
390 }
391  
392 0 return $response->{OrderID};
393 }
394 catch {
395 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
396 0 };
397 }
398  
399 44 1;
400  
401 __END__
402  
403 =pod
404  
405 =head1 NAME
406  
407 WWW::eNom::Role::Command::Domain - Domain Related Operations
408  
409 =head1 SYNOPSIS
410  
411 use WWW::eNom;
412 use WWW::eNom::Domain;
413  
414 my $api = WWW::eNom->new( ... );
415  
416 # Get a fully formed WWW::eNom::Domain object for a domain
417 my $domain = $api->get_domain_by_name( 'drzigman.com' );
418  
419  
420 # Check if a domain is locked
421 if( $api->get_is_domain_locked_by_name( 'drzigman.com' ) ) {
422 print "Domain is Locked!\n";
423 }
424 else {
425 print "Domain is NOT Locked!\n";
426 }
427  
428 # Lock Domain
429 my $updated_domain = $api->enable_domain_lock_by_name( 'drzigman.com' );
430  
431 # Unlock Domain
432 my $updated_domain = $api->disable_domain_lock_by_name( 'drzigman.com' );
433  
434  
435 # Get domain authoritative nameservers
436 for my $ns ( $api->get_domain_name_servers_by_name( 'drzigman.com' ) ) {
437 print "Nameserver: $ns\n";
438 }
439  
440 # Update Domain Nameservers
441 my $updated_domain = $api->update_nameservers_for_domain_name({
442 domain_name => 'drzigman.com',
443 ns => [ 'ns1.enom.org', 'ns2.enom.org' ],
444 });
445  
446  
447 # Get auto renew status
448 if( $api->get_is_domain_auto_renew_by_name( 'drzigman.com' ) ) {
449 print "Domain will be auto renewed!\n";
450 }
451 else {
452 print "Domain will NOT be renewed automatically!\n";
453 }
454  
455 # Enable domain auto renew
456 my $updated_domain = $api->enable_domain_auto_renew_by_name( 'drzigman.com' );
457  
458 # Disable domain auto renew
459 my $updated_domain = $api->disable_domain_auto_renew_by_name( 'drzigman.com' );
460  
461 # Renew Domain
462 my $order_id = $api->renew_domain({
463 domain_name => 'drzigman.com',
464 years => 1,
465 });
466  
467 # Get Created Date
468 my $created_date = $api->get_domain_created_date_by_name( 'drzigman.com' );
469 print "This domain was created on: " . $created_date->ymd . "\n";
470  
471 =head1 REQUIRES
472  
473 =over 4
474  
475 =item submit
476  
477 =item get_contacts_by_domain_name
478  
479 Needed in order to construct a full L<WWW::eNom::Domain> object.
480  
481 =item delete_private_nameserver
482  
483 Needed in order to keep private nameservers and authoritative nameservers in sync.
484  
485 =back
486  
487 =head1 DESCRIPTION
488  
489 Implements domain related operations with the L<eNom|https://www.enom.com> API.
490  
491 =head2 See Also
492  
493 =over 4
494  
495 =item For Domain Registration please see L<WWW::eNom::Role::Command::Domain::Registration>
496  
497 =item For Domain Availability please see L<WWW::eNom::Role::Command::Domain::Availability>
498  
499 =back
500  
501 =head1 METHODS
502  
503 =head2 get_domain_by_name
504  
505 my $domain = $api->get_domain_by_name( 'drzigman.com' );
506  
507 At it's core, this is an Abstraction of the L<GetDomainInfo|https://www.enom.com/api/API%20topics/api_GetDomainInfo.htm> eNom API Call. However, because this API Call does not return enough information to fully populate a L<WWW::eNom::Domain> object, internally the following additional methods are called:
508  
509 =over 4
510  
511 =item L<WWW::eNom::Role::Command::Domain/get_is_domain_auto_renew_by_name>
512  
513 =item L<WWW::eNom::Role::Command::Domain/get_is_domain_locked_by_name>
514  
515 =item L<WWW::eNom::Role::Command::Domain/get_domain_name_servers_by_name>
516  
517 =item L<WWW::eNom::Role::Command::Domain/get_domain_created_date_by_name>
518  
519 =item L<WWW::eNom::Role::Command::Contact/get_contacts_by_domain_name>
520  
521 =back
522  
523 Because of all of these API calls this method can be fairly slow (usually about a second or two).
524  
525 Given a FQDN, this method returns a fully formed L<WWW::eNom::Domain> object. If the domain does not exist in your account (either because it's registered by someone else or it's available) this method will croak.
526  
527 =head2 get_is_domain_locked_by_name
528  
529 if( $api->get_is_domain_locked_by_name( 'drzigman.com' ) ) {
530 print "Domain is Locked!\n";
531 }
532 else {
533 print "Domain is NOT Locked!\n";
534 }
535  
536 Abstraction of the L<GetRegLock|https://www.enom.com/api/API%20topics/api_GetRegLock.htm> eNom API Call. Given a FQDN, returns a truthy value if the domain is locked and falsey if it is not.
537  
538 This method will croak if the domain is owned by someone else or if it is not registered.
539  
540 =head2 enable_domain_lock_by_name
541  
542 my $updated_domain = $api->enable_domain_lock_by_name( 'drzigman.com' );
543  
544 Abstraction of the L<SetRegLock|https://www.enom.com/api/API%20topics/api_SetRegLock.htm> eNom API Call. Given a FQDN, enables the registrar lock for the provided domain. If the domain is already locked this is effectively a NO OP.
545  
546 This method will croak if the domain is owned by someone else or if it is not registered.
547  
548 =head2 disable_domain_lock_by_name
549  
550 my $updated_domain = $api->disable_domain_lock_by_name( 'drzigman.com' );
551  
552 Abstraction of the L<SetRegLock|https://www.enom.com/api/API%20topics/api_SetRegLock.htm> eNom API Call. Given a FQDN, disabled the registrar lock for the provided domain. If the domain is already unlocked this is effectively a NO OP.
553  
554 This method will croak if the domain is owned by someone else or if it is not registered.
555  
556 =head2 get_domain_name_servers_by_name
557  
558 for my $ns ( $api->get_domain_name_servers_by_name( 'drzigman.com' ) ) {
559 print "Nameserver: $ns\n";
560 }
561  
562 Abstraction of the L<GetDNS|https://www.enom.com/api/API%20topics/api_GetDNS.htm> eNom API Call. Given a FQDN, returns an ArrayRef of FQDNs that are the authoritative name servers for the specified FQDN.
563  
564 This method will croak if the domain is owned by someone else or if it is not registered.
565  
566 =head2 update_nameservers_for_domain_name
567  
568 my $updated_domain = $api->update_nameservers_for_domain_name({
569 domain_name => 'drzigman.com',
570 ns => [ 'ns1.enom.org', 'ns2.enom.org' ],
571 });
572  
573 Abstraction of the L<ModifyNS|https://www.enom.com/api/API%20topics/api_ModifyNS.htm> eNom API Call. Given a FQDN and an ArrayRef of FQDNs to use as nameservers, updates the nameservers and returns an updated version L<WWW::eNom::Domain>.
574  
575 This method will croak if the domain is owned by someone else or if it is not registered. It will also croak if you provide an invalid nameserver (such as ns1.some-domain-that-does-not-really-exist.com).
576  
577 B<NOTE> If, during the update, you remove a private nameserver (by not including it in the ns ArrayRef) that private nameserver will be B<deleted>. This is a limitation of L<eNom|https://www.enom.com>'s API.
578  
579 =head2 get_is_domain_auto_renew_by_name
580  
581 if( $api->get_is_domain_auto_renew_by_name( 'drzigman.com' ) ) {
582 print "Domain will be auto renewed!\n";
583 }
584 else {
585 print "Domain will NOT be renewed automatically!\n";
586 }
587  
588 Abstraction of the L<GetRenew|https://www.enom.com/api/API%20topics/api_GetRenew.htm> eNom API Call. Given a FQDN, returns a truthy value if auto renew is enabled for this domain (you want eNom to automatically renew this) or a falsey value if auto renew is not enabled for this domain.
589  
590 This method will croak if the domain is owned by someone else or if it is not registered.
591  
592 =head2 enable_domain_auto_renew_by_name
593  
594 my $updated_domain = $api->enable_domain_auto_renew_by_name( 'drzigman.com' );
595  
596 Abstraction of the L<SetRenew|https://www.enom.com/api/API%20topics/api_SetRenew.htm> eNom API Call. Given a FQDN, enables auto renew for the provided domain. If the domain is already set to auto renew this is effectively a NO OP.
597  
598 This method will croak if the domain is owned by someone else or if it is not registered.
599  
600 =head2 disable_domain_auto_renew_by_name
601  
602 my $updated_domain = $api->disable_domain_auto_renew_by_name( 'drzigman.com' );
603  
604 Abstraction of the L<SetRenew|https://www.enom.com/api/API%20topics/api_SetRenew.htm> eNom API Call. Given a FQDN, disables auto renew for the provided domain. If the domain is already set not to auto renew this is effectively a NO OP.
605  
606 This method will croak if the domain is owned by someone else or if it is not registered.
607  
608 =head2 get_domain_created_date_by_name
609  
610 my $created_date = $api->get_domain_created_date_by_name( 'drzigman.com' );
611  
612 print "This domain was created on: " . $created_date->ymd . "\n";
613  
614 Abstraction of the L<GetWhoisContact|https://www.enom.com/api/API%20topics/api_GetWhoisContact.htm> eNom API Call. Given a FQDN, returns a L<DateTime> object representing when this domain registration was created.
615  
616 This method will croak if the domain is owned by someone else or if it is not registered.
617  
618 =head2 renew_domain
619  
620 my $order_id = $api->renew_domain({
621 domain_name => 'drzigman.com',
622 years => 1,
623 });
624  
625 Abstraction of the L<Extend|https://www.enom.com/api/API%20topics/api_Extend.htm> eNom API Call. Given a FQDN and the number of years, renews the domain for the requested number of years returning the order_id.
626  
627 B<NOTE> There is a limit as to how far into the future you can renew a domain (usually it's 10 years but that can vary based on the public suffix and the registry). In the event you try to renew too far into the future this method will croak with 'Requested renewal too long'
628  
629 This method will croak if the domain is owned by someone else or if it is not registered.
630  
631 =cut
« blib/lib/WWW/eNom/Role/Command/Raw.pm ↑ Summary blib/lib/WWW/eNom/Role/Command/Service.pm »