| 1 | package WWW::eNom::Role::Command::Domain::Registration; | ||||||||||
| 2 | |||||||||||
| 3 | 47 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 47 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 47 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 47 | ▶ | use MooseX::Params::Validate; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 47 | ▶ | use WWW::eNom::Types qw( DomainRegistration ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 47 | ▶ | use WWW::eNom::DomainRequest::Registration; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 47 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 47 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 47 | requires 'submit', 'purchase_domain_privacy_for_domain'; | |||||||||
| 16 | |||||||||||
| 17 | 47 | our $VERSION = 'v2.7.0'; # VERSION | |||||||||
| 18 | # ABSTRACT: Domain Registration API Calls | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub register_domain { | ||||||||
|
Subroutine
register_domain: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 21 | 0 | my $self = shift; | |||||||||
| 22 | 0 | my ( %args ) = validated_hash( | |||||||||
| 23 | \@_, | ||||||||||
| 24 | request => { isa => DomainRegistration, coerce => 1 }, | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | return try { | ||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||
| 28 | my $response = $self->submit({ | ||||||||||
| 29 | method => 'Purchase', | ||||||||||
| 30 | 0 | params => $args{request}->construct_request(), | |||||||||
| 31 | }); | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | if( $response->{ErrCount} > 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | ▶ | if( grep { $_ eq 'Domain name not available' } @{ $response->{errors} } ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | croak 'Domain not available for registration'; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | croak 'Unknown error'; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | if( $args{request}->is_private ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | $self->purchase_domain_privacy_for_domain({ | ||||||||||
| 43 | domain_name => $args{request}->name, | ||||||||||
| 44 | years => $args{request}->years, | ||||||||||
| 45 | is_auto_renew => $args{request}->is_auto_renew, | ||||||||||
| 46 | 0 | }); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | # Because there can be some lag between domain creation and being able to | ||||||||||
| 50 | # fetch the data from eNom, give it a few tries before calling it a failure | ||||||||||
| 51 | 0 | ▶ | for ( my $attempt_number = 1; $attempt_number <= 5; $attempt_number++ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | my $domain; | |||||||||
| 53 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 54 | $domain = $self->get_domain_by_name( $args{request}->name ) | ||||||||||
| 55 | 0 | } | |||||||||
| 56 | 0 | ▶ | catch { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 57 | 0 | sleep $attempt_number; | |||||||||
| 58 | 0 | }; | |||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | $domain and return $domain; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 0 | croak 'Domain registered but unable to retrieve it'; | |||||||||
| 64 | } | ||||||||||
| 65 | 0 | ▶ | catch { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 66 | 0 | croak $_; | |||||||||
| 67 | 0 | }; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 47 | 1; | |||||||||
| 71 | |||||||||||
| 72 | __END__ | ||||||||||