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 37     37   25936343 use strict;
  37         340  
  37         1161  
4 37     37   214 use warnings;
  37         65  
  37         991  
5              
6 37     37   843 use Moose;
  37         181342  
  37         316  
7 37     37   278983 use MooseX::StrictConstructor;
  37         1191389  
  37         155  
8 37     37   393515 use MooseX::Aliases;
  37         45358  
  37         144  
9 37     37   1798527 use namespace::autoclean;
  37         98  
  37         316  
10              
11 37     37   26031 use WWW::LogicBoxes::Types qw( Bool ResponseType Str URI );
  37         218  
  37         297  
12              
13 37     37   439466 use Data::Util qw( is_hash_ref );
  37         34423  
  37         3189  
14 37     37   318 use Carp;
  37         87  
  37         2927  
15              
16             our $VERSION = '1.11.0'; # VERSION
17             # ABSTRACT: Interact with LogicBoxes reseller API
18              
19 37     37   21773 use Readonly;
  37         156611  
  37         15204  
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             =item L<|submit_auth_code|WWW::LogicBoxes::Role::Command::Domain::Transfer/submit_auth_code>
211              
212             =back
213              
214             =head2 L<Domain|WWW::LogicBoxes::Role::Command::Domain>
215              
216             Retrieval of and management of registered domains.
217              
218             =over 4
219              
220             =item L<get_domain_by_id|WWW::LogicBoxes::Role::Command::Domain/get_domain_by_id>
221              
222             =item L<get_domain_by_name|WWW::LogicBoxes::Role::Command::Domain/get_domain_by_name>
223              
224             =item L<update_domain_contacts|WWW::LogicBoxes::Role::Command::Domain/update_domain_contacts>
225              
226             =item L<enable_domain_lock_by_id|WWW::LogicBoxes::Role::Command::Domain/enable_domain_lock_by_id>
227              
228             =item L<disable_domain_lock_by_id|WWW::LogicBoxes::Role::Command::Domain/disable_domain_lock_by_id>
229              
230             =item L<update_domain_nameservers|WWW::LogicBoxes::Role::Command::Domain/update_domain_nameservers>
231              
232             =item L<renew_domain|WWW::LogicBoxes::Role::Command::Domain/renew_domain>
233              
234             =item L<resend_verification_email|WWW::LogicBoxes::Role::Command::Domain/resend_verification_email>
235              
236             =back
237              
238             =head2 L<Domain Private Nameservers|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer>
239              
240             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.
241              
242             =over 4
243              
244             =item L<create_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/create_private_nameserver>
245              
246             =item L<rename_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/rename_private_nameserver>
247              
248             =item L<modify_private_nameserver_ip|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/modify_private_nameserver_ip>
249              
250             =item L<delete_private_nameserver_ip|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/delete_private_nameserver_ip>
251              
252             =item L<delete_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/delete_private_nameserver>
253              
254             =back
255              
256             =head1 OBJECTS
257              
258             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.
259              
260             =head2 L<WWW::LogicBoxes>
261              
262             Primary interface to LogicBoxes. Documented further below.
263              
264             =head2 L<WWW::LogicBoxes::Contact>
265              
266             WHOIS data contacts. Typically (with few exceptions) domains contains a Registrant, Admin, Technical, and Billing contact.
267              
268             =head2 L<WWW::LogicBoxes::Contact::US>
269              
270             Extended contact used for .us domain registrations that contains the required L<Nexus Data|http://www.neustar.us/the-ustld-nexus-requirements/>.
271              
272             =head2 L<WWW::LogicBoxes::Contact::CA>
273              
274             Extended contact used for .ca domain registrations that contains the required CPR and CA Registrant Agreement Data.
275              
276             =head2 L<WWW::LogicBoxes::Contact::CA::Agreement>
277              
278             The CA Registrant Agreement, contacts for .ca domains must accept it before being allowed to purchase .ca domains.
279              
280             =head2 L<WWW::LogicBoxes::Customer>
281              
282             A LogicBoxes customer under the reseller account.
283              
284             =head2 L<WWW::LogicBoxes::IRTPDetail>
285              
286             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.
287              
288             =head2 L<WWW::LogicBoxes::Domain>
289              
290             A registered domain and all of it's related information.
291              
292             =head2 L<WWW::LogicBoxes::DomainTransfer>
293              
294             A pending domain transfer and all of it's related information.
295              
296             =head2 L<WWW::LogicBoxes::DomainAvailability>
297              
298             A response to a domain availability request. Contains the status of the domain and if it is available for registration.
299              
300             =head2 L<WWW::LogicBoxes::DomainRequest::Registration>
301              
302             Request to register a domain.
303              
304             =head2 L<WWW::LogicBoxes::DomainRequest::Transfer>
305              
306             Request to transfer a domain.
307              
308             =head2 L<WWW::LogicBoxes::PrivateNameServer>
309              
310             Private Name Server record for a domain. Not all domains will have these.
311              
312             =head1 FACTORIES
313              
314             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.
315              
316             =head2 L<WWW::LogicBoxes::Contact::Factory>
317              
318             Constructs the correct subclassed contact.
319              
320             =head1 WITH
321              
322             L<WWW::LogicBoxes::Role::Command>
323              
324             =head1 ATTRIBUTES
325              
326             =head2 B<username>
327              
328             The reseller id to use.
329              
330             =head2 password
331              
332             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.
333              
334             =head2 api_key
335              
336             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.
337              
338             =head2 sandbox
339              
340             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>
341              
342             =head2 response_type
343              
344             Defaults to "xml." Valid values include:
345              
346             =over 4
347              
348             =item xml
349              
350             =item json
351              
352             =item xml_simple
353              
354             =back
355              
356             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.
357              
358             Defaults to
359              
360             =head1 METHODS
361              
362             =head2 new
363              
364             my $logic_boxes = WWW::LogicBoxes->new(
365             username => 'resellerid',
366              
367             # You may specify a password OR an api_key
368             password => 'Top S3cr3t!',
369             api_key => 'reseller_api_key',
370              
371             response_type => 'json',
372             sandbox => 0,
373             );
374              
375             Creates a new instance of WWW::LogicBoxes that can be used for API Requests.
376              
377             =head1 AUTHORS
378              
379             Robert Stone, C<< <drzigman AT cpan DOT org > >>
380              
381             =head1 ACKNOWLEDGMENTS
382              
383             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.
384              
385             =head1 CONTRIBUTIONS
386              
387             Special thanks to the following individuals who have offered commits, bug reports, and/or pull requests.
388              
389             =over 4
390              
391             =item Doug Schrag
392              
393             =item Brandon Husbands
394              
395             =item Slaven Rezic
396              
397             =item David Foster
398              
399             =item Eris Caffee
400              
401             =item Boris Voskresenskiy
402              
403             =back
404              
405             =head1 COPYRIGHT & LICENSE
406              
407             Copyright 2016 Robert Stone
408              
409             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.
410              
411             See http://dev.perl.org/licenses/ for more information.