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

filter: Statementstmt 18.3% 13 / 71 Branchbran 0.0% 0 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 4 / 12 Podpod 0.0% 0 / 8 totaltotal 14.5% 17 / 117 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-2019 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-2019 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 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my ($class,$version)=@_;
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 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
92 0 my ($class,$po,$version)=@_;
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 0 ▶{
Subroutine create_keyvalue_extension: not called CC=4 SCAR=30.0
Pod undocumented
103 0 my ($epp,$hash)=@_;
104  
105 0 my @kv;
106  
107 0 foreach my $key ( sort { $a cmp $b } keys %{$hash} ) {
108 0 my $value = $hash->{$key};
109 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
110 0 push @kv, ['keyvalue:kv', { key => $key, value => $value }];
111 }
112 else {
113 0 push @kv, ['keyvalue:kv', { key => $key }];
114 }
115 }
116 0 ▶ return unless @kv;
Branch: 1 branch
BranchTrueFalseTotal
unless @kv 0 0 0
117 0 $epp->message()->command_extension('keyvalue', ['extension', @kv]);
118 0 return;
119 }
120  
121  
122 sub create_keyvalue
123 0 ▶{
Subroutine create_keyvalue: not called CC=2 SCAR=17.9
Pod undocumented
124 0 my ($epp,$domain,$rd)=@_;
125  
126 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
127  
128 0 return create_keyvalue_extension($epp, $rd->{keyvalue});
129 }
130  
131  
132 sub create_keyvalue_update
133 0 ▶{
Subroutine create_keyvalue_update: not called CC=2 SCAR=17.9
Pod undocumented
134 0 my ($epp,$domain,$todo) = @_;
135 0 my $mes=$epp->message();
136  
137 0 ▶ return unless $todo->set('keyvalue');
Branch: 1 branch
BranchTrueFalseTotal
unless $todo->set("keyvalue") 0 0 0
138  
139 0 return create_keyvalue_extension($epp, $todo->set('keyvalue'));
140 }
141  
142  
143 sub parse_keyvalue
144 0 ▶{
Subroutine parse_keyvalue: not called CC=3 SCAR=24.8
Pod undocumented
145 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
146 0 my $mes = $po->message();
147 0 my $extension = $mes->get_extension('keyvalue', 'extension');
148 0 ▶ return unless (defined($extension));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $extension 0 0 0
149  
150 0 my $keyvalue = {};
151  
152 0 foreach my $kv ( $extension->getChildrenByTagNameNS($mes->ns('keyvalue'), 'kv') ) {
153 0 $keyvalue->{$kv->getAttribute('key')} = $kv->getAttribute('value');
154 }
155 0 $rinfo->{$otype}{$oname}{keyvalue} = $keyvalue;
156 0 return;
157 }
158  
159  
160 sub list_domains
161 0 ▶{
Subroutine list_domains: not called CC=6 SCAR=37.4
Pod undocumented
162 0 my ($epp, $hash)=@_;
163 0 ▶ $hash = {} if !defined $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hash 0 0 0
164 0 ▶ $hash->{COMMAND} = 'QueryDomainList' if !exists $hash->{COMMAND};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"COMMAND"} 0 0 0
165 0 ▶ $hash->{USERDEPTH} = 'SELF' if !exists $hash->{USERDEPTH};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"USERDEPTH"} 0 0 0
166 0 ▶ $hash->{ORDERBY} = 'DOMAIN' if !exists $hash->{DOMAIN};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"DOMAIN"} 0 0 0
167 0 ▶ $hash->{LIMIT} = '10000' if !exists $hash->{LIMIT};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"LIMIT"} 0 0 0
168  
169 0 return create_keyvalue_extension( $epp, $hash );
170 }
171  
172  
173 sub list_domains_parse
174 0 ▶{
Subroutine list_domains_parse: not called CC=4 SCAR=30.0
Pod undocumented
175 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
176  
177 0 parse_keyvalue($po,'account','list','domains',$rinfo);
178  
179 0 ▶ if ( exists $rinfo->{account}{domains}{keyvalue} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rinfo->{"account"}{"domains"}{"keyvalue"}) 0 0 0
180 0 my @domains = ();
181 0 my $hash = $rinfo->{account}{domains}{keyvalue};
182  
183 0 ▶ if ( exists $hash->{DOMAIN} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash->{"DOMAIN"}) 0 0 0
184 0 push @domains, $hash->{DOMAIN};
185 0 my $i;
186 0 ▶ for ( $i = 1; exists $hash->{"DOMAIN$i"}; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$hash{"DOMAIN$i"}) 0 0 0
187 0 push @domains, $hash->{"DOMAIN$i"};
188 }
189 }
190  
191 0 delete $rinfo->{account}{domains}{keyvalue};
192  
193 0 $rinfo->{account}->{domains}->{action} = 'list';
194 0 $rinfo->{account}->{domains}->{list} = \@domains;
195 }
196 0 return;
197 }
198  
199 ####################################################################################################
200 1 1;
« DRI/Protocol/EPP/Extensions/VeriSign/Sync.pm ↑ Summary DRI/Protocol/EPP/Extensions/COZA/Domain.pm »