File Coverage

blib/lib/Net/DRI/Data/Contact/CIRA.pm
Criterion Covered Total %
statement 15 41 36.5
branch 0 30 0.0
condition 0 53 0.0
subroutine 5 7 71.4
pod 0 2 0.0
total 20 133 15.0


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Handling of contact data for CIRA
2             ##
3             ## Copyright (c) 2010,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::CIRA;
16              
17 1     1   728 use strict;
  1         2  
  1         27  
18 1     1   5 use warnings;
  1         1  
  1         20  
19              
20 1     1   4 use base qw/Net::DRI::Data::Contact/;
  1         1  
  1         56  
21              
22 1     1   5 use Net::DRI::Exception;
  1         1  
  1         19  
23 1     1   5 use Net::DRI::Util;
  1         7  
  1         677  
24              
25             __PACKAGE__->register_attributes(qw(legal_form lang is_individual ip_address agreement reseller_id whois_display));
26              
27             ####################################################################################################
28              
29             sub validate
30             {
31 0     0 0   my ($self,$change)=@_;
32 0   0       $change||=0;
33              
34 0           $self->SUPER::validate(1); ## will trigger an Exception if problem
35              
36 0           my @errs;
37 0 0         if (!$change)
38             {
39 0 0 0       my @missing=grep { my $r=scalar $self->$_(); (defined $r && length $r)? 0 : 1 } qw/name cc lang srid auth/;
  0            
  0            
40 0 0         Net::DRI::Exception::usererr_insufficient_parameters('Mandatory contact information missing: '.join('/',@missing)) if @missing;
41 0 0         push @errs,'srid' unless Net::DRI::Util::xml_is_token($self->srid(),3,16);
42             }
43              
44 0 0 0       push @errs,'sp' if (defined $self->sp() && defined $self->cc() && $self->cc() eq 'CA' && $self->sp()!~m/^(?:AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT)$/);
      0        
      0        
45              
46 0 0 0       push @errs,'legal_form' if (defined $self->legal_form() && $self->legal_form()!~m!^(?:CCO|CCT|RES|GOV|EDU|ASS|HOP|PRT|TDM|TRD|PLT|LAM|TRS|ABO|INB|LGR|OMK|MAJ)$!);
47 0 0 0       push @errs,'lang' if (defined $self->lang() && $self->lang()!~m/^(?:fr|en)$/o);
48 0 0 0       push @errs,'ip_address' if (defined $self->ip_address() && !Net::DRI::Util::is_ipv4($self->ip_address(),1) && !Net::DRI::Util::is_ipv6($self->ip_address(),1));
      0        
49 0 0         if (defined $self->agreement())
50             {
51 0           my $ra=$self->agreement();
52 0 0 0       push @errs,'agreement' if (ref($ra) ne 'HASH' || 2!=keys(%$ra) || !exists($ra->{version}) || !exists($ra->{signed}) || length($ra->{version}) > 4 || $ra->{signed}!~m/^(?:0|1)$/);
      0        
      0        
      0        
      0        
53             }
54 0 0 0       push @errs,'reseller_id' if (defined $self->reseller_id() && length($self->reseller_id()) > 255);
55 0 0 0       push @errs,'whois_display' if (defined $self->whois_display() && $self->whois_display()!~m/^(?:FULL|PRIVATE)$/o);
56              
57 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
58 0           return 1; ## everything ok.
59             }
60              
61             sub init
62             {
63 0     0 0   my ($self,$what,$ndr)=@_;
64 0 0         if ($what eq 'create')
65             {
66 0           my $a=$self->auth();
67 0 0 0       $self->auth({pw=>''}) unless ($a && (ref($a) eq 'HASH') && exists($a->{pw})); ## authInfo is not used
      0        
68             }
69 0           return;
70             }
71              
72             ####################################################################################################
73             1;
74              
75             __END__