blib/lib/WebService/ZombiesRun.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 70 CC 2 SCAR 9.2
CC
2
Cov
0%
_fetch_user_path
6.0
_build_agent
2.0
_build_json
2.0
CRAP 2.5
1 package WebService::ZombiesRun;
2 use v5.010;
3 use strict;
4 use warnings;
5 use autodie;
6 use Moo;
7 use JSON::Any;
8 use WWW::Mechanize;
9 use Data::Dumper;
10  
11 our $DEBUG = 0;
12  
13 use constant API_BASE => 'https://www.zombiesrungame.com/api/v3';
14  
15 # ABSTRACT: Access run information from the Zombies, Run! game
16  
17 our $VERSION = '0.01'; # VERSION: Generated by DZP::OurPkg:Version
18  
19 has player => (is => 'rw');
20 has agent => (is => 'lazy');
21 has json => (is => 'lazy');
22  
23 sub _build_agent { return WWW::Mechanize->new; }
24 sub _build_json { return JSON::Any->new; }
25  
26  
27 sub runs_raw {
28 my ($self) = @_;
29  
30 return $self->_fetch_user_path("manifest")->{objects};
31 }
32  
33  
34 sub total_runs { my ($self) = @_; return $self->meta_raw->{total_count}; }
35  
36  
37 sub meta_raw { my ($self) = @_; return $self->_fetch_user_path("manifest")->{meta}; }
38  
39 sub _fetch_user_path {
40 my ($self, $path) = @_;
41  
42 my $user = $self->player;
43  
44 my $call = join("/", API_BASE, "user/$user", $path, "?format=json");
45  
46 warn "Calling $call\n" if $DEBUG;
47 $self->agent->get($call);
48  
49 return $self->json->decode( $self->agent->content );
50 }
51  
52  
53 1;
54  
55 __END__