File Coverage

blib/lib/Net/DRI/Data/Contact/LU.pm
Criterion Covered Total %
statement 15 35 42.8
branch 0 24 0.0
condition 0 14 0.0
subroutine 5 7 71.4
pod 0 2 0.0
total 20 82 24.3


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Handling of contact data for LU
2             ##
3             ## Copyright (c) 2007-2009,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::Data::Contact::LU;
16              
17 2     2   7 use strict;
  2         2  
  2         43  
18 2     2   6 use warnings;
  2         2  
  2         39  
19              
20 2     2   11 use base qw/Net::DRI::Data::Contact/;
  2         2  
  2         602  
21 2     2   9 use Net::DRI::Exception;
  2         2  
  2         33  
22 2     2   5 use Net::DRI::Util;
  2         2  
  2         497  
23              
24             __PACKAGE__->register_attributes(qw(type));
25              
26             =pod
27              
28             =head1 NAME
29              
30             Net::DRI::Data::Contact::LU - Handle .LU contact data for Net::DRI
31              
32             =head1 DESCRIPTION
33              
34             This subclass of Net::DRI::Data::Contact adds accessors and validation for
35             .LU specific data.
36              
37             This registry uses only localized data with characters in US-ASCII and ISO-LATIN-1
38              
39             =head1 METHODS
40              
41             The following accessors/mutators can be called in chain, as they all return the object itself.
42              
43             =head2 type()
44              
45             type of contact : holder_org, holder_pers (for contact objects used as holders) or contact
46              
47             =head1 SUPPORT
48              
49             For now, support questions should be sent to:
50              
51             Enetdri@dotandco.comE
52              
53             Please also see the SUPPORT file in the distribution.
54              
55             =head1 SEE ALSO
56              
57             http://www.dotandco.com/services/software/Net-DRI/
58              
59             =head1 AUTHOR
60              
61             Patrick Mevzek, Enetdri@dotandco.comE
62              
63             =head1 COPYRIGHT
64              
65             Copyright (c) 2007-2009,2013 Patrick Mevzek .
66             All rights reserved.
67              
68             This program is free software; you can redistribute it and/or modify
69             it under the terms of the GNU General Public License as published by
70             the Free Software Foundation; either version 2 of the License, or
71             (at your option) any later version.
72              
73             See the LICENSE file that comes with this distribution for more details.
74              
75             =cut
76              
77             ####################################################################################################
78              
79             sub validate
80             {
81 0     0 0   my ($self,$change)=@_;
82 0   0       $change||=0;
83 0           my @errs;
84              
85 0           $self->SUPER::validate($change); ## will trigger an Exception if problem
86              
87 0 0         if (!$change)
88             {
89 0 0         Net::DRI::Exception::usererr_insufficient_parameters('Invalid contact information: pc mandatory') unless (scalar($self->pc()));
90             }
91              
92 0 0         push @errs,'sp' if $self->sp(); ## not allowed
93 0 0 0       push @errs,'type' if ($self->type() && $self->type()!~m/^(?:holder_org|holder_pers|contact)/);
94 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
95              
96 0 0 0       if ($self->type() && ($self->type() ne 'contact'))
97             {
98 0 0         push @errs,'voice' if $self->voice();
99 0 0         push @errs,'fax' if $self->fax();
100 0 0         push @errs,'org' if $self->org();
101 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information (not allowed for holders): '.join('/',@errs)) if @errs;
102             }
103              
104 0           return 1; ## everything ok.
105             }
106              
107             sub init
108             {
109 0     0 0   my ($self,$what,$ndr)=@_;
110              
111 0 0         if ($what eq 'create')
112             {
113 0           my $a=$self->auth();
114 0 0 0       $self->auth({pw=>''}) unless ($a && (ref($a) eq 'HASH') && exists($a->{pw}));
      0        
115             }
116 0           return;
117             }
118              
119             ####################################################################################################
120             1;