File Coverage

blib/lib/WebService/Shutterstock/Video.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             package WebService::Shutterstock::Video;
2             {
3             $WebService::Shutterstock::Video::VERSION = '0.006';
4             }
5              
6             # ABSTRACT: Represent the set of information about a Shutterstock video as returned by the API
7              
8 10     10   31594 use strict;
  10         26  
  10         403  
9 10     10   56 use warnings;
  10         26  
  10         382  
10              
11 10     10   1362 use Moo;
  10         39124  
  10         66  
12 10     10   6755 use WebService::Shutterstock::DeferredData qw(deferred);
  10         25  
  10         105  
13              
14 10     10   3685 use WebService::Shutterstock::HasClient;
  10         26  
  10         3721  
15             with 'WebService::Shutterstock::HasClient';
16              
17              
18             has id => ( is => 'ro', required => 1, init_arg => 'video_id' );
19              
20             deferred(
21             qw(
22             categories
23             description
24             keywords
25             aspect_ratio_common
26             aspect
27             duration
28             sizes
29             model_release
30             r_rated
31             submitter_id
32             web_url
33             is_available
34             ),
35             sub {
36             my $self = shift;
37             my $client = $self->client;
38             $client->GET( sprintf( '/videos/%s.json', $self->id ) );
39             my $data = $client->process_response(404 => sub {
40             return { is_available => 0 };
41             });
42             $data->{is_available} = 1 if $data->{video_id} && $self->id == $data->{video_id};
43             return $data;
44             }
45             );
46              
47             sub size {
48 2     2 1 989 my $self = shift;
49 2         4 my $size = shift;
50 2 100       8 return exists($self->sizes->{$size}) ? $self->sizes->{$size} : undef;
51             }
52              
53             1;
54              
55             __END__