WWW/eNom/Role/Command/Domain/Transfer.pm

filter: Statementstmt 37.8% 36 / 95 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 47.8% 11 / 23 Podpod 100% 4 / 4 totaltotal 34.6% 51 / 147 CC 13 SCAR 23.7
CC
13
Cov
31%
__ANON__
30.0
__ANON__
20.0
__ANON__
20.0
CRAP 10.7
« WWW/eNom/Domain.pm ↑ Summary WWW/eNom/Role/Command.pm »
1 package WWW::eNom::Role::Command::Domain::Transfer;
2  
3 47 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 47 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 47 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 47 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 47 ▶use WWW::eNom::Types qw( DomainName DomainTransfer PositiveInt );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 47 ▶use WWW::eNom::DomainRequest::Transfer;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 47 ▶use WWW::eNom::DomainTransfer;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 47 ▶use Data::Util qw( is_array_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 47 ▶use Math::Currency;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 47 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 47 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 47 requires 'submit', 'get_domain_privacy_wholesale_price';
19  
20 47 our $VERSION = 'v2.7.0'; # VERSION
21 # ABSTRACT: Domain Transfer API Calls
22  
23 0 ▶sub transfer_domain {
Subroutine transfer_domain: not called CC=1 SCAR=6.9
Pod documented
24 0 my $self = shift;
25 0 my ( %args ) = validated_hash(
26 \@_,
27 request => { isa => DomainTransfer, coerce => 1 },
28 );
29  
30 0 ▶ return try {
Subroutine __ANON__: not called CC=4 SCAR=30.0
31 0 my $domain_privacy_price;
32 0 ▶ if( $args{request}->is_private ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"request"}->is_private) 0 0 0
33 0 $domain_privacy_price = $self->get_domain_privacy_wholesale_price();
34 }
35  
36 my $response = $self->submit({
37 method => 'TP_CreateOrder',
38 params => {
39 0 ▶ %{ $args{request}->construct_request() },
Branch: 1 branch
BranchTrueFalseTotal
$domain_privacy_price ? : 0 0 0
40 $domain_privacy_price ? ( IDPPrice => $domain_privacy_price->as_float ) : ( ),
41 },
42 });
43  
44 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
45 0 croak 'Unknown error';
46 }
47  
48 0 $self->get_transfer_by_order_id( $response->{transferorder}{transferorderdetail}{transferorderdetailid} );
49 }
50 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 0 croak $_;
52 0 };
53 }
54  
55 0 ▶sub get_transfer_by_order_id {
Subroutine get_transfer_by_order_id: not called CC=1 SCAR=6.9
Pod documented
56 0 my $self = shift;
57 0 my ( $order_id ) = pos_validated_list( \@_, { isa => PositiveInt } );
58  
59 0 ▶ return try {
Subroutine __ANON__: not called CC=4 SCAR=30.0
60 0 my $response = $self->submit({
61 method => 'TP_GetOrderDetail',
62 params => {
63 TransferOrderDetailID => $order_id,
64 }
65 });
66  
67 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
68 0 ▶ if( ( grep { $_ eq 'Transfer Order Detail record does not exist.' } @{ $response->{errors} } )
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Transfer Order Detail record does not exist.";} @{$$response{"errors"};} or grep {$_ eq "Invalid Transfer Order Detail ID";} @{$$response{"errors"};}) 0 0 0
Condition0%0/3
grep {$_ eq "Transfer Order Detail record does not exist.";} @{$$response{"errors"};} or grep {$_ eq "Invalid Transfer Order Detail ID";} @{$$response{"errors"};}
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {$_ eq "Transfer Order Detail record does not exist.";} @{$$response{"errors"};} or grep {$_ eq "Invalid Transfer Order Detail ID";} @{$$response{"errors"};}
grep {$_ eq "Transfer Order Detail record does not exist.";} @{$$response{"errors"};} grep {$_ eq "Invalid Transfer Order Detail ID";} @{$$response{"errors"};}
Truth table0%0/3
A or B
A= grep {$_ eq "Transfer Order Detail record does not exist.";} @{$$response{"errors"};}B= grep {$_ eq "Invalid Transfer Order Detail ID";} @{$$response{"errors"};}
ABresult
1X1
011
000
69 0 || ( grep { $_ eq 'Invalid Transfer Order Detail ID' } @{ $response->{errors} } ) ) {
70 0 croak 'No transfer found in your account with specified id';
71 }
72  
73 0 croak 'Unknown error';
74 }
75  
76 0 return WWW::eNom::DomainTransfer->construct_from_response( transfer_detail => $response->{transferorderdetail} );
77 }
78 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 0 croak $_;
80 0 };
81 }
82  
83 0 ▶sub get_transfer_by_name {
Subroutine get_transfer_by_name: not called CC=1 SCAR=6.9
Pod documented
84 0 my $self = shift;
85 0 my ( $domain_name ) = pos_validated_list( \@_, { isa => DomainName } );
86  
87 0 ▶ return try {
Subroutine __ANON__: not called CC=5 SCAR=34.0
88 0 my $response = $self->submit({
89 method => 'TP_GetDetailsByDomain',
90 params => {
91 Domain => $domain_name,
92 }
93 });
94  
95 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
96 0 ▶ if( grep { $_ eq 'There are no transfer order details' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "There are no transfer order details";} @{$$response{"errors"};}) 0 0 0
97 0 croak 'No transfer found for specified domain name';
98 }
99  
100 0 croak 'Unknown error';
101 }
102  
103 0 my @raw_transfer_orders;
104 0 ▶ if( is_array_ref( $response->{TransferOrder} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_array_ref($response->{'TransferOrder'})) { } 0 0 0
105 0 @raw_transfer_orders = @{ $response->{TransferOrder} };
106 }
107 else {
108 0 @raw_transfer_orders = ( $response->{TransferOrder} );
109 }
110  
111 0 my @transfers;
112 0 for my $transfer_order ( @raw_transfer_orders ) {
113 0 my $order_id = $self->get_transfer_order_id_from_parent_order_id( $transfer_order->{orderid} );
114 0 push @transfers, $self->get_transfer_by_order_id( $order_id );
115 }
116  
117 0 return \@transfers;
118 }
119 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
120 0 croak $_;
121 0 };
122 }
123  
124 0 ▶sub get_transfer_order_id_from_parent_order_id {
Subroutine get_transfer_order_id_from_parent_order_id: not called CC=1 SCAR=6.9
Pod documented
125 0 my $self = shift;
126 0 my ( $parent_order_id ) = pos_validated_list( \@_, { isa => PositiveInt } );
127  
128 0 ▶ return try {
Subroutine __ANON__: not called CC=3 SCAR=24.8
129 0 my $response = $self->submit({
130 method => 'TP_GetOrder',
131 params => {
132 TransferOrderID => $parent_order_id,
133 }
134 });
135  
136 0 ▶ if( $response->{ErrCount} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->{"ErrCount"} > 0) 0 0 0
137 0 ▶ if( grep { $_ eq 'Transfer Order does not exist.' } @{ $response->{errors} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "Transfer Order does not exist.";} @{$$response{"errors"};}) 0 0 0
138 0 croak 'No transfer found for specified parent order id';
139 }
140  
141 0 croak 'Unknown error';
142 }
143  
144 0 return $response->{transferorder}{transferorderdetail}{transferorderdetailid};
145 }
146 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
147 0 croak $_;
148 0 };
149 }
150  
151 47 1;
152  
153 __END__
« WWW/eNom/Domain.pm ↑ Summary WWW/eNom/Role/Command.pm »