File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/E164Validation/RFC5076.pm
Criterion Covered Total %
statement 12 53 22.6
branch 0 30 0.0
condition 0 6 0.0
subroutine 4 11 36.3
pod 0 7 0.0
total 16 107 14.9


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, EPP E.164 Validation Information Example from RFC5076
2             ##
3             ## Copyright (c) 2008-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::Protocol::EPP::Extensions::E164Validation::RFC5076;
16              
17 1     1   964 use strict;
  1         2  
  1         30  
18 1     1   4 use warnings;
  1         2  
  1         21  
19              
20 1     1   4 use Net::DRI::Exception;
  1         2  
  1         21  
21 1     1   3 use Net::DRI::Util;
  1         1  
  1         650  
22              
23             our $NS='urn:ietf:params:xml:ns:e164valex-1.1';
24              
25             =pod
26              
27             =head1 NAME
28              
29             Net::DRI::Protocol::EPP::Extensions::E164Validation::RFC5076 - EPP E.164 Validation Information Example from RFC5076 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) 2008-2010,2013 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 load
68             {
69 0     0 0   return $NS;
70             }
71              
72             sub info_parse
73             {
74 0     0 0   my ($class,$po,$top)=@_;
75 0 0 0       Net::DRI::Exception::usererr_insufficient_parameters('Root element for information validation of URI='.$NS.' must be simpleVal') unless (($top->localname() || $top->nodeName()) eq 'simpleVal');
76              
77 0           my %n;
78 0           foreach my $el (Net::DRI::Util::xml_list_children($top))
79             {
80 0           my ($name,$c)=@$el;
81 0 0         if ($name=~m/^(methodID|validationEntityID|registrarID)$/)
    0          
82             {
83 0           $n{Net::DRI::Util::remcam($1)}=$c->textContent();
84             } elsif ($name=~m/^(executionDate|expirationDate)$/)
85             {
86 0           $n{Net::DRI::Util::remcam($1)}=$po->parse_iso8601($c->textContent());
87             }
88             }
89 0           return \%n;
90             }
91              
92             sub output_date
93             {
94 0     0 0   my $d=shift;
95 0 0         return unless defined($d);
96 0 0         if (Net::DRI::Util::is_class($d,'DateTime'))
97             {
98 0           return $d->strftime('%Y-%m-%d');
99             } else
100             {
101 0 0         return unless ($d=~m/^\d{4}-\d{2}-\d{2}$/);
102 0           return $d;
103             }
104             }
105              
106             sub create
107             {
108 0     0 0   my ($class,$rd)=@_;
109              
110 0           my @c;
111 0 0 0       Net::DRI::Exception::usererr_insufficient_parameters('method_id and execution_date are mandatory in validation information') unless (exists $rd->{method_id} && exists $rd->{execution_date});
112 0 0         Net::DRI::Exception::usererr_invalid_parameters('method_id must be an xml token from 1 to 63 characters') unless Net::DRI::Util::xml_is_token($rd->{method_id},1,63);
113 0           push @c,['valex:methodID',$rd->{method_id}];
114              
115 0 0         if (exists $rd->{validation_entity_id})
116             {
117 0 0         Net::DRI::Exception::usererr_invalid_parameters('validation_entity_id must be an xml token from 3 to 16 characters') unless Net::DRI::Util::xml_is_token($rd->{validation_entity_id},3,16);
118 0           push @c,['valex:validationEntityID',$rd->{validation_entity_id}];
119             }
120 0 0         if (exists $rd->{registrar_id})
121             {
122 0 0         Net::DRI::Exception::usererr_invalid_parameters('registrar_id must be an xml token from 3 to 16 characters') unless Net::DRI::Util::xml_is_token($rd->{registrar_id},3,16);
123 0           push @c,['valex:registrarID',$rd->{registrar_id}];
124             }
125              
126 0           my $d=output_date($rd->{execution_date});
127 0 0         Net::DRI::Exception::usererr_invalid_parameters('execution_date must be a DateTime object or a string like YYYY-MM-DD') unless defined($d);
128 0           push @c,['valex:executionDate',$d];
129              
130 0 0         if (exists $rd->{expiration_date})
131             {
132 0           $d=output_date($rd->{expiration_date});
133 0 0         Net::DRI::Exception::usererr_invalid_parameters('expiration_date must be a DateTime object or a string like YYYY-MM-DD') unless defined($d);
134 0           push @c,['valex:expirationDate',$d];
135             }
136              
137 0           return ['valex:simpleVal',{'xmlns:valex' => $NS},@c];
138             }
139              
140 0     0 0   sub renew { my (@args)=@_; return create(@args); }
  0            
141 0     0 0   sub transfer { my (@args)=@_; return create(@args); }
  0            
142 0     0 0   sub update { my (@args)=@_; return create(@args); }
  0            
143              
144             ####################################################################################################
145             1;