File Coverage

blib/lib/XML/SRS/Result.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1              
2             # this is called 'Response' in the XML, but we call it 'Result' to not clash
3             # with 'Response', which is actually 'NZSRSResponse'
4             package XML::SRS::Result;
5              
6 1     1   1322 use Carp;
  1         2  
  1         68  
7 1     1   172 use Moose;
  0            
  0            
8             use PRANG::Graph;
9             use XML::SRS::Types;
10             use Moose::Util::TypeConstraints;
11              
12             has_attr 'action' =>
13             is => "ro",
14             isa => "XML::SRS::ActionEtc",
15             required => 1,
16             xml_name => "Action",
17             ;
18              
19             has_attr 'fe_id' =>
20             is => "ro",
21             isa => "XML::SRS::Number",
22             required => 1,
23             xml_name => "FeId",
24             ;
25              
26             has_attr 'unique_id' =>
27             is => "ro",
28             isa => "XML::SRS::Number",
29             required => 1,
30             xml_name => "FeSeq",
31             ;
32              
33             has_attr 'by_id' =>
34             is => "ro",
35             isa => "XML::SRS::RegistrarId",
36             required => 1,
37             xml_name => "OrigRegistrarId",
38             ;
39              
40             has_attr 'for_id' =>
41             is => "ro",
42             isa => "XML::SRS::RegistrarId",
43             xml_required => 0,
44             xml_name => "RecipientRegistrarId",
45             ;
46              
47             has_attr 'client_id' =>
48             is => "ro",
49             isa => "XML::SRS::UID",
50             xml_required => 0,
51             xml_name => "TransId",
52             ;
53              
54             has_attr 'rows' =>
55             is => "ro",
56             isa => "XML::SRS::Number",
57             xml_required => 0,
58             xml_name => "Rows",
59             ;
60              
61             has_attr 'has_more_rows' =>
62             is => "ro",
63             isa => "XML::SRS::Boolean",
64             coerce => 1,
65             xml_required => 0,
66             xml_name => "MoreRowsAvailable",
67             ;
68              
69             has_attr 'count' =>
70             is => "ro",
71             isa => "XML::SRS::Number",
72             xml_required => 0,
73             xml_name => "Count",
74             ;
75              
76             subtype 'XML::SRS::timeStampType'
77             => as "XML::SRS::TimeStamp",
78             ;
79              
80             has_element 'server_time' =>
81             is => "ro",
82             isa => "XML::SRS::timeStampType",
83             coerce => 1,
84             xml_nodeName => "FeTimeStamp",
85             ;
86              
87             use MooseX::Timestamp;
88             use MooseX::TimestampTZ;
89              
90             coerce "XML::SRS::timeStampType"
91             => from TimestampTZ
92             => via {
93             XML::SRS::TimeStamp->new(timestamptz => $_);
94             };
95              
96             # this is for GetMessages responses, so let's call it messages
97             has_element 'messages' =>
98             is => "ro",
99             isa => "ArrayRef[XML::SRS::Result]",
100             xml_nodeName => "Response",
101             xml_min => 0,
102             ;
103              
104             has_element 'responses' =>
105             is => "ro",
106             isa => "ArrayRef[XML::SRS::ActionResponse]",
107             xml_required => 0,
108             lazy => 1,
109             default => sub {
110             my $self = shift;
111             ($self->has_response and defined $self->response)
112             ? [ $self->response ] : [];
113             },
114             ;
115              
116             has 'response' =>
117             is => "ro",
118             isa => "Maybe[XML::SRS::ActionResponse]",
119             predicate => "has_response",
120             lazy => 1,
121             default => sub {
122             my $self = shift;
123             my $rs_a = $self->responses;
124             if ( $rs_a and @$rs_a ) {
125             if ( @$rs_a > 1 ) {
126             confess "result has multiple responses";
127             }
128             else {
129             $rs_a->[0];
130             }
131             }
132             else {
133             undef;
134             }
135             },
136             ;
137              
138             with 'XML::SRS::Node';
139              
140             1;