blib/lib/WWW/LogicBoxes/Role/Command/Domain/Transfer.pm

filter: Statementstmt 41.5% 27 / 65 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 8 / 18 Podpod 100% 4 / 4 totaltotal 37.1% 39 / 105 CC 10 SCAR 17.8
CC
10
Cov
33%
transfer_domain
12.0
__ANON__
12.0
__ANON__
12.0
CRAP 5.9
« blib/lib/WWW/LogicBoxes/Domain.pm ↑ Summary blib/lib/WWW/LogicBoxes/Role/Command/Contact.pm »
1 package WWW::LogicBoxes::Role::Command::Domain::Transfer;
2  
3 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 37 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 37 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 37 ▶use WWW::LogicBoxes::Types qw( DomainName DomainTransfer Int );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 37 ▶use WWW::LogicBoxes::DomainRequest::Transfer;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 37 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 37 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 37 requires 'submit', 'get_domain_by_id';
17  
18 37 our $VERSION = '1.2.0'; # VERSION
19 # ABSTRACT: Domain Transfer API Calls
20  
21 sub is_domain_transferable {
22 0 ▶ my $self = shift;
Subroutine is_domain_transferable: not called CC=1 SCAR=6.9
Pod documented
23 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
24  
25 return try {
26 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 method => 'domains__validate_transfer',
28 params => {
29 'domain-name' => $domain_name
30 }
31 });
32  
33 0 return ( $response->{result} eq 'true' );
34 }
35 catch {
36 0 ▶ if( $_ =~ m/is currently available for Registration/ ) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /is currently available for Registration/) 0 0 0
37 0 return;
38 }
39  
40 0 croak $_;
41 0 };
42 }
43  
44 sub transfer_domain {
45 0 ▶ my $self = shift;
Subroutine transfer_domain: not called CC=3 SCAR=24.8
Pod documented
46 0 my ( %args ) = validated_hash(
47 \@_,
48 request => { isa => DomainTransfer, coerce => 1 },
49 );
50  
51 my $response = $self->submit({
52 method => 'domains__transfer',
53 params => $args{request}->construct_request,
54 0 });
55  
56 0 ▶ if( $response->{status} eq 'Failed' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"status"} eq "Failed") 0 0 0
57 0 ▶ if( $response->{actionstatusdesc} =~ m/Order Locked In Processing/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{'actionstatusdesc'} =~ /Order Locked In Processing/) { } 0 0 0
58 0 croak 'Domain is locked';
59 }
60 else {
61 0 croak $response->{actionstatusdesc};
62 }
63 }
64  
65 0 return $self->get_domain_by_id( $response->{entityid} );
66 }
67  
68 sub delete_domain_transfer_by_id {
69 0 ▶ my $self = shift;
Subroutine delete_domain_transfer_by_id: not called CC=1 SCAR=6.9
Pod documented
70 0 my ( $domain_id ) = pos_validated_list( \@_, { isa => Int } );
71  
72 return try {
73 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=2 SCAR=17.9
74 method => 'domains__cancel_transfer',
75 params => {
76 'order-id' => $domain_id,
77 }
78 });
79  
80 0 ▶ if( lc $response->{result} eq 'success' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $response->{"result"} eq "success") 0 0 0
81 0 return;
82 }
83  
84 0 croak $response;
85 }
86 catch {
87 0 ▶ if( $_ =~ m/You are not allowed to perform this action/ ) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
if ($_ =~ /You are not allowed to perform this action/) { } 0 0 0
elsif ($_ =~ m[Invalid action status/action type for this operation]) { } 0 0 0
88 0 croak 'No matching order found';
89 }
90 elsif( $_ =~ m|Invalid action status/action type for this operation| ) {
91 0 croak 'Unable to delete';
92 }
93  
94 0 croak $_;
95 0 };
96 }
97  
98 sub resend_transfer_approval_mail_by_id {
99 0 ▶ my $self = shift;
Subroutine resend_transfer_approval_mail_by_id: not called CC=1 SCAR=6.9
Pod documented
100 0 my ( $domain_id ) = pos_validated_list( \@_, { isa => Int } );
101  
102 return try {
103 0 ▶ my $response = $self->submit({
Subroutine __ANON__: not called CC=2 SCAR=17.9
104 method => 'domains__resend_rfa',
105 params => {
106 'order-id' => $domain_id,
107 }
108 });
109  
110 0 ▶ if( lc $response->{result} eq 'true' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $response->{"result"} eq "true") 0 0 0
111 0 return;
112 }
113  
114 0 croak $response;
115 }
116 catch {
117 ## no critic ( RegularExpressions::ProhibitComplexRegexes )
118 0 ▶ if( $_ =~ m/You are not allowed to perform this action/ ) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
if ($_ =~ /You are not allowed to perform this action/) { } 0 0 0
elsif ($_ =~ /The current status of Transfer action for the domain name does not allow this operation/) { } 0 0 0
119 0 croak 'No matching pending transfer order found';
120 }
121 elsif( $_ =~ m/The current status of Transfer action for the domain name does not allow this operation/ ) {
122 0 croak 'Domain is not pending admin approval';
123 }
124 ## use critic
125  
126 0 croak $_;
127 0 };
128 }
129  
130 37 1;
131  
132 __END__
133 =pod
134  
135 =head1 NAME
136  
137 WWW::LogicBoxes::Role::Command::Domain::Transfer - Domain Transfer Related Operations
138  
139 =head1 SYNOPSIS
140  
141 use WWW::LogicBoxes;
142 use WWW::LogicBoxes::DomainTransfer;
143 use WWW::LogicBoxes::DomainRequest::Transfer;
144  
145 my $logic_boxes = WWW::LogicBoxes->new( ... );
146  
147 # Check Transferability
148 if( $logic_boxes->is_domain_transferable( 'some-domain.com' ) ) {
149 print "Domain is transferable';
150 }
151 else {
152 print "Domain is not transferable";
153 }
154  
155 # Transfer Domain
156 my $transfer_request = WWW::LogicBoxes::DomainRequest::Transfer->new( ... );
157 my $domain_transfer = $logic_boxes->transfer_domain( $transfer_request );
158  
159 # Deletion
160 $logic_boxes->delete_domain_transfer_by_id( $domain_transfer->id );
161  
162 # Resend Transfer Approval Mail
163 $logic_boxes->resend_transfer_approval_mail_by_id( $domain_transfer->id );
164  
165 =head1 REQUIRES
166  
167 =over 4
168  
169 =item submit
170  
171 =item get_domain_by_id
172  
173 =back
174  
175 =head1 DESCRIPTION
176  
177 Implemented domain transfer related operations with the L<LogicBoxes'|http://www.logicobxes.com> API.
178  
179 =head1 METHODS
180  
181 =head2 is_domain_transferable
182  
183 use WWW::LogicBoxes;
184  
185 my $logic_boxes = WWW::LogicBoxes->new( ... );
186  
187 if( $logic_boxes->is_domain_transferable( 'some-domain.com' ) ) {
188 print "Domain is transferable';
189 }
190 else {
191 print "Domain is not transferable";
192 }
193  
194 Given a domain name, uses L<LogicBoxes|http://www.logicboxes.com> to determine if this domain is transferable in it's current state.
195  
196 B<NOTE> L<LogicBoxes|http://www.logicboxes.com> will accept transfer requests even if the domain is not actually eligble for transfer so you should call this method before making a domain transfer request.
197  
198 =head2 transfer_domain
199  
200 use WWW::LogicBoxes;
201 use WWW::LogicBoxes::DomainTransfer;
202 use WWW::LogicBoxes::DomainRequest::Transfer;
203  
204 my $logic_boxes = WWW::LogicBoxes->new( ... );
205  
206 my $transfer_request = WWW::LogicBoxes::DomainRequest::Transfer->new( ... );
207 my $domain_transfer = $logic_boxes->transfer_domain( $transfer_request );
208  
209 Given a L<WWW::LogicBoxes::DomainRequest::Transfer> or a HashRef that can be coerced into a L<WWW::LogicBoxes::DomainRequest::Transfer>, attempt to transfer the domain with L<LogicBoxes|http://www.logicboxes.com>.
210  
211 Returns a fully formed L<WWW::LogicBoxes::DomainTransfer>.
212  
213 =head2 delete_domain_transfer_by_id
214  
215 use WWW::LogicBoxes;
216 use WWW::LogicBoxes::DomainTransfer;
217 use WWW::LogicBoxes::DomainRequest::Transfer;
218  
219 my $logic_boxes = WWW::LogicBoxes->new( ... );
220  
221 my $domain_transfer = $logic_boxes->get_domain_by_id( ... );
222 $logic_boxes->delete_domain_transfer_by_id( $domain_transfer->id );
223  
224 Given an Integer representing an in progress L<transfer|WWW::LogicBoxes::DomainTransfer>, deletes the specfied domain transfer. There is a limited amount of time in which you can do this for a new transfer, and you can only do it before the transfer is completed. If you do this too often then L<LogicBoxes|http://www.logicboxes.com> will get grumpy with you.
225  
226 =head2 resend_transfer_approval_mail_by_id
227  
228 use WWW::LogicBoxes;
229 use WWW::LogicBoxes::DomainTransfer;
230 use WWW::LogicBoxes::DomainRequest::Transfer;
231  
232 my $logic_boxes = WWW::LogicBoxes->new( ... );
233  
234 my $domain_transfer = $logic_boxes->get_domain_by_id( ... );
235 $logic_boxes->resend_transfer_approval_mail_by_id( $domain_transfer->id );
236  
237 Given an Integer representing an in progress L<transfer|WWW::LogicBoxes::DomainTransfer> that has not yet been approved by the L<admin contact|WWW::LogicBoxes::Contact> as specified by the losing registrar, will resend the transfer approval email. If this method is used on a completed transfer, a registration, or a domain that has already been approved this method will croak with an error.
238  
239 =cut
« blib/lib/WWW/LogicBoxes/Domain.pm ↑ Summary blib/lib/WWW/LogicBoxes/Role/Command/Contact.pm »