line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Yahoo::BOSS::Response; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
WebService::Yahoo::BOSS::Response - Response class for Yahoo BOSS searches |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
17
|
use Moo; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
23
|
|
10
|
3
|
|
|
3
|
|
3984
|
use JSON::XS (); |
|
3
|
|
|
|
|
17427
|
|
|
3
|
|
|
|
|
77
|
|
11
|
3
|
|
|
3
|
|
19
|
use Data::Dumper; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
157
|
|
12
|
3
|
|
|
3
|
|
15
|
use Module::Runtime qw(require_module); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
24
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'count' => ( is => 'ro', required => 1 ); |
15
|
|
|
|
|
|
|
has 'start' => ( is => 'ro', required => 1 ); |
16
|
|
|
|
|
|
|
has 'results' => ( is => 'ro', required => 1 ); |
17
|
|
|
|
|
|
|
has 'totalresults' => ( is => 'ro', required => 0 ); # not provided by all services |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub parse { |
21
|
0
|
|
|
0
|
0
|
|
my ( $class, $content, $resultclass ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $response = JSON::XS::decode_json($content); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $rc = $response->{bossresponse}->{responsecode}; |
26
|
0
|
0
|
|
|
|
|
die "Boss response error $rc: " . Dumper($response) |
27
|
|
|
|
|
|
|
unless $rc == 200; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
require_module($resultclass); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $results = $resultclass->parse($response->{bossresponse}); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $self = $class->new( %$results ); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |