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

filter: Statementstmt 33.9% 19 / 56 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 4 totaltotal 23.5% 25 / 106 CC 16 SCAR 41.0
CC
16
Cov
22%
check
110.0
check_parse
56.0
register_commands
2.0
CRAP 60.1
« DRI/Logging/Syslog.pm ↑ Summary DRI/Protocol/Whois/Domain/PT.pm »
1 ## Domain Registry Interface, CentralNic EPP Pricing extension
2 ## From https://www.centralnic.com/company/labs/epp/ext/pricing
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::CentralNic::Pricing;
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  
25 1 ▶use DateTime::Duration;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 =pod
28  
29 =head1 NAME
30  
31 Net::DRI::Protocol::EPP::Extensions::CentralNic::Pricing - CentralNic EPP Pricing extension commands for Net::DRI
32  
33 =head1 DESCRIPTION
34  
35 Please see the README file for details.
36  
37 =head1 SUPPORT
38  
39 For now, support questions should be sent to:
40  
41 E<lt>netdri@dotandco.comE<gt>
42  
43 Please also see the SUPPORT file in the distribution.
44  
45 =head1 SEE ALSO
46  
47 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
48  
49 =head1 AUTHOR
50  
51 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
52  
53 =head1 COPYRIGHT
54  
55 Copyright (c) 2011,2013,2018-2019 Patrick Mevzek <netdri@dotandco.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  
69 sub register_commands
70 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my ($class,$version)=@_;
72 0 my %tmp=(
73 check => [ \&check, \&check_parse ],
74 );
75 0 return { 'domain' => \%tmp };
76 }
77  
78 sub setup
79 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
80 0 my ($class,$po,$version)=@_;
81 0 $po->ns({ 'pricing' => 'urn:centralnic:params:xml:ns:pricing-1.0' });
82 0 return;
83 }
84  
85 ####################################################################################################
86  
87 sub check
88 0 ▶{
Subroutine check: not called CC=10 SCAR=47.0
Pod undocumented
89 0 my ($epp,$domain,$rd)=@_;
90 0 my $mes=$epp->message();
91  
92 0 ▶ return unless Net::DRI::Util::has_key($rd,'pricing');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "pricing") 0 0 0
93  
94 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('pricing extension can be used only with one domain:name in check operation') if (ref $domain && @$domain > 1);
Branch: 1 branch
BranchTrueFalseTotal
if ref $domain and @$domain > 1 0 0 0
Condition0%0/3
ref $domain and @$domain > 1
!ll&&!rl&&r
000
MC/DC0%0/2
ref $domain and @$domain > 1
ref $domain @$domain > 1
Truth table0%0/3
A and B
A= ref $domainB= @$domain > 1
ABresult
0X0
100
111
95 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('For "pricing" key parameter the value must be a ref hash with keys: currency, action, duration') unless Net::DRI::Util::has_key($rd->{pricing},'currency') && Net::DRI::Util::has_key($rd->{pricing},'action') && Net::DRI::Util::has_key($rd->{pricing},'duration');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd->{"pricing"}, "currency") and Net::DRI::Util::has_key($rd->{"pricing"}, "action") and Net::DRI::Util::has_key($rd->{"pricing"}, "duration") 0 0 0
Condition0%0/6
Net::DRI::Util::has_key($rd->{"pricing"}, "currency") and Net::DRI::Util::has_key($rd->{"pricing"}, "action") and Net::DRI::Util::has_key($rd->{"pricing"}, "duration")
!ll&&!rl&&r
000
Net::DRI::Util::has_key($rd->{"pricing"}, "currency") and Net::DRI::Util::has_key($rd->{"pricing"}, "action")
!ll&&!rl&&r
000
MC/DC0%0/3
Net::DRI::Util::has_key($rd->{"pricing"}, "currency") and Net::DRI::Util::has_key($rd->{"pricing"}, "action") and Net::DRI::Util::has_key($rd->{"pricing"}, "duration")
Net::DRI::Util::has_key($rd->{"pricing"}, "currency") Net::DRI::Util::has_key($rd->{"pricing"}, "action") Net::DRI::Util::has_key($rd->{"pricing"}, "duration")
Truth table0%0/4
A and B and C
A= Net::DRI::Util::has_key($rd->{"pricing"}, "currency")B= Net::DRI::Util::has_key($rd->{"pricing"}, "action")C= Net::DRI::Util::has_key($rd->{"pricing"}, "duration")
ABCresult
0XX0
10X0
1100
1111
96  
97 0 my @n;
98 0 my $rp=$rd->{pricing};
99 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('currency should be 3 letters ISO-4217 code') unless $rp->{currency}=~m/^[A-Z]{3}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $rp->{"currency"} =~ /^[A-Z]{3}$/ 0 0 0
100 0 push @n,['pricing:currency',$rp->{currency}];
101 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('action should be: create, transfer, renew or restore') unless $rp->{action}=~m/^(?:create|transfer|renew|restore)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $rp->{"action"} =~ /^(?:create|transfer|renew|restore)$/ 0 0 0
102 0 push @n,['pricing:action',$rp->{action}];
103 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('duration should be a DateTime::Duration object') unless Net::DRI::Util::is_class($rp->{duration},'DateTime::Duration');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_class($rp->{"duration"}, "DateTime::Duration") 0 0 0
104 0 my $rj=Net::DRI::Protocol::EPP::Util::build_period($rp->{duration});
105 0 push @n,['pricing:period',$rj->[1],$rj->[2]];
106  
107 0 $epp->message()->command_extension('pricing', ['check', @n]);
108 0 return;
109 }
110  
111 sub check_parse
112 0 ▶{
Subroutine check_parse: not called CC=7 SCAR=40.3
Pod undocumented
113 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
114 0 my $mes=$po->message();
115 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
116  
117 0 my $chkdata=$mes->get_extension('pricing','chkData');
118 0 ▶ return unless $chkdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $chkdata 0 0 0
119  
120 0 my %p;
121 0 foreach my $el (Net::DRI::Util::xml_list_children($chkdata))
122 {
123 0 my ($name,$node)=@$el;
124 0 ▶ if ($name=~m/^(currency|action)$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($name =~ /^(currency|action)$/) { } 0 0 0
elsif ($name eq 'period') { } 0 0 0
elsif ($name eq 'price') { } 0 0 0
125 {
126 0 $p{$1}=$node->textContent();
127 } elsif ($name eq 'period')
128 {
129 0 my $unit={y=>'years',m=>'months'}->{$node->getAttribute('unit')};
130 0 $p{duration}=DateTime::Duration->new($unit => 0+$node->textContent());
131 } elsif ($name eq 'price')
132 {
133 0 $p{price}=0+$node->textContent();
134 }
135 }
136  
137 0 $rinfo->{domain}->{$oname}->{pricing}=\%p;
138 0 return;
139 }
140  
141 ####################################################################################################
142 1 1;
« DRI/Logging/Syslog.pm ↑ Summary DRI/Protocol/Whois/Domain/PT.pm »