blib/lib/Flickr/API/Cameras.pm

filter: Statementstmt 22.9% 14 / 61 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 100% 3 / 3 totaltotal 26.9% 21 / 78 CC 6 SCAR 19.3
CC
6
Cov
21%
brands_list
12.0
get_cameras
12.0
brands_hash
6.0
CRAP 6.9
« blib/lib/Flickr/API/Request.pm ↑ Summary blib/script/flickr_make_stored_config.pl »
1 package Flickr::API::Cameras;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use parent qw( Flickr::API );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our $VERSION = '1.28';
9  
10 0 ▶sub _initialize {
Subroutine _initialize: not called CC=1 SCAR=6.9
11  
12 0 my $self = shift;
13 0 $self->_set_status(1,'API::Cameras initialized');
14 0 return;
15  
16 }
17  
18 0 ▶sub brands_list {
Subroutine brands_list: not called CC=3 SCAR=24.8
Pod documented
19  
20 0 my $self = shift;
21 0 my $rsp = $self->execute_method('flickr.cameras.getBrands');
22 0 my $listref = ();
23  
24 0 $rsp->_propagate_status($self->{flickr}->{status});
25  
26 0 ▶ if ($rsp->success() == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rsp->success == 1) { } 0 0 0
27  
28 0 foreach my $cam (@{$rsp->as_hash()->{brands}->{brand}}) {
29  
30 0 push (@{$listref},$cam->{name});
31  
32 }
33  
34 0 $self->_set_status(1,"flickr.camera.getBrands returned " . $#{$listref} . " brands.");
35  
36 }
37 else {
38  
39  
40 0 $self->_set_status(0,"Flickr::API::Cameras Methods list/hash failed with response error");
41  
42 0 carp "Flickr::API::Cameras Methods list/hash failed with response error: ",$rsp->error_code()," \n ",
43 $rsp->error_message(),"\n";
44  
45 }
46 0 return $listref;
47 }
48  
49  
50  
51  
52 0 ▶sub brands_hash {
Subroutine brands_hash: not called CC=2 SCAR=17.9
Pod documented
53  
54 0 my $self = shift;
55 0 my $arrayref = $self->brands_list();
56 0 my $hashref;
57  
58  
59 0 ▶ if ($arrayref) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arrayref) { } 0 0 0
60  
61 0 %{$hashref} = map {$_ => 1} @{$arrayref};
62  
63 }
64 else {
65  
66 0 $hashref = {};
67  
68 }
69 0 return $hashref;
70 }
71  
72 0 ▶sub get_cameras {
Subroutine get_cameras: not called CC=3 SCAR=24.8
Pod documented
73  
74 0 my $self = shift;
75 0 my $brand = shift;
76 0 my $rsp = $self->execute_method('flickr.cameras.getBrandModels',
77 {'brand' => $brand});
78 0 my $hash = $rsp->as_hash();
79 0 my $AoH = {};
80 0 my $desc = {};
81  
82 0 my $cam;
83  
84 0 $rsp->_propagate_status($self->{flickr}->{status});
85  
86 0 ▶ if ($rsp->success() == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rsp->success == 1) { } 0 0 0
87  
88 0 $AoH = $hash->{cameras}->{camera};
89  
90 0 foreach $cam (@{$AoH}) {
91  
92 0 $desc->{$brand}->{$cam->{id}}->{name} = $cam->{name};
93 0 $desc->{$brand}->{$cam->{id}}->{details} = $cam->{details};
94 0 $desc->{$brand}->{$cam->{id}}->{images} = $cam->{images};
95  
96 }
97  
98 0 $self->_set_status(1,"flickr.camera.getBrandModels returned " . $#{$AoH} . " models.");
99  
100 }
101 else {
102  
103  
104 0 $self->_set_status(0,"Flickr::API::Cameras get_cameras failed with response error");
105  
106 0 carp "Flickr::API::Cameras get_cameras method failed with error code: ",$rsp->error_code()," \n ",
107 $rsp->error_message(),"\n";
108  
109  
110 }
111  
112 0 return $desc;
113 }
114  
115  
116 1 1;
117  
118 __END__
« blib/lib/Flickr/API/Request.pm ↑ Summary blib/script/flickr_make_stored_config.pl »