API2/People.pm

filter: Statementstmt 88.8% 24 / 27 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 87.5% 7 / 8 Podpod 100% 4 / 4 totaltotal 84.0% 37 / 44 CC 3 SCAR 5.5
CC
3
Cov
84%
getPublicPhotos
3.1
findByEmail
2.0
BEGIN
1.0
CRAP 1.7
« API2/Interestingness.pm ↑ Summary API2.pm »
1 package Flickr::API2::People;
2 4 ▶use 5.12.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Flickr::API2::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 extends 'Flickr::API2::Base';
7  
8 =head1 NAME
9  
10 Flickr::API2::People
11  
12 =head1 METHODS
13  
14 =head2 findByEmail
15  
16 Return a user's NSID, given their email address.
17  
18 eg. $api->people->findByEmail('john.doe@example.com')
19  
20 =cut
21  
22 0 ▶sub findByEmail {
Subroutine findByEmail: not called CC=1 SCAR=6.9
Pod documented
23 0 my ($self, $email) = @_;
24 0 my $r = $self->api->execute_method(
25 'flickr.people.findByEmail', { find_email => $email }
26 );
27 return Flickr::API2::User->new(
28 api => $self->api,
29 NSID => $r->{user}->{nsid},
30 username => $r->{user}->{username}->{_content},
31 0 );
32 }
33  
34 =head2 findByUsername
35  
36 Return a user's NSID, given their username.
37  
38 eg. $api->people->findByUsername('fakeuser')
39  
40 =cut
41  
42 1 ▶sub findByUsername {
Subroutine findByUsername: called CC=1 SCAR=0.0
Pod documented
43 1 my ($self, $username) = @_;
44 1 my $r = $self->api->execute_method(
45 'flickr.people.findByUsername', { username => $username }
46 );
47 return Flickr::API2::User->new(
48 api => $self->api,
49 NSID => $r->{user}->{nsid},
50 username => $r->{user}->{username}->{_content},
51 1 );
52 }
53  
54 =head2 getInfo
55  
56 Get information about a user.
57  
58 eg. $api->people->getInfo('12345678@N00');
59  
60 or $api->people->findByUsername('fakeuser')->getInfo;
61  
62 =cut
63  
64 1 ▶sub getInfo {
Subroutine getInfo: called CC=1 SCAR=0.0
Pod documented
65 1 my ($self, $id) = @_;
66  
67 1 my $r = $self->api->execute_method(
68 'flickr.people.getInfo', { user_id => $id }
69 );
70 1 return $r->{person};
71 }
72  
73 =head2 getPublicPhotos
74  
75 Get a list of public photos for the given user.
76  
77 eg. $api->people->getPublicPhotos('12345678@N00')
78  
79 or $api->people->findByUsername('foobar')->getPublicPhotos( per_page => 10 )
80  
81 See http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html
82 for options.
83  
84 =cut
85  
86 1 ▶sub getPublicPhotos {
Subroutine getPublicPhotos: called CC=3 SCAR=11.3
Pod documented
87 1 my ($self, $id, %args) = @_;
88  
89 1 ▶ $args{extras} ||= join(',',
Condition50%1/2
$args{"extras"} ||= "date_upload,date_taken,owner_name,url_s,url_m,url_l,path_alias,count_faves,views"
l!l
01
MC/DC0%0/1
$args{"extras"} ||= "date_upload,date_taken,owner_name,url_s,url_m,url_l,path_alias,count_faves,views"
$args{"extras"}
Truth table50%1/2
A
A= $args{"extras"}
Aresult
11
00
90 qw(
91 date_upload date_taken owner_name url_s url_m url_l path_alias count_faves views
92 )
93 );
94  
95 1 my $r = $self->api->execute_method(
96 'flickr.people.getPublicPhotos', { user_id => $id, %args }
97 );
98  
99 die("Didn't understand response (or no photos)")
100 1 ▶ unless exists $r->{photos};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $r->{"photos"} 0 1 1
101  
102 return $self->_response_to_photos($r->{photos})
103 1 }
104  
105 4 1;
« API2/Interestingness.pm ↑ Summary API2.pm »