File Coverage

blib/lib/Net/EPP/Frame/Response.pm
Criterion Covered Total %
statement 6 34 17.6
branch 0 4 0.0
condition n/a
subroutine 2 12 16.6
pod 2 9 22.2
total 10 59 16.9


line stmt bran cond sub pod time code
1             package Net::EPP::Frame::Response;
2 1     1   619 use Net::EPP::ResponseCodes;
  1         6  
  1         197  
3 1     1   8 use base qw(Net::EPP::Frame);
  1         3  
  1         676  
4              
5             =pod
6              
7             =head1 NAME
8              
9             Net::EPP::Frame::Response - an instance of L for server responses
10              
11             =head1 DESCRIPTION
12              
13             This module is a subclass of L that represents EPP server
14             responses.
15              
16             Responses are sent back to clients when the server receives a
17             CcommandE> frame.
18              
19             =head1 OBJECT HIERARCHY
20              
21             L
22             +----L
23             +----L
24             +----L
25              
26             =cut
27              
28             sub new {
29 0     0 1   my $package = shift;
30 0           my $self = $package->SUPER::new('response');
31 0           return bless($self, $package);
32             }
33              
34             sub _addExtraElements {
35 0     0     my $self = shift;
36              
37 0           my $result = $self->createElement('result');
38 0           $result->appendChild($self->createElement('msg'));
39 0           $self->response->addChild($result);
40              
41 0           $self->result->setAttribute('code' => COMMAND_FAILED);
42              
43 0           $self->response->addChild($self->createElement('resData'));
44              
45 0           my $trID = $self->createElement('trID');
46 0           $trID->addChild($self->createElement('clTRID'));
47 0           $trID->addChild($self->createElement('svTRID'));
48 0           $self->response->addChild($trID);
49              
50 0           return 1;
51             }
52              
53             =pod
54              
55             =head1 METHODS
56              
57             my $node = $frame->response;
58              
59             This method returns the L object corresponding to the
60             CcommandE> element.
61              
62             my $node = $frame->result;
63              
64             This method returns the L object corresponding to the
65             CresultE> element.
66              
67             my $node = $frame->resData;
68              
69             This method returns the L object corresponding to the
70             CresDataE> element.
71              
72             my $node = $frame->trID;
73              
74             This method returns the L object corresponding to the
75             CtrIDE> element.
76              
77             my $node = $frame->clTRID;
78              
79             This method returns the L object corresponding to the
80             CclTRIDE> element.
81              
82             my $node = $frame->svTRID;
83              
84             This method returns the L object corresponding to the
85             CsvTRIDE> element.
86              
87             =cut
88              
89 0     0 1   sub response { $_[0]->getNode('response') }
90 0     0 0   sub result { $_[0]->getNode('result') }
91 0     0 0   sub resData { $_[0]->getNode('resData') }
92 0     0 0   sub trID { $_[0]->getNode('trID') }
93 0     0 0   sub clTRID { $_[0]->getNode('clTRID') }
94 0     0 0   sub svTRID { $_[0]->getNode('svTRID') }
95              
96             =pod
97              
98             my $msg = $frame->code;
99              
100             This method returns the code attribute of the CresultE>
101             element.
102              
103             =cut
104              
105             sub code {
106 0     0 0   my $self = shift;
107 0           my $result = $self->result;
108 0 0         if ($result) {
109 0           return $result->getAttribute('code');
110             }
111 0           return COMMAND_FAILED;
112             }
113              
114             =pod
115              
116             my $msg = $frame->msg;
117              
118             This method returns a string containing the text content of the
119             CmsgE> element.
120              
121             =cut
122              
123             sub msg {
124 0     0 0   my $self = shift;
125 0           my $msgs = $self->getElementsByLocalName('msg');
126 0 0         return $msgs->shift->textContent if ($msgs->size == 1);
127             }
128              
129             1;