DRI/Protocol/EPP/Extensions/Afilias/IPR.pm

filter: Statementstmt 16.6% 10 / 60 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 37.5% 3 / 8 Podpod 0.0% 0 / 5 totaltotal 12.1% 13 / 107 CC 19 SCAR 40.2
CC
19
Cov
11%
build_ipr
110.0
info_parse
42.0
update
20.0
CRAP 55.7
« DRI/Protocol/EPP/Extensions/AT/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/VeriSign/PollLowBalance.pm »
1 ## Domain Registry Interface, Afilias IPR extension (for .ME and .ASIA)
2 ##
3 ## Copyright (c) 2010,2013 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::Afilias::IPR;
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  
20 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 ####################################################################################################
23  
24 sub register_commands
25 {
26 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
27 0 my %tmp=(
28 create => [ \&create, undef ],
29 update => [ \&update, undef ],
30 info => [ undef, \&info_parse ],
31 );
32  
33 0 return { 'domain' => \%tmp };
34 }
35  
36 ## Namespace should be set in calling superclass, as it differs in .ASIA & .ME
37  
38 ####################################################################################################
39  
40 sub build_ipr
41 {
42 0 ▶ my ($ipr)=@_;
Subroutine build_ipr: not called CC=10 SCAR=47.0
Pod undocumented
43  
44 0 my @iprdata;
45 0 foreach my $k (qw/name ccLocality number/)
46 {
47 0 ▶ my $kk=($k eq 'ccLocality') ? 'cc' : $k;
Branch: 1 branch
BranchTrueFalseTotal
$k eq 'ccLocality' ? : 0 0 0
48 0 ▶ next unless exists $ipr->{$kk} && length $ipr->{$kk};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ipr->{$kk} and length $ipr->{$kk} 0 0 0
Condition0%0/3
exists $ipr->{$kk} and length $ipr->{$kk}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ipr->{$kk} and length $ipr->{$kk}
exists $ipr->{$kk} length $ipr->{$kk}
Truth table0%0/3
A and B
A= exists $ipr->{$kk}B= length $ipr->{$kk}
ABresult
0X0
100
111
49 0 push @iprdata,['ipr:'.$k,$ipr->{$kk}];
50 }
51 0 foreach my $k (qw/appDate regDate/)
52 {
53 0 ▶ next unless exists $ipr->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ipr->{$k} 0 0 0
54 0 Net::DRI::Util::check_isa($ipr->{$k},'DateTime');
55 0 push @iprdata,['ipr:'.$k,$ipr->{$k}->set_time_zone('UTC')->ymd()];
56 }
57 0 foreach my $k (qw/class entitlement form type preVerified/)
58 {
59 0 ▶ next unless exists $ipr->{$k} && length $ipr->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ipr->{$k} and length $ipr->{$k} 0 0 0
Condition0%0/3
exists $ipr->{$k} and length $ipr->{$k}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ipr->{$k} and length $ipr->{$k}
exists $ipr->{$k} length $ipr->{$k}
Truth table0%0/3
A and B
A= exists $ipr->{$k}B= length $ipr->{$k}
ABresult
0X0
100
111
60 0 push @iprdata,['ipr:'.$k,$ipr->{$k}];
61 }
62  
63 0 return @iprdata;
64 }
65  
66 sub create
67 {
68 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create: not called CC=2 SCAR=17.9
Pod undocumented
69 0 ▶ return unless Net::DRI::Util::has_key($rd,'ipr');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "ipr") 0 0 0
70 0 my @n=build_ipr($rd->{ipr});
71  
72 0 my $mes=$epp->message();
73 0 my $eid=$mes->command_extension_register('ipr','create');
74 0 $mes->command_extension($eid,\@n);
75 0 return;
76 }
77  
78 # ipr-1.1 adds ability to change or remove (but not add?)
79 sub update
80 {
81 0 ▶ my ($epp,$domain,$todo)=@_;
Subroutine update: not called CC=4 SCAR=30.0
Pod undocumented
82 0 my $todel=$todo->del('ipr');
83 0 my $tochg=$todo->set('ipr');
84 0 my @def=grep { defined } ($todel,$tochg);
85 0 ▶ return unless @def; ## no updates asked
Branch: 1 branch
BranchTrueFalseTotal
unless @def 0 0 0
86  
87 0 my $mes=$epp->message();
88 0 my $eid=$mes->command_extension_register('ipr','update');
89  
90 0 my @n;
91 0 ▶ push @n,['ipr:rem',build_ipr($todel)] if defined $todel;
Branch: 1 branch
BranchTrueFalseTotal
if defined $todel 0 0 0
92 0 ▶ push @n,['ipr:chg',build_ipr($tochg)] if defined $tochg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $tochg 0 0 0
93 0 $mes->command_extension($eid,\@n);
94 0 return;
95 }
96  
97 sub info_parse
98 {
99 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
100 0 my $mes=$po->message();
101 0 my $infdata=$mes->get_extension('ipr','infData');
102 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
103  
104 0 my %ipr;
105 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
106 {
107 0 my ($n,$c)=@$el;
108 0 ▶ if ($n=~m/^(?:name|number|class|entitlement|form|preVerified|type)$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($n =~ /^(?:name|number|class|entitlement|form|preVerified|type)$/) { } 0 0 0
elsif ($n eq 'ccLocality') { } 0 0 0
elsif ($n =~ /^(?:appDate|regDate)$/) { } 0 0 0
109 {
110 0 $ipr{$n}=$c->textContent();
111 } elsif ($n eq 'ccLocality')
112 {
113 0 $ipr{cc}=$c->textContent();
114 } elsif ($n=~m/^(?:appDate|regDate)$/)
115 {
116 0 $ipr{$n}=$po->parse_iso8601($c->textContent());
117 }
118 }
119  
120 0 $rinfo->{$otype}->{$oname}->{ipr}=\%ipr;
121 0 return;
122 }
123  
124 ####################################################################################################
125 1 1;
126  
127 __END__
128  
129 =pod
130  
131 =head1 NAME
132  
133 Net::DRI::Protocol::EPP::Extensions::Afilias::IPR - Afilias IPR EPP Extension for Net::DRI
134  
135 =head1 DESCRIPTION
136  
137 Please see the README file for details.
138  
139 =head1 SUPPORT
140  
141 For now, support questions should be sent to:
142  
143 E<lt>netdri@dotandco.comE<gt>
144  
145 Please also see the SUPPORT file in the distribution.
146  
147 =head1 SEE ALSO
148  
149 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
150  
151 =head1 AUTHOR
152  
153 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
154  
155 =head1 COPYRIGHT
156  
157 Copyright (c) 2010,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
158 All rights reserved.
159  
160 This program is free software; you can redistribute it and/or modify
161 it under the terms of the GNU General Public License as published by
162 the Free Software Foundation; either version 2 of the License, or
163 (at your option) any later version.
164  
165 See the LICENSE file that comes with this distribution for more details.
166  
167 =cut
« DRI/Protocol/EPP/Extensions/AT/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/VeriSign/PollLowBalance.pm »