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

filter: Statementstmt 30.1% 16 / 53 Branchbran 0.0% 0 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 4 totaltotal 23.3% 21 / 90 CC 14 SCAR 36.5
CC
14
Cov
21%
info_parse
72.0
update
42.0
create
6.0
CRAP 38.5
« DRI/Protocol/AdamsNames/WS/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/ICANN/RegistrarExpirationDate.pm »
1 ## Domain Registry Interface, SIDN EPP Contact commands
2 ##
3 ## Copyright (c) 2009,2010,2013,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::SIDN::Contact;
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 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 ####################################################################################################
25  
26 sub register_commands
27 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my ($class,$version)=@_;
29  
30 0 state $contact = {
31 info => [ undef, \&info_parse ],
32 create => [ \&create, undef ],
33 update => [ \&update ],
34 };
35 0 state $commands = { 'contact' => $contact };
36  
37 0 return $commands;
38 }
39  
40 ####################################################################################################
41 ########### Query commands
42  
43 sub info_parse
44 0 ▶{
Subroutine info_parse: not called CC=8 SCAR=42.8
Pod undocumented
45 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
46 0 my $mes=$po->message();
47 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
48  
49 0 my $infdata=$mes->get_extension('sidn','ext');
50 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
51  
52 0 my $ns=$mes->ns('sidn');
53 0 $infdata=Net::DRI::Util::xml_traverse($infdata,$ns,'infData','contact');
54 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
55  
56 0 my $contact=$rinfo->{contact}->{$oname}->{self};
57  
58 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
59 {
60 0 my ($name,$c)=@$el;
61 0 ▶ if ($name eq 'legalForm')
Branch: 3 branches
BranchTrueFalseTotal
if ($name eq 'legalForm') { } 0 0 0
elsif ($name eq 'legalFormRegNo') { } 0 0 0
elsif ($name eq 'limited') { } 0 0 0
62 {
63 0 $contact->legal_form($c->textContent());
64 } elsif ($name eq 'legalFormRegNo')
65 {
66 0 $contact->legal_id($c->textContent());
67 } elsif ($name eq 'limited')
68 {
69 0 $contact->limited(Net::DRI::Util::xml_parse_boolean($c->textContent()));
70 }
71 }
72 0 return;
73 }
74  
75 ########### Transform commands
76  
77 sub create
78 0 ▶{
Subroutine create: not called CC=2 SCAR=17.9
Pod undocumented
79 0 my ($epp,$contact)=@_;
80  
81 ## $contact->validate() has been called
82 0 my @n;
83 0 push @n,['sidn:legalForm',$contact->legal_form()];
84 0 ▶ push @n,['sidn:legalFormRegNo',$contact->legal_id()] if $contact->legal_id();
Branch: 1 branch
BranchTrueFalseTotal
if $contact->legal_id 0 0 0
85  
86 0 $epp->message()->command_extension('sidn', ['ext', ['create', ['contact',@n]]]);
87 0 return;
88 }
89  
90 sub update
91 0 ▶{
Subroutine update: not called CC=6 SCAR=37.4
Pod undocumented
92 0 my ($epp,$contact,$todo)=@_;
93  
94 0 my $newc=$todo->set('info');
95 0 ▶ return unless defined $newc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $newc 0 0 0
96  
97 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',10,'Invalid contact '.$newc) unless Net::DRI::Util::isa_contact($newc,'Net::DRI::Data::Contact::SIDN');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($newc, "Net::DRI::Data::Contact::SIDN") 0 0 0
98 0 $newc->validate(1); ## will trigger an Exception if needed
99  
100 0 my @n;
101 0 ▶ push @n,['sidn:legalForm',$newc->legal_form()] if $newc->legal_form();
Branch: 1 branch
BranchTrueFalseTotal
if $newc->legal_form 0 0 0
102 0 ▶ push @n,['sidn:legalFormRegNo',$newc->legal_id()] if $newc->legal_id();
Branch: 1 branch
BranchTrueFalseTotal
if $newc->legal_id 0 0 0
103  
104 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
105  
106 0 $epp->message()->command_extension('sidn', ['ext', ['update', ['contact',@n]]]);
107 0 return;
108 }
109  
110 ####################################################################################################
111 1 1;
112  
113 __END__
« DRI/Protocol/AdamsNames/WS/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/ICANN/RegistrarExpirationDate.pm »