File Coverage

blib/lib/Net/DRI/Data/Contact/Nominet.pm
Criterion Covered Total %
statement 18 33 54.5
branch 0 18 0.0
condition 0 23 0.0
subroutine 6 7 85.7
pod 0 1 0.0
total 24 82 29.2


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Handling of contact data for Nominet (.UK)
2             ##
3             ## Copyright (c) 2008,2013 Patrick Mevzek . All rights reserved.
4             ## (c) 2013 Michael Holloway . 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::Data::Contact::Nominet;
17              
18 1     1   612 use strict;
  1         1  
  1         22  
19 1     1   3 use warnings;
  1         1  
  1         20  
20              
21 1     1   3 use base qw(Net::DRI::Data::Contact);
  1         1  
  1         53  
22 1     1   4 use Email::Valid;
  1         1  
  1         17  
23 1     1   3 use Net::DRI::Exception;
  1         1  
  1         18  
24 1     1   3 use Net::DRI::Util;
  1         1  
  1         279  
25              
26             __PACKAGE__->register_attributes(qw(type co_no opt_out trad_name));
27              
28             =pod
29              
30             =head1 NAME
31              
32             Net::DRI::Data::Contact::Nominet - Handle .UK contact data for Net::DRI
33              
34             =head1 DESCRIPTION
35              
36             Please refer to Net::DRI::Data::Contact for core methods
37             and http://www.nominet.org.uk/registrars/systems/data/fields/ for registry extra data
38              
39             =head1 METHODS
40              
41             =head2 type()
42              
43             (registrant contact only) describes what type of organisation the domain name has been registered for ;
44             see http://www.nominet.org.uk/registrars/systems/data/regtype/
45              
46             =head2 co_no()
47              
48             (registrant contact only) registered number of the company or organisation
49              
50             =head2 opt_out()
51              
52             (registrant contact only) do not display address details in whois if yes (Y)
53              
54             =head1 SUPPORT
55              
56             For now, support questions should be sent to:
57              
58             Enetdri@dotandco.comE
59              
60             Please also see the SUPPORT file in the distribution.
61              
62             =head1 SEE ALSO
63              
64             http://www.dotandco.com/services/software/Net-DRI/
65              
66             =head1 AUTHOR
67              
68             Patrick Mevzek, Enetdri@dotandco.comE
69              
70             =head1 COPYRIGHT
71              
72             Copyright (c) 2008,2013 Patrick Mevzek .
73             (c) 2013 Michael Holloway .
74             All rights reserved.
75              
76             This program is free software; you can redistribute it and/or modify
77             it under the terms of the GNU General Public License as published by
78             the Free Software Foundation; either version 2 of the License, or
79             (at your option) any later version.
80              
81             See the LICENSE file that comes with this distribution for more details.
82              
83             =cut
84              
85             ####################################################################################################
86              
87             sub validate
88             {
89 0     0 0   my ($self,$change)=@_;
90 0   0       $change||=0;
91 0           my @errs;
92              
93 0           $self->auth({'pw' => ''});
94 0           $self->SUPER::validate($change);
95              
96 0 0         if (!$change)
97             {
98 0 0         Net::DRI::Exception::usererr_insufficient_parameters('Invalid contact information: name mandatory') unless ($self->name());
99             }
100              
101             ## See http://www.nominet.org.uk/registrars/systems/data/regtype/
102 0 0 0       push @errs,'type' if (defined($self->type()) && $self->type()!~m/^(?:LTD|PLC|IND|FIND|RCHAR|SCH|LLP|STRA|PTNR|GOV|CRC|STAT|FCORP|IP|FOTHER|OTHER|UNKNOWN)$/);
103 0 0 0       push @errs,'co_no' if (defined($self->co_no()) && !Net::DRI::Util::xml_is_token($self->co_no(),undef,255));
104             ## TO FIX : co_no is mandatory for registrations in .net, .ltd and .plc SLDs
105 0 0 0       push @errs,'opt_out' if (defined($self->opt_out()) && $self->opt_out()!~m/^[YN]$/i);
106 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
107              
108 0 0 0       if (defined($self->type()) && defined($self->opt_out()))
109             {
110 0 0 0       Net::DRI::Exception::usererr_invalid_parameters('opt_out must be N if type is not IND or FIND') if ($self->type()!~m/^(?:IND|FIND)$/ && lc($self->opt_out()) ne 'n');
111             }
112 0 0 0       Net::DRI::Exception::usererr_invalid_parameters('co_no must be defined if type is SCH') if (defined($self->type()) && $self->type() eq 'SCH' && !defined($self->co_no()));
      0        
113              
114 0           return 1; ## everything ok.
115             }
116              
117             ####################################################################################################
118             1;