File Coverage

blib/lib/WWW/LogicBoxes.pm
Criterion Covered Total %
statement 30 32 93.7
branch 0 2 0.0
condition n/a
subroutine 10 11 90.9
pod n/a
total 40 45 88.8


line stmt bran cond sub pod time code
1             package WWW::LogicBoxes;
2              
3 36     36   25129281 use strict;
  36         329  
  36         1006  
4 36     36   187 use warnings;
  36         77  
  36         842  
5              
6 36     36   652 use Moose;
  36         149585  
  36         275  
7 36     36   255553 use MooseX::StrictConstructor;
  36         1066508  
  36         151  
8 36     36   357472 use MooseX::Aliases;
  36         41024  
  36         133  
9 36     36   1626314 use namespace::autoclean;
  36         112  
  36         332  
10              
11 36     36   23002 use WWW::LogicBoxes::Types qw( Bool ResponseType Str URI );
  36         178  
  36         270  
12              
13 36     36   396190 use Data::Util qw( is_hash_ref );
  36         29695  
  36         2691  
14 36     36   323 use Carp;
  36         76  
  36         2498  
15              
16             our $VERSION = '1.10.0'; # VERSION
17             # ABSTRACT: Interact with LogicBoxes reseller API
18              
19 36     36   17898 use Readonly;
  36         133848  
  36         11671  
