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

filter: Statementstmt 27.6% 13 / 47 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 44.4% 4 / 9 Podpod 0.0% 0 / 5 totaltotal 19.5% 17 / 87 CC 12 SCAR 31.0
CC
12
Cov
19%
info_parse
42.0
info
30.0
update
12.0
CRAP 22.3
« DRI/Data/Contact/BR.pm ↑ Summary DRI/Protocol/EPP/Extensions/PL/Contact.pm »
1 ## Domain Registry Interface, .CO.ZA Contact EPP extension commands
2 ## From http://registry.coza.net.za/doku.php?id=eppcontactextension
3 ##
4 ## Copyright (c) 2011,2013,2018-2019 Patrick Mevzek <netdri@dotandco.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::COZA::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  
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 0 my %tmp=(
30 info => [ \&info, \&info_parse ],
31 update => [ \&update, undef ],
32 );
33  
34 0 return { 'contact' => \%tmp };
35 }
36  
37 sub setup
38 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my ($class,$po,$version)=@_;
40 0 $po->ns({ 'cozacontact' => 'http://co.za/epp/extensions/cozacontact-1-0' });
41 0 return;
42 }
43  
44 ####################################################################################################
45  
46 sub info
47 0 ▶{
Subroutine info: not called CC=5 SCAR=34.0
Pod undocumented
48 0 my ($epp,$c,$rp)=@_;
49 0 my $mes=$epp->message();
50  
51 0 ▶ if (Net::DRI::Util::has_key($rp,'domain_listing') && $rp->{domain_listing})
Branch: 2 branches
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rp, 'domain_listing') and $rp->{'domain_listing'}) { } 0 0 0
elsif (Net::DRI::Util::has_key($rp, 'balance') and $rp->{'balance'}) { } 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rp, "domain_listing") and $rp->{"domain_listing"}
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rp, "domain_listing") and $rp->{"domain_listing"}
Net::DRI::Util::has_key($rp, "domain_listing") $rp->{"domain_listing"}
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rp, "domain_listing")B= $rp->{"domain_listing"}
ABresult
0X0
100
111
52 {
53 0 $epp->message()->command_extension('cozacontact', ['info', ['domainListing', 'true']]);
54 ▶ } elsif (Net::DRI::Util::has_key($rp,'balance') && $rp->{balance})
Condition0%0/3
Net::DRI::Util::has_key($rp, "balance") and $rp->{"balance"}
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rp, "balance") and $rp->{"balance"}
Net::DRI::Util::has_key($rp, "balance") $rp->{"balance"}
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rp, "balance")B= $rp->{"balance"}
ABresult
0X0
100
111
55 {
56 0 $epp->message()->command_extension('cozacontact', ['info', ['balance', 'true']]);
57 }
58 0 return;
59 }
60  
61 sub info_parse
62 0 ▶{
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
63 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
64 0 my $mes=$po->message();
65 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
66  
67 0 my $infdata=$mes->get_extension('cozacontact','infData');
68 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
69  
70 0 my %l;
71 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
72 {
73 0 my ($name,$node)=@$el;
74 0 ▶ next unless $name eq 'domain';
Branch: 1 branch
BranchTrueFalseTotal
unless $name eq "domain" 0 0 0
75 0 push @{$l{lc $node->getAttribute('level')}},$node->textContent();
76 }
77 0 $rinfo->{contact}->{$oname}->{domain_listing}=\%l;
78  
79 0 my $ns=$mes->ns('cozacontact');
80 0 my $balance=Net::DRI::Util::xml_traverse($infdata,$ns,'balance');
81 0 ▶ $rinfo->{registrar}->{$oname}->{balance}=0+$balance->textContent() if defined $balance;
Branch: 1 branch
BranchTrueFalseTotal
if defined $balance 0 0 0
82 0 return;
83 }
84  
85 sub update
86 0 ▶{
Subroutine update: not called CC=3 SCAR=24.8
Pod undocumented
87 0 my ($epp,$c,$todo)=@_;
88  
89 0 my $cancel=$todo->set('cancel_action');
90 0 ▶ return unless defined $cancel;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cancel 0 0 0
91  
92 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('cancel_action parameter must be PendingUpdate') unless $cancel=~m/^Pending(?:Update)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $cancel =~ /^Pending(?:Update)$/ 0 0 0
93 0 $epp->message()->command_extension('cozacontact', ['update', {cancelPendingAction=>$cancel}]);
94 0 return;
95 }
96  
97 ####################################################################################################
98 1 1;
99  
100 __END__
« DRI/Data/Contact/BR.pm ↑ Summary DRI/Protocol/EPP/Extensions/PL/Contact.pm »