DRI/Protocol/EPP/Extensions/FCCN/Domain.pm

filter: Statementstmt 16.0% 16 / 100 Branchbran 0.0% 0 / 56 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 31.2% 5 / 16 Podpod 0.0% 0 / 11 totaltotal 9.8% 21 / 213 CC 38 SCAR 41.8
CC
38
Cov
9%
create
110.0
info_parse
110.0
renew
90.0
CRAP 65.5
« DRI/Protocol/EPP/Extensions/Afilias/Trademark.pm ↑ Summary DRI/Transport.pm »
1 ## Domain Registry Interface, .PT Domain EPP extension commands
2 ##
3 ## Copyright (c) 2008,2013-2014,2016,2019 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::EPP::Extensions::FCCN::Domain;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use DateTime::Duration;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Protocol::EPP::Extensions::FCCN::Domain - FCCN (.PT) EPP Domain extension commands for Net::DRI
29  
30 =head1 DESCRIPTION
31  
32 Please see the README file for details.
33  
34 =head1 SUPPORT
35  
36 For now, support questions should be sent to:
37  
38 E<lt>netdri@dotandco.comE<gt>
39  
40 Please also see the SUPPORT file in the distribution.
41  
42 =head1 SEE ALSO
43  
44 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
45  
46 =head1 AUTHOR
47  
48 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
49  
50 =head1 COPYRIGHT
51  
52 Copyright (c) 2008,2013-2014,2016,2019 Patrick Mevzek <netdri@dotandco.com>.
53 All rights reserved.
54  
55 This program is free software; you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
57 the Free Software Foundation; either version 2 of the License, or
58 (at your option) any later version.
59  
60 See the LICENSE file that comes with this distribution for more details.
61  
62 =cut
63  
64 ####################################################################################################
65  
66 sub register_commands
67 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
68 0 my ($class,$version)=@_;
69 0 my %tmp=(
70 create => [ \&create, \&create_parse ],
71 info => [ \&info, \&info_parse ],
72 update => [ \&update ],
73 renew => [ \&renew ],
74 renounce => [ \&renounce ],
75 delete => [ \&delete ],
76 transfer_request => [ \&transfer_request ],
77 );
78  
79 0 return { 'domain' => \%tmp };
80 }
81  
82 ####################################################################################################
83  
84 sub create
85 0 ▶{
Subroutine create: not called CC=10 SCAR=47.0
Pod undocumented
86 0 my ($epp,$domain,$rd)=@_;
87  
88 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Registrant contact required for .PT domain name creation') unless (Net::DRI::Util::has_contact($rd) && $rd->{contact}->has_type('registrant'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant") 0 0 0
Condition0%0/3
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant")
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("registrant")
Net::DRI::Util::has_contact($rd) $rd->{"contact"}->has_type("registrant")
Truth table0%0/3
A and B
A= Net::DRI::Util::has_contact($rd)B= $rd->{"contact"}->has_type("registrant")
ABresult
0X0
100
111
89 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Tech contact required for .PT domain name creation') unless (Net::DRI::Util::has_contact($rd) && $rd->{contact}->has_type('tech'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("tech") 0 0 0
Condition0%0/3
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("tech")
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->has_type("tech")
Net::DRI::Util::has_contact($rd) $rd->{"contact"}->has_type("tech")
Truth table0%0/3
A and B
A= Net::DRI::Util::has_contact($rd)B= $rd->{"contact"}->has_type("tech")
ABresult
0X0
100
111
90  
91 0 foreach my $d (qw/legitimacy registration_basis auto_renew/)
92 {
93 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters($d.' attribute is mandatory for .PT domain name creation') unless Net::DRI::Util::has_key($rd,$d);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, $d) 0 0 0
94 }
95 0 foreach my $d (qw/auto_renew/)
96 {
97 0 ▶ Net::DRI::Exception::usererr_invalid_parameters($d.' must be either 0 or 1 for .PT domain name creation') unless ($rd->{$d}==0 || $rd->{$d}==1);
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{$d} == 0 or $rd->{$d} == 1 0 0 0
Condition0%0/3
$rd->{$d} == 0 or $rd->{$d} == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$rd->{$d} == 0 or $rd->{$d} == 1
$rd->{$d} == 0 $rd->{$d} == 1
Truth table0%0/3
A or B
A= $rd->{$d} == 0B= $rd->{$d} == 1
ABresult
1X1
011
000
98 }
99  
100 0 my @n;
101 0 push @n,['ptdomain:legitimacy',{type => $rd->{legitimacy}}];
102 0 push @n,['ptdomain:registration_basis',{type => $rd->{registration_basis}}];
103 0 push @n,['ptdomain:autoRenew',$rd->{auto_renew}];
104 0 $epp->message()->command_extension('ptdomain', ['create', @n]);
105 0 return;
106 }
107  
108 sub create_parse
109 0 ▶{
Subroutine create_parse: not called CC=7 SCAR=40.3
Pod undocumented
110 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
111 0 my $mes=$po->message();
112 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
113  
114 0 my $credata=$mes->get_extension('ptdomain','creData');
115 0 ▶ return unless $credata;
Branch: 1 branch
BranchTrueFalseTotal
unless $credata 0 0 0
116  
117 0 my $c=$credata->getFirstChild();
118 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
119 {
120 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
121 0 ▶ my $n=$c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
122 0 ▶ if ($n eq 'roid')
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "roid") 0 0 0
123 {
124 0 $rinfo->{domain}->{$oname}->{roid}=$c->getFirstChild()->getData();
125 }
126 0 } continue { $c=$c->getNextSibling(); }
127 0 return;
128 }
129  
130 sub add_roid
131 0 ▶{
Subroutine add_roid: not called CC=1 SCAR=6.9
Pod undocumented
132 0 my ($roid)=@_;
133 0 return ['ptdomain:roid',$roid];
134 }
135  
136 sub info
137 0 ▶{
Subroutine info: not called CC=2 SCAR=17.9
Pod undocumented
138 0 my ($epp,$domain,$rd)=@_;
139  
140 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name info') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
141  
142 0 $epp->message()->command_extension('ptdomain', ['info', add_roid($rd->{roid})]);
143 0 return;
144 }
145  
146 sub info_parse
147 0 ▶{
Subroutine info_parse: not called CC=10 SCAR=47.0
Pod undocumented
148 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
149 0 my $mes=$po->message();
150 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
151  
152 0 my $infdata=$mes->get_extension('ptdomain','infData');
153 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
154  
155 0 my $c=$infdata->getFirstChild();
156 0 ▶ while($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
157 {
158 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
159 0 ▶ my $name=$c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
160 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
161  
162 0 ▶ if ($name=~m/^(?:legitimacy|registration_basis)$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($name =~ /^(?:legitimacy|registration_basis)$/) { } 0 0 0
elsif ($name =~ /^(?:autoRenew|notRenew|nextPossibleRegistration|addPeriod|waitingRemoval)$/) { } 0 0 0
elsif ($name eq 'renew') { } 0 0 0
163 {
164 0 $rinfo->{domain}->{$oname}->{$name}=$c->getAttribute('type');
165 } elsif ($name=~m/^(?:autoRenew|notRenew|nextPossibleRegistration|addPeriod|waitingRemoval)$/)
166 {
167 0 $rinfo->{domain}->{$oname}->{Net::DRI::Util::remcam($name)}=Net::DRI::Util::xml_parse_boolean($c->getFirstChild()->getData());
168 } elsif ($name eq 'renew')
169 {
170 0 $rinfo->{domain}->{$oname}->{renew_period}=DateTime::Duration->new(years => $c->getAttribute('period'));
171 }
172 0 } continue { $c=$c->getNextSibling(); }
173 0 return;
174 }
175  
176 sub update
177 0 ▶{
Subroutine update: not called CC=2 SCAR=17.9
Pod undocumented
178 0 my ($epp,$domain,$toc,$rd)=@_;
179  
180 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name update') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
181  
182 0 $epp->message()->command_extension('ptdomain', ['update', add_roid($rd->{roid})]);
183 0 return;
184 }
185  
186 sub renew
187 0 ▶{
Subroutine renew: not called CC=9 SCAR=45.0
Pod undocumented
188 0 my ($epp,$domain,$rd)=@_;
189  
190 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name renew') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
191  
192 0 my $c=Net::DRI::Util::has_key($rd,'duration');
193 0 foreach my $d (qw/auto_renew not_renew/)
194 {
195 0 ▶ next unless Net::DRI::Util::has_key($rd,$d);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, $d) 0 0 0
196 0 ▶ Net::DRI::Exception::usererr_invalid_parameters($d.' must be either 0 or 1 for .PT domain name creation') unless ($rd->{$d}==0 || $rd->{$d}==1);
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{$d} == 0 or $rd->{$d} == 1 0 0 0
Condition0%0/3
$rd->{$d} == 0 or $rd->{$d} == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$rd->{$d} == 0 or $rd->{$d} == 1
$rd->{$d} == 0 $rd->{$d} == 1
Truth table0%0/3
A or B
A= $rd->{$d} == 0B= $rd->{$d} == 1
ABresult
1X1
011
000
197 0 $c+=$rd->{$d};
198 }
199 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('only one of duration, auto_renew and not_renew attributes can be set for .PT domain name renew') if $c > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $c > 1 0 0 0
200  
201 0 my @n=add_roid($rd->{roid});
202 0 ▶ push @n,['ptdomain:autoRenew',$rd->{auto_renew}] if Net::DRI::Util::has_key($rd,'auto_renew');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_key($rd, "auto_renew") 0 0 0
203 0 ▶ push @n,['ptdomain:notRenew',$rd->{not_renew}] if Net::DRI::Util::has_key($rd,'not_renew');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_key($rd, "not_renew") 0 0 0
204 0 $epp->message()->command_extension('ptdomain', ['renew', @n]);
205 0 return;
206 }
207  
208 sub renounce
209 0 ▶{
Subroutine renounce: not called CC=2 SCAR=17.9
Pod undocumented
210 0 my ($epp,$domain,$rd)=@_;
211  
212 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name renounce') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
213  
214 0 my $mes=$epp->message();
215 0 my @n=(['ptdomain:name',$domain]);
216 0 push @n,add_roid($rd->{roid});
217 0 push @n,['ptdomain:clTRID',$mes->cltrid()];
218 0 $mes->command_extension('ptdomain', ['renounce', @n]);
219 0 return;
220 }
221  
222 sub delete ## no critic (Subroutines::ProhibitBuiltinHomonyms)
223 0 ▶{
Subroutine delete: not called CC=2 SCAR=17.9
Pod undocumented
224 0 my ($epp,$domain,$rd)=@_;
225  
226 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('roid attribute required for .PT domain name delete') unless (Net::DRI::Util::has_key($rd,'roid'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "roid") 0 0 0
227  
228 0 $epp->message()->command_extension('ptdomain', ['delete', add_roid($rd->{roid})]);
229 0 return;
230 }
231  
232 sub transfer_request
233 0 ▶{
Subroutine transfer_request: not called CC=2 SCAR=17.9
Pod undocumented
234 0 my ($epp,$domain,$rd)=@_;
235  
236 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('you have to specify authinfo for .PT domain transfer (mapped to transferKey)') unless Net::DRI::Util::has_auth($rd);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_auth($rd) 0 0 0
237  
238 0 $epp->message()->command_extension('ptdomain', ['transfer', ['transferKey',$rd->{"auth"}->{"pw"}]]);
239 0 return;
240 }
241  
242 ####################################################################################################
243 1 1;
« DRI/Protocol/EPP/Extensions/Afilias/Trademark.pm ↑ Summary DRI/Transport.pm »