File Coverage

blib/lib/Facebook/Graph/Picture.pm
Criterion Covered Total %
statement 3 20 15.0
branch 0 2 0.0
condition n/a
subroutine 1 5 20.0
pod 4 4 100.0
total 8 31 25.8


line stmt bran cond sub pod time code
1             package Facebook::Graph::Picture;
2             $Facebook::Graph::Picture::VERSION = '1.1202';
3 4     4   15 use Moo;
  4         5  
  4         20  
4             with 'Facebook::Graph::Role::Uri';
5              
6             has type => (
7             is => 'rw',
8             predicate => 'has_type',
9             );
10              
11             has object_name => (
12             is => 'rw',
13             default => sub {''},
14             );
15              
16             sub get_small {
17 0     0 1   my ($self) = @_;
18 0           $self->type('small');
19 0           return $self;
20             }
21              
22             sub get_square {
23 0     0 1   my ($self) = @_;
24 0           $self->type('square');
25 0           return $self;
26             }
27              
28             sub get_large {
29 0     0 1   my ($self) = @_;
30 0           $self->type('large');
31 0           return $self;
32             }
33              
34             sub uri_as_string {
35 0     0 1   my ($self) = @_;
36 0           my %query;
37 0 0         if ($self->has_type) {
38 0           $query{type} = $self->type;
39             }
40 0           my $uri = $self->uri;
41 0           $uri->path($self->generate_versioned_path($self->object_name . '/picture'));
42 0           $uri->query_form(%query);
43 0           return $uri->as_string;
44             }
45              
46              
47             1;
48              
49             =head1 NAME
50              
51             Facebook::Graph::Picture - Get the URI for the picture of any object.
52              
53             =head1 VERSION
54              
55             version 1.1202
56              
57             =head1 SYNOPSIS
58              
59             my $fb = Facebook::Graph->new;
60            
61             my $default_picture = $fb->picture('16665510298')->uri_as_string;
62             my $large_picture = $fb->picture('16665510298')->get_large->uri_as_string;
63             my $small_picture = $fb->picture('16665510298')->get_small->uri_as_string;
64             my $square_picture = $fb->picture('16665510298')->get_square->uri_as_string;
65              
66             =head1 DESCRIPTION
67              
68             This module allows you to generate the URL needed to fetch a picture for any object on Facebook.
69              
70             =head1 METHODS
71              
72             =head2 new ( [ params ] )
73              
74             =over
75              
76             =item params
77              
78             A hash or hashref of parameters to pass to the constructor.
79              
80             =over
81              
82             =item object_name
83              
84             An profile id like C<sarahbownds> or an object id like C<16665510298> for the Perl page.
85              
86             =item type
87              
88             Type of picture to return. Valid types are small, square, large
89              
90             =back
91              
92             =back
93              
94             =head2 get_large ( id )
95              
96             Get a large picture. 200 pixels wide by a variable height.
97              
98             =head3 id
99              
100             The unique id or object name of an object.
101              
102             B<Example:> For user "Sarah Bownds" you could use either her profile id C<sarahbownds> or her object id C<767598108>.
103              
104              
105             =head2 get_small ( id )
106              
107             Get a small picture. 50 pixels wide by a variable height.
108              
109             =head3 id
110              
111             The unique id or object name of an object.
112              
113             B<Example:> For user "Sarah Bownds" you could use either her profile id C<sarahbownds> or her object id C<767598108>.
114              
115              
116             =head2 get_square ( id )
117              
118             Get a square picture. 50 pixels wide by 50 pixels tall.
119              
120             =head3 id
121              
122             The unique id or object name of an object.
123              
124             B<Example:> For user "Sarah Bownds" you could use either her profile id C<sarahbownds> or her object id C<767598108>.
125              
126              
127              
128              
129             =head2 uri_as_string ()
130              
131             Returns a URI string based upon all the methods you've called so far on the query. You can throw the resulting URI right into an <img> tag.
132              
133              
134             =head1 LEGAL
135              
136             Facebook::Graph is Copyright 2010 - 2012 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself.
137              
138             =cut