| 1 | package WWW::LogicBoxes::DomainAvailability; | ||
| 2 | |||
| 3 | 40 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 40 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 40 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 40 | ▶ | use MooseX::StrictConstructor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 40 | ▶ | use MooseX::Aliases; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 40 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 40 | ▶ | use WWW::LogicBoxes::Types qw( Bool DomainName Str ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 40 | ▶ | use Mozilla::PublicSuffix; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 40 | our $VERSION = '1.2.0'; # VERSION | |
| 16 | # ABSTRACT: LogicBoxes Domain Availability Response | ||
| 17 | |||
| 18 | 40 | has name => ( | |
| 19 | is => 'ro', | ||
| 20 | isa => DomainName, | ||
| 21 | required => 1, | ||
| 22 | ); | ||
| 23 | |||
| 24 | 40 | has is_available => ( | |
| 25 | is => 'ro', | ||
| 26 | isa => Bool, | ||
| 27 | required => 1, | ||
| 28 | ); | ||
| 29 | |||
| 30 | 40 | has sld => ( | |
| 31 | is => 'ro', | ||
| 32 | isa => Str, | ||
| 33 | builder => '_build_sld', | ||
| 34 | lazy => 1, | ||
| 35 | init_arg => undef, | ||
| 36 | ); | ||
| 37 | |||
| 38 | 40 | has public_suffix => ( | |
| 39 | is => 'ro', | ||
| 40 | isa => Str, | ||
| 41 | alias => 'tld', | ||
| 42 | builder => '_build_public_suffix', | ||
| 43 | lazy => 1, | ||
| 44 | init_arg => undef, | ||
| 45 | ); | ||
| 46 | |||
| 47 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||
| 48 | sub _build_sld { | ||
| 49 | 4 | ▶ | my $self = shift; |
|
Subroutine
_build_sld: called CC=1 SCAR=0.0
| |||
| 50 | |||
| 51 | 4 | return substr( $self->name, 0, length( $self->name ) - ( length( $self->public_suffix ) + 1 ) ); | |
| 52 | } | ||
| 53 | ## use critic | ||
| 54 | |||
| 55 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||
| 56 | sub _build_public_suffix { | ||
| 57 | 4 | ▶ | my $self = shift; |
|
Subroutine
_build_public_suffix: called CC=1 SCAR=0.0
| |||
| 58 | |||
| 59 | 4 | return Mozilla::PublicSuffix::public_suffix( $self->name ); | |
| 60 | } | ||
| 61 | ## use critic | ||
| 62 | |||
| 63 | 40 | __PACKAGE__->meta->make_immutable; | |
| 64 | |||
| 65 | 40 | 1; | |
| 66 | |||
| 67 | __END__ | ||
| 68 | =pod | ||
| 69 | |||
| 70 | =head1 NAME | ||
| 71 | |||
| 72 | WWW::LogicBoxes::DomainAvailability | ||
| 73 | |||
| 74 | =head1 SYNOPSIS | ||
| 75 | |||
| 76 | use WWW::LogicBoxes; | ||
| 77 | |||
| 78 | my $logic_boxes = WWW::LogicBoxes->new( ... ); | ||
| 79 | |||
| 80 | my $domain_availabilities = $logic_boxes->check_domain_availability( | ||
| 81 | slds => [qw( cpan drzigman brainstormincubator ], | ||
| 82 | tlds => [qw( com net org )], | ||
| 83 | suggestions => 0, | ||
| 84 | ); | ||
| 85 | |||
| 86 | for my $domain_availability (@{ $domain_availabilities }) { | ||
| 87 | if ( $domain_availability->is_available ) { | ||
| 88 | print 'Domain: ' . $domain_availability->name . " is available! :) \n"; | ||
| 89 | } | ||
| 90 | else { | ||
| 91 | print 'Domain: ' . $domain_availability->name . " is not available! :( \n"; | ||
| 92 | } | ||
| 93 | } | ||
| 94 | |||
| 95 | =head1 DESCRIPTION | ||
| 96 | |||
| 97 | Contains details about the availability of a domain. | ||
| 98 | |||
| 99 | =head1 ATTRIBUTES | ||
| 100 | |||
| 101 | =head2 B<name> | ||
| 102 | |||
| 103 | The full domain name (test-domain.com). | ||
| 104 | |||
| 105 | =head2 B<is_available> | ||
| 106 | |||
| 107 | Boolean indicating if this domain is available for registration. | ||
| 108 | |||
| 109 | =head2 sld | ||
| 110 | |||
| 111 | The portion of the domain name excluding the public_suffix, (test-domain). | ||
| 112 | |||
| 113 | =head2 public_suffix | ||
| 114 | |||
| 115 | The "root" of the domain (.com). There is an alias of tld to this attribute. | ||
| 116 | |||
| 117 | B<NOTE> For domains like test-domain.co.uk the public_suffix is .co.uk. The public suffix is what is available for someone to actually register. For additional information between the distinction between Top Level Domain and Public Suffix please see L<https://publicsuffix.org/learn/> | ||
| 118 | |||
| 119 | =cut | ||