| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WWW::Google::URLShortener::Params; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | $WWW::Google::URLShortener::Params::VERSION = '0.19'; | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =head1 NAME | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | WWW::Google::URLShortener::Params - Placeholder for parameters for L. | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 VERSION | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | Version 0.19 | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =cut | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 2 |  |  | 2 |  | 52 | use 5.006; | 
|  | 2 |  |  |  |  | 6 |  | 
| 16 | 2 |  |  | 2 |  | 10 | use strict; use warnings; | 
|  | 2 |  |  | 2 |  | 3 |  | 
|  | 2 |  |  |  |  | 41 |  | 
|  | 2 |  |  |  |  | 9 |  | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 54 |  | 
| 17 | 2 |  |  | 2 |  | 1709 | use Data::Validate::URI qw(is_uri); | 
|  | 2 |  |  |  |  | 102826 |  | 
|  | 2 |  |  |  |  | 129 |  | 
| 18 | 2 |  |  | 2 |  | 15 | use Data::Dumper; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 107 |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 2 |  |  | 2 |  | 11 | use vars qw(@ISA @EXPORT @EXPORT_OK); | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 781 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | require Exporter; | 
| 23 |  |  |  |  |  |  | @ISA = qw(Exporter); | 
| 24 |  |  |  |  |  |  | @EXPORT_OK = qw(validate); | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | sub check_url { | 
| 27 | 3 |  |  | 3 | 0 | 5 | my ($str) = @_; | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 3 | 50 | 33 |  |  | 69 | die "ERROR: Invalid data type 'url' [$str]" unless (defined $str && is_uri($str)); | 
| 30 |  |  |  |  |  |  | }; | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | our $FIELDS = { | 
| 33 |  |  |  |  |  |  | 'shortUrl' => { check => sub { check_url(@_) }, type => 's' }, | 
| 34 |  |  |  |  |  |  | 'longUrl'  => { check => sub { check_url(@_) }, type => 's' }, | 
| 35 |  |  |  |  |  |  | }; | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | sub validate { | 
| 38 | 6 |  |  | 6 | 0 | 12 | my ($fields, $values) = @_; | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 6 | 50 |  |  |  | 14 | die "ERROR: Missing params list." unless (defined $values); | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 6 | 50 |  |  |  | 19 | die "ERROR: Parameters have to be hash ref" unless (ref($values) eq 'HASH'); | 
| 43 |  |  |  |  |  |  |  | 
| 44 | 6 |  |  |  |  | 8 | foreach my $field (keys %{$fields}) { | 
|  | 6 |  |  |  |  | 20 |  | 
| 45 |  |  |  |  |  |  | die "ERROR: Received invalid param: $field" | 
| 46 | 6 | 50 |  |  |  | 17 | unless (exists $FIELDS->{$field}); | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | die "ERROR: Missing mandatory param: $field" | 
| 49 | 6 | 50 | 33 |  |  | 35 | if ($fields->{$field} && !exists $values->{$field}); | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | die "ERROR: Received undefined mandatory param: $field" | 
| 52 | 6 | 100 | 66 |  |  | 47 | if ($fields->{$field} && !defined $values->{$field}); | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | $FIELDS->{$field}->{check}->($values->{$field}) | 
| 55 | 3 | 50 |  |  |  | 13 | if defined $values->{$field}; | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =head1 AUTHOR | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | Mohammad S Anwar, C<<  >> | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =head1 REPOSITORY | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | L | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | =head1 BUGS | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | Please report any bugs or feature requests to C, | 
| 70 |  |  |  |  |  |  | or through the web interface at L. | 
| 71 |  |  |  |  |  |  | I will be notified, and then you'll automatically be notified of progress on your | 
| 72 |  |  |  |  |  |  | bug as I make changes. | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =head1 SUPPORT | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | perldoc WWW::Google::Places::Params | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | You can also look for information at: | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =over 4 | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | =item * RT: CPAN's request tracker (report bugs here) | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | L | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | L | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | L | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =item * Search CPAN | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | L | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | =back | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | Copyright (C) 2011 - 2015 Mohammad S Anwar. | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | This  program  is  free software; you can redistribute it and/or modify it under | 
| 107 |  |  |  |  |  |  | the  terms  of the the Artistic License (2.0). You may obtain a copy of the full | 
| 108 |  |  |  |  |  |  | license at: | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | L | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | Any  use,  modification, and distribution of the Standard or Modified Versions is | 
| 113 |  |  |  |  |  |  | governed by this Artistic License.By using, modifying or distributing the Package, | 
| 114 |  |  |  |  |  |  | you accept this license. Do not use, modify, or distribute the Package, if you do | 
| 115 |  |  |  |  |  |  | not accept this license. | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | If your Modified Version has been derived from a Modified Version made by someone | 
| 118 |  |  |  |  |  |  | other than you,you are nevertheless required to ensure that your Modified Version | 
| 119 |  |  |  |  |  |  | complies with the requirements of this license. | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | This  license  does  not grant you the right to use any trademark,  service mark, | 
| 122 |  |  |  |  |  |  | tradename, or logo of the Copyright Holder. | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | This license includes the non-exclusive, worldwide, free-of-charge patent license | 
| 125 |  |  |  |  |  |  | to make,  have made, use,  offer to sell, sell, import and otherwise transfer the | 
| 126 |  |  |  |  |  |  | Package with respect to any patent claims licensable by the Copyright Holder that | 
| 127 |  |  |  |  |  |  | are  necessarily  infringed  by  the  Package. If you institute patent litigation | 
| 128 |  |  |  |  |  |  | (including  a  cross-claim  or  counterclaim) against any party alleging that the | 
| 129 |  |  |  |  |  |  | Package constitutes direct or contributory patent infringement,then this Artistic | 
| 130 |  |  |  |  |  |  | License to you shall terminate on the date that such litigation is filed. | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | Disclaimer  of  Warranty:  THE  PACKAGE  IS  PROVIDED BY THE COPYRIGHT HOLDER AND | 
| 133 |  |  |  |  |  |  | CONTRIBUTORS  "AS IS'  AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | 
| 134 |  |  |  |  |  |  | WARRANTIES    OF   MERCHANTABILITY,   FITNESS   FOR   A   PARTICULAR  PURPOSE, OR | 
| 135 |  |  |  |  |  |  | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | 
| 136 |  |  |  |  |  |  | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | 
| 137 |  |  |  |  |  |  | INDIRECT, INCIDENTAL,  OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | 
| 138 |  |  |  |  |  |  | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | =cut | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | 1; # End of WWW::Google::Places::Params |