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