File Coverage

blib/lib/WWW/Google/Places/DetailResult.pm
Criterion Covered Total %
statement 26 105 24.7
branch 0 14 0.0
condition 0 2 0.0
subroutine 9 11 81.8
pod 0 2 0.0
total 35 134 26.1


line stmt bran cond sub pod time code
1             package WWW::Google::Places::DetailResult;
2              
3             $WWW::Google::Places::DetailResult::VERSION = '0.35';
4             $WWW::Google::Places::DetailResult::AUTHORITY = 'cpan:MANWAR';
5              
6             =head1 NAME
7              
8             WWW::Google::Places::DetailResult - Placeholder for detail Search Result for WWW::Google::Places.
9              
10             =head1 VERSION
11              
12             Version 0.35
13              
14             =cut
15              
16 8     8   146 use 5.006;
  8         28  
17 8     8   43 use Data::Dumper;
  8         19  
  8         367  
18 8     8   3554 use WWW::Google::Places::Photo;
  8         26  
  8         245  
19 8     8   3685 use WWW::Google::Places::Review;
  8         29  
  8         378  
20 8     8   3725 use WWW::Google::Places::Address;
  8         27  
  8         293  
21 8     8   62 use WWW::Google::Places::Geometry;
  8         35  
  8         212  
22              
23 8     8   39 use Moo;
  8         16  
  8         33  
24 8     8   2397 use namespace::clean;
  8         18  
  8         63  
25              
26 8     8   2203 use overload q{""} => 'as_string', fallback => 1;
  8         16  
  8         43  
