File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/IT/Notifications.pm
Criterion Covered Total %
statement 6 52 11.5
branch 0 18 0.0
condition n/a
subroutine 2 9 22.2
pod 0 7 0.0
total 8 86 9.3


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, .IT message extensions
2             ##
3             ## Copyright (C) 2009-2010,2013 Tower Technologies. All rights reserved.
4             ##
5             ## This program free software; you can redistribute it and/or modify
6             ## it under the terms of the GNU General Public License v2.
7             ##
8              
9             package Net::DRI::Protocol::EPP::Extensions::IT::Notifications;
10              
11 1     1   710 use strict;
  1         1  
  1         22  
12 1     1   3 use warnings;
  1         1  
  1         571  
13              
14             =pod
15              
16             =head1 NAME
17              
18             Net::DRI::Protocol::EPP::Extensions::IT::Notifications - .IT EPP Notifications Parsing for Net::DRI
19              
20             =head1 SUPPORT
21              
22             For now, support questions should be sent to:
23              
24             Enoc@towertech.itE
25              
26             Please also see the SUPPORT file in the distribution.
27              
28             =head1 AUTHOR
29              
30             Alessandro Zummo, Ea.zummo@towertech.itE
31              
32             =head1 COPYRIGHT
33              
34             Copyright (C) 2009-2010,2013 Tower Technologies.
35             All rights reserved.
36              
37             This program is free software; you can redistribute it and/or modify
38             it under the terms of the GNU General Public License v2 as published by
39             the Free Software Foundation.
40              
41             See the LICENSE file that comes with this distribution for more details.
42              
43              
44             =cut
45              
46             sub register_commands
47             {
48 0     0 0   my ($class, $version) = @_;
49              
50 0           my $ops = {
51             'review_credit' => [ undef, \&parse_credit ],
52             'review_passwd' => [ undef, \&parse_reminder ],
53             'review_simple' => [ undef, \&parse_simple ],
54             'review_change' => [ undef, \&parse_chgstatus ],
55             'review_dnserror' => [ undef, \&parse_dnserror ],
56             };
57              
58             return {
59 0           'message' => $ops,
60             };
61             }
62              
63             sub retrieve_ext
64             {
65 0     0 0   my ($po,$ns,$node)=@_;
66 0           my $msg = $po->message;
67 0 0         return unless $msg->is_success;
68 0           my $ext = $msg->get_extension($ns,$node);
69 0 0         return unless defined $ext;
70 0           my $id = $msg->msg_id;
71 0           return ($ext,$id);
72             }
73              
74             sub parse_credit
75             {
76 0     0 0   my ($po, $type, $action, $name, $rinfo) = @_;
77 0           my ($ext,$id)=retrieve_ext($po,'it_epp','creditMsgData');
78 0 0         return unless defined $ext;
79              
80 0           $rinfo->{'message'}->{$id}->{credit}=($ext->getElementsByTagName('extepp:credit'))[0]->textContent; ## TODO: use xml_child_content() instead
81 0           return;
82             }
83              
84             sub parse_reminder
85             {
86 0     0 0   my ($po, $type, $action, $name, $rinfo) = @_;
87 0           my ($ext,$id)=retrieve_ext($po,'it_epp','passwdReminder');
88 0 0         return unless defined $ext;
89              
90 0           $rinfo->{'message'}->{$id}->{'passwd_expires_on'}= ($ext->getElementsByTagName('extepp:exDate'))[0]->textContent; ## TODO: use xml_child_content() instead + convert date to DateTime object ?
91 0           return;
92             }
93              
94             sub parse_simple
95             {
96 0     0 0   my ($po, $type, $action, $name, $rinfo) = @_;
97 0           my ($ext,$id)=retrieve_ext($po,'it_domain','simpleMsgData');
98 0 0         return unless defined $ext;
99              
100 0           $rinfo->{'message'}->{$id}->{'domain'}=($ext->getElementsByTagName('extdom:name'))[0]->textContent; ## TODO: use xml_child_content() instead
101 0           return;
102             }
103              
104             sub parse_chgstatus
105             {
106 0     0 0   my ($po, $type, $action, $name, $rinfo) = @_;
107 0           my ($ext,$id)=retrieve_ext($po,'it_domain','chgStatusMsgData');
108 0 0         return unless defined $ext;
109              
110 0           $rinfo->{'message'}->{$id}->{'domain'}=($ext->getElementsByTagName('extdom:name'))[0]->textContent; ## TODO: use xml_child_content() instead
111            
112 0           foreach ($ext->findnodes('//extdom:targetStatus/*')) {
113            
114 0 0         $rinfo->{'message'}->{$id}->{'status'} = $_->getAttribute('s')
115             if $_->nodeName eq 'domain:status';
116            
117 0 0         $rinfo->{'message'}->{$id}->{'own_status'} = $_->getAttribute('s')
118             if $_->nodeName eq 'extdom:ownStatus'; ## TODO : what is the difference between the two statuses ? + create a true StatusList object
119             }
120 0           return;
121             }
122              
123             sub parse_dnserror
124             {
125 0     0 0   my ($po, $type, $action, $name, $rinfo) = @_;
126 0           my ($ext,$id)=retrieve_ext($po,'it_domain','dnsErrorMsgData');
127 0 0         return unless defined $ext;
128            
129 0           $rinfo->{'message'}->{$id}->{'domain'}
130             = ($ext->getElementsByTagName('extdom:domain'))[0]
131             ->getAttribute('name'); ## TODO: use xml_child_content() instead
132              
133 0           $rinfo->{'message'}->{$id}->{'status'}
134             = ($ext->getElementsByTagName('extdom:domain'))[0]
135             ->getAttribute('status'); ## TODO: use xml_child_content() instead
136              
137 0           $rinfo->{'message'}->{$id}->{'response_id'}
138             = ($ext->getElementsByTagName('extdom:responseId'))[0]->textContent; ## TODO: use xml_child_content() instead
139              
140 0           $rinfo->{'message'}->{$id}->{'validation_date'}
141             = ($ext->getElementsByTagName('extdom:validationDate'))[0]->textContent; ## TODO: use xml_child_content() instead
142              
143 0           foreach my $test ($ext->findnodes('//extdom:test')) {
144              
145 0           my $name = $test->getAttribute('name');
146              
147 0           $rinfo->{'message'}->{$id}->{'test'}{$name}{'status'} = $test->getAttribute('status');
148              
149 0           foreach my $dns ($test->findnodes('./extdom:dns')) {
150              
151 0           $rinfo->{'message'}->{$id}->{'test'}{$name}{'dns'}{$dns->getAttribute('name')}
152             = $dns->getAttribute('status');
153             }
154             }
155 0           return;
156             }
157            
158             1;