DRI/Protocol/EPP/Extensions/CentralNic/AuxContact.pm

filter: Statementstmt 18.3% 13 / 71 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 6 totaltotal 14.7% 17 / 115 CC 15 SCAR 33.4
CC
15
Cov
14%
update
56.0
info_parse
42.0
create
12.0
CRAP 28.1
« DRI/Protocol/EPP/Extensions/VeriSign/PollRGP.pm ↑ Summary DRI/Protocol/EPP/Extensions/CentralNic/TTL.pm »
1 ## Domain Registry Interface, Auxiliary Contacts Extension Mapping for EPP
2 ##
3 ## Copyright (c) 2016,2018 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::CentralNic::AuxContact;
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 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 ####################################################################################################
24  
25 sub register_commands
26 {
27 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
28 0 state $rcmds = { 'domain' => {
29 'info' => [ undef, \&info_parse ],
30 'create' => [ \&create, undef ],
31 'update' => [ \&update, undef ],
32 },
33 };
34 0 return $rcmds;
35 }
36  
37 sub setup
38 {
39 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
40 0 state $rns = { 'auxcontact' => 'urn:ietf:params:xml:ns:auxcontact-0.1' };
41 0 $po->ns($rns);
42 0 return;
43 }
44  
45 0 ▶sub implements { return 'https://gitlab.centralnic.com/centralnic/epp-auxcontact-extension/blob/1b7a0e935523b306387d236908017ea7ba72f794/draft-brown-auxcontact.txt'; }
Subroutine implements: not called CC=1 SCAR=6.9
Pod undocumented
46  
47 ####################################################################################################
48  
49 sub info_parse
50 {
51 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
52 0 my $mes=$po->message();
53 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
54  
55 0 my $ns=$mes->ns('auxcontact');
56 0 my $data=$mes->get_extension('auxcontact', 'infData');
57 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
58  
59 0 my $cs=$rinfo->{domain}->{$oname}->{contact};
60 0 my %ccache=map { $_->id() => $_ } $cs->get_all();
61 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
62 {
63 0 my ($name,$node)=@$el;
64 0 ▶ if ($name eq 'contact')
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "contact") 0 0 0
65 {
66 0 my $id=$node->textContent();
67 0 ▶ $ccache{$id}=$po->create_local_object('contact')->srid($id) unless exists $ccache{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ccache{$id} 0 0 0
68 0 $cs->add($ccache{$id},$node->getAttribute('type'));
69 }
70 }
71  
72 0 return;
73 }
74  
75 sub _build_contacts
76 {
77 0 ▶ my ($epp, $cs) = @_;
Subroutine _build_contacts: not called CC=2 SCAR=17.9
78  
79 0 my @d;
80 0 my %r=map { $_ => 1 } ('registrant', $epp->core_contact_types());
81 0 foreach my $t (sort { $a cmp $b } grep { ! exists $r{$_} } $cs->types())
82 {
83 0 my @o=$cs->get($t);
84 0 push @d,map { [ 'auxcontact:contact',$_->srid(),{'type'=>$t}] } @o;
85 }
86  
87 0 return @d;
88 }
89  
90 sub create
91 {
92 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create: not called CC=3 SCAR=24.8
Pod undocumented
93  
94 0 ▶ return unless Net::DRI::Util::has_contact($rd);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) 0 0 0
95 0 my $cs=$rd->{contact};
96  
97 0 my @d = _build_contacts($epp, $cs);
98 0 ▶ return unless @d;
Branch: 1 branch
BranchTrueFalseTotal
unless @d 0 0 0
99  
100 0 my $mes=$epp->message();
101 0 my $eid=$mes->command_extension_register('auxcontact', 'create');
102 0 $mes->command_extension($eid, \@d);
103 0 return;
104 }
105  
106 sub update
107 {
108 0 ▶ my ($epp,$domain,$todo)=@_;
Subroutine update: not called CC=7 SCAR=40.3
Pod undocumented
109  
110 0 my $cadd=$todo->add('contact');
111 0 my $cdel=$todo->del('contact');
112 0 my (@add,@del);
113 0 ▶ push @add,_build_contacts($epp,$cadd) if Net::DRI::Util::isa_contactset($cadd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::isa_contactset($cadd) 0 0 0
114 0 ▶ push @del,_build_contacts($epp,$cdel) if Net::DRI::Util::isa_contactset($cdel);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::isa_contactset($cdel) 0 0 0
115  
116 0 ▶ return unless @add || @del;
Branch: 1 branch
BranchTrueFalseTotal
unless @add or @del 0 0 0
Condition0%0/3
@add or @del
l!l&&r!l&&!r
000
MC/DC0%0/2
@add or @del
@add @del
Truth table0%0/3
A or B
A= @addB= @del
ABresult
1X1
011
000
117  
118 0 my @d;
119 0 ▶ push @d,['auxcontact:rem',@del] if @del;
Branch: 1 branch
BranchTrueFalseTotal
if @del 0 0 0
120 0 ▶ push @d,['auxcontact:add',@add] if @add;
Branch: 1 branch
BranchTrueFalseTotal
if @add 0 0 0
121  
122 0 my $mes=$epp->message();
123 0 my $eid=$mes->command_extension_register('auxcontact', 'update');
124 0 $mes->command_extension($eid, \@d);
125 0 return;
126 }
127  
128 ####################################################################################################
129 1 1;
130  
131 __END__
132  
133 =pod
134  
135 =head1 NAME
136  
137 Net::DRI::Protocol::EPP::Extensions::CentralNic::AuxContact - EPP Auxiliary Contacts Extension mapping (draft-brown-epp-auxcontact-00) for Net::DRI
138  
139 =head1 DESCRIPTION
140  
141 Please see the README file for details.
142  
143 =head1 SUPPORT
144  
145 For now, support questions should be sent to:
146  
147 E<lt>netdri@dotandco.comE<gt>
148  
149 Please also see the SUPPORT file in the distribution.
150  
151 =head1 SEE ALSO
152  
153 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
154  
155 =head1 AUTHOR
156  
157 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
158  
159 =head1 COPYRIGHT
160  
161 Copyright (c) 2016,2018 Patrick Mevzek <netdri@dotandco.com>.
162 All rights reserved.
163  
164 This program is free software; you can redistribute it and/or modify
165 it under the terms of the GNU General Public License as published by
166 the Free Software Foundation; either version 2 of the License, or
167 (at your option) any later version.
168  
169 See the LICENSE file that comes with this distribution for more details.
170  
171 =cut
« DRI/Protocol/EPP/Extensions/VeriSign/PollRGP.pm ↑ Summary DRI/Protocol/EPP/Extensions/CentralNic/TTL.pm »