27              
28             has 'place_id' => (is => 'ro', required => 1 );
29             has 'website' => (is => 'ro', default => sub { 'N/A' });
30             has 'formatted_phone_number' => (is => 'ro', default => sub { 'N/A' });
31             has 'opening_hours' => (is => 'ro', default => sub { 'N/A' });
32             has 'internation_number' => (is => 'ro', default => sub { 'N/A' });
33             has 'photos' => (is => 'ro', default => sub { 'N/A' });
34             has 'utf_offset' => (is => 'ro', default => sub { 'N/A' });
35             has 'rating' => (is => 'ro', default => sub { 'N/A' });
36             has 'user_ratings_total' => (is => 'ro', default => sub { 'N/A' });
37             has 'reviews' => (is => 'ro');
38             has 'vicinity' => (is => 'ro');
39             has 'adr_address' => (is => 'ro');
40             has 'reference' => (is => 'ro');
41             has 'geometry' => (is => 'ro');
42             has 'scope' => (is => 'ro');
43             has 'icon' => (is => 'ro');
44             has 'name' => (is => 'ro');
45             has 'types' => (is => 'ro');
46             has 'formatted_address' => (is => 'ro');
47             has 'url' => (is => 'ro');
48             has 'address_components' => (is => 'ro');
49              
50             sub BUILDARGS {
51 0     0 0   my ($class, $args) = @_;
52              
53 0           my $reviews = [];
54 0 0         if (exists $args->{reviews}) {
55 0           foreach (@{$args->{reviews}}) {
  0            
56 0           push @$reviews, WWW::Google::Places::Review->new($_);
57             }
58             }
59             else {
60 0           push @$reviews, WWW::Google::Places::Review->new;
61             }
62              
63 0           $args->{reviews} = $reviews;
64              
65 0 0         if (exists $args->{geometry}) {
66 0           $args->{geometry} = WWW::Google::Places::Geometry->new($args->{geometry});
67             }
68              
69 0 0         if (exists $args->{photos}) {
70 0           my $photos = [];
71 0           foreach (@{$args->{photos}}) {
  0            
72 0           push @$photos, WWW::Google::Places::Photo->new($_);
73             }
74              
75 0           $args->{photos} = $photos;
76             }
77              
78 0 0         if (exists $args->{address_components}) {
79 0           my $address_components = [];
80 0           foreach (@{$args->{address_components}}) {
  0            
81 0           push @$address_components, WWW::Google::Places::Address->new($_);
82             }
83              
84 0           $args->{address_components} = $address_components;
85             }
86              
87 0           return $args;
88             }
89              
90             =head1 METHODS
91              
92             =head2 name()
93              
94             Returns place name.
95              
96             =head2 types()
97              
98             Returns ref to a list of place types as defined in the pod document of L.
99              
100             =head2 url()
101              
102             Returns place URL.
103              
104             =head2 place_id()
105              
106             Returns place id.
107              
108             =head2 vicinity()
109              
110             =head2 website()
111              
112             Returns place website.
113              
114             =head2 formatted_phone_number()
115              
116             Returns place formatted phone number.
117              
118             =head2 adr_address()
119              
120             =head2 reference()
121              
122             Returns place reference.
123              
124             =head2 utf_offset()
125              
126             =head2 geometry()
127              
128             Returns an object of type L.
129              
130             =head2 scope()
131              
132             Returns place search scope.
133              
134             =head2 icon()
135              
136             Returns link to the place icon.
137              
138             =head2 reviews()
139              
140             Returns ref to a list of objects of type L.
141              
142             =head2 rating()
143              
144             Returns place rating.
145              
146             =head2 user_ratings_total()
147              
148             Retuns place total user ratings.
149              
150             =head2 formatted_address()
151              
152             Returns place address.
153              
154             =head2 address_components()
155              
156             Returns ref to a list of objects of type L.
157              
158             =head2 opening_hours()
159              
160             Returns place opening hours.
161              
162             =head2 internation_number()
163              
164             Returns place internation number.
165              
166             =head2 photos()
167              
168             Returns ref to a list of objects of type L.
169              
170             =cut
171              
172             sub as_string {
173 0     0 0   my ($self) = @_;
174              
175 0           my $detail_result = '';
176 0           $detail_result .= sprintf("Place ID : %s\n", $self->place_id);
177 0           $detail_result .= sprintf("Name : %s\n", $self->name);
178 0           $detail_result .= sprintf("Website : %s\n", $self->website);
179 0           $detail_result .= sprintf("URL : %s\n", $self->url);
180 0           $detail_result .= sprintf("Phone Number : %s\n", $self->formatted_phone_number);
181 0           $detail_result .= sprintf("Opening Hours : %s\n", $self->opening_hours);
182 0           $detail_result .= sprintf("Internation Number: %s\n", $self->internation_number);
183 0           $detail_result .= sprintf("UTF Offset : %s\n", $self->utf_offset);
184 0           $detail_result .= sprintf("Rating : %s\n", $self->rating);
185 0           $detail_result .= sprintf("User Ratings : %s\n", $self->user_ratings_total);
186 0           $detail_result .= sprintf("Vicinity : %s\n", $self->vicinity);
187 0           $detail_result .= sprintf("Address : %s\n", $self->adr_address);
188 0           $detail_result .= sprintf("Reference : %s\n", $self->reference);
189 0           $detail_result .= sprintf("Geometry : %s\n", $self->geometry);
190 0           $detail_result .= sprintf("Scope : %s\n", $self->scope);
191 0           $detail_result .= sprintf("Icon : %s\n", $self->icon);
192 0           $detail_result .= sprintf("Types : %s\n", join(", ", @{$self->types}));
  0            
193 0           $detail_result .= sprintf("Address : %s\n", $self->formatted_address);
194              
195 0 0         if (@{$self->address_components}) {
  0            
196 0           $detail_result .= sprintf("Address Components:\n");
197 0           foreach (@{$self->address_components}) {
  0            
198 0           $detail_result .= sprintf("\tShort Name: %s\n", $_->short_name);
199 0           $detail_result .= sprintf("\tLong Name : %s\n", $_->long_name);
200 0           $detail_result .= sprintf("\tTypes : %s\n", join(", ", @{$_->types}));
  0            
201 0           $detail_result .= sprintf("\t-----------\n");
202             }
203             }
204              
205 0 0         if (@{$self->reviews}) {
  0            
206 0           $detail_result .= sprintf("Reviews :\n");
207 0           foreach (@{$self->reviews}) {
  0            
208 0           $detail_result .= sprintf("\tAuthor Name: %s\n", $_->author_name);
209 0           $detail_result .= sprintf("\tAuthor URL : %s\n", $_->author_url);
210 0           $detail_result .= sprintf("\tLanguage : %s\n", $_->language);
211 0           $detail_result .= sprintf("\tRating : %s\n", $_->rating);
212 0           $detail_result .= sprintf("\tText : %s\n", $_->text);
213 0           $detail_result .= sprintf("\tTime : %s\n", $_->time);
214 0   0       $detail_result .= sprintf("\tAspects : %s\n", $_->aspects||'N/A');
215 0           $detail_result .= sprintf("\t-----------\n");
216             }
217             }
218 0 0         if (@{$self->photos}) {
  0            
219 0           $detail_result .= sprintf("Photos : \n");
220 0           foreach (@{$self->photos}) {
  0            
221 0           $detail_result .= sprintf("\tWidth :%s\n", $_->width);
222 0           $detail_result .= sprintf("\tHeight :%s\n", $_->height);
223 0           $detail_result .= sprintf("\tReference :%s\n", $_->photo_reference);
224 0           $detail_result .= sprintf("\tHTML Attributions :%s\n", join("html_attributions}));
  0            
225 0           $detail_result .= sprintf("\t-------------------\n");
226             }
227             }
228              
229 0           return $detail_result;
230             }
231              
232             =head1 AUTHOR
233              
234             Mohammad S Anwar, C<< >>
235              
236             =head1 REPOSITORY
237              
238             L
239              
240             =head1 BUGS
241              
242             Please report any bugs or feature requests to C,
243             or through the web interface at L.
244             I will be notified, and then you'll automatically be notified of progress on your
245             bug as I make changes.
246              
247             =head1 SUPPORT
248              
249             You can find documentation for this module with the perldoc command.
250              
251             perldoc WWW::Google::Places::DetailResult
252              
253             You can also look for information at:
254              
255             =over 4
256              
257             =item * RT: CPAN's request tracker (report bugs here)
258              
259             L
260              
261             =item * AnnoCPAN: Annotated CPAN documentation
262              
263             L
264              
265             =item * CPAN Ratings
266              
267             L
268              
269             =item * Search CPAN
270              
271             L
272              
273             =back
274              
275             =head1 LICENSE AND COPYRIGHT
276              
277             Copyright (C) 2011 - 2016 Mohammad S Anwar.
278              
279             This program is free software; you can redistribute it and / or modify it under
280             the terms of the the Artistic License (2.0). You may obtain a copy of the full
281             license at:
282              
283             L
284              
285             Any use, modification, and distribution of the Standard or Modified Versions is
286             governed by this Artistic License.By using, modifying or distributing the Package,
287             you accept this license. Do not use, modify, or distribute the Package, if you do
288             not accept this license.
289              
290             If your Modified Version has been derived from a Modified Version made by someone
291             other than you,you are nevertheless required to ensure that your Modified Version
292             complies with the requirements of this license.
293              
294             This license does not grant you the right to use any trademark, service mark,
295             tradename, or logo of the Copyright Holder.
296              
297             This license includes the non-exclusive, worldwide, free-of-charge patent license
298             to make, have made, use, offer to sell, sell, import and otherwise transfer the
299             Package with respect to any patent claims licensable by the Copyright Holder that
300             are necessarily infringed by the Package. If you institute patent litigation
301             (including a cross-claim or counterclaim) against any party alleging that the
302             Package constitutes direct or contributory patent infringement,then this Artistic
303             License to you shall terminate on the date that such litigation is filed.
304              
305             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
306             CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
307             WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
308             NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
309             REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
310             INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
311             OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
312              
313             =cut
314              
315             1; # End of WWW::Google::Places::DetailResult