File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/AT/IOptions.pm
Criterion Covered Total %
statement 12 42 28.5
branch 0 14 0.0
condition 0 6 0.0
subroutine 4 8 50.0
pod 0 4 0.0
total 16 74 21.6


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, ENUM.AT Options extension
2             ## Contributed by Michael Braunoeder from ENUM.AT
3             ##
4             ## Copyright (c) 2006,2008,2013 Patrick Mevzek . All rights reserved.
5             ##
6             ## This file is part of Net::DRI
7             ##
8             ## Net::DRI is free software; you can redistribute it and/or modify
9             ## it under the terms of the GNU General Public License as published by
10             ## the Free Software Foundation; either version 2 of the License, or
11             ## (at your option) any later version.
12             ##
13             ## See the LICENSE file that comes with this distribution for more details.
14             ####################################################################################################
15              
16             package Net::DRI::Protocol::EPP::Extensions::AT::IOptions;
17              
18 1     1   653 use strict;
  1         1  
  1         22  
19 1     1   3 use warnings;
  1         1  
  1         18  
20              
21 1     1   3 use Net::DRI::Util;
  1         1  
  1         12  
22 1     1   3 use Net::DRI::Exception;
  1         1  
  1         350  
23              
24             our $NS='http://www.enum.at/rxsd/ienum43-options-1.0';
25              
26             =pod
27              
28             =head1 NAME
29              
30             Net::DRI::Protocol::EPP::Extensions::AT::IOptions - ENUM.AT Options EPP Mapping 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             Enetdri@dotandco.comE
41              
42             Please also see the SUPPORT file in the distribution.
43              
44             =head1 SEE ALSO
45              
46             Ehttp://www.dotandco.com/services/software/Net-DRI/E
47              
48             =head1 AUTHOR
49              
50             Patrick Mevzek, Enetdri@dotandco.comE
51              
52             =head1 COPYRIGHT
53              
54             Copyright (c) 2006,2008,2013 Patrick Mevzek .
55             All rights reserved.
56              
57             This program is free software; you can redistribute it and/or modify
58             it under the terms of the GNU General Public License as published by
59             the Free Software Foundation; either version 2 of the License, or
60             (at your option) any later version.
61              
62             See the LICENSE file that comes with this distribution for more details.
63              
64             =cut
65              
66             ####################################################################################################
67              
68             sub register_commands
69             {
70 0     0 0   my ($class,$version)=@_;
71 0           my %tmp=(
72             info => [ undef, \&parse_options ],
73             update => [ \&set_options, undef ],
74             #create => [ \&set_options, undef ],
75             );
76              
77 0           return { 'domain' => \%tmp };
78             }
79              
80 0     0 0   sub capabilities_add { return ('domain_update','options',['set']); }
81              
82             sub parse_options
83             {
84 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
85 0           my $mes=$po->message();
86              
87 0           my $condata=$mes->get_extension($NS,'options');
88 0 0         return unless $condata;
89              
90 0           my @options;
91              
92 0           foreach my $el ($condata->getElementsByTagNameNS($NS,'naptr-application'))
93             {
94 0           my %opts;
95 0           my $c=$el->getFirstChild();
96              
97 0 0         $opts{'naptr_application_origin'} =$el->getAttribute('origin') if (defined $el->getAttribute('origin'));
98 0 0         $opts{'naptr_application_wildcard'}=$el->getAttribute('wildcard') if (defined $el->getAttribute('wildcard'));
99              
100 0           push @options,\%opts;
101             }
102              
103 0           $rinfo->{domain}->{$oname}->{options}=\@options;
104 0           return;
105             }
106              
107             sub set_options
108             {
109 0     0 0   my ($epp,$domain,$rd)=@_;
110 0           my $mes=$epp->message();
111              
112 0           my $roptions=$rd->set('options');
113 0 0 0       return unless (defined($roptions) && (ref($roptions) eq 'HASH') && keys(%$roptions));
      0        
114              
115 0           my %options;
116 0           foreach my $d ('origin','wildcard')
117             {
118 0 0         next unless exists($roptions->{'naptr_application_'.$d});
119 0 0         Net::DRI::Exception::usererr_invalid_paramaters("Option naptr_application_${d} must be of an XML boolean") unless Net::DRI::Utils::xml_is_boolean($roptions->{'naptr_application_'.$d});
120 0           $options{$d}=$roptions->{'naptr_application_'.$d};
121             }
122              
123 0 0         return unless keys(%options);
124              
125 0           my $eid=$mes->command_extension_register('ienum43:update','xmlns:ienum43="'.$NS.'" xsi:schemaLocation="'.$NS.' ienum43-options-1.0.xsd"');
126 0           $mes->command_extension($eid,[['ienum43:options',['ienum43:naptr-application',\%options]]]);
127 0           return;
128             }
129              
130             ####################################################################################################
131             1;