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 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 32 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 32 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 32 ▶use MooseX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 32 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 32 ▶use WWW::LogicBoxes::Types qw( Bool ResponseType Str URI );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 32 ▶use Data::Util qw( is_hash_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 32 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 32 our $VERSION = '1.1.0'; # VERSION
17 # ABSTRACT: Interact with LogicBoxes reseller API
18  
19 32 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 32 Readonly my $LIVE_BASE_URI => 'https://httpapi.com';
21 32 Readonly my $TEST_BASE_URI => 'https://test.httpapi.com';
22  
23 32 has username => (
24 is => 'ro',
25 isa => Str,
26 required => 1,
27 );
28  
29 32 has password => (
30 is => 'ro',
31 isa => Str,
32 required => 0,
33 predicate => 'has_password',
34 );
35  
36 32 has api_key => (
37 is => 'ro',
38 isa => Str,
39 required => 0,
40 alias => 'apikey',
41 predicate => 'has_api_key',
42 );
43  
44 32 has sandbox => (
45 is => 'ro',
46 isa => Bool,
47 default => 0,
48 );
49  
50 32 has response_type => (
51 is => 'rw',
52 isa => ResponseType,
53 default => 'xml',
54 );
55  
56 32 has _base_uri => (
57 is => 'ro',
58 isa => URI,
59 lazy => 1,
60 builder => '_build_base_uri',
61 );
62  
63 32 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 32 };
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 32 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 =back
229  
230 =head2 L<Domain Private Nameservers|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer>
231  
232 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.
233  
234 =over 4
235  
236 =item L<create_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/create_private_nameserver>
237  
238 =item L<rename_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/rename_private_nameserver>
239  
240 =item L<modify_private_nameserver_ip|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/modify_private_nameserver_ip>
241  
242 =item L<delete_private_nameserver_ip|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/delete_private_nameserver_ip>
243  
244 =item L<delete_private_nameserver|WWW::LogicBoxes::Role::Command::Domain::PrivateNameServer/delete_private_nameserver>
245  
246 =back
247  
248 =head1 OBJECTS
249  
250 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.
251  
252 =head2 L<WWW::LogicBoxes>
253  
254 Primary interface to LogicBoxes. Documented further below.
255  
256 =head2 L<WWW::LogicBoxes::Contact>
257  
258 WHOIS data contacts. Typically (with few exceptions) domains contains a Registrant, Admin, Technical, and Billing contact.
259  
260 =head2 L<WWW::LogicBoxes::Contact::US>
261  
262 Extended contact used for .us domain registrations that contains the required L<Nexus Data|http://www.neustar.us/the-ustld-nexus-requirements/>.
263  
264 =head2 L<WWW::LogicBoxes::Customer>
265  
266 A LogicBoxes customer under the reseller account.
267  
268 =head2 L<WWW::LogicBoxes::Domain>
269  
270 A registered domain and all of it's related information.
271  
272 =head2 L<WWW::LogicBoxes::DomainTransfer>
273  
274 A pending domain transfer and all of it's related information.
275  
276 =head2 L<WWW::LogicBoxes::DomainAvailability>
277  
278 A response to a domain availability request. Contains the status of the domain and if it is available for registration.
279  
280 =head2 L<WWW::LogicBoxes::DomainRequest::Registration>
281  
282 Request to register a domain.
283  
284 =head2 L<WWW::LogicBoxes::DomainRequest::Transfer>
285  
286 Request to transfer a domain.
287  
288 =head2 L<WWW::LogicBoxes::PrivateNameServer>
289  
290 Private Name Server record for a domain. Not all domains will have these.
291  
292 =head1 WITH
293  
294 L<WWW::LogicBoxes::Role::Command>
295  
296 =head1 ATTRIBUTES
297  
298 =head2 B<username>
299  
300 The reseller id to use.
301  
302 =head2 password
303  
304 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.
305  
306 =head2 api_key
307  
308 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.
309  
310 =head2 sandbox
311  
312 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>
313  
314 =head2 response_type
315  
316 Defaults to "xml." Valid values include:
317  
318 =over 4
319  
320 =item xml
321  
322 =item json
323  
324 =item xml_simple
325  
326 =back
327  
328 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.
329  
330 Defaults to
331  
332 =head1 METHODS
333  
334 =head2 new
335  
336 my $logic_boxes = WWW::LogicBoxes->new(
337 username => 'resellerid',
338  
339 # You may specify a password OR an api_key
340 password => 'Top S3cr3t!',
341 api_key => 'reseller_api_key',
342  
343 response_type => 'json',
344 sandbox => 0,
345 );
346  
347 Creates a new instance of WWW::LogicBoxes that can be used for API Requests.
348  
349 =head1 AUTHORS
350  
351 Robert Stone, C<< <drzigman AT cpan DOT org > >>
352  
353 =head1 ACKNOWLEDGMENTS
354  
355 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.
356  
357 =head1 COPYRIGHT & LICENSE
358  
359 Copyright 2016 Robert Stone
360  
361 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.
362  
363 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 »