DRI/Protocol/EPP/Extensions/Nominet/Contact.pm

filter: Statementstmt 25.6% 19 / 74 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 46.1% 6 / 13 Podpod 0.0% 0 / 7 totaltotal 18.8% 25 / 133 CC 21 SCAR 33.5
CC
21
Cov
17%
info_parse
72.0
contact_nom_ext
30.0
fork
20.0
CRAP 28.5
« DRI/Protocol/RRI/Session.pm ↑ Summary DRI/Protocol/EPP/Extensions/IDN.pm »
1 ## Domain Registry Interface, .UK EPP Contact commands
2 ##
3 ## Copyright (c) 2008-2010,2013-2014,2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ## (c) 2013 Michael Holloway <michael@thedarkwinter.com>. All rights reserved.
5 ##
6 ## This file is part of Net::DRI
7 ##
8 ## Net::DRI is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12 ##
13 ## See the LICENSE file that comes with this distribution for more details.
14 ####################################################################################################
15  
16 package Net::DRI::Protocol::EPP::Extensions::Nominet::Contact;
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::DRI::Protocol::EPP::Core::Contact;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 =pod
27  
28 =head1 NAME
29  
30 Net::DRI::Protocol::EPP::Extensions::Nominet::Contact - .UK EPP Contact commands for Net::DRI
31  
32 =head1 DESCRIPTION
33  
34 Please see the README file for details.
35  
36 =head1 SUPPORT
37  
38 For now, support questions should be sent to:
39  
40 E<lt>netdri@dotandco.comE<gt>
41  
42 Please also see the SUPPORT file in the distribution.
43  
44 =head1 SEE ALSO
45  
46 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
47  
48 =head1 AUTHOR
49  
50 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
51  
52 =head1 COPYRIGHT
53  
54 Copyright (c) 2008-2010,2013-2014,2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>.
55 (c) 2013 Michael Holloway <michael@thedarkwinter.com>.
56 All rights reserved.
57  
58 This program is free software; you can redistribute it and/or modify
59 it under the terms of the GNU General Public License as published by
60 the Free Software Foundation; either version 2 of the License, or
61 (at your option) any later version.
62  
63 See the LICENSE file that comes with this distribution for more details.
64  
65 =cut
66  
67 ####################################################################################################
68 sub register_commands
69 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my ($class,$version)=@_;
71 0 my %tmp=(
72 info => [ undef, \&info_parse ],
73 create => [ \&create ],
74 update => [ \&update ],
75 fork => [ \&fork, \&Net::DRI::Protocol::EPP::Core::Contact::create_parse ],
76 lock => [ \&lock ],
77 );
78  
79 0 return { 'contact' => \%tmp };
80 }
81  
82 ####################################################################################################
83 ########### Query commands
84  
85 sub info_parse
86 0 ▶{
Subroutine info_parse: not called CC=8 SCAR=42.8
Pod undocumented
87 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
88 0 my $mes=$po->message();
89 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
90  
91 0 my $infdata=$mes->get_extension('contact-nom-ext','infData');
92 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
93  
94 0 my $s=$rinfo->{contact}->{$oname}->{self};
95 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
96 {
97 0 my ($name,$c)=@$el;
98 0 ▶ $s->type($c->textContent()) if $name eq 'type';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "type" 0 0 0
99 0 ▶ $s->co_no($c->textContent()) if $name eq 'co-no';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "co-no" 0 0 0
100 0 ▶ $s->opt_out($c->textContent()) if $name eq 'opt-out';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "opt-out" 0 0 0
101 0 ▶ $s->trad_name($c->textContent()) if $name eq 'trad-name';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "trad-name" 0 0 0
102 }
103 0 return;
104 }
105  
106 ############ Transform commands ####################################################################
107  
108 sub contact_nom_ext
109 0 ▶{
Subroutine contact_nom_ext: not called CC=5 SCAR=34.0
Pod undocumented
110 0 my $c=shift;
111 0 my @n;
112 0 ▶ push @n, ['contact-nom-ext:trad-name', $c->trad_name()] if defined $c->trad_name();
Branch: 1 branch
BranchTrueFalseTotal
if defined $c->trad_name 0 0 0
113 0 ▶ push @n, ['contact-nom-ext:type', $c->type()] if defined $c->type();
Branch: 1 branch
BranchTrueFalseTotal
if defined $c->type 0 0 0
114 0 ▶ push @n, ['contact-nom-ext:co-no', $c->co_no()] if defined $c->co_no();
Branch: 1 branch
BranchTrueFalseTotal
if defined $c->co_no 0 0 0
115 0 ▶ push @n, ['contact-nom-ext:opt-out', $c->opt_out()] if defined $c->opt_out();
Branch: 1 branch
BranchTrueFalseTotal
if defined $c->opt_out 0 0 0
116 0 return @n;
117 }
118  
119 sub create
120 0 ▶{
Subroutine create: not called CC=2 SCAR=17.9
Pod undocumented
121 0 my ($epp,$c)=@_;
122 0 my @n = contact_nom_ext($c);
123 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
124 0 $epp->message()->command_extension('contact-nom-ext', ['create', @n]);
125 0 return;
126 }
127  
128 sub update
129 0 ▶{
Subroutine update: not called CC=3 SCAR=24.8
Pod undocumented
130 # I don't think name/org can be updated so this should be checked and return an exception. If they are the same then just remove from the changes
131 0 my ($epp,$c,$todo)=@_;
132 0 my $tochg = $todo->set('info');
133 0 ▶ return unless $tochg;
Branch: 1 branch
BranchTrueFalseTotal
unless $tochg 0 0 0
134 0 my @n = contact_nom_ext($tochg);
135 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
136 0 $epp->message()->command_extension('contact-nom-ext', ['update', @n]);
137 0 return;
138 }
139  
140 sub fork ## no critic (Subroutines::ProhibitBuiltinHomonyms)
141 0 ▶{
Subroutine fork: not called CC=4 SCAR=30.0
Pod undocumented
142 0 my ($epp,$c,$rd)=@_;
143 0 my $mes=$epp->message();
144 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Contact srID is required') unless $c->srid();
Branch: 1 branch
BranchTrueFalseTotal
unless $c->srid 0 0 0
145 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('newContactID is required') unless $rd->{newContactId};
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"newContactId"} 0 0 0
146 0 $mes->command(['update','f:fork',sprintf('xmlns:f="%s"',$mes->ns('std-fork'))]);
147 0 my @doms = @{$rd->{domains}};
148 0 my @d=(['f:contactID',$c->srid()],['f:newContactId',$rd->{newContactId}]);
149 0 foreach (@doms) { push @d,['f:domainName',$_]; }
150 0 $mes->command_body(\@d);
151 0 return;
152 }
153  
154 sub lock ## no critic (Subroutines::ProhibitBuiltinHomonyms)
155 0 ▶{
Subroutine lock: not called CC=4 SCAR=30.0
Pod undocumented
156 0 my ($epp,$c,$rd)=@_;
157 0 my $mes=$epp->message();
158 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Contact srID is required') unless $c->srid();
Branch: 1 branch
BranchTrueFalseTotal
unless $c->srid 0 0 0
159 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('type must be set to investigation OR opt-out to lock a contact') unless $rd->{type} && $rd->{type} =~ m/^(investigation|opt-out)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"type"} and $rd->{"type"} =~ /^(investigation|opt-out)$/ 0 0 0
Condition0%0/3
$rd->{"type"} and $rd->{"type"} =~ /^(investigation|opt-out)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$rd->{"type"} and $rd->{"type"} =~ /^(investigation|opt-out)$/
$rd->{"type"} $rd->{"type"} =~ /^(investigation|opt-out)$/
Truth table0%0/3
A and B
A= $rd->{"type"}B= $rd->{"type"} =~ /^(investigation|opt-out)$/
ABresult
0X0
100
111
160 0 $mes->command(['update','l:lock',sprintf('xmlns:l="%s"',$mes->ns('std-locks')). ' object="contact" type="'.$rd->{type}.'"']);
161 0 my @d=(['l:contactId',$c->srid()]);
162 0 $mes->command_body(\@d);
163 0 return;
164 }
165  
166 ####################################################################################################
167 1 1;
« DRI/Protocol/RRI/Session.pm ↑ Summary DRI/Protocol/EPP/Extensions/IDN.pm »