File Coverage

blib/lib/WWW/LogicBoxes/Role/Command/Domain/Registration.pm
Criterion Covered Total %
statement 24 36 66.6
branch 0 2 0.0
condition n/a
subroutine 8 12 66.6
pod 2 2 100.0
total 34 52 65.3


line stmt bran cond sub pod time code
1             package WWW::LogicBoxes::Role::Command::Domain::Registration;
2              
3 39     39   469067 use strict;
  39         125  
  39         1355  
4 39     39   257 use warnings;
  39         91  
  39         1170  
5              
6 39     39   749 use Moose::Role;
  39         183762  
  39         435  
7 39     39   222461 use MooseX::Params::Validate;
  39         88316  
  39         319  
8              
9 39     39   21083 use WWW::LogicBoxes::Types qw( DomainRegistration Int );
  39         116  
  39         349  
10              
11 39     39   436248 use WWW::LogicBoxes::DomainRequest::Registration;
  39         196  
  39         1923  
12              
13 39     39   405 use Try::Tiny;
  39         101  
  39         3310  
14 39     39   304 use Carp;
  39         103  
  39         13023  
15              
16             requires 'submit', 'get_domain_by_id';
17              
18             our $VERSION = '1.11.0'; # VERSION
19             # ABSTRACT: Domain Registration API Calls
20              
21             sub register_domain {
22 0     0 1   my $self = shift;
23 0           my ( %args ) = validated_hash(
24             \@_,
25             request => { isa => DomainRegistration, coerce => 1 }
26             );
27              
28             my $response = $self->submit({
29             method => 'domains__register',
30 0           params => $args{request}->construct_request(),
31             });
32              
33 0           return $self->get_domain_by_id( $response->{entityid} );
34             }
35              
36             sub delete_domain_registration_by_id {
37 0     0 1   my $self = shift;
38 0           my ( $domain_id ) = pos_validated_list( \@_, { isa => Int } );
39              
40             return try {
41 0     0     $self->submit({
42             method => 'domains__delete',
43             params => {
44             'order-id' => $domain_id,
45             },
46             });
47              
48 0           return;
49             }
50             catch {
51 0 0   0     if( $_ =~ m/No Entity found for Entityid/ ) {
52 0           croak 'No such domain to delete';
53             }
54              
55 0           croak $_;
56 0           };
57             }
58              
59             1;
60              
61             __END__
62             =pod
63              
64             =head1 NAME
65              
66             WWW::LogicBoxes::Role::Command::Domain::Registration - Domain Registration Related Operations
67              
68             =head1 SYNOPSIS
69              
70             use WWW::LogicBoxes;
71             use WWW::LogicBoxes::Domain;
72             use WWW::LogicBoxes::DomainRequest::Registration;
73              
74             my $logic_boxes = WWW::LogicBoxes->new( ... );
75              
76             # Creation
77             my $registration_request = WWW::LogicBoxes::DomainRequest::Registration->new( ... );
78             my $domain = $logic_boxes->register_domain( request => $registration_request );
79              
80             # Deletion
81             $logic_boxes->delete_domain_registration_by_id( $domain->id );
82              
83             =head1 REQUIRES
84              
85             =over 4
86              
87             =item submit
88              
89             =item get_domain_by_id
90              
91             =back
92              
93             =head1 DESCRIPTION
94              
95             Implements domain registration related operations with the L<LogicBoxes's|http://www.logicboxes.com> API.
96              
97             =head1 METHODS
98              
99             =head2 register_domain
100              
101             use WWW::LogicBoxes;
102             use WWW::LogicBoxes::Domain;
103             use WWW::LogicBoxes::DomainRequest::Registration;
104              
105             my $logic_boxes = WWW::LogicBoxes->new( ... );
106              
107             my $registration_request = WWW::LogicBoxes::DomainRequest::Registration->new( ... );
108             my $domain = $logic_boxes->register_domain( request => $registration_request );
109              
110             Given a L<WWW::LogicBoxes::DomainRequest::Registration> or a HashRef that can be coreced into a L<WWW::LogicBoxes::DomainRequest::Registration>, attempts to register a domain with L<LogicBoxes|http://www.logicboxes.com>.
111              
112             Returned is a fully formed L<WWW::LogicBoxes::Domain>.
113              
114             =head2 delete_domain_registration_by_id
115              
116             use WWW::LogicBoxes;
117             use WWW::LogicBoxes::Domain;
118              
119             my $logic_boxes = WWW::LogicBoxes->new( ... );
120              
121             $logic_boxes->delete_domain_registration_by_id( $domain->id );
122              
123             Given an Integer L<domain|WWW::LogicBoxes::Domain> id, deletes the specified domain registration. There is a limited amount of time in which you can do this for a new order (typically between 24 and 72 hours) and if you do this too often then L<LogicBoxes|http://www.logicboxes.com> will get grumpy with you.
124              
125             =cut