| 1 | package WWW::LogicBoxes::Role::Command::Domain; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 36 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 36 | ▶ | use MooseX::Params::Validate; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 36 | ▶ | use WWW::LogicBoxes::Types qw( Bool DomainName DomainNames Int PrivateNameServer Str ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 36 | ▶ | use WWW::LogicBoxes::Domain::Factory; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 36 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 36 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 36 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 36 | Readonly my $DOMAIN_DETAIL_OPTIONS => [qw( All )]; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 36 | requires 'submit'; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 36 | our $VERSION = '1.1.0'; # VERSION | |||||||||||||||||||||||||||
| 22 | # ABSTRACT: Domain API Calls | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | sub get_domain_by_id { | ||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_domain_by_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 0 | my ( $domain_id ) = pos_validated_list( \@_, { isa => Int } ); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | return try { | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my $response = $self->submit({ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 30 | method => 'domains__details', | ||||||||||||||||||||||||||||
| 31 | params => { | ||||||||||||||||||||||||||||
| 32 | 'order-id' => $domain_id, | ||||||||||||||||||||||||||||
| 33 | 'options' => $DOMAIN_DETAIL_OPTIONS, | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | }); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | return WWW::LogicBoxes::Domain::Factory->construct_from_response( $response ); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | catch { | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if( $_ =~ m/^No Entity found for Entityid/ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | return; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | croak $_; | |||||||||||||||||||||||||||
| 45 | 0 | }; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub get_domain_by_name { | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_domain_by_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 0 | my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } ); | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | return try { | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $response = $self->submit({ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 54 | method => 'domains__details_by_name', | ||||||||||||||||||||||||||||
| 55 | params => { | ||||||||||||||||||||||||||||
| 56 | 'domain-name' => $domain_name, | ||||||||||||||||||||||||||||
| 57 | 'options' => $DOMAIN_DETAIL_OPTIONS, | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | }); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | return WWW::LogicBoxes::Domain::Factory->construct_from_response( $response ); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | catch { | ||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if( $_ =~ m/^Website doesn't exist for/ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | return; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | croak $_; | |||||||||||||||||||||||||||
| 69 | 0 | }; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub update_domain_contacts { | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
update_domain_contacts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 0 | my ( %args ) = validated_hash( | |||||||||||||||||||||||||||
| 75 | \@_, | ||||||||||||||||||||||||||||
| 76 | id => { isa => Int }, | ||||||||||||||||||||||||||||
| 77 | registrant_contact_id => { isa => Int, optional => 1 }, | ||||||||||||||||||||||||||||
| 78 | admin_contact_id => { isa => Int, optional => 1 }, | ||||||||||||||||||||||||||||
| 79 | technical_contact_id => { isa => Int, optional => 1 }, | ||||||||||||||||||||||||||||
| 80 | billing_contact_id => { isa => Int, optional => 1 }, | ||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | return try { | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $original_domain = $self->get_domain_by_id( $args{id} ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if( !$original_domain ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | croak 'No such domain exists'; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | my $contact_mapping = { | |||||||||||||||||||||||||||
| 91 | registrant_contact_id => 'reg-contact-id', | ||||||||||||||||||||||||||||
| 92 | admin_contact_id => 'admin-contact-id', | ||||||||||||||||||||||||||||
| 93 | technical_contact_id => 'tech-contact-id', | ||||||||||||||||||||||||||||
| 94 | billing_contact_id => 'billing-contact-id', | ||||||||||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | my $num_changes = 0; | |||||||||||||||||||||||||||
| 98 | 0 | my $contacts_to_update; | |||||||||||||||||||||||||||
| 99 | 0 | for my $contact_type ( keys %{ $contact_mapping } ) { | |||||||||||||||||||||||||||
| 100 | 0 | ▶ | if( $args{$contact_type} && $args{$contact_type} != $original_domain->$contact_type ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{$contact_type} and $args{$contact_type} != $original_domain->$contact_type
MC/DC0%0/2
$args{$contact_type} and $args{$contact_type} != $original_domain->$contact_type
$args{$contact_type}
$args{$contact_type} != $original_domain->$contact_type
Truth table0%0/3
A and B
A= $args{$contact_type}B= $args{$contact_type} != $original_domain->$contact_type
| |||||||||||||||||||||||||||||
| 101 | 0 | $contacts_to_update->{ $contact_mapping->{ $contact_type } } = $args{ $contact_type }; | |||||||||||||||||||||||||||
| 102 | 0 | $num_changes++; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | else { | ||||||||||||||||||||||||||||
| 105 | 0 | $contacts_to_update->{ $contact_mapping->{ $contact_type } } = $original_domain->$contact_type; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if( $num_changes == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | return $original_domain; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | $self->submit({ | ||||||||||||||||||||||||||||
| 114 | method => 'domains__modify_contact', | ||||||||||||||||||||||||||||
| 115 | params => { | ||||||||||||||||||||||||||||
| 116 | 'order-id' => $args{id}, | ||||||||||||||||||||||||||||
| 117 | 0 | %{ $contacts_to_update } | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | }); | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | return $self->get_domain_by_id( $args{id} ); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | catch { | ||||||||||||||||||||||||||||
| 124 | ## no critic (ControlStructures::ProhibitCascadingIfElse) | ||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if( $_ =~ m/{registrantcontactid=registrantcontactid is invalid}/ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 126 | 0 | croak 'Invalid registrant_contact_id specified'; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | elsif( $_ =~ m/{admincontactid=admincontactid is invalid}/ ) { | ||||||||||||||||||||||||||||
| 129 | 0 | croak 'Invalid admin_contact_id specified'; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | elsif( $_ =~ m/{techcontactid=techcontactid is invalid}/ ) { | ||||||||||||||||||||||||||||
| 132 | 0 | croak 'Invalid technical_contact_id specified'; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | elsif( $_ =~ m/{billingcontactid=billingcontactid is invalid}/ ) { | ||||||||||||||||||||||||||||
| 135 | 0 | croak 'Invalid billing_contact_id specified'; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | ## use critic | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | croak $_; | |||||||||||||||||||||||||||
| 140 | 0 | }; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub enable_domain_lock_by_id { | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
enable_domain_lock_by_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 145 | 0 | my ( $domain_id ) = pos_validated_list( \@_, { isa => Int } ); | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | return try { | ||||||||||||||||||||||||||||
| 148 | 0 | ▶ | $self->submit({ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 149 | method => 'domains__enable_theft_protection', | ||||||||||||||||||||||||||||
| 150 | params => { | ||||||||||||||||||||||||||||
| 151 | 'order-id' => $domain_id, | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | }); | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 0 | return $self->get_domain_by_id( $domain_id ); | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | catch { | ||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if( $_ =~ m/^No Entity found for Entityid/ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 0 | croak 'No such domain'; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | croak $_; | |||||||||||||||||||||||||||
| 163 | 0 | }; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | sub disable_domain_lock_by_id { | ||||||||||||||||||||||||||||
| 167 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
disable_domain_lock_by_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 168 | 0 | my ( $domain_id ) = pos_validated_list( \@_, { isa => Int } ); | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | return try { | ||||||||||||||||||||||||||||
| 171 | 0 | ▶ | $self->submit({ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 172 | method => 'domains__disable_theft_protection', | ||||||||||||||||||||||||||||
| 173 | params => { | ||||||||||||||||||||||||||||
| 174 | 'order-id' => $domain_id, | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | }); | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | return $self->get_domain_by_id( $domain_id ); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | catch { | ||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if( $_ =~ m/^No Entity found for Entityid/ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | croak 'No such domain'; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | croak $_; | |||||||||||||||||||||||||||
| 186 | 0 | }; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | sub enable_domain_privacy { | ||||||||||||||||||||||||||||
| 190 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
enable_domain_privacy: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 191 | 0 | my ( %args ) = validated_hash( | |||||||||||||||||||||||||||
| 192 | \@_, | ||||||||||||||||||||||||||||
| 193 | id => { isa => Int }, | ||||||||||||||||||||||||||||
| 194 | reason => { isa => Str, optional => 1 }, | ||||||||||||||||||||||||||||
| 195 | ); | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $args{reason} //= 'Enabling Domain Privacy'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"reason"} //= "Enabling Domain Privacy"
MC/DC0%0/1
$args{"reason"} //= "Enabling Domain Privacy"
$args{"reason"}
Truth table0%0/2
A
A= $args{"reason"}
| |||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | return $self->_set_domain_privacy( | ||||||||||||||||||||||||||||
| 200 | id => $args{id}, | ||||||||||||||||||||||||||||
| 201 | status => 1, | ||||||||||||||||||||||||||||
| 202 | reason => $args{reason}, | ||||||||||||||||||||||||||||
| 203 | 0 | ); | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | sub disable_domain_privacy { | ||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
disable_domain_privacy: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 208 | 0 | my ( %args ) = validated_hash( | |||||||||||||||||||||||||||
| 209 | \@_, | ||||||||||||||||||||||||||||
| 210 | id => { isa => Int }, | ||||||||||||||||||||||||||||
| 211 | reason => { isa => Str, optional => 1 }, | ||||||||||||||||||||||||||||
| 212 | ); | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $args{reason} //= 'Disabling Domain Privacy'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"reason"} //= "Disabling Domain Privacy"
MC/DC0%0/1
$args{"reason"} //= "Disabling Domain Privacy"
$args{"reason"}
Truth table0%0/2
A
A= $args{"reason"}
| |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | return try { | ||||||||||||||||||||||||||||
| 217 | return $self->_set_domain_privacy( | ||||||||||||||||||||||||||||
| 218 | id => $args{id}, | ||||||||||||||||||||||||||||
| 219 | status => 0, | ||||||||||||||||||||||||||||
| 220 | reason => $args{reason}, | ||||||||||||||||||||||||||||
| 221 | 0 | ▶ | ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | catch { | ||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if( $_ =~ m/^Privacy Protection not Purchased/ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 0 | return $self->get_domain_by_id( $args{id} ); | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | croak $_; | |||||||||||||||||||||||||||
| 229 | 0 | }; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | sub _set_domain_privacy { | ||||||||||||||||||||||||||||
| 233 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_set_domain_privacy: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 234 | 0 | my ( %args ) = validated_hash( | |||||||||||||||||||||||||||
| 235 | \@_, | ||||||||||||||||||||||||||||
| 236 | id => { isa => Int }, | ||||||||||||||||||||||||||||
| 237 | status => { isa => Bool }, | ||||||||||||||||||||||||||||
| 238 | reason => { isa => Str }, | ||||||||||||||||||||||||||||
| 239 | ); | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | return try { | ||||||||||||||||||||||||||||
| 242 | $self->submit({ | ||||||||||||||||||||||||||||
| 243 | method => 'domains__modify_privacy_protection', | ||||||||||||||||||||||||||||
| 244 | params => { | ||||||||||||||||||||||||||||
| 245 | 'order-id' => $args{id}, | ||||||||||||||||||||||||||||
| 246 | 'protect-privacy' => $args{status} ? 'true' : 'false', | ||||||||||||||||||||||||||||
| 247 | 'reason' => $args{reason}, | ||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | return $self->get_domain_by_id( $args{id} ); | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | catch { | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if( $_ =~ m/^No Entity found for Entityid/ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 0 | croak 'No such domain'; | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | croak $_; | |||||||||||||||||||||||||||
| 259 | 0 | }; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | sub update_domain_nameservers { | ||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
update_domain_nameservers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 264 | 0 | my ( %args ) = validated_hash( | |||||||||||||||||||||||||||
| 265 | \@_, | ||||||||||||||||||||||||||||
| 266 | id => { isa => Int }, | ||||||||||||||||||||||||||||
| 267 | nameservers => { isa => DomainNames }, | ||||||||||||||||||||||||||||
| 268 | ); | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | return try { | ||||||||||||||||||||||||||||
| 271 | $self->submit({ | ||||||||||||||||||||||||||||
| 272 | method => 'domains__modify_ns', | ||||||||||||||||||||||||||||
| 273 | params => { | ||||||||||||||||||||||||||||
| 274 | 'order-id' => $args{id}, | ||||||||||||||||||||||||||||
| 275 | 'ns' => $args{nameservers}, | ||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | 0 | ▶ | }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 0 | return $self->get_domain_by_id( $args{id} ); | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | catch { | ||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if( $_ =~ m/^No Entity found for Entityid/ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 283 | 0 | croak 'No such domain'; | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | elsif( $_ =~ m/is not a valid Nameserver/ ) { | ||||||||||||||||||||||||||||
| 286 | 0 | croak 'Invalid nameservers provided'; | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | elsif( $_ =~ m/Same value for new and old NameServers/ ) { | ||||||||||||||||||||||||||||
| 289 | 0 | return $self->get_domain_by_id( $args{id} ); | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 0 | croak $_; | |||||||||||||||||||||||||||
| 293 | 0 | }; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 36 | 1; | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | __END__ | ||||||||||||||||||||||||||||
| 299 | =pod | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =head1 NAME | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | WWW::LogicBoxes::Role::Command::Domain - Domain Related Operations | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 308 | use WWW::LogicBoxes::Contact; | ||||||||||||||||||||||||||||
| 309 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | # Retrieval | ||||||||||||||||||||||||||||
| 314 | my $domain = $logic_boxes->get_domain_by_id( 42 ); | ||||||||||||||||||||||||||||
| 315 | my $domain = $logic_boxes->get_domain_by_domain( 'test-domain.com' ); | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | # Update Contacts | ||||||||||||||||||||||||||||
| 318 | my $contacts = { | ||||||||||||||||||||||||||||
| 319 | registrant_contact => WWW::LogicBoxes::Contact->new( ... ), | ||||||||||||||||||||||||||||
| 320 | admin_contact => WWW::LogicBoxes::Contact->new( ... ), | ||||||||||||||||||||||||||||
| 321 | technical_contact => WWW::LogicBoxes::Contact->new( ... ), | ||||||||||||||||||||||||||||
| 322 | billing_contact => WWW::LogicBoxes::Contact->new( ... ), | ||||||||||||||||||||||||||||
| 323 | }; | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | $logic_boxes->update_domain_contacts( | ||||||||||||||||||||||||||||
| 326 | id => $domain->id, | ||||||||||||||||||||||||||||
| 327 | registrant_contact_id => $contacts->{registrant_contact}->id, | ||||||||||||||||||||||||||||
| 328 | admin_contact_id => $contacts->{admin_contact}->id, | ||||||||||||||||||||||||||||
| 329 | technical_contact_id => $contacts->{technical_contact}->id, | ||||||||||||||||||||||||||||
| 330 | billing_contact_id => $contacts->{billing_contact}->id, | ||||||||||||||||||||||||||||
| 331 | ); | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | # Domain Locking | ||||||||||||||||||||||||||||
| 334 | $logic_boxes->enable_domain_lock_by_id( $domain->id ); | ||||||||||||||||||||||||||||
| 335 | $logic_boxes->disable_domain_lock_by_id( $domain->id ); | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | # Domain Privacy | ||||||||||||||||||||||||||||
| 338 | $logic_boxes->enable_domain_privacy( | ||||||||||||||||||||||||||||
| 339 | id => $domain->id, | ||||||||||||||||||||||||||||
| 340 | reason => 'Enabling Domain Privacy', | ||||||||||||||||||||||||||||
| 341 | ); | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | $logic_boxes->disable_domain_privacy( | ||||||||||||||||||||||||||||
| 344 | id => $domain->id, | ||||||||||||||||||||||||||||
| 345 | reason => 'Disabling Domain Privacy', | ||||||||||||||||||||||||||||
| 346 | ); | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | # Nameservers | ||||||||||||||||||||||||||||
| 349 | $logic_boxes->update_domain_nameservers( | ||||||||||||||||||||||||||||
| 350 | id => $domain->id, | ||||||||||||||||||||||||||||
| 351 | nameservers => [ 'ns1.logicboxes.com', 'ns1.logicboxes.com' ], | ||||||||||||||||||||||||||||
| 352 | ); | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | =head1 REQUIRES | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | submit | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | Implements domain related operations with the L<LogicBoxes's|http://www.logicboxes.com> API. | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | =head2 See Also | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | =over 4 | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | =item For Domain Registration please see L<WWW::LogicBoxes::Role::Command::Domain::Registration> | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | =item For Domain Availability please see L<WWW::LogicBoxes::Role::Command::Domain::Availability> | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | =item For Private Nameservers please see L<WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer> | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | =back | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =head1 METHODS | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =head2 get_domain_by_id | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 379 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 382 | my $domain = $logic_boxes->get_domain_by_id( 42 ); | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | Given a Integer L<domain|WWW::LogicBoxes::Domain> id, returns a matching L<WWW::LogicBoxes::Domain> from L<LogicBoxes|http://www.logicobxes.com>. In the event of no matching L<domain|WWW::LogicBoxes::Domain>, returns undef. | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | B<NOTE> For domain transfers that are in progress a L<domain_transfer|WWW::LogicBoxes::DomainTransfer> record will be returned. | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | =head2 get_domain_by_name | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 391 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 394 | my $domain = $logic_boxes->get_domain_by_domain( 'test-domain.com' ); | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | Given a full L<domain|WWW::LogicBoxes::Domain> name, returns a matching L<WWW::LogicBoxes::Domain> from L<LogicBoxes|http://www.logicobxes.com>. In the event of no matching L<domain|WWW::LogicBoxes::Domain>, returns undef, | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | B<NOTE> For domain transfers that are in progress a L<domain_transfer|WWW::LogicBoxes::DomainTransfer> record will be returned. | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | =head2 update_domain_contacts | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 403 | use WWW::LogicBoxes::Contact; | ||||||||||||||||||||||||||||
| 404 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | # Update Contacts | ||||||||||||||||||||||||||||
| 409 | my $contacts = { | ||||||||||||||||||||||||||||
| 410 | registrant_contact => WWW::LogicBoxes::Contact->new( ... ), | ||||||||||||||||||||||||||||
| 411 | admin_contact => WWW::LogicBoxes::Contact->new( ... ), | ||||||||||||||||||||||||||||
| 412 | technical_contact => WWW::LogicBoxes::Contact->new( ... ), | ||||||||||||||||||||||||||||
| 413 | billing_contact => WWW::LogicBoxes::Contact->new( ... ), | ||||||||||||||||||||||||||||
| 414 | }; | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | $logic_boxes->update_domain_contacts( | ||||||||||||||||||||||||||||
| 417 | id => $domain->id, | ||||||||||||||||||||||||||||
| 418 | registrant_contact_id => $contacts->{registrant_contact}->id, | ||||||||||||||||||||||||||||
| 419 | admin_contact_id => $contacts->{admin_contact}->id, | ||||||||||||||||||||||||||||
| 420 | technical_contact_id => $contacts->{technical_contact}->id, | ||||||||||||||||||||||||||||
| 421 | billing_contact_id => $contacts->{billing_contact}->id, | ||||||||||||||||||||||||||||
| 422 | ); | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | Given a L<domain|WWW::LogicBoxes::Domain> id and optionally a L<contact|WWW::LogicBoxes::Contact> id for registrant_contact_id, admin_contact_id, technical_contact_id, and/or billing_contact_id, updates the L<domain|WWW::LogicBoxes::Domain> contacts. This method is smart enough to not request a change if the contact hasn't been updated and consumers need only specify the elements that are changing. | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | =head2 enable_domain_lock_by_id | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 429 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 432 | $logic_boxes->enable_domain_lock_by_id( $domain->id ); | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | Given an Integer L<domain|WWW::LogicBoxes::Domain> id, locks the L<domain|WWW::LogicBoxes::Domain> so that it can not be transfered away. | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | =head2 disable_domain_lock_by_id | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 439 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 442 | $logic_boxes->disable_domain_lock_by_id( $domain->id ); | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | Given an Integer L<domain|WWW::LogicBoxes::Domain> id, unlocks the L<domain|WWW::LogicBoxes::Domain> so that it can be transfered away. | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | =head2 enable_domain_privacy | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 449 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 452 | $logic_boxes->enable_domain_privacy( | ||||||||||||||||||||||||||||
| 453 | id => $domain->id, | ||||||||||||||||||||||||||||
| 454 | reason => 'Enabling Domain Privacy', | ||||||||||||||||||||||||||||
| 455 | ); | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | Given an Integer L<domain|WWW::LogicBoxes::Domain> id and an optional reason ( defaults to "Enabling Domain Privacy" ), enables WHOIS Privacy Protect for the L<domain|WWW::LogicBoxes::Domain>. | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | =head2 disable_domain_privacy | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 462 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 465 | $logic_boxes->disable_domain_privacy( | ||||||||||||||||||||||||||||
| 466 | id => $domain->id, | ||||||||||||||||||||||||||||
| 467 | reason => 'Disabling Domain Privacy', | ||||||||||||||||||||||||||||
| 468 | ); | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | Given an Integer L<domain|WWW::LogicBoxes::Domain> id and an optional reason ( defaults to "Disabling Domain Privacy" ), disabled WHOIS Privacy Protect for the L<domain|WWW::LogicBoxes::Domain>. | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | =head2 update_domain_nameservers | ||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | use WWW::LogicBoxes; | ||||||||||||||||||||||||||||
| 475 | use WWW::LogicBoxes::Domain; | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||||||||||||||||||||||||||||
| 478 | $logic_boxes->update_domain_nameservers( | ||||||||||||||||||||||||||||
| 479 | id => $domain->id, | ||||||||||||||||||||||||||||
| 480 | nameservers => [ 'ns1.logicboxes.com', 'ns1.logicboxes.com' ], | ||||||||||||||||||||||||||||
| 481 | ); | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | Given an Integer L<domain|WWW::LogicBoxes::Domain> id and an ArrayRef of nameserver hostnames, sets the L<domain|WWW::LogicBoxes::Domain>'s authoritative nameservers. | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =cut | ||||||||||||||||||||||||||||