20             Readonly my $LIVE_BASE_URI => 'https://httpapi.com';
21             Readonly my $TEST_BASE_URI => 'https://test.httpapi.com';
22              
23             has username => (
24             is => 'ro',
25             isa => Str,
26             required => 1,
27             );
28              
29             has password => (
30             is => 'ro',
31             isa => Str,
32             required => 0,
33             predicate => 'has_password',
34             );
35              
36             has api_key => (
37             is => 'ro',
38             isa => Str,
39             required => 0,
40             alias => 'apikey',
41             predicate => 'has_api_key',
42             );
43              
44             has sandbox => (
45             is => 'ro',
46             isa => Bool,
47             default => 0,
48             );
49              
50             has response_type => (
51             is => 'rw',
52             isa => ResponseType,
53             default => 'xml',
54             );
55              
56             has _base_uri => (
57             is => 'ro',
58             isa => URI,
59             lazy => 1,
60             builder => '_build_base_uri',
61             );
62              
63             with 'WWW::LogicBoxes::Role::Command';
64              
65             around BUILDARGS => sub {
66             my $orig = shift;
67             my $class = shift;
68             my %args = @_ == 1 && is_hash_ref( $_[0] ) ? %{ $_[0] } : @_;
69              
70             # Assign since api_key or apikey are both valid due to backwards compaitability
71             my $password = $args{password};
72             my $api_key = $args{apikey} // $args{api_key};
73              
74             if( !$password && !$api_key ) {
75             croak 'A password or api_key must be specified';
76             }
77              
78             if( $password && $api_key ) {
79             croak "You must specify a password or an api_key, not both";
80             }
81              
82             return $class->$orig(%args);
83             };
84              
85             ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
86             sub _build_base_uri {
87 0     0     my $self = shift;
88              
89 0 0         return $self->sandbox ? $TEST_BASE_URI : $LIVE_BASE_URI;
90             }
91             ## use critic
92              
93             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> - OBSOLETE!
165              
166             =item L<delete_contact_by_id|WWW::LogicBoxes::Role::Command::Contact/delete_contact_by_id>
167              
168             =item L<get_ca_registrant_agreement|WWW::LogicBoxes::Role::Command::Contact/get_ca_registrant_agreement>
169              
170             =back
171              
172             =head2 L<Domain Availability|WWW::LogicBoxes::Role::Command::Domain::Availability>
173              
174             Used for checking to see if a domain is available for registration as well as getting suggestions of other potentially relevant domains.
175              
176             =over 4
177              
178             =item L<check_domain_availability|WWW::LogicBoxes::Role::Command::Domain::Availability/check_domain_availability>
179              
180             =item L<suggest_domain_names|WWW::LogicBoxes::Role::Command::Domain::Availability/suggest_domain_names>
181              
182             =back
183              
184             =head2 L<Domain Registration|WWW::LogicBoxes::Role::Command::Domain::Registration>
185              
186             New Domain Registration.
187              
188             =over 4
189              
190             =item L<register_domain|WWW::LogicBoxes::Role::Command::Domain::Registration/register_domain>
191              
192             =item L<delete_domain_registration_by_id|WWW::LogicBoxes::Role::Command::Domain::Registration/delete_domain_registration_by_id>
193              
194             =back
195              
196             =head2 L<Domain Transfer|WWW::LogicBoxes::Role::Command::Domain::Transfer>
197              
198             New Domain Transfers.
199              
200             =over 4
201              
202             =item L<is_domain_transferable|WWW::LogicBoxes::Role::Command::Domain::Transfer/is_domain_transferable>
203              
204             =item L<transfer_domain|WWW::LogicBoxes::Role::Command::Domain::Transfer/transfer_domain>
205              
206             =item L<delete_domain_transfer_by_id|WWW::LogicBoxes::Role::Command::Domain::Transfer/delete_domain_transfer_by_id>
207              
208             =item L<resend_transfer_approval_mail_by_id|WWW::LogicBoxes::Role::Command::Domain::Transfer/resend_transfer_approval_mail_by_id>
209              
210             =back
211              
212             =head2 L<Domain|WWW::LogicBoxes::Role::Command::Domain>
213              
214             Retrieval of and management of registered domains.
215              
216             =over 4
217              
218             =item L<get_domain_by_id|WWW::LogicBoxes::Role::Command::Domain/get_domain_by_id>
219              
220             =item L<get_domain_by_name|WWW::LogicBoxes::Role::Command::Domain/get_domain_by_name>
221              
222             =item L<update_domain_contacts|WWW::LogicBoxes::Role::Command::Domain/update_domain_contacts>
223              
224             =item L<enable_domain_lock_by_id|WWW::LogicBoxes::Role::Command::Domain/enable_domain_lock_by_id>
225              
226             =item L<disable_domain_lock_by_id|WWW::LogicBoxes::Role::Command::Domain/disable_domain_lock_by_id>
227              
228             =item L<update_domain_nameservers|WWW::LogicBoxes::Role::Command::Domain/update_domain_nameservers>
229              
230             =item L<renew_domain|WWW::LogicBoxes::Role::Command::Domain/renew_domain>
231              
232             =item L<resend_verification_email|WWW::LogicBoxes::Role::Command::Domain/resend_verification_email>
233              
234             =back
235              
236             =head2 L<Domain Private Nameservers|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer>
237              
238             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.
239              
240             =over 4
241              
242             =item L<create_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/create_private_nameserver>
243              
244             =item L<rename_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/rename_private_nameserver>
245              
246             =item L<modify_private_nameserver_ip|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/modify_private_nameserver_ip>
247              
248             =item L<delete_private_nameserver_ip|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/delete_private_nameserver_ip>
249              
250             =item L<delete_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/delete_private_nameserver>
251              
252             =back
253              
254             =head1 OBJECTS
255              
256             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.
257              
258             =head2 L<WWW::LogicBoxes>
259              
260             Primary interface to LogicBoxes. Documented further below.
261              
262             =head2 L<WWW::LogicBoxes::Contact>
263              
264             WHOIS data contacts. Typically (with few exceptions) domains contains a Registrant, Admin, Technical, and Billing contact.
265              
266             =head2 L<WWW::LogicBoxes::Contact::US>
267              
268             Extended contact used for .us domain registrations that contains the required L<Nexus Data|http://www.neustar.us/the-ustld-nexus-requirements/>.
269              
270             =head2 L<WWW::LogicBoxes::Contact::CA>
271              
272             Extended contact used for .ca domain registrations that contains the required CPR and CA Registrant Agreement Data.
273              
274             =head2 L<WWW::LogicBoxes::Contact::CA::Agreement>
275              
276             The CA Registrant Agreement, contacts for .ca domains must accept it before being allowed to purchase .ca domains.
277              
278             =head2 L<WWW::LogicBoxes::Customer>
279              
280             A LogicBoxes customer under the reseller account.
281              
282             =head2 L<WWW::LogicBoxes::IRTPDetail>
283              
284             With the changes that became effective on Dec 1st, 2016 to ICANN rules for updating the registrant contact, this object was created to contain information related to an in progress IRTP Verification. See this object for additional information about the IRTP Changes.
285              
286             =head2 L<WWW::LogicBoxes::Domain>
287              
288             A registered domain and all of it's related information.
289              
290             =head2 L<WWW::LogicBoxes::DomainTransfer>
291              
292             A pending domain transfer and all of it's related information.
293              
294             =head2 L<WWW::LogicBoxes::DomainAvailability>
295              
296             A response to a domain availability request. Contains the status of the domain and if it is available for registration.
297              
298             =head2 L<WWW::LogicBoxes::DomainRequest::Registration>
299              
300             Request to register a domain.
301              
302             =head2 L<WWW::LogicBoxes::DomainRequest::Transfer>
303              
304             Request to transfer a domain.
305              
306             =head2 L<WWW::LogicBoxes::PrivateNameServer>
307              
308             Private Name Server record for a domain. Not all domains will have these.
309              
310             =head1 FACTORIES
311              
312             In cases where a domain or contact requires additional information (such as .us domains requirning nexus data) factories exist so that the correct subclassed object is returned. As a consumer, you almost never want to call these directly, rather make use of the above L</COMMANDS> and let this library worry about constructing the correct objects.
313              
314             =head2 L<WWW::LogicBoxes::Contact::Factory>
315              
316             Constructs the correct subclassed contact.
317              
318             =head1 WITH
319              
320             L<WWW::LogicBoxes::Role::Command>
321              
322             =head1 ATTRIBUTES
323              
324             =head2 B<username>
325              
326             The reseller id to use.
327              
328             =head2 password
329              
330             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.
331              
332             =head2 api_key
333              
334             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.
335              
336             =head2 sandbox
337              
338             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>
339              
340             =head2 response_type
341              
342             Defaults to "xml." Valid values include:
343              
344             =over 4
345              
346             =item xml
347              
348             =item json
349              
350             =item xml_simple
351              
352             =back
353              
354             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.
355              
356             Defaults to
357              
358             =head1 METHODS
359              
360             =head2 new
361              
362             my $logic_boxes = WWW::LogicBoxes->new(
363             username => 'resellerid',
364              
365             # You may specify a password OR an api_key
366             password => 'Top S3cr3t!',
367             api_key => 'reseller_api_key',
368              
369             response_type => 'json',
370             sandbox => 0,
371             );
372              
373             Creates a new instance of WWW::LogicBoxes that can be used for API Requests.
374              
375             =head1 AUTHORS
376              
377             Robert Stone, C<< <drzigman AT cpan DOT org > >>
378              
379             =head1 ACKNOWLEDGMENTS
380              
381             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.
382              
383             =head1 CONTRIBUTIONS
384              
385             Special thanks to the following individuals who have offered commits, bug reports, and/or pull requests.
386              
387             =over 4
388              
389             =item Doug Schrag
390              
391             =item Brandon Husbands
392              
393             =item Slaven Rezic
394              
395             =item David Foster
396              
397             =back
398              
399             =head1 COPYRIGHT & LICENSE
400              
401             Copyright 2016 Robert Stone
402              
403             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.
404              
405             See http://dev.perl.org/licenses/ for more information.