File Coverage

blib/lib/Role/REST/Client/Response.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Role::REST::Client::Response;
2             $Role::REST::Client::Response::VERSION = '0.21';
3 3     3   18 use Moo;
  3         19  
  3         19  
4 3     3   2666 use MooX::HandlesVia;
  3         10  
  3         32  
5 3     3   353 use Types::Standard qw(Str Int CodeRef InstanceOf);
  3         6  
  3         32  
6              
7             has 'code' => (
8             isa => Int,
9             is => 'ro',
10             );
11             has 'response' => (
12             isa => InstanceOf['HTTP::Response'],
13             is => 'ro',
14             );
15             has 'error' => (
16             isa => Str,
17             is => 'ro',
18             predicate => 'failed',
19             );
20             has 'data_callback' => (
21             init_arg => 'data',
22             isa => CodeRef,
23             is => 'ro',
24             default => sub { sub { {} } },
25             handles_via => 'Code',
26             handles => { data => 'execute' },
27             );
28              
29             1;
30              
31             __END__
32              
33             =pod
34              
35             =encoding UTF-8
36              
37             =head1 NAME
38              
39             Role::REST::Client::Response
40              
41             =head1 VERSION
42              
43             version 0.21
44              
45             =head1 SYNOPSIS
46              
47             my $res = Role::REST::Client::Response->new(
48             code => '200',
49             response => HTTP::Response->new(...),
50             error => 0,
51             data_callback => sub { sub { ... } },
52             );
53              
54             =head1 NAME
55              
56             Role::REST::Client::Response - Response class for REST
57              
58             =head1 ATTRIBUTES
59              
60             =head2 code
61              
62             HTTP status code of the request
63              
64             =head2 response
65              
66             L<HTTP::Response> object. Use this if you need more information than status and content.
67              
68             =head2 error
69              
70             The error description returned from the user agent when the HTTP status code is 500 or higher. More detail may be found
71             by calling C<< $res->response->content >>.
72              
73             =head2 failed
74              
75             True if the request didn't succeed.
76              
77             =head2 data
78              
79             The deserialized data. Returns an empty hashref if the response was unsuccessful.
80              
81             =head1 BUGS
82              
83             Please report any bugs or feature requests to bug-role-rest-client at rt.cpan.org, or through the
84             web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Role-REST-Client.
85              
86             =head1 AUTHOR
87              
88             Kaare Rasmussen <kaare at cpan dot org>
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             This software is copyright (c) 2017 by Kaare Rasmussen.
93              
94             This is free software; you can redistribute it and/or modify it under
95             the same terms as the Perl 5 programming language system itself.
96              
97             =cut