| 1 | ## Domain Registry Interface, .UK EPP Contact commands | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2008-2010,2013-2014,2016,2018 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 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 | { | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | my ($class,$version)=@_; | ||||||||||||||||||||||||||
|
Subroutine
register_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 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 | { | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
info_parse: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 89 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | my $infdata=$mes->get_extension('contact-nom-ext','infData'); | |||||||||||||||||||||||||||
| 92 | 0 | ▶ | return unless $infdata; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $s->co_no($c->textContent()) if $name eq 'co-no'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $s->opt_out($c->textContent()) if $name eq 'opt-out'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $s->trad_name($c->textContent()) if $name eq 'trad-name'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | 0 | return; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | ############ Transform commands #################################################################### | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub contact_nom_ext | ||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | my $c=shift; | ||||||||||||||||||||||||||
|
Subroutine
contact_nom_ext: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 111 | 0 | my @n; | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | push @n, ['contact-nom-ext:trad-name', $c->trad_name()] if defined $c->trad_name(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | push @n, ['contact-nom-ext:type', $c->type()] if defined $c->type(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | push @n, ['contact-nom-ext:co-no', $c->co_no()] if defined $c->co_no(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | push @n, ['contact-nom-ext:opt-out', $c->opt_out()] if defined $c->opt_out(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | return @n; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | sub create | ||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my ($epp,$c)=@_; | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 122 | 0 | my @n = contact_nom_ext($c); | |||||||||||||||||||||||||||
| 123 | 0 | ▶ | return unless @n; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | my $mes=$epp->message(); | |||||||||||||||||||||||||||
| 125 | 0 | my $eid=$mes->command_extension_register('contact-nom-ext', 'create'); | |||||||||||||||||||||||||||
| 126 | 0 | $mes->command_extension($eid,\@n); | |||||||||||||||||||||||||||
| 127 | 0 | return; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | sub update | ||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||
| 132 | # 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 | ||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my ($epp,$c,$todo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
update: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 134 | 0 | my $tochg = $todo->set('info'); | |||||||||||||||||||||||||||
| 135 | 0 | ▶ | return unless $tochg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 0 | my @n = contact_nom_ext($tochg); | |||||||||||||||||||||||||||
| 137 | 0 | ▶ | return unless @n; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | my $mes=$epp->message(); | |||||||||||||||||||||||||||
| 139 | 0 | my $eid=$mes->command_extension_register('contact-nom-ext', 'update'); | |||||||||||||||||||||||||||
| 140 | 0 | $mes->command_extension($eid,\@n); | |||||||||||||||||||||||||||
| 141 | 0 | return; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | sub fork ## no critic (Subroutines::ProhibitBuiltinHomonyms) | ||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my ($epp,$c,$rd)=@_; | ||||||||||||||||||||||||||
|
Subroutine
fork: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 147 | 0 | my $mes=$epp->message(); | |||||||||||||||||||||||||||
| 148 | 0 | ▶ | Net::DRI::Exception::usererr_insufficient_parameters('Contact srID is required') unless $c->srid(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | Net::DRI::Exception::usererr_insufficient_parameters('newContactID is required') unless $rd->{newContactId}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | $mes->command(['update','f:fork',sprintf('xmlns:f="%s"',$mes->ns('std-fork'))]); | |||||||||||||||||||||||||||
| 151 | 0 | my @doms = @{$rd->{domains}}; | |||||||||||||||||||||||||||
| 152 | 0 | my @d=(['f:contactID',$c->srid()],['f:newContactId',$rd->{newContactId}]); | |||||||||||||||||||||||||||
| 153 | 0 | foreach (@doms) { push @d,['f:domainName',$_]; } | |||||||||||||||||||||||||||
| 154 | 0 | $mes->command_body(\@d); | |||||||||||||||||||||||||||
| 155 | 0 | return; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | sub lock ## no critic (Subroutines::ProhibitBuiltinHomonyms) | ||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | my ($epp,$c,$rd)=@_; | ||||||||||||||||||||||||||
|
Subroutine
lock: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 161 | 0 | my $mes=$epp->message(); | |||||||||||||||||||||||||||
| 162 | 0 | ▶ | Net::DRI::Exception::usererr_insufficient_parameters('Contact srID is required') unless $c->srid(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 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
Condition0%0/3
$rd->{"type"} and $rd->{"type"} =~ /^(investigation|opt-out)$/
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)$/
| |||||||||||||||||||||||||||||
| 164 | 0 | $mes->command(['update','l:lock',sprintf('xmlns:l="%s"',$mes->ns('std-locks')). ' object="contact" type="'.$rd->{type}.'"']); | |||||||||||||||||||||||||||
| 165 | 0 | my @d=(['l:contactId',$c->srid()]); | |||||||||||||||||||||||||||
| 166 | 0 | $mes->command_body(\@d); | |||||||||||||||||||||||||||
| 167 | 0 | return; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | #################################################################################################### | ||||||||||||||||||||||||||||
| 171 | 1 | 1; | |||||||||||||||||||||||||||