DRI/Protocol/EPP/Extensions/AusRegistry/Price.pm

filter: Statementstmt 30.1% 19 / 63 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 6 / 16 Podpod 0.0% 0 / 9 totaltotal 20.6% 25 / 121 CC 18 SCAR 35.0
CC
18
Cov
20%
check_parse
90.0
_build
30.0
check_build
20.0
CRAP 33.2
« DRI/Protocol/Gandi/WS/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/EURid/Notifications.pm »
1 ## Domain Registry Interface, Price Extension Mapping for EPP
2 ##
3 ## Copyright (c) 2015,2018-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::AusRegistry::Price;
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 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 ####################################################################################################
26  
27 sub register_commands
28 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my ($class,$version)=@_;
30  
31 0 state $rops = { 'domain' => { check => [ \&check_build, \&check_parse ],
32 check_multi => [ \&check_build, \&check_parse ],
33 create => [ \&create_build, undef ],
34 renew => [ \&renew_build, undef ],
35 transfer_request => [ \&transfer_build, undef ],
36 update => [ \&update_build, undef ],
37 }
38 };
39  
40 0 return $rops;
41 }
42  
43 sub setup
44 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
45 0 my ($class,$po,$version)=@_;
46 0 state $ns = { 'price' => 'urn:ar:params:xml:ns:price-1.2' };
47 0 $po->ns($ns);
48 0 return;
49 }
50  
51 0 ▶sub implements { return 'https://ausregistry.github.io/doc/price-1.2/price-1.2.html'; }
Subroutine implements: not called CC=1 SCAR=6.9
Pod undocumented
52  
53 ####################################################################################################
54  
55 sub check_build
56 0 ▶{
Subroutine check_build: not called CC=4 SCAR=30.0
Pod undocumented
57 0 my ($epp,$domain,$rp)=@_;
58  
59 0 ▶ return unless Net::DRI::Util::has_key($rp,'price');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rp, "price") 0 0 0
60 0 ▶ return unless $rp->{price};
Branch: 1 branch
BranchTrueFalseTotal
unless $rp->{"price"} 0 0 0
61  
62 0 ▶ $epp->message()->command_extension('price', ['check', Net::DRI::Protocol::EPP::Util::build_period($rp->{price}, 'price')]) if Net::DRI::Util::is_class($rp->{price}, 'DateTime::Duration');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::is_class($rp->{"price"}, "DateTime::Duration") 0 0 0
63  
64 0 return;
65 }
66  
67 sub check_parse
68 0 ▶{
Subroutine check_parse: not called CC=9 SCAR=45.0
Pod undocumented
69 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
70 0 my $mes=$po->message();
71 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
72  
73 0 my $data=$mes->get_extension('price','chkData');
74 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
75  
76 0 foreach my $cd (grep { $_->[0] eq 'cd' } Net::DRI::Util::xml_list_children($data))
77 {
78 0 my ($domain,%p);
79 0 foreach my $el (Net::DRI::Util::xml_list_children($cd->[1]))
80 {
81 0 my ($name,$node)=@$el;
82 0 ▶ if ($name eq 'name')
Branch: 4 branches
BranchTrueFalseTotal
if ($name eq 'name') { } 0 0 0
elsif ($name =~ /^(category|reason)$/) { } 0 0 0
elsif ($name eq 'period') { } 0 0 0
elsif ($name =~ /^(create|renew|transfer|restore)Price$/) { } 0 0 0
83 {
84 0 $domain=$node->textContent();
85 } elsif ($name=~m/^(category|reason)$/)
86 {
87 0 $p{$name}=$node->textContent();
88 } elsif ($name eq 'period')
89 {
90 0 state $rperiods={qw/y years m months/};
91 0 $p{duration}=$po->create_local_object('duration',$rperiods->{$node->getAttribute('unit')},$node->textContent());
92 } elsif ($name=~m/^(create|renew|transfer|restore)Price$/)
93 {
94 0 $p{$1}=0+$node->textContent();
95 }
96 }
97 0 $rinfo->{$otype}->{$domain}->{price}=\%p;
98 }
99  
100 0 return;
101 }
102  
103 sub _build
104 0 ▶{
Subroutine _build: not called CC=5 SCAR=34.0
105 0 my ($epp,$domain,$rp,$topname)=@_;
106  
107 0 ▶ return unless Net::DRI::Util::has_key($rp,'price');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rp, "price") 0 0 0
108 0 ▶ return unless $rp->{price};
Branch: 1 branch
BranchTrueFalseTotal
unless $rp->{"price"} 0 0 0
109 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('if provided, price element must be "ack" or a decimal number') unless $rp->{price}=~m/^(?:ack|\d+(?:\.\d+)?)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $rp->{"price"} =~ /^(?:ack|\d+(?:\.\d+)?)$/ 0 0 0
110  
111 0 ▶ $epp->message()->command_extension('price', [$topname, ['ack', $rp->{price} ne 'ack' ? ['price', 0+$rp->{price}] : ()]]);
Branch: 1 branch
BranchTrueFalseTotal
$rp->{'price'} ne 'ack' ? : 0 0 0
112 0 return;
113 }
114  
115 0 ▶sub create_build { return _build(@_,'create'); } ## no critic (Subroutines::RequireArgUnpacking)
Subroutine create_build: not called CC=1 SCAR=6.9
Pod undocumented
116 0 ▶sub renew_build { return _build(@_,'renew'); } ## no critic (Subroutines::RequireArgUnpacking)
Subroutine renew_build: not called CC=1 SCAR=6.9
Pod undocumented
117 0 ▶sub transfer_build { return _build(@_,'transfer'); } ## no critic (Subroutines::RequireArgUnpacking)
Subroutine transfer_build: not called CC=1 SCAR=6.9
Pod undocumented
118  
119 sub update_build
120 0 ▶{
Subroutine update_build: not called CC=3 SCAR=24.8
Pod undocumented
121 0 my ($epp,$domain,$todo,$rp)=@_;
122 0 my $rgp=$todo->set('rgp');
123 0 ▶ return unless Net::DRI::Util::has_key($rgp,'op') && $rgp->{op} eq 'request';
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rgp, "op") and $rgp->{"op"} eq "request" 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rgp, "op") and $rgp->{"op"} eq "request"
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rgp, "op") and $rgp->{"op"} eq "request"
Net::DRI::Util::has_key($rgp, "op") $rgp->{"op"} eq "request"
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rgp, "op")B= $rgp->{"op"} eq "request"
ABresult
0X0
100
111
124 0 return _build($epp,$domain,$rp,'update');
125 }
126  
127 ####################################################################################################
128 1 1;
129  
130 __END__
« DRI/Protocol/Gandi/WS/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/EURid/Notifications.pm »