File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/GracePeriod.pm
Criterion Covered Total %
statement 12 61 19.6
branch 0 22 0.0
condition 0 12 0.0
subroutine 4 10 40.0
pod 0 6 0.0
total 16 111 14.4


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, EPP Grace Period commands (RFC3915)
2             ##
3             ## Copyright (c) 2005,2006,2008-2010,2013 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::GracePeriod;
16              
17 1     1   666 use strict;
  1         1  
  1         23  
18 1     1   3 use warnings;
  1         1  
  1         18  
19              
20 1     1   2 use Net::DRI::Util;
  1         1  
  1         13  
21 1     1   3 use Net::DRI::Exception;
  1         1  
  1         493  
22              
23             =pod
24              
25             =head1 NAME
26              
27             Net::DRI::Protocol::EPP::Extensions::GracePeriod - EPP Grace Period commands (RFC3915) for Net::DRI
28              
29             =head1 DESCRIPTION
30              
31             Please see the README file for details.
32              
33             =head1 SUPPORT
34              
35             For now, support questions should be sent to:
36              
37             Enetdri@dotandco.comE
38              
39             Please also see the SUPPORT file in the distribution.
40              
41             =head1 SEE ALSO
42              
43             Ehttp://www.dotandco.com/services/software/Net-DRI/E
44              
45             =head1 AUTHOR
46              
47             Patrick Mevzek, Enetdri@dotandco.comE
48              
49             =head1 COPYRIGHT
50              
51             Copyright (c) 2005,2006,2008-2010,2013 Patrick Mevzek .
52             All rights reserved.
53              
54             This program is free software; you can redistribute it and/or modify
55             it under the terms of the GNU General Public License as published by
56             the Free Software Foundation; either version 2 of the License, or
57             (at your option) any later version.
58              
59             See the LICENSE file that comes with this distribution for more details.
60              
61             =cut
62              
63             ####################################################################################################
64              
65             sub register_commands
66             {
67 0     0 0   my ($class,$version)=@_;
68 0           my %tmp=(
69             info => [ undef, \&info_parse ],
70             update => [ \&update, \&update_parse ],
71             );
72              
73 0           return { 'domain' => \%tmp };
74             }
75              
76 0     0 0   sub capabilities_add { return ('domain_update','rgp',['set']); }
77              
78             sub setup
79             {
80 0     0 0   my ($class,$po,$version)=@_;
81 0           $po->ns({ 'rgp' => [ 'urn:ietf:params:xml:ns:rgp-1.0','rgp-1.0.xsd' ] });
82 0           return;
83             }
84              
85             ####################################################################################################
86             ########### Query commands
87              
88             sub info_parse
89             {
90 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
91 0           my $mes=$po->message();
92 0 0         return unless $mes->is_success();
93              
94 0           my $ns=$mes->ns('rgp');
95 0           my $infdata=$mes->get_extension($ns,'infData');
96 0 0         return unless defined $infdata;
97              
98 0           my $cs=$rinfo->{domain}->{$oname}->{status}; ## a Net::DRI::Protocol::EPP::Core::Status object
99              
100 0           foreach my $el ($infdata->getChildrenByTagNameNS($ns,'rgpStatus'))
101             {
102 0           $cs->add($el->getAttribute('s'));
103             }
104 0           return;
105             }
106              
107             ############ Transform commands
108              
109             sub update
110             {
111 0     0 0   my ($epp,$domain,$todo)=@_;
112 0           my $mes=$epp->message();
113              
114 0           my $rgp=$todo->set('rgp');
115 0 0 0       return unless (defined $rgp && $rgp && ref $rgp eq 'HASH');
      0        
116              
117 0   0       my $op=$rgp->{op} || '';
118 0 0         Net::DRI::Exception::usererr_invalid_parameters('RGP op must be request or report') unless ($op=~m/^(?:request|report)$/);
119 0 0 0       Net::DRI::Exception::usererr_invalid_parameters('Report data must be included if the operation is a report') unless (($op eq 'request') xor exists $rgp->{report});
120              
121 0           my $eid=$mes->command_extension_register('rgp:update',sprintf('xmlns:rgp="%s" xsi:schemaLocation="%s %s"',$mes->nsattrs('rgp')));
122              
123 0 0         if ($op eq 'request')
124             {
125 0           $mes->command_extension($eid,['rgp:restore',{ op => $op }]);
126             } else
127             {
128 0           my %r=%{$rgp->{report}};
  0            
129 0           my $def=$epp->default_parameters();
130 0           my @d;
131 0           push @d,['rgp:preData',$r{predata}]; ## XML data is possible in the RFC, but not here ?!
132 0           push @d,['rgp:postData',$r{postdata}]; ## ditto
133              
134 0           Net::DRI::Util::check_isa($r{deltime},'DateTime');
135 0           push @d,['rgp:delTime',$r{deltime}->strftime('%Y-%m-%dT%T.%1NZ')];
136 0           Net::DRI::Util::check_isa($r{restime},'DateTime');
137 0           push @d,['rgp:resTime',$r{restime}->strftime('%Y-%m-%dT%T.%1NZ')];
138 0           push @d,['rgp:resReason',$r{reason}];
139 0 0         push @d,['rgp:statement',$r{statement1},exists $r{statement1_lang} ? {lang => $r{statement1_lang}} : ()];
140 0 0         push @d,['rgp:statement',$r{statement2},exists $r{statement2_lang} ? {lang => $r{statement2_lang}} : ()];
141 0 0         push @d,['rgp:other',$r{other}] if exists $r{other};
142 0           $mes->command_extension($eid,['rgp:restore',['rgp:report',@d],{ op => $op }]);
143             }
144 0           return;
145             }
146              
147             sub update_parse
148             {
149 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
150 0           my $mes=$po->message();
151 0 0         return unless $mes->is_success();
152              
153 0           my $updata=$mes->get_extension($mes->ns('rgp'),'upData');
154 0 0         return unless defined $updata;
155              
156             ## We do nothing, since the rgpStatus alone is useless
157             ## (we do not have the other status)
158 0           return;
159             }
160              
161             ####################################################################################################
162             1;