File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/CNNIC/Bundling.pm
Criterion Covered Total %
statement 12 46 26.0
branch 0 12 0.0
condition n/a
subroutine 4 15 26.6
pod 0 11 0.0
total 16 84 19.0


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Bundling Registration Extension Mapping for EPP
2             ##
3             ## Copyright (c) 2015-2016 Patrick Mevzek . 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::CNNIC::Bundling;
16              
17 1     1   675 use strict;
  1         1  
  1         22  
18 1     1   3 use warnings;
  1         2  
  1         19  
19 1     1   3 use feature 'state';
  1         1  
  1         50  
20              
21 1     1   3 use Net::DRI::Util;
  1         1  
  1         456  
22              
23             ####################################################################################################
24              
25             sub register_commands
26             {
27 0     0 0   my ($class,$version)=@_;
28              
29 0           state $rops = { 'domain' => { info => [ undef, \&info_parse ],
30             create => [ \&create, \&create_parse ],
31             delete => [ undef, \&delete_parse ],
32             renew => [ undef, \&renew_parse ],
33             transfer_request => [ undef, \&transfer_parse ],
34             transfer_cancel => [ undef, \&transfer_parse ],
35             transfer_answer => [ undef, \&transfer_parse ],
36             update => [ undef, \&update_parse ],
37             }
38             };
39              
40 0           return $rops;
41             }
42              
43             sub setup
44             {
45 0     0 0   my ($class,$po,$version)=@_;
46 0           state $ns = { 'b-dn' => [ 'urn:ietf:params:xml:ns:b-dn-1.0','b-dn-1.0.xsd' ] };
47 0           $po->ns($ns);
48 0           return;
49             }
50              
51 0     0 0   sub implements { return 'https://tools.ietf.org/id/draft-kong-eppext-bundling-registration-02'; }
52              
53             ####################################################################################################
54              
55             sub parse
56             {
57 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo,$topname)=@_;
58 0           my $mes=$po->message();
59 0 0         return unless $mes->is_success();
60              
61 0           my $data=$mes->get_extension('b-dn',$topname);
62 0 0         return unless defined $data;
63              
64 0           $data=Net::DRI::Util::xml_traverse($data,$mes->ns('b-dn'),'bundle');
65 0 0         return unless defined $data;
66              
67 0           foreach my $el (Net::DRI::Util::xml_list_children($data))
68             {
69 0           my ($name,$node)=@$el;
70 0 0         if ($name=~m/^(rdn|bdn)$/)
71             {
72 0           my %r=(alabel => $node->textContent());
73 0 0         $r{ulabel}=$node->getAttribute('uLabel') if $node->hasAttribute('uLabel');
74 0           $rinfo->{$otype}->{$oname}->{$name}=\%r;
75             }
76             }
77              
78 0           return;
79             }
80              
81 0     0 0   sub info_parse { return parse(@_,'infData'); } ## no critic (Subroutines::RequireArgUnpacking)
82 0     0 0   sub create_parse { return parse(@_,'creData'); } ## no critic (Subroutines::RequireArgUnpacking)
83 0     0 0   sub delete_parse { return parse(@_,'delData'); } ## no critic (Subroutines::RequireArgUnpacking)
84 0     0 0   sub renew_parse { return parse(@_,'renData'); } ## no critic (Subroutines::RequireArgUnpacking)
85 0     0 0   sub transfer_parse { return parse(@_,'trnData'); } ## no critic (Subroutines::RequireArgUnpacking)
86 0     0 0   sub update_parse { return parse(@_,'upData'); } ## no critic (Subroutines::RequireArgUnpacking)
87              
88             sub create
89             {
90 0     0 0   my ($epp,$domain,$rp)=@_;
91 0           my $mes=$epp->message();
92              
93 0           my $eid=$mes->command_extension_register('b-dn','create');
94 0 0         Net::DRI::Exception::usererr_invalid_parameters('ulabel property is mandatory for create with bundling extension') unless Net::DRI::Util::has_key($rp, 'ulabel');
95 0           $mes->command_extension($eid, [ 'b-dn:rdn', { uLabel => $rp->{ulabel} }, $domain]);
96 0           return;
97             }
98              
99             ####################################################################################################
100             1;
101              
102             __END__