Shutterstock/Lightbox.pm

filter: Statementstmt 45.0% 18 / 40 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 60.0% 6 / 10 Podpod n/a totaltotal 43.6% 24 / 55 CC 3 SCAR 10.4
CC
3
Cov
41%
_build_public_url
6.0
images
6.0
delete_image
2.0
CRAP 2.8
« Shutterstock/Video.pm ↑ Summary Shutterstock/Image.pm »
1 package WebService::Shutterstock::Lightbox;
2 {
3 $WebService::Shutterstock::Lightbox::VERSION = '0.006';
4 }
5  
6 # ABSTRACT: Representation of a lightbox in Shutterstock's public API
7  
8 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use WebService::Shutterstock::Image;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use WebService::Shutterstock::DeferredData qw(deferred);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 12 ▶use WebService::Shutterstock::AuthedClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 with 'WebService::Shutterstock::AuthedClient';
16  
17 deferred(
18 ['lightbox_name' => 'name', 'rw'],
19 ['images' => '_images', 'ro'],
20 sub {
21 my $self = shift;
22 my $client = $self->client;
23 $client->GET( sprintf('/lightboxes/%s/extended.json', $self->id), $self->with_auth_params );
24 return $client->process_response;
25 }
26 );
27  
28  
29 has id => ( is => 'rw', init_arg => 'lightbox_id' );
30 has public_url => ( is => 'lazy' );
31  
32 0 ▶sub _build_public_url {
Subroutine _build_public_url: not called CC=2 SCAR=17.9
33 0 my $self = shift;
34 0 my $client = $self->client;
35 0 $client->GET( sprintf( '/lightboxes/%s/public_url.json', $self->id ), $self->with_auth_params );
36 0 ▶ if(my $data = $client->process_response){
Branch: 1 branch
BranchTrueFalseTotal
if (my $data = $client->process_response) 0 0 0
37 0 return $data->{public_url};
38 }
39 0 return;
40 }
41  
42  
43 0 ▶sub delete_image {
Subroutine delete_image: not called CC=1 SCAR=6.9
44 0 my $self = shift;
45 0 my $image_id = shift;
46 0 my $client = $self->client;
47 0 $client->DELETE(
48 sprintf( '/lightboxes/%s/images/%s.json', $self->id, $image_id ),
49 $self->with_auth_params( username => $self->username )
50 );
51 0 delete $self->{_images};
52 0 return $client->process_response;
53 }
54  
55  
56 0 ▶sub add_image {
Subroutine add_image: not called CC=1 SCAR=6.9
57 0 my $self = shift;
58 0 my $image_id = shift;
59 0 my $client = $self->client;
60 0 $client->PUT(
61 sprintf(
62 '/lightboxes/%s/images/%s.json?%s',
63 $self->id,
64 $image_id,
65 $client->buildQuery(
66 username => $self->username,
67 auth_token => $self->auth_token
68 )
69 )
70 );
71 0 delete $self->{_images};
72 0 return $client->process_response;
73 }
74  
75  
76 0 ▶sub images {
Subroutine images: not called CC=2 SCAR=17.9
77 0 my $self = shift;
78 0 ▶ return [ map { $self->new_with_auth('WebService::Shutterstock::Image', %$_ ) } @{ $self->_images || [] } ];
Condition0%0/2
$self->_images || []
l!l
00
MC/DC0%0/1
$self->_images || []
$self->_images
Truth table0%0/2
A
A= $self->_images
Aresult
11
00
79 }
80  
81 1;
82  
83 __END__
« Shutterstock/Video.pm ↑ Summary Shutterstock/Image.pm »