blib/lib/WWW/LogicBoxes.pm

filter: Statementstmt 76.3% 42 / 55 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 83.3% 10 / 12 Podpod n/a totaltotal 54.7% 52 / 95 CC 9 SCAR 34.0
CC
9
Cov
56%
__ANON__
72.0
_build_base_uri
6.0
BEGIN
1.0
CRAP 29.9
« blib/lib/WWW/LogicBoxes/Role/Command/Domain/Availability.pm ↑ Summary blib/lib/WWW/LogicBoxes/Contact.pm »
1 package WWW::LogicBoxes;
2  
3 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 33 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 33 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 33 ▶use MooseX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 33 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 33 ▶use WWW::LogicBoxes::Types qw( Bool ResponseType Str URI );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 33 ▶use Data::Util qw( is_hash_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 33 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 33 our $VERSION = '1.2.0'; # VERSION
17 # ABSTRACT: Interact with LogicBoxes reseller API
18  
19 33 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 33 Readonly my $LIVE_BASE_URI => 'https://httpapi.com';
21 33 Readonly my $TEST_BASE_URI => 'https://test.httpapi.com';
22  
23 33 has username => (
24 is => 'ro',
25 isa => Str,
26 required => 1,
27 );
28  
29 33 has password => (
30 is => 'ro',
31 isa => Str,
32 required => 0,
33 predicate => 'has_password',
34 );
35  
36 33 has api_key => (
37 is => 'ro',
38 isa => Str,
39 required => 0,
40 alias => 'apikey',
41 predicate => 'has_api_key',
42 );
43  
44 33 has sandbox => (
45 is => 'ro',
46 isa => Bool,
47 default => 0,
48 );
49  
50 33 has response_type => (
51 is => 'rw',
52 isa => ResponseType,
53 default => 'xml',
54 );
55  
56 33 has _base_uri => (
57 is => 'ro',
58 isa => URI,
59 lazy => 1,
60 builder => '_build_base_uri',
61 );
62  
63 33 with 'WWW::LogicBoxes::Role::Command';
64  
65 around BUILDARGS => sub {
66 0 ▶ my $orig = shift;
Subroutine __ANON__: not called CC=8 SCAR=42.8
67 0 my $class = shift;
68 0 ▶ my %args = @_ == 1 && is_hash_ref( $_[0] ) ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && is_hash_ref($_[0]) ? : 0 0 0
Condition0%0/3
@_ == 1 and is_hash_ref($_[0])
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and is_hash_ref($_[0])
@_ == 1 is_hash_ref($_[0])
Truth table0%0/3
A and B
A= @_ == 1B= is_hash_ref($_[0])
ABresult
0X0
100
111
69  
70 # Assign since api_key or apikey are both valid due to backwards compaitability
71 0 my $password = $args{password};
72 0 ▶ my $api_key = $args{apikey} // $args{api_key};
Condition0%0/3
$args{"apikey"} // $args{"api_key"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"apikey"} // $args{"api_key"}
$args{"apikey"} $args{"api_key"}
Truth table0%0/3
A // B
A= $args{"apikey"}B= $args{"api_key"}
ABresult
1X1
011
000
73  
74 0 ▶ if( !$password && !$api_key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($password or $api_key) 0 0 0
Condition0%0/3
$password or $api_key
l!l&&r!l&&!r
000
MC/DC0%0/2
$password or $api_key
$password $api_key
Truth table0%0/3
A or B
A= $passwordB= $api_key
ABresult
1X1
011
000
75 0 croak 'A password or api_key must be specified';
76 }
77  
78 0 ▶ if( $password && $api_key ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($password and $api_key) 0 0 0
Condition0%0/3
$password and $api_key
!ll&&!rl&&r
000
MC/DC0%0/2
$password and $api_key
$password $api_key
Truth table0%0/3
A and B
A= $passwordB= $api_key
ABresult
0X0
100
111
79 0 croak "You must specify a password or an api_key, not both";
80 }
81  
82 0 return $class->$orig(%args);
83 33 };
84  
85 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
86 sub _build_base_uri {
87 0 ▶ my $self = shift;
Subroutine _build_base_uri: not called CC=2 SCAR=17.9
88  
89 0 ▶ return $self->sandbox ? $TEST_BASE_URI : $LIVE_BASE_URI;
Branch: 1 branch
BranchTrueFalseTotal
$self->sandbox ? : 0 0 0
90 }
91 ## use critic
92  
93 33 1;
94  
95 __END__
96 =pod
97  
98 =head1 NAME
99  
100 WWW::LogicBoxes - Interact with LogicBoxes Reseller API
101  
102 =head1 SYNOPSIS
103  
104 use strict;
105 use warnings;
106  
107 use WWW::LogicBoxes;
108  
109 my $logic_boxes = WWW::LogicBoxes->new(
110 username => 'resellerid',
111  
112 # You may specify a password OR an api_key
113 password => 'Top S3cr3t!',
114 api_key => 'reseller_api_key',
115  
116 response_type => 'json',
117 sandbox => 0,
118 );
119  
120 my $domain_availabilities = $logic_boxes->check_domain_availability(
121 slds => [qw( cpan drzigman brainstormincubator ],
122 tlds => [qw( com net org )],
123 suggestions => 0,
124 );
125  
126 =head1 DESCRIPTION
127  
128 L<WWW::LogicBoxes> is a module for interacting with the L<LogicBoxes|http://www.logicboxes.com/> API. LogicBoxes is a domain registrar and the API performs operations such as checking domain availability, purchasing domains, and managing them.
129  
130 This module is broken down into two primary components (documented below). These are L<WWW::LogicBoxes/COMMANDS> which are used for making requests and L<WWW::LogicBoxes/OBJECTS> which are used to represent data. Below these, documentation for the L<WWW::LogicBoxes> module is included.
131  
132 =head1 COMMANDS
133  
134 Commands are how operations are performed using the L<WWW::LogicBoxes> API. They are seperated into related operations, for documentation on the specific command please see the linked pages.
135  
136 =head2 L<Raw|WWW::LogicBoxes::Role::Command::Raw>
137  
138 Low level direct access to the LogicBoxes API. You rarely want to make use of this and instead want to use the abstracted commands outlined below.
139  
140 =head2 L<Customer|WWW::LogicBoxes::Role::Command::Customer>
141  
142 Customer creation and retrieval. All domains belong to a customer.
143  
144 =over 4
145  
146 =item L<create_customer|WWW::LogicBoxes::Role::Command::Customer/create_customer>
147  
148 =item L<get_customer_by_id|WWW::LogicBoxes::Role::Command::Customer/get_customer_by_id>
149  
150 =item L<get_customer_by_username|WWW::LogicBoxes::Role::Command::Customer/get_customer_by_username>
151  
152 =back
153  
154 =head2 L<Contact|WWW::LogicBoxes::Role::Command::Contact>
155  
156 Contacts are used in whois information and are required for domain registration.
157  
158 =over 4
159  
160 =item L<create_contact|WWW::LogicBoxes::Role::Command::Contact/create_contact>
161  
162 =item L<get_contact_by_id|WWW::LogicBoxes::Role::Command::Contact/get_contact_by_id>
163  
164 =item L<update_contact|WWW::LogicBoxes::Role::Command::Contact/update_contact>
165  
166 =item L<delete_contact_by_id|WWW::LogicBoxes::Role::Command::Contact/delete_contact_by_id>
167  
168 =back
169  
170 =head2 L<Domain Availability|WWW::LogicBoxes::Role::Command::Domain::Availability>
171  
172 Used for checking to see if a domain is available for registration as well as getting suggestions of other potentially relevant domains.
173  
174 =over 4
175  
176 =item L<check_domain_availability|WWW::LogicBoxes::Role::Command::Domain::Availability/check_domain_availability>
177  
178 =item L<suggest_domain_names|WWW::LogicBoxes::Role::Command::Domain::Availability/suggest_domain_names>
179  
180 =back
181  
182 =head2 L<Domain Registration|WWW::LogicBoxes::Role::Command::Domain::Registration>
183  
184 New Domain Registration.
185  
186 =over 4
187  
188 =item L<register_domain|WWW::LogicBoxes::Role::Command::Domain::Registration/register_domain>
189  
190 =item L<delete_domain_registration_by_id|WWW::LogicBoxes::Role::Command::Domain::Registration/delete_domain_registration_by_id>
191  
192 =back
193  
194 =head2 L<Domain Transfer|WWW::LogicBoxes::Role::Command::Domain::Transfer>
195  
196 New Domain Transfers.
197  
198 =over 4
199  
200 =item L<is_domain_transferable|WWW::LogicBoxes::Role::Command::Domain::Transfer/is_domain_transferable>
201  
202 =item L<transfer_domain|WWW::LogicBoxes::Role::Command::Domain::Transfer/transfer_domain>
203  
204 =item L<delete_domain_transfer_by_id|WWW::LogicBoxes::Role::Command::Domain::Transfer/delete_domain_transfer_by_id>
205  
206 =item L<resend_transfer_approval_mail_by_id|WWW::LogicBoxes::Role::Command::Domain::Transfer/resend_transfer_approval_mail_by_id>
207  
208 =back
209  
210 =head2 L<Domain|WWW::LogicBoxes::Role::Command::Domain>
211  
212 Retrieval of and management of registered domains.
213  
214 =over 4
215  
216 =item L<get_domain_by_id|WWW::LogicBoxes::Role::Command::Domain/get_domain_by_id>
217  
218 =item L<get_domain_by_name|WWW::LogicBoxes::Role::Command::Domain/get_domain_by_name>
219  
220 =item L<update_domain_contacts|WWW::LogicBoxes::Role::Command::Domain/update_domain_contacts>
221  
222 =item L<enable_domain_lock_by_id|WWW::LogicBoxes::Role::Command::Domain/enable_domain_lock_by_id>
223  
224 =item L<disable_domain_lock_by_id|WWW::LogicBoxes::Role::Command::Domain/disable_domain_lock_by_id>
225  
226 =item L<update_domain_nameservers|WWW::LogicBoxes::Role::Command::Domain/update_domain_nameservers>
227  
228 =item L<renew_domain|WWW::LogicBoxes::Role::Command::Domain/renew_domain>
229  
230 =back
231  
232 =head2 L<Domain Private Nameservers|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer>
233  
234 I<Private> nameservers are those that are based on the registered domain. For example, a domain of test-domain.com could have private nameservers ns1.test-domain.com and ns2.test-domain.com.
235  
236 =over 4
237  
238 =item L<create_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/create_private_nameserver>
239  
240 =item L<rename_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/rename_private_nameserver>
241  
242 =item L<modify_private_nameserver_ip|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/modify_private_nameserver_ip>
243  
244 =item L<delete_private_nameserver_ip|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/delete_private_nameserver_ip>
245  
246 =item L<delete_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/delete_private_nameserver>
247  
248 =back
249  
250 =head1 OBJECTS
251  
252 Rather than working with messy JSON objects, WWW::LogicBoxes implements a series of L<Moose> objects for making requests and processing responses. All commands that take an object have coercion so a HashRef can be used in it's place.
253  
254 =head2 L<WWW::LogicBoxes>
255  
256 Primary interface to LogicBoxes. Documented further below.
257  
258 =head2 L<WWW::LogicBoxes::Contact>
259  
260 WHOIS data contacts. Typically (with few exceptions) domains contains a Registrant, Admin, Technical, and Billing contact.
261  
262 =head2 L<WWW::LogicBoxes::Contact::US>
263  
264 Extended contact used for .us domain registrations that contains the required L<Nexus Data|http://www.neustar.us/the-ustld-nexus-requirements/>.
265  
266 =head2 L<WWW::LogicBoxes::Customer>
267  
268 A LogicBoxes customer under the reseller account.
269  
270 =head2 L<WWW::LogicBoxes::Domain>
271  
272 A registered domain and all of it's related information.
273  
274 =head2 L<WWW::LogicBoxes::DomainTransfer>
275  
276 A pending domain transfer and all of it's related information.
277  
278 =head2 L<WWW::LogicBoxes::DomainAvailability>
279  
280 A response to a domain availability request. Contains the status of the domain and if it is available for registration.
281  
282 =head2 L<WWW::LogicBoxes::DomainRequest::Registration>
283  
284 Request to register a domain.
285  
286 =head2 L<WWW::LogicBoxes::DomainRequest::Transfer>
287  
288 Request to transfer a domain.
289  
290 =head2 L<WWW::LogicBoxes::PrivateNameServer>
291  
292 Private Name Server record for a domain. Not all domains will have these.
293  
294 =head1 WITH
295  
296 L<WWW::LogicBoxes::Role::Command>
297  
298 =head1 ATTRIBUTES
299  
300 =head2 B<username>
301  
302 The reseller id to use.
303  
304 =head2 password
305  
306 B<NOTE> Password based authentication is now deprecated and is not allowed unless specifically requested from LogicBoxes for your reseller account. Instead, you should be using the api_key.
307  
308 =head2 api_key
309  
310 The API Key used for authentication. Either the password or the api_key B<MUST> be specified, but B<NOT> both. For backwards compatability B<apikey> is an alias.
311  
312 =head2 sandbox
313  
314 Defaults to false. Determines if requests should go to the production system L<https://httpapi.com> or the development environment L<https://test.httpapi.com>
315  
316 =head2 response_type
317  
318 Defaults to "xml." Valid values include:
319  
320 =over 4
321  
322 =item xml
323  
324 =item json
325  
326 =item xml_simple
327  
328 =back
329  
330 It should be noted that this setting is really only relevant when making L<Raw|WWW::LogicBoxes::Role::Command::Raw> requests of the LogicBoxes API. When doing so this attribute defines the format of the responses.
331  
332 Defaults to
333  
334 =head1 METHODS
335  
336 =head2 new
337  
338 my $logic_boxes = WWW::LogicBoxes->new(
339 username => 'resellerid',
340  
341 # You may specify a password OR an api_key
342 password => 'Top S3cr3t!',
343 api_key => 'reseller_api_key',
344  
345 response_type => 'json',
346 sandbox => 0,
347 );
348  
349 Creates a new instance of WWW::LogicBoxes that can be used for API Requests.
350  
351 =head1 AUTHORS
352  
353 Robert Stone, C<< <drzigman AT cpan DOT org > >>
354  
355 =head1 ACKNOWLEDGMENTS
356  
357 Thanks to L<HostGator|http://hostgator.com> and L<BrainStorm Incubator|http://brainstormincubator.com> for funding the development of this module and providing test resources.
358  
359 =head1 CONTRIBUTIONS
360  
361 Special thanks to the following individuals who have offered commits, bug reports, and/or pull requests.
362  
363 =over 4
364  
365 =item Doug Schrag
366  
367 =item Brandon Husbands
368  
369 =item Slaven Rezic
370  
371 =back
372  
373 =head1 COPYRIGHT & LICENSE
374  
375 Copyright 2016 Robert Stone
376  
377 This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU Lesser General Public License as published by the Free Software Foundation; or any compatible license.
378  
379 See http://dev.perl.org/licenses/ for more information.
« blib/lib/WWW/LogicBoxes/Role/Command/Domain/Availability.pm ↑ Summary blib/lib/WWW/LogicBoxes/Contact.pm »