line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::LogicBoxes::Role::Command::Domain::Availability; |
2
|
|
|
|
|
|
|
|
3
|
39
|
|
|
39
|
|
394738
|
use strict; |
|
39
|
|
|
|
|
131
|
|
|
39
|
|
|
|
|
1484
|
|
4
|
39
|
|
|
39
|
|
263
|
use warnings; |
|
39
|
|
|
|
|
107
|
|
|
39
|
|
|
|
|
1460
|
|
5
|
|
|
|
|
|
|
|
6
|
39
|
|
|
39
|
|
697
|
use Moose::Role; |
|
39
|
|
|
|
|
150864
|
|
|
39
|
|
|
|
|
402
|
|
7
|
39
|
|
|
39
|
|
234065
|
use MooseX::Params::Validate; |
|
39
|
|
|
|
|
73410
|
|
|
39
|
|
|
|
|
475
|
|
8
|
|
|
|
|
|
|
|
9
|
39
|
|
|
39
|
|
21681
|
use WWW::LogicBoxes::Types qw( Bool Int Str Strs ); |
|
39
|
|
|
|
|
116
|
|
|
39
|
|
|
|
|
477
|
|
10
|
|
|
|
|
|
|
|
11
|
39
|
|
|
39
|
|
457490
|
use WWW::LogicBoxes::DomainAvailability; |
|
39
|
|
|
|
|
237
|
|
|
39
|
|
|
|
|
2589
|
|
12
|
|
|
|
|
|
|
|
13
|
39
|
|
|
39
|
|
406
|
use Data::Validate::Domain qw( is_domain ); |
|
39
|
|
|
|
|
98
|
|
|
39
|
|
|
|
|
3142
|
|
14
|
|
|
|
|
|
|
|
15
|
39
|
|
|
39
|
|
276
|
use Carp; |
|
39
|
|
|
|
|
112
|
|
|
39
|
|
|
|
|
28189
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
requires 'submit'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.11.0'; # VERSION |
20
|
|
|
|
|
|
|
# ABSTRACT: Domain Availability API Calls |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub check_domain_availability { |
23
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
24
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
25
|
|
|
|
|
|
|
\@_, |
26
|
|
|
|
|
|
|
slds => { isa => Strs }, |
27
|
|
|
|
|
|
|
tlds => { isa => Strs }, |
28
|
|
|
|
|
|
|
suggestions => { isa => Bool, default => 0 }, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $response = $self->submit({ |
32
|
|
|
|
|
|
|
method => 'domains__available', |
33
|
|
|
|
|
|
|
params => { |
34
|
|
|
|
|
|
|
'domain-name' => $args{slds}, |
35
|
|
|
|
|
|
|
'tlds' => $args{tlds}, |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
}); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my @domain_availabilities; |
40
|
0
|
|
|
|
|
|
for my $domain_name ( keys %{ $response }) { |
|
0
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if( is_domain( $domain_name ) ) { |
42
|
|
|
|
|
|
|
# Standard Response Record |
43
|
|
|
|
|
|
|
push @domain_availabilities, WWW::LogicBoxes::DomainAvailability->new({ |
44
|
|
|
|
|
|
|
name => $domain_name, |
45
|
0
|
0
|
|
|
|
|
is_available => $response->{$domain_name}{status} eq "available" ? 1 : 0, |
46
|
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
|
|
|
|
|
|
# Suggestion Response Record |
50
|
0
|
|
|
|
|
|
for my $sld ( keys %{ $response->{ $domain_name } } ) { |
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
for my $tld ( keys %{ $response->{ $domain_name }{ $sld } } ) { |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
push @domain_availabilities, WWW::LogicBoxes::DomainAvailability->new({ |
53
|
|
|
|
|
|
|
name => lc sprintf('%s.%s', $sld, $tld ), |
54
|
0
|
0
|
|
|
|
|
is_available => $response->{$domain_name}{$sld}{$tld} eq "available" ? 1 : 0, |
55
|
|
|
|
|
|
|
}); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if( $args{suggestions} ) { |
62
|
|
|
|
|
|
|
push @domain_availabilities, $self->suggest_domain_names( |
63
|
0
|
|
|
|
|
|
phrase => join(' ', @{ $args{slds} } ), |
64
|
|
|
|
|
|
|
tlds => $args{tlds}, |
65
|
0
|
|
|
|
|
|
related => 1, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return \@domain_availabilities; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub suggest_domain_names { |
73
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
74
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
75
|
|
|
|
|
|
|
\@_, |
76
|
|
|
|
|
|
|
phrase => { isa => Str }, |
77
|
|
|
|
|
|
|
tlds => { isa => Strs }, |
78
|
|
|
|
|
|
|
hyphen => { isa => Bool, optional => 1 }, |
79
|
|
|
|
|
|
|
related => { isa => Bool, default => 0 }, |
80
|
|
|
|
|
|
|
num_results => { isa => Int, default => 10 }, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
exists $args{hyphen} and carp 'The hyphen argument is deprecated, please see POD for more information'; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $response = $self->submit({ |
86
|
|
|
|
|
|
|
method => 'domains__v5__suggest_names', |
87
|
|
|
|
|
|
|
params => { |
88
|
|
|
|
|
|
|
keyword => $args{phrase}, |
89
|
|
|
|
|
|
|
'tld-only' => $args{tlds}, |
90
|
|
|
|
|
|
|
'exact-match' => !$args{related}, |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
|
}); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my @domain_availabilities; |
95
|
0
|
|
|
|
|
|
for my $domain_name (keys %{ $response }) { |
|
0
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
push @domain_availabilities, WWW::LogicBoxes::DomainAvailability->new({ |
97
|
|
|
|
|
|
|
name => lc $domain_name, |
98
|
0
|
0
|
|
|
|
|
is_available => $response->{$domain_name}{status} eq "available" ? 1 : 0, |
99
|
|
|
|
|
|
|
}); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return [ splice( @domain_availabilities, 0, $args{num_results} * scalar @{ $args{tlds} } ) ]; |
|
0
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
108
|
|
|
|
|
|
|
=pod |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
WWW::LogicBoxes::Role::Command::Domain::Availability - Domain Availability Related Operations |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SYNOPSIS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use WWW::LogicBoxes; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $logic_boxes = WWW::LogicBoxes->new( ... ); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Check If Domains Are Available |
121
|
|
|
|
|
|
|
my $domain_availabilities = $logic_boxes->check_domain_availability( |
122
|
|
|
|
|
|
|
slds => [qw( cpan drzigman brainstormincubator )], |
123
|
|
|
|
|
|
|
tlds => [qw( com net org )], |
124
|
|
|
|
|
|
|
suggestions => 0, |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
for my $domain_availability (@{ $domain_availabilities }) { |
128
|
|
|
|
|
|
|
if( $domain_availability->is_available ) { |
129
|
|
|
|
|
|
|
print 'Domain ' . $domain_availability->name . " is available!\n"; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
else { |
132
|
|
|
|
|
|
|
print 'Domain ' . $domain_availability->name . " is not available.\n"; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# Get Domain Suggestions |
137
|
|
|
|
|
|
|
my $domain_availabilities = $logic_boxes->suggest_domain_names( |
138
|
|
|
|
|
|
|
phrase => 'fast race cars', |
139
|
|
|
|
|
|
|
tlds => [qw( com net org )], |
140
|
|
|
|
|
|
|
hyphen => 0, # DEPRECATED! Will Generate Warnings (see Method for more information) |
141
|
|
|
|
|
|
|
related => 1, |
142
|
|
|
|
|
|
|
num_results => 10, |
143
|
|
|
|
|
|
|
); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
for my $domain_availability (@{ $domain_availabilities }) { |
146
|
|
|
|
|
|
|
if( $domain_availability->is_available ) { |
147
|
|
|
|
|
|
|
print 'Domain ' . $domain_availability->name . " is available!\n"; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
else { |
150
|
|
|
|
|
|
|
print 'Domain ' . $domain_availability->name . " is not available.\n"; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 REQUIRES |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
submit |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 DESCRIPTION |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Implements domain availability related operations with the L<LogicBoxes's|http://www.logicboxes.com> API. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 METHODS |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 check_domain_availability |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
use WWW::LogicBoxes; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
my $logic_boxes = WWW::LogicBoxes->new( ... ); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# Check If Domains Are Available |
171
|
|
|
|
|
|
|
my $domain_availabilities = $logic_boxes->check_domain_availability( |
172
|
|
|
|
|
|
|
slds => [qw( cpan drzigman brainstormincubator )], |
173
|
|
|
|
|
|
|
tlds => [qw( com net org )], |
174
|
|
|
|
|
|
|
suggestions => 0, |
175
|
|
|
|
|
|
|
); |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
for my $domain_availability (@{ $domain_availabilities }) { |
178
|
|
|
|
|
|
|
if( $domain_availability->is_available ) { |
179
|
|
|
|
|
|
|
print 'Domain ' . $domain_availability->name . " is available!\n"; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
else { |
182
|
|
|
|
|
|
|
print 'Domain ' . $domain_availability->name . " is not available.\n"; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Given an ArrayRef of slds and tlds returns an ArrayRef of L<WWW::LogicBoxes::DomainAvailability> objects. Optionally takes suggestions params (defaults to false), if specified then additional domain suggestions will be returned using a search term of the list of slds concatenated together with spaces. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 suggest_domain_names |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
use WWW::LogicBoxes; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
my $logic_boxes = WWW::LogicBoxes->new( ... ); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
my $domain_availabilities = $logic_boxes->suggest_domain_names( |
195
|
|
|
|
|
|
|
phrase => 'fast race cars', |
196
|
|
|
|
|
|
|
tlds => [qw( com net org )], |
197
|
|
|
|
|
|
|
hyphen => 0, # DEPRECATED! Will Generate Warnings. |
198
|
|
|
|
|
|
|
related => 0, |
199
|
|
|
|
|
|
|
num_results => 10, |
200
|
|
|
|
|
|
|
); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
for my $domain_availability (@{ $domain_availabilities }) { |
203
|
|
|
|
|
|
|
if( $domain_availability->is_available ) { |
204
|
|
|
|
|
|
|
print 'Domain ' . $domain_availability->name . " is available!\n"; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
else { |
207
|
|
|
|
|
|
|
print 'Domain ' . $domain_availability->name . " is not available.\n"; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Accepts the following arguments: |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=over 4 |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item B<phrase> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
A search phrase to be used for domain suggestions |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item B<tlds> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
ArrayRef of Public Suffixes to return domains for. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item hyphen |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Default false, if true will include - hacks. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
B<NOTE> THIS ATTRIBUTE IS DEPRECATED. Passing it is still supported (for backwards compaitability) but it has not effect on the results. Usage will generated the carp'ed warning 'The hyphen argument is deprecated, please see POD for more information'' |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item related |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Default false, if true will include related domains based on related keyboard (if you specify 'fast' you may get results with 'quick', 'instant' and 'hurry') |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item num_results |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Default 10, number of results to return. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=back |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Return an ArrayRef of L<WWW::LogicBoxes::DomainAvailability> objects. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=cut |