File Coverage

blib/lib/WWW/NHKProgram/API/Provider/Genre.pm
Criterion Covered Total %
statement 27 35 77.1
branch 0 2 0.0
condition n/a
subroutine 9 10 90.0
pod 0 1 0.0
total 36 48 75.0


line stmt bran cond sub pod time code
1             package WWW::NHKProgram::API::Provider::Genre;
2 1     1   976 use strict;
  1         2  
  1         32  
3 1     1   7 use warnings;
  1         2  
  1         31  
4 1     1   6 use utf8;
  1         1  
  1         6  
5 1     1   21 use JSON ();
  1         3  
  1         18  
6 1     1   4 use WWW::NHKProgram::API::Area qw/fetch_area_id/;
  1         9  
  1         44  
7 1     1   547 use WWW::NHKProgram::API::Genre qw/fetch_genre_id/;
  1         2  
  1         53  
8 1     1   5 use WWW::NHKProgram::API::Service qw/fetch_service_id/;
  1         2  
  1         34  
9 1     1   5 use WWW::NHKProgram::API::Date;
  1         1  
  1         18  
10 1     1   4 use WWW::NHKProgram::API::Provider::Common;
  1         2  
  1         158  
11              
12             sub call {
13 0     0 0   my ($class, $context, $arg, $raw) = @_;
14              
15 0           my $area = fetch_area_id($arg->{area});
16 0           my $service = fetch_service_id($arg->{service});
17 0           my $genre = fetch_genre_id($arg->{genre});
18 0           my $date = WWW::NHKProgram::API::Date::validate($arg->{date});
19              
20 0           my $content = WWW::NHKProgram::API::Provider::Common::call(
21             $context,
22             "genre/%(area)s/%(service)s/%(genre)s/%(date)s.json",
23             {
24             area => $area,
25             service => $service,
26             genre => $genre,
27             date => $date,
28             },
29             $raw,
30             );
31 0 0         return $content if $raw;
32 0           return JSON::decode_json($content)->{list}->{$service};
33             }
34              
35             1;
36