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   376161 use strict;
  38         147  
  38         1281  
4 38     38   288 use warnings;
  38         91  
  38         1257  
5              
6 38     38   582 use Moose::Role;
  38         148797  
  38         368  
7 38     38   197867 use MooseX::Params::Validate;
  38         71790  
  38         289  
8              
9 38     38   18654 use WWW::LogicBoxes::Types qw( DomainRegistration Int );
  38         96  
  38         308  
10              
11 38     38   397484 use WWW::LogicBoxes::DomainRequest::Registration;
  38         173  
  38         1728  
12              
13 38     38   410 use Try::Tiny;
  38         86  
  38         2909  
14 38     38   249 use Carp;
  38         92  
  38         11267  
15              
16             requires 'submit', 'get_domain_by_id';
17              
18             our $VERSION = '1.10.1'; # 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