File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/CentralNic/TTL.pm
Criterion Covered Total %
statement 12 39 30.7
branch 0 14 0.0
condition 0 12 0.0
subroutine 4 8 50.0
pod 0 4 0.0
total 16 77 20.7


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, CentralNic DNS TTL EPP extension
2             ## (http://labs.centralnic.com/epp/ext/ttl.php)
3             ##
4             ## Copyright (c) 2007,2008,2010,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::CentralNic::TTL;
17              
18 1     1   942 use strict;
  1         2  
  1         22  
19 1     1   3 use warnings;
  1         1  
  1         18  
20              
21 1     1   4 use DateTime::Duration;
  1         2  
  1         15  
22              
23 1     1   3 use Net::DRI::Util;
  1         1  
  1         398  
24              
25             =pod
26              
27             =head1 NAME
28              
29             Net::DRI::Protocol::EPP::Extensions::CentralNic::TTL - EPP DNS TTL CentralNic extension commands for Net::DRI
30              
31             =head1 DESCRIPTION
32              
33             Please see the README file for details.
34              
35             =head1 SUPPORT
36              
37             For now, support questions should be sent to:
38              
39             Enetdri@dotandco.comE
40              
41             Please also see the SUPPORT file in the distribution.
42              
43             =head1 SEE ALSO
44              
45             Ehttp://www.dotandco.com/services/software/Net-DRI/E
46              
47             =head1 AUTHOR
48              
49             Patrick Mevzek, Enetdri@dotandco.comE
50              
51             =head1 COPYRIGHT
52              
53             Copyright (c) 2007,2008,2010,2013 Patrick Mevzek .
54             All rights reserved.
55              
56             This program is free software; you can redistribute it and/or modify
57             it under the terms of the GNU General Public License as published by
58             the Free Software Foundation; either version 2 of the License, or
59             (at your option) any later version.
60              
61             See the LICENSE file that comes with this distribution for more details.
62              
63             =cut
64              
65             ####################################################################################################
66              
67             sub register_commands
68             {
69 0     0 0   my ($class,$version)=@_;
70 0           my %tmp=( create => [ \&create ],
71             update => [ \&update ],
72             info => [ undef, \&info_parse ],
73             );
74 0           return { 'domain' => \%tmp };
75             }
76              
77             ####################################################################################################
78             ########### Query commands
79              
80             sub info_parse
81             {
82 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
83 0           my $mes=$po->message();
84 0 0         return unless $mes->is_success();
85              
86 0           my $infdata=$mes->get_extension('ttl','infData');
87 0 0         return unless $infdata;
88              
89 0           my @secs=$infdata->getChildrenByTagNameNS($mes->ns('ttl'),'secs');
90 0 0         return unless @secs;
91              
92 0           $rinfo->{domain}->{$oname}->{ttl}=DateTime::Duration->new(seconds => $secs[0]->textContent());
93 0           return;
94             }
95              
96             ############ Transform commands
97              
98             sub create
99             {
100 0     0 0   my ($epp,$domain,$rd)=@_;
101 0           my $mes=$epp->message();
102              
103 0 0 0       return unless (exists($rd->{ttl}) && ((ref($rd->{ttl}) && Net::DRI::Util::is_class($rd->{ttl},'DateTime::Duration')) || $rd->{ttl}=~m/^\d+$/));
      0        
104              
105 0           my $eid=$mes->command_extension_register('ttl:create',sprintf('xmlns:ttl="%s" xsi:schemaLocation="%s %s"',$mes->nsattrs('ttl')));
106 0 0         my @n=(['ttl:secs',ref($rd->{ttl})? $rd->{ttl}->in_units('seconds') : $rd->{ttl}]);
107 0           $mes->command_extension($eid,\@n);
108 0           return;
109             }
110              
111             sub update
112             {
113 0     0 0   my ($epp,$domain,$todo)=@_;
114 0           my $mes=$epp->message();
115              
116 0           my $toset=$todo->set('ttl');
117 0 0 0       return unless (defined $toset && ((ref $toset && Net::DRI::Util::is_class($toset,'DateTime::Duration')) || $toset=~m/^\d+$/));
      0        
118              
119 0           my $eid=$mes->command_extension_register('ttl:update',sprintf('xmlns:ttl="%s" xsi:schemaLocation="%s %s"',$mes->nsattrs('ttl')));
120 0 0         my @n=(['ttl:secs',ref($toset)? $toset->in_units('seconds') : $toset]);
121 0           $mes->command_extension($eid,\@n);
122 0           return;
123             }
124              
125             ####################################################################################################
126             1;