File Coverage

blib/lib/Net/DRI/Data/Contact/COOP.pm
Criterion Covered Total %
statement 15 29 51.7
branch 0 12 0.0
condition 0 8 0.0
subroutine 5 6 83.3
pod 0 1 0.0
total 20 56 35.7


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Handling of contact data for .COOP
2             ##
3             ## Copyright (c) 2006-2008,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::COOP;
16              
17 1     1   1392 use strict;
  1         2  
  1         27  
18 1     1   4 use warnings;
  1         2  
  1         24  
19              
20 1     1   3 use base qw/Net::DRI::Data::Contact/;
  1         2  
  1         67  
21 1     1   5 use Net::DRI::Exception;
  1         1  
  1         14  
22 1     1   3 use Net::DRI::Util;
  1         2  
  1         194  
23              
24             __PACKAGE__->register_attributes(qw(sponsors state lang mailing_list));
25              
26             =pod
27              
28             =head1 NAME
29              
30             Net::DRI::Data::Contact::COOP - Handle .COOP contact data for Net::DRI
31              
32             =head1 DESCRIPTION
33              
34             This subclass of Net::DRI::Data::Contact adds accessors and validation for
35             .COOP specific data.
36              
37             Organizations must have names and phone numbers.
38              
39             Contact ids must begin with a prefix given by the registry (tied to the registrar account).
40             If you specify a localized version for data, you need the internationalized version also
41             (see documentation of Net::DRI::Data::Contact and its loc2int method) ; you can however
42             specify just internationalized data, without a localized version.
43              
44             =head1 METHODS
45              
46             The following accessors/mutators can be called in chain, as they all return the object itself.
47              
48             =head2 sponsors()
49              
50             list of sponsors as registry contact ids (mandatory for registrants, at least 2)
51              
52             =head2 state()
53              
54             verification state : verified, pendingVerification, ableToApeal, underInvestigation, refused
55              
56             =head2 lang()
57              
58             language of contact
59              
60             =head2 mailing_list()
61              
62             boolean showing opt-in status of contact for .COOP newsletters
63              
64             =head1 SUPPORT
65              
66             For now, support questions should be sent to:
67              
68             Enetdri@dotandco.comE
69              
70             Please also see the SUPPORT file in the distribution.
71              
72             =head1 SEE ALSO
73              
74             http://www.dotandco.com/services/software/Net-DRI/
75              
76             =head1 AUTHOR
77              
78             Patrick Mevzek, Enetdri@dotandco.comE
79              
80             =head1 COPYRIGHT
81              
82             Copyright (c) 2006-2008,2013 Patrick Mevzek .
83             All rights reserved.
84              
85             This program is free software; you can redistribute it and/or modify
86             it under the terms of the GNU General Public License as published by
87             the Free Software Foundation; either version 2 of the License, or
88             (at your option) any later version.
89              
90             See the LICENSE file that comes with this distribution for more details.
91              
92             =cut
93              
94             ####################################################################################################
95              
96             sub validate
97             {
98 0     0 0   my ($self,$change)=@_;
99 0   0       $change||=0;
100 0           my @errs;
101              
102 0           $self->SUPER::validate($change); ## will trigger an Exception if problem
103              
104 0 0         if ($self->sponsors())
105             {
106 0 0         foreach my $id (ref($self->sponsors())? @{$self->sponsors()} : ($self->sponsors()))
  0            
107             {
108 0 0         next if Net::DRI::Util::xml_is_token($id,3,16); ## clIDType
109 0           push @errs,'sponsors';
110 0           last;
111             }
112             }
113 0 0 0       push @errs,'lang' if ($self->lang() && !Net::DRI::Util::xml_is_language($self->lang()));
114 0 0 0       push @errs,'mailing_list' if ($self->mailing_list() && !Net::DRI::Util::xml_is_boolean($self->mailing_list()));
115              
116 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
117              
118 0           return 1; ## everything ok.
119             }
120              
121             ####################################################################################################
122             1;