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 38     38   515390 use strict;
  38         119  
  38         1213  
4 38     38   249 use warnings;
  38         114  
  38         1104  
5              
6 38     38   669 use Moose::Role;
  38         180346  
  38         400  
7 38     38   200619 use MooseX::Params::Validate;
  38         90272  
  38         297  
8              
9 38     38   19562 use WWW::LogicBoxes::Types qw( DomainRegistration Int );
  38         113  
  38         302  
10              
11 38     38   397689 use WWW::LogicBoxes::DomainRequest::Registration;
  38         186  
  38         1792  
12              
13 38     38   396 use Try::Tiny;
  38         122  
  38         3001  
14 38     38   272 use Carp;
  38         97  
  38         11979  
15              
16             requires 'submit', 'get_domain_by_id';
17              
18             our $VERSION = '1.10.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