line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pikeo::API::Album; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use base qw( Pikeo::API::Base ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
9
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
10
|
1
|
|
|
1
|
|
7
|
use Pikeo::API::User; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
461
|
|
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
|
|
sub _info_fields {qw( id owner_id owner_username title |
13
|
|
|
|
|
|
|
description cover_url )} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Pikeo::API::Album - Abstraction of a pikeo photo album |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Pikeo::API; |
22
|
|
|
|
|
|
|
use Pikeo::API::User; |
23
|
|
|
|
|
|
|
use Pikeo::API::Album; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# create an API object to maintain you session |
26
|
|
|
|
|
|
|
# trough out the diferent calls |
27
|
|
|
|
|
|
|
my $api = Pikeo::API->new({api_secret=>'asd', api_key=>'asdas'}); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Get a user by id... |
30
|
|
|
|
|
|
|
my $user = Pikeo::API::User->new({ api => $api, id=>1 }); |
31
|
|
|
|
|
|
|
# get the albums for this user |
32
|
|
|
|
|
|
|
my $albums = $user->getAlbumsList; |
33
|
|
|
|
|
|
|
# get one album photos |
34
|
|
|
|
|
|
|
my $album = $albums->[0]; |
35
|
|
|
|
|
|
|
my $photos = $album->getPhotos(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# .. or get a album by id |
38
|
|
|
|
|
|
|
my $other_album = Pikeo::API::Album->new({ api => $api, id=>999 }); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 CONSTRUCTORS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head3 new( \%args ) |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Returns a Pikeo::API::User object. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Required args are: |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over 4 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * api |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Pikeo::API object |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Optional args are: |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * from_xml |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
XML::LibXML node containing the album details |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item * id |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
id of the album |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub new { |
67
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
68
|
0
|
|
|
|
|
|
my $params = shift; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new($params); |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if ( $params->{from_xml} ) { |
73
|
0
|
|
|
|
|
|
$self->_init_from_xml( $params->{from_xml} ); |
74
|
0
|
|
|
|
|
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
0
|
0
|
|
|
|
|
if ( $params->{id} ) { |
77
|
0
|
|
|
|
|
|
$self->{id} = $params->{id}; |
78
|
0
|
|
|
|
|
|
return $self; |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
|
croak "Need an xml object"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 INSTANCE METHODS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head3 owner() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Pikeo::API::User that owns the album |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub owner { |
94
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
return Pikeo::API::User->new({ id => $self->owner_id, api => $self->api }); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head3 id() |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns the album id |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
1
|
|
sub id { return shift->{id} } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head3 getPhotos() |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Return a list of Pikeo::API::Photo with all the photos in the album |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
sub getPhotos { |
112
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
113
|
0
|
|
|
|
|
|
my $params = shift; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $req_params = { album_id => $self->id }; |
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
if ( $params->{'num_items'} ) { |
118
|
0
|
|
|
|
|
|
$req_params->{'num_items'} = $params->{'num_items'}; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.albums.getPhotos', $req_params ); |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return $self->_photos_from_xml({ xml => [$doc->findnodes('//photo')] }); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _init_from_xml { |
127
|
0
|
|
|
0
|
|
|
my $self = shift; |
128
|
0
|
|
|
|
|
|
my $doc = shift; |
129
|
0
|
|
|
|
|
|
my $nodes = $doc->findnodes("./*"); |
130
|
0
|
|
|
|
|
|
for ($nodes->get_nodelist()) { |
131
|
0
|
0
|
|
|
|
|
$self->{$_->nodeName} = ( $_->to_literal eq 'null' ? undef : $_->to_literal ); |
132
|
|
|
|
|
|
|
} |
133
|
0
|
0
|
|
|
|
|
croak "could not init from XML, missing id" unless $self->{id}; |
134
|
0
|
|
|
|
|
|
$self->{_init} = 1; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |