File Coverage

blib/lib/Net/DRI/Protocol/EPP/Core/Status.pm
Criterion Covered Total %
statement 15 50 30.0
branch 0 20 0.0
condition 0 24 0.0
subroutine 5 17 29.4
pod 9 12 75.0
total 29 123 23.5


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, EPP Status
2             ##
3             ## Copyright (c) 2005,2007,2008,2010,2014 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::Core::Status;
16              
17 1     1   1257 use base qw!Net::DRI::Data::StatusList!;
  1         2  
  1         104  
18              
19 1     1   6 use utf8;
  1         1  
  1         9  
20 1     1   20 use strict;
  1         2  
  1         29  
21 1     1   3 use warnings;
  1         7  
  1         28  
22              
23 1     1   4 use Net::DRI::Exception;
  1         2  
  1         527  
24              
25             =pod
26              
27             =head1 NAME
28              
29             Net::DRI::Protocol::EPP::Core::Status - EPP Status 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) 2005,2007,2008,2010,2014 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 new
68             {
69 0     0 0   my $class=shift;
70 0           my $self=$class->SUPER::new('epp','1.0');
71              
72 0           my %s=('delete' => 'clientDeleteProhibited',
73             'renew' => 'clientRenewProhibited',
74             'update' => 'clientUpdateProhibited',
75             'transfer' => 'clientTransferProhibited',
76             'publish' => 'clientHold',
77             );
78 0           $self->_register_pno(\%s);
79              
80 0           my $msg=shift;
81 0 0         return $self unless defined $msg;
82 0 0         Net::DRI::Exception::err_invalid_parameters() unless ref $msg eq 'ARRAY';
83 0           $self->add(@$msg);
84 0           return $self;
85             }
86              
87             sub is_core_status
88             {
89 0     0 0   return (shift=~m/^client(?:Hold|(?:Delete|Renew|Update|Transfer)Prohibited)$/);
90             }
91              
92             sub build_xml
93             {
94 0     0 0   my ($self,$name,$range)=@_;
95 0 0         $range='core' unless defined($range);
96 0           my @d;
97 0           my $rd=$self->status_details();
98 0           while(my ($k,$v)=each(%$rd))
99             {
100 0 0 0       next if (($range eq 'core') xor is_core_status($k));
101 0 0 0       if ($v && ref $v eq 'HASH' && keys %$v)
      0        
102             {
103 0           my %tmp=(s => $k);
104 0 0         $tmp{lang}=$v->{lang} if exists $v->{lang};
105 0   0       push @d,[$name,$v->{msg} || '',\%tmp];
106             } else
107             {
108 0           push @d,[$name,{s=>$k}];
109             }
110             }
111 0           return @d;
112             }
113              
114 0     0 1   sub is_active { return shift->has_any('ok'); }
115 0     0 1   sub is_published { return shift->has_not(qw/clientHold serverHold inactive/); }
116 0     0 1   sub is_pending { return shift->has_any(qw/pendingCreate pendingDelete pendingRenew pendingTransfer pendingUpdate/); }
117 0     0 1   sub is_linked { return shift->has_any('linked'); }
118 0     0 1   sub is_grace { return shift->has_any(qw/addPeriod autoRenewPeriod renewPeriod transferPeriod redemptionPeriod pendingRestore pendingDelete/); } ## defined in RFC3915 ยง3.1
119              
120 0 0 0 0 1   sub can_delete { my $self=shift; return (!$self->is_linked() && !$self->is_pending() && $self->has_not(qw/clientDeleteProhibited serverDeleteProhibited/))? 1 : 0; }
  0            
121 0 0 0 0 1   sub can_renew { my $self=shift; return (!$self->is_pending() && $self->has_not(qw/clientRenewProhibited serverRenewProhibited/))? 1 : 0; }
  0            
122 0 0 0 0 1   sub can_update { my $self=shift; return (!$self->is_pending() && $self->has_not(qw/clientUpdateProhibited serverUpdateProhibited/))? 1 : 0; }
  0            
123 0 0 0 0 1   sub can_transfer { my $self=shift; return (!$self->is_pending() && $self->has_not(qw/clientTransferProhibited serverTransferProhibited/))? 1 : 0; }
  0            
124              
125             ####################################################################################################
126             1;