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

filter: Statementstmt 17.0% 36 / 211 Branchbran 0.0% 0 / 76 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 24.4% 11 / 45 Podpod 100% 12 / 12 totaltotal 16.9% 59 / 349 CC 41 SCAR 29.8
CC
41
Cov
12%
__ANON__
42.0
__ANON__
42.0
__ANON__
42.0
CRAP 19.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 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::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 46 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 46 ▶use WWW::eNom::Types qw( Bool DomainName DomainNames PositiveInt );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 46 ▶use WWW::eNom::Domain;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 46 ▶use Data::Util qw( is_array_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 46 ▶use DateTime::Format::DateParse;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 46 ▶use Mozilla::PublicSuffix qw( public_suffix );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 46 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 46 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 46 requires 'submit', 'get_contacts_by_domain_name', 'delete_private_nameserver';
20  
21 46 our $VERSION = 'v2.6.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=6 SCAR=37.4
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: 2 branches
BranchTrueFalseTotal
if (grep {$_ eq 'Domain name not found';} @{$$response{'errors'};}) { } 0 0 0
elsif (grep {$_ eq 'This domain name is expired and cannot be updated';} @{$$response{'errors'};}) { } 0 0 0
174 0 croak 'Domain not found in your account';
175 }
176  
177 0 elsif( grep { $_ eq 'This domain name is expired and cannot be updated' } @{ $response->{errors} } ) {
178 0 return [ ];
179 }
180  
181 0 croak 'Unknown error';
182 }
183  
184 0 ▶ if( !exists $response->{dns} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $response->{"dns"}) 0 0 0
185 0 croak 'Response did not contain nameserver data';
186 }
187  
188 # If there is only one NS convert the scalar to an arrayref
189 0 ▶ return is_array_ref( $response->{dns} ) ? $response->{dns} : [ $response->{dns} ];
Branch: 1 branch
BranchTrueFalseTotal
is_array_ref($response->{'dns'}) ? : 0 0 0
190 }
191 catch {
192 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
193 0 };
194 }
195  
196 sub update_nameservers_for_domain_name {
197 0 ▶ my $self = shift;
Subroutine update_nameservers_for_domain_name: not called CC=1 SCAR=6.9
Pod documented
198 0 my ( %args ) = validated_hash(
199 \@_,
200 domain_name => { isa => DomainName },
201 ns => { isa => DomainNames },
202 );
203  
204 try {
205 my @initial_private_nameserver_names = grep {
206 0 $_ =~ m/\Q$args{domain_name}/
207 0 ▶ } @{ $self->get_domain_name_servers_by_name( $args{domain_name} ) };
Subroutine __ANON__: not called CC=6 SCAR=37.4
208  
209 my $response = $self->submit({
210 method => 'ModifyNS',
211 params => {
212 Domain => $args{domain_name},
213 0 map { 'NS' . ( $_ + 1 ) => $args{ns}->[ $_ ] } 0 .. ( scalar (@{ $args{ns} }) - 1)
214 }
215 });
216  
217 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
218 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
219 0 croak 'Domain not found in your account';
220 }
221  
222 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
223 0 croak 'Invalid Nameserver provided';
224 }
225  
226 0 croak 'Unknown error';
227 }
228  
229 # Delete private nameservers that are no longer being used as authoritative
230 0 for my $private_nameserver_name ( @initial_private_nameserver_names ) {
231 0 ▶ if( grep { $_ eq $private_nameserver_name } @{ $args{ns} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $private_nameserver_name;} @{$args{"ns"};}) 0 0 0
232 0 next;
233 }
234  
235 $self->delete_private_nameserver(
236 domain_name => $args{domain_name},
237 0 private_nameserver_name => $private_nameserver_name,
238 );
239 }
240 }
241 catch {
242 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
243 0 };
244  
245  
246 0 return $self->get_domain_by_name( $args{domain_name} );
247 }
248  
249 sub get_is_domain_auto_renew_by_name {
250 0 ▶ my $self = shift;
Subroutine get_is_domain_auto_renew_by_name: not called CC=1 SCAR=6.9
Pod documented
251 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
252  
253 return try {
254 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=5 SCAR=34.0
255 method => 'GetRenew',
256 params => {
257 Domain => $domain_name,
258 }
259 });
260  
261 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
262 0 ▶ if( grep { $_ eq 'Domain name not found' } @{ $response->{errors} } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (grep {$_ eq 'Domain name not found';} @{$$response{'errors'};}) { } 0 0 0
elsif (grep {$_ eq 'This domain name is expired and cannot be updated';} @{$$response{'errors'};}) { } 0 0 0
263 0 croak 'Domain not found in your account';
264 }
265 0 elsif( grep { $_ eq 'This domain name is expired and cannot be updated' } @{ $response->{errors} } ) {
266 0 return !!0;
267 }
268  
269 0 croak 'Unknown error';
270 }
271  
272 0 ▶ if( !exists $response->{'auto-renew'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $response->{"auto-renew"}) 0 0 0
273 0 croak 'Response did not contain renewal data';
274 }
275  
276 0 return !!$response->{'auto-renew'};
277 }
278 catch {
279 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
280 0 };
281 }
282  
283 sub enable_domain_auto_renew_by_name {
284 0 ▶ my $self = shift;
Subroutine enable_domain_auto_renew_by_name: not called CC=1 SCAR=6.9
Pod documented
285 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
286  
287 0 return $self->_set_domain_auto_renew({
288 domain_name => $domain_name,
289 is_auto_renew => 1,
290 });
291 }
292  
293 sub disable_domain_auto_renew_by_name {
294 0 ▶ my $self = shift;
Subroutine disable_domain_auto_renew_by_name: not called CC=1 SCAR=6.9
Pod documented
295 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
296  
297 0 return $self->_set_domain_auto_renew({
298 domain_name => $domain_name,
299 is_auto_renew => 0,
300 });
301 }
302  
303 sub _set_domain_auto_renew {
304 0 ▶ my $self = shift;
Subroutine _set_domain_auto_renew: not called CC=1 SCAR=6.9
305 0 my ( %args ) = validated_hash(
306 \@_,
307 domain_name => { isa => DomainName },
308 is_auto_renew => { isa => Bool },
309 privacy_is_auto_renew => { isa => Bool, optional => 1 },
310 );
311  
312 return try {
313 my $response = $self->submit({
314 method => 'SetRenew',
315 params => {
316 Domain => $args{domain_name},
317 RenewFlag => ( $args{is_auto_renew} ? 1 : 0 ),
318 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
319 }
320 });
321  
322 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
323 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
324 0 croak 'Domain not found in your account';
325 }
326 }
327  
328 0 return $self->get_domain_by_name( $args{domain_name} );
329 }
330 catch {
331 0 ▶ croak "$_";
Subroutine __ANON__: not called CC=1 SCAR=6.9
332 0 };
333  
334 }
335  
336 sub get_domain_created_date_by_name {
337 0 ▶ my $self = shift;
Subroutine get_domain_created_date_by_name: not called CC=1 SCAR=6.9
Pod documented
338 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
339  
340 return try {
341 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=4 SCAR=30.0
342 method => 'GetWhoisContact',
343 params => {
344 Domain => $domain_name,
345 }
346 });
347  
348 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
349 0 ▶ if( grep { $_ eq 'No results found' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "No results found";} @{$$response{"errors"};}) 0 0 0
350 0 croak 'Domain not found in your account';
351 }
352  
353 0 croak 'Unknown error';
354 }
355  
356 0 ▶ if( !exists $response->{GetWhoisContacts}{'rrp-info'}{'created-date'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $response->{"GetWhoisContacts"}{"rrp-info"}{"created-date"}) 0 0 0
357 0 croak 'Response did not contain creation data';
358 }
359  
360 0 return DateTime::Format::DateParse->parse_datetime( $response->{GetWhoisContacts}{'rrp-info'}{'created-date'}, 'UTC' );
361  
362 }
363 catch {
364 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
365 0 };
366  
367 }
368  
369 sub renew_domain {
370 0 ▶ my $self = shift;
Subroutine renew_domain: not called CC=1 SCAR=6.9
Pod documented
371 0 my ( %args ) = validated_hash(
372 \@_,
373 domain_name => { isa => DomainName },
374 years => { isa => PositiveInt },
375 );
376  
377 return try {
378 my $response = $self->submit({
379 method => 'Extend',
380 params => {
381 Domain => $args{domain_name},
382 NumYears => $args{years},
383 }
384 0 ▶ });
Subroutine __ANON__: not called CC=5 SCAR=34.0
385  
386 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
387 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
388 0 croak 'Domain not found in your account';
389 }
390  
391 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
392 0 || ( grep { $_ =~ qr/cannot be extended/ } @{ $response->{errors} } ) ) {
393 0 croak 'Requested renewal too long';
394 }
395  
396 0 croak 'Unknown error';
397 }
398  
399 0 return $response->{OrderID};
400 }
401 catch {
402 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
403 0 };
404 }
405  
406 sub email_epp_key_by_name {
407 0 ▶ my $self = shift;
Subroutine email_epp_key_by_name: not called CC=1 SCAR=6.9
Pod documented
408 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
409  
410 return try {
411 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=3 SCAR=24.8
412 method => 'GetSubAccountPassword',
413 params => {
414 Domain => $domain_name,
415 }
416 });
417  
418 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
419 0 ▶ if( grep { $_ eq 'Domain is not available to get password' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Domain is not available to get password";} @{$$response{"errors"};}) 0 0 0
420 0 croak 'Domain not found in your account';
421 }
422  
423 0 croak 'Unknown error';
424 }
425  
426 # If there are no errors, assume success
427 0 return;
428 }
429 catch {
430 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
431 0 };
432 }
433  
434 46 1;
435  
436 __END__
437  
438 =pod
439  
440 =head1 NAME
441  
442 WWW::eNom::Role::Command::Domain - Domain Related Operations
443  
444 =head1 SYNOPSIS
445  
446 use WWW::eNom;
447 use WWW::eNom::Domain;
448  
449 my $api = WWW::eNom->new( ... );
450  
451 # Get a fully formed WWW::eNom::Domain object for a domain
452 my $domain = $api->get_domain_by_name( 'drzigman.com' );
453  
454  
455 # Check if a domain is locked
456 if( $api->get_is_domain_locked_by_name( 'drzigman.com' ) ) {
457 print "Domain is Locked!\n";
458 }
459 else {
460 print "Domain is NOT Locked!\n";
461 }
462  
463 # Lock Domain
464 my $updated_domain = $api->enable_domain_lock_by_name( 'drzigman.com' );
465  
466 # Unlock Domain
467 my $updated_domain = $api->disable_domain_lock_by_name( 'drzigman.com' );
468  
469  
470 # Get domain authoritative nameservers
471 for my $ns ( $api->get_domain_name_servers_by_name( 'drzigman.com' ) ) {
472 print "Nameserver: $ns\n";
473 }
474  
475 # Update Domain Nameservers
476 my $updated_domain = $api->update_nameservers_for_domain_name({
477 domain_name => 'drzigman.com',
478 ns => [ 'ns1.enom.org', 'ns2.enom.org' ],
479 });
480  
481  
482 # Get auto renew status
483 if( $api->get_is_domain_auto_renew_by_name( 'drzigman.com' ) ) {
484 print "Domain will be auto renewed!\n";
485 }
486 else {
487 print "Domain will NOT be renewed automatically!\n";
488 }
489  
490 # Enable domain auto renew
491 my $updated_domain = $api->enable_domain_auto_renew_by_name( 'drzigman.com' );
492  
493 # Disable domain auto renew
494 my $updated_domain = $api->disable_domain_auto_renew_by_name( 'drzigman.com' );
495  
496 # Renew Domain
497 my $order_id = $api->renew_domain({
498 domain_name => 'drzigman.com',
499 years => 1,
500 });
501  
502 # Get Created Date
503 my $created_date = $api->get_domain_created_date_by_name( 'drzigman.com' );
504 print "This domain was created on: " . $created_date->ymd . "\n";
505  
506 # Email EPP Key to Registrant Contact
507 try { $api->email_epp_key_by_name( 'drzigman.com' ) }
508 catch {
509 ...;
510 };
511  
512 =head1 REQUIRES
513  
514 =over 4
515  
516 =item submit
517  
518 =item get_contacts_by_domain_name
519  
520 Needed in order to construct a full L<WWW::eNom::Domain> object.
521  
522 =item delete_private_nameserver
523  
524 Needed in order to keep private nameservers and authoritative nameservers in sync.
525  
526 =back
527  
528 =head1 DESCRIPTION
529  
530 Implements domain related operations with the L<eNom|https://www.enom.com> API.
531  
532 =head2 See Also
533  
534 =over 4
535  
536 =item For Domain Registration please see L<WWW::eNom::Role::Command::Domain::Registration>
537  
538 =item For Domain Availability please see L<WWW::eNom::Role::Command::Domain::Availability>
539  
540 =back
541  
542 =head1 METHODS
543  
544 =head2 get_domain_by_name
545  
546 my $domain = $api->get_domain_by_name( 'drzigman.com' );
547  
548 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:
549  
550 =over 4
551  
552 =item L<WWW::eNom::Role::Command::Domain/get_is_domain_auto_renew_by_name>
553  
554 =item L<WWW::eNom::Role::Command::Domain/get_is_domain_locked_by_name>
555  
556 =item L<WWW::eNom::Role::Command::Domain/get_domain_name_servers_by_name>
557  
558 =item L<WWW::eNom::Role::Command::Domain/get_domain_created_date_by_name>
559  
560 =item L<WWW::eNom::Role::Command::Contact/get_contacts_by_domain_name>
561  
562 =back
563  
564 Because of all of these API calls this method can be fairly slow (usually about a second or two).
565  
566 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.
567  
568 =head2 get_is_domain_locked_by_name
569  
570 if( $api->get_is_domain_locked_by_name( 'drzigman.com' ) ) {
571 print "Domain is Locked!\n";
572 }
573 else {
574 print "Domain is NOT Locked!\n";
575 }
576  
577 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.
578  
579 This method will croak if the domain is owned by someone else or if it is not registered.
580  
581 =head2 enable_domain_lock_by_name
582  
583 my $updated_domain = $api->enable_domain_lock_by_name( 'drzigman.com' );
584  
585 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.
586  
587 This method will croak if the domain is owned by someone else or if it is not registered.
588  
589 =head2 disable_domain_lock_by_name
590  
591 my $updated_domain = $api->disable_domain_lock_by_name( 'drzigman.com' );
592  
593 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.
594  
595 This method will croak if the domain is owned by someone else or if it is not registered.
596  
597 =head2 get_domain_name_servers_by_name
598  
599 for my $ns ( $api->get_domain_name_servers_by_name( 'drzigman.com' ) ) {
600 print "Nameserver: $ns\n";
601 }
602  
603 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.
604  
605 This method will croak if the domain is owned by someone else or if it is not registered.
606  
607 =head2 update_nameservers_for_domain_name
608  
609 my $updated_domain = $api->update_nameservers_for_domain_name({
610 domain_name => 'drzigman.com',
611 ns => [ 'ns1.enom.org', 'ns2.enom.org' ],
612 });
613  
614 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>.
615  
616 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).
617  
618 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.
619  
620 =head2 get_is_domain_auto_renew_by_name
621  
622 if( $api->get_is_domain_auto_renew_by_name( 'drzigman.com' ) ) {
623 print "Domain will be auto renewed!\n";
624 }
625 else {
626 print "Domain will NOT be renewed automatically!\n";
627 }
628  
629 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.
630  
631 This method will croak if the domain is owned by someone else or if it is not registered.
632  
633 =head2 enable_domain_auto_renew_by_name
634  
635 my $updated_domain = $api->enable_domain_auto_renew_by_name( 'drzigman.com' );
636  
637 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.
638  
639 This method will croak if the domain is owned by someone else or if it is not registered.
640  
641 =head2 disable_domain_auto_renew_by_name
642  
643 my $updated_domain = $api->disable_domain_auto_renew_by_name( 'drzigman.com' );
644  
645 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.
646  
647 This method will croak if the domain is owned by someone else or if it is not registered.
648  
649 =head2 get_domain_created_date_by_name
650  
651 my $created_date = $api->get_domain_created_date_by_name( 'drzigman.com' );
652  
653 print "This domain was created on: " . $created_date->ymd . "\n";
654  
655 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.
656  
657 This method will croak if the domain is owned by someone else or if it is not registered.
658  
659 =head2 renew_domain
660  
661 my $order_id = $api->renew_domain({
662 domain_name => 'drzigman.com',
663 years => 1,
664 });
665  
666 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.
667  
668 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'
669  
670 This method will croak if the domain is owned by someone else or if it is not registered.
671  
672 =head2 email_epp_key_by_name
673  
674 try { $api->email_epp_key_by_name( 'drzigman.com' ) }
675 catch {
676 ...;
677 };
678  
679 Abstraction of the L<GetSubAccountPassword|http://www.enom.com/api/API%20topics/api_GetSubAccountPassword.htm> eNom API Call. Given a FQDN, emails the EPP Key to the email address listed for the registrant contact.
680  
681 B<NOTE> Unfortunately, eNom provides no API method to get the actual EPP Key. Instead, you must use this method to ask eNom to email the EPP Key to the registrant for you.
682  
683 =cut
« blib/lib/WWW/eNom/Role/Command/Raw.pm ↑ Summary blib/lib/WWW/eNom/Role/Command/Service.pm »