File Coverage

blib/lib/WebService/Shutterstock/Subscription.pm
Criterion Covered Total %
statement 31 31 100.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 10 10 100.0
pod 3 3 100.0
total 47 51 92.1


line stmt bran cond sub pod time code
1             package WebService::Shutterstock::Subscription;
2             {
3             $WebService::Shutterstock::Subscription::VERSION = '0.006';
4             }
5              
6             # ABSTRACT: Class representing a subscription for a specific Shutterstock customer
7              
8 9     9   50 use strict;
  9         19  
  9         292  
9 9     9   51 use warnings;
  9         26  
  9         214  
10 9     9   46 use Moo;
  9         18  
  9         48  
11 9     9   2992 use JSON qw(encode_json);
  9         19  
  9         499  
12 9     9   7088 use WebService::Shutterstock::LicensedImage;
  9         29  
  9         349  
13 9     9   70 use Carp qw(croak);
  9         17  
  9         472  
14              
15 9     9   83 use WebService::Shutterstock::AuthedClient;
  9         32  
  9         2959  
16             with 'WebService::Shutterstock::AuthedClient';
17              
18              
19             has id => ( is => 'ro', required => 1, init_arg => 'subscription_id' );
20             my @fields = qw(
21             unix_expiration_time
22             current_allotment
23             description
24             license
25             sizes
26             site
27             expiration_time
28             price_per_download
29             );
30             foreach my $f(@fields){
31             has $f => ( is => 'ro' );
32             }
33              
34              
35             sub sizes_for_licensing {
36 3     3 1 7 my $self = shift;
37 3         5 my %uniq;
38             return
39 3         26 grep { !$uniq{$_}++ }
  3         13  
40 3 50 33     40 map { $_->{name} }
41 3 50       25 grep { $_->{name} ne 'supersize' && (!$_->{format} || $_->{format} ne 'tiff') }
42 3         7 values %{ $self->sizes || {} };
43             }
44              
45              
46             sub is_active {
47 9     9 1 16 my $self = shift;
48 9         65 return $self->unix_expiration_time > time;
49             }
50              
51              
52             sub is_expired {
53 1     1 1 1970 return !shift->is_active;
54             }
55              
56             1;
57              
58             __END__