line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Flickr::API::Cameras; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14076
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
2
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
66
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
375
|
use parent qw( Flickr::API ); |
|
1
|
|
|
|
|
216
|
|
|
1
|
|
|
|
|
3
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.28'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _initialize { |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
$self->_set_status(1,'API::Cameras initialized'); |
14
|
|
|
|
|
|
|
return; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub brands_list { |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
my $rsp = $self->execute_method('flickr.cameras.getBrands'); |
22
|
|
|
|
|
|
|
my $listref = (); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$rsp->_propagate_status($self->{flickr}->{status}); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
if ($rsp->success() == 1) { |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
foreach my $cam (@{$rsp->as_hash()->{brands}->{brand}}) { |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
push (@{$listref},$cam->{name}); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$self->_set_status(1,"flickr.camera.getBrands returned " . $#{$listref} . " brands."); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->_set_status(0,"Flickr::API::Cameras Methods list/hash failed with response error"); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
carp "Flickr::API::Cameras Methods list/hash failed with response error: ",$rsp->error_code()," \n ", |
43
|
|
|
|
|
|
|
$rsp->error_message(),"\n"; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
return $listref; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub brands_hash { |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
my $arrayref = $self->brands_list(); |
56
|
|
|
|
|
|
|
my $hashref; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if ($arrayref) { |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
%{$hashref} = map {$_ => 1} @{$arrayref}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$hashref = {}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
return $hashref; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_cameras { |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
my $brand = shift; |
76
|
|
|
|
|
|
|
my $rsp = $self->execute_method('flickr.cameras.getBrandModels', |
77
|
|
|
|
|
|
|
{'brand' => $brand}); |
78
|
|
|
|
|
|
|
my $hash = $rsp->as_hash(); |
79
|
|
|
|
|
|
|
my $AoH = {}; |
80
|
|
|
|
|
|
|
my $desc = {}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $cam; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$rsp->_propagate_status($self->{flickr}->{status}); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
if ($rsp->success() == 1) { |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$AoH = $hash->{cameras}->{camera}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
foreach $cam (@{$AoH}) { |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$desc->{$brand}->{$cam->{id}}->{name} = $cam->{name}; |
93
|
|
|
|
|
|
|
$desc->{$brand}->{$cam->{id}}->{details} = $cam->{details}; |
94
|
|
|
|
|
|
|
$desc->{$brand}->{$cam->{id}}->{images} = $cam->{images}; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$self->_set_status(1,"flickr.camera.getBrandModels returned " . $#{$AoH} . " models."); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else { |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$self->_set_status(0,"Flickr::API::Cameras get_cameras failed with response error"); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
return $desc; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |