DRI/Protocol/EPP/Extensions/ISPAPI/KeyValue.pm

filter: Statementstmt 17.5% 13 / 74 Branchbran 0.0% 0 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 4 / 12 Podpod 0.0% 0 / 8 totaltotal 14.1% 17 / 120 CC 16 SCAR 28.8
CC
16
Cov
13%
list_domains
42.0
create_keyvalue_extension
20.0
list_domains_parse
20.0
CRAP 17.8
« DRI/Protocol/EPP/Extensions/VeriSign/Sync.pm ↑ Summary DRI/Protocol/EPP/Extensions/COZA/Domain.pm »
1 ## Domain Registry Interface, ISPAPI (aka HEXONET) Key-Value EPP extensions
2 ##
3 ## Copyright (c) 2010,2013-2015 HEXONET GmbH, http://www.hexonet.net,
4 ## Jens Wagner <info@hexonet.net>
5 ## Copyright (c) 2016,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
6 ## All rights reserved.
7 ##
8 ## This file is part of Net::DRI
9 ##
10 ## Net::DRI is free software; you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation; either version 2 of the License, or
13 ## (at your option) any later version.
14 ##
15 ## See the LICENSE file that comes with this distribution for more details.
16 ####################################################################################################
17  
18 package Net::DRI::Protocol::EPP::Extensions::ISPAPI::KeyValue;
19  
20 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 =pod
27  
28 =head1 NAME
29  
30 Net::DRI::Protocol::EPP::Extensions::ISPAPI::KeyValue - EPP extension for Net::DRI
31  
32 =head1 DESCRIPTION
33  
34 Please see the README file for details.
35  
36 =head1 SUPPORT
37  
38 For now, support questions should be sent to:
39  
40 E<lt>support@hexonet.netE<gt>
41  
42 Please also see the SUPPORT file in the distribution.
43  
44 =head1 SEE ALSO
45  
46 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
47  
48 =head1 AUTHOR
49  
50 Alexander Biehl, E<lt>abiehl@hexonet.netE<gt>
51 Jens Wagner, E<lt>jwagner@hexonet.netE<gt>
52  
53 =head1 COPYRIGHT
54  
55 Copyright (c) 2010,2013-2015 HEXONET GmbH, E<lt>http://www.hexonet.netE<gt>,
56 Alexander Biehl <abiehl@hexonet.net>,
57 Jens Wagner <jwagner@hexonet.net>
58 Copyright (c) 2016,2018 Patrick Mevzek <netdri@dotandco.com>
59 All rights reserved.
60  
61 This program is free software; you can redistribute it and/or modify
62 it under the terms of the GNU General Public License as published by
63 the Free Software Foundation; either version 2 of the License, or
64 (at your option) any later version.
65  
66 See the LICENSE file that comes with this distribution for more details.
67  
68 =cut
69  
70 ####################################################################################################
71  
72 sub register_commands
73 {
74 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
75  
76 0 state $objects = {
77 check => [ \&create_keyvalue, \&parse_keyvalue ],
78 info => [ \&create_keyvalue, \&parse_keyvalue ],
79 create => [ \&create_keyvalue, \&parse_keyvalue ],
80 update => [ \&create_keyvalue_update, \&parse_keyvalue ],
81 transfer_request => [ \&create_keyvalue, \&parse_keyvalue ],
82 };
83 0 my $account = { list_domains => [ \&list_domains, \&list_domains_parse ] };
84 0 my $api = { call => [ \&create_keyvalue_extension, \&parse_keyvalue ] };
85  
86 0 state $commands = { 'domain' => $objects, 'contact' => $objects, 'ns' => $objects, 'account' => $account, 'api' => $api };
87 0 return $commands;
88 }
89  
90 sub setup
91 {
92 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
93 0 $po->ns({ 'keyvalue' => 'http://schema.ispapi.net/epp/xml/keyvalue-1.0' });
94 0 return;
95 }
96  
97 ####################################################################################################
98  
99 ############ Transform commands
100  
101 sub create_keyvalue_extension
102 {
103 0 ▶ my ($epp,$hash)=@_;
Subroutine create_keyvalue_extension: not called CC=4 SCAR=30.0
Pod undocumented
104  
105 0 my $mes=$epp->message();
106  
107 0 my $eid=$mes->command_extension_register('keyvalue', 'extension');
108  
109 0 my @kv = ();
110  
111 0 foreach my $key ( sort { $a cmp $b } keys %{$hash} ) {
112 0 my $value = $hash->{$key};
113 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
114 0 push @kv, ['keyvalue:kv', { key => $key, value => $value }];
115 }
116 else {
117 0 push @kv, ['keyvalue:kv', { key => $key }];
118 }
119 }
120 0 ▶ return unless @kv;
Branch: 1 branch
BranchTrueFalseTotal
unless @kv 0 0 0
121 0 $mes->command_extension($eid,\@kv);
122 0 return;
123 }
124  
125  
126 sub create_keyvalue
127 {
128 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create_keyvalue: not called CC=2 SCAR=17.9
Pod undocumented
129 0 my $mes=$epp->message();
130  
131 0 ▶ return unless Net::DRI::Util::has_key($rd,'keyvalue');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "keyvalue") 0 0 0
132  
133 0 return create_keyvalue_extension($epp, $rd->{keyvalue});
134 }
135  
136  
137 sub create_keyvalue_update
138 {
139 0 ▶ my ($epp,$domain,$todo) = @_;
Subroutine create_keyvalue_update: not called CC=2 SCAR=17.9
Pod undocumented
140 0 my $mes=$epp->message();
141  
142 0 ▶ return unless $todo->set('keyvalue');
Branch: 1 branch
BranchTrueFalseTotal
unless $todo->set("keyvalue") 0 0 0
143  
144 0 return create_keyvalue_extension($epp, $todo->set('keyvalue'));
145 }
146  
147  
148 sub parse_keyvalue
149 {
150 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine parse_keyvalue: not called CC=3 SCAR=24.8
Pod undocumented
151 0 my $mes = $po->message();
152 0 my $extension = $mes->get_extension('keyvalue', 'extension');
153 0 ▶ return unless (defined($extension));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $extension 0 0 0
154  
155 0 my $keyvalue = {};
156  
157 0 foreach my $kv ( $extension->getChildrenByTagNameNS($mes->ns('keyvalue'), 'kv') ) {
158 0 $keyvalue->{$kv->getAttribute('key')} = $kv->getAttribute('value');
159 }
160 0 $rinfo->{$otype}{$oname}{keyvalue} = $keyvalue;
161 0 return;
162 }
163  
164  
165 sub list_domains
166 {
167 0 ▶ my ($epp, $hash)=@_;
Subroutine list_domains: not called CC=6 SCAR=37.4
Pod undocumented
168 0 ▶ $hash = {} if !defined $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hash 0 0 0
169 0 ▶ $hash->{COMMAND} = 'QueryDomainList' if !exists $hash->{COMMAND};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"COMMAND"} 0 0 0
170 0 ▶ $hash->{USERDEPTH} = 'SELF' if !exists $hash->{USERDEPTH};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"USERDEPTH"} 0 0 0
171 0 ▶ $hash->{ORDERBY} = 'DOMAIN' if !exists $hash->{DOMAIN};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"DOMAIN"} 0 0 0
172 0 ▶ $hash->{LIMIT} = '10000' if !exists $hash->{LIMIT};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"LIMIT"} 0 0 0
173  
174 0 return create_keyvalue_extension( $epp, $hash );
175 }
176  
177  
178 sub list_domains_parse
179 {
180 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine list_domains_parse: not called CC=4 SCAR=30.0
Pod undocumented
181  
182 0 parse_keyvalue($po,'account','list','domains',$rinfo);
183  
184 0 ▶ if ( exists $rinfo->{account}{domains}{keyvalue} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rinfo->{"account"}{"domains"}{"keyvalue"}) 0 0 0
185 0 my @domains = ();
186 0 my $hash = $rinfo->{account}{domains}{keyvalue};
187  
188 0 ▶ if ( exists $hash->{DOMAIN} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash->{"DOMAIN"}) 0 0 0
189 0 push @domains, $hash->{DOMAIN};
190 0 my $i;
191 0 ▶ for ( $i = 1; exists $hash->{"DOMAIN$i"}; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$hash{"DOMAIN$i"}) 0 0 0
192 0 push @domains, $hash->{"DOMAIN$i"};
193 }
194 }
195  
196 0 delete $rinfo->{account}{domains}{keyvalue};
197  
198 0 $rinfo->{account}->{domains}->{action} = 'list';
199 0 $rinfo->{account}->{domains}->{list} = \@domains;
200 }
201 0 return;
202 }
203  
204 ####################################################################################################
205 1 1;
« DRI/Protocol/EPP/Extensions/VeriSign/Sync.pm ↑ Summary DRI/Protocol/EPP/Extensions/COZA/Domain.pm »