| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Address::PostCode::India; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | $Address::PostCode::India::VERSION   = '0.12'; | 
| 4 |  |  |  |  |  |  | $Address::PostCode::India::AUTHORITY = 'cpan:MANWAR'; | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | =head1 NAME | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | Address::PostCode::India - Interface to the India PinCode. | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | =head1 VERSION | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | Version 0.12 | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | =cut | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 4 |  |  | 4 |  | 142284 | use 5.006; | 
|  | 4 |  |  |  |  | 42 |  | 
| 17 | 4 |  |  | 4 |  | 2999 | use JSON; | 
|  | 4 |  |  |  |  | 52010 |  | 
|  | 4 |  |  |  |  | 35 |  | 
| 18 | 4 |  |  | 4 |  | 3156 | use Data::Dumper; | 
|  | 4 |  |  |  |  | 30466 |  | 
|  | 4 |  |  |  |  | 323 |  | 
| 19 | 4 |  |  | 4 |  | 1996 | use Address::PostCode::UserAgent; | 
|  | 4 |  |  |  |  | 471705 |  | 
|  | 4 |  |  |  |  | 185 |  | 
| 20 | 4 |  |  | 4 |  | 2276 | use Address::PostCode::India::Place; | 
|  | 4 |  |  |  |  | 15 |  | 
|  | 4 |  |  |  |  | 172 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 4 |  |  | 4 |  | 31 | use Moo; | 
|  | 4 |  |  |  |  | 13 |  | 
|  | 4 |  |  |  |  | 19 |  | 
| 23 | 4 |  |  | 4 |  | 1363 | use namespace::autoclean; | 
|  | 4 |  |  |  |  | 11 |  | 
|  | 4 |  |  |  |  | 33 |  | 
| 24 |  |  |  |  |  |  | extends 'Address::PostCode::UserAgent'; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | our $BASE_URL = 'http://getpincodes.info/api.php'; | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | The API service  is provided by L. | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | A Postal Index Number or PIN or Pincode is the post office numbering or post code | 
| 33 |  |  |  |  |  |  | system used by India Post, the Indian postal administration. The code is 6 digits | 
| 34 |  |  |  |  |  |  | long. The PIN was introduced on 15 August 1972. | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | There are nine PIN zones in India,including eight regional zones & one functional | 
| 37 |  |  |  |  |  |  | zone  (Indian Army). The  first  digit  of the PIN code indicates the region. The | 
| 38 |  |  |  |  |  |  | second digit indicates the sub-region, and  the third digit indicates the sorting | 
| 39 |  |  |  |  |  |  | district within the region.The final three digits are assigned to individual post | 
| 40 |  |  |  |  |  |  | offices. | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | +-------------------------+-------------------------------------------------+ | 
| 43 |  |  |  |  |  |  | | First 2/3 Digits of PIN | Postal Circle                                   | | 
| 44 |  |  |  |  |  |  | +-------------------------+-------------------------------------------------+ | 
| 45 |  |  |  |  |  |  | | 11                      | Delhi                                           | | 
| 46 |  |  |  |  |  |  | | 12 and 13               | Haryana                                         | | 
| 47 |  |  |  |  |  |  | | 14 to 15                | Punjab                                          | | 
| 48 |  |  |  |  |  |  | | 16                      | Chandigarh                                      | | 
| 49 |  |  |  |  |  |  | | 17                      | Himachal Pradesh                                | | 
| 50 |  |  |  |  |  |  | | 18 to 19                | Jammu and Kashmir                               | | 
| 51 |  |  |  |  |  |  | | 20 to 28                | Uttar Pradesh/Uttrakhand                        | | 
| 52 |  |  |  |  |  |  | | 30 to 34                | Rajasthan                                       | | 
| 53 |  |  |  |  |  |  | | 36 to 39                | Gujarat                                         | | 
| 54 |  |  |  |  |  |  | | 40                      | Goa                                             | | 
| 55 |  |  |  |  |  |  | | 40 to 44                | Maharashtra                                     | | 
| 56 |  |  |  |  |  |  | | 45 to 48                | Madhya Pradesh                                  | | 
| 57 |  |  |  |  |  |  | | 49                      | Chhattisgarh                                    | | 
| 58 |  |  |  |  |  |  | | 50 to 53                | Andhra Pradesh                                  | | 
| 59 |  |  |  |  |  |  | | 56 to 59                | Karnataka                                       | | 
| 60 |  |  |  |  |  |  | | 60 to 64                | Tamil Nadu                                      | | 
| 61 |  |  |  |  |  |  | | 67 to 69                | Kerala                                          | | 
| 62 |  |  |  |  |  |  | | 682                     | Lakshadweep (Islands)                           | | 
| 63 |  |  |  |  |  |  | | 70 to 74                | West Bengal                                     | | 
| 64 |  |  |  |  |  |  | | 744                     | Andaman and Nicobar Islands                     | | 
| 65 |  |  |  |  |  |  | | 75 to 77                | Odisha                                          | | 
| 66 |  |  |  |  |  |  | | 78                      | Assam                                           | | 
| 67 |  |  |  |  |  |  | | 79                      | Arunachal Pradesh                               | | 
| 68 |  |  |  |  |  |  | | 793, 794, 783123        | Meghalaya                                       | | 
| 69 |  |  |  |  |  |  | | 795                     | Manipur                                         | | 
| 70 |  |  |  |  |  |  | | 796                     | Mizoram                                         | | 
| 71 |  |  |  |  |  |  | | 799                     | Tripura                                         | | 
| 72 |  |  |  |  |  |  | | 80 to 85                | Bihar and Jharkhand                             | | 
| 73 |  |  |  |  |  |  | +-------------------------+-------------------------------------------------+ | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | =head1 METHODS | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =head2 details($pin_code) | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | It  returns  an object of type L on success. The | 
| 80 |  |  |  |  |  |  | only parameter requires is the 6-digits pin code. | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | use strict; use warnings; | 
| 83 |  |  |  |  |  |  | use Address::PostCode::India; | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | my $address  = Address::PostCode::India->new; | 
| 86 |  |  |  |  |  |  | my $pin_code = 832110; | 
| 87 |  |  |  |  |  |  | my $place    = $address->details($pin_code); | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | print "City    : ", $place->city,     "\n"; | 
| 90 |  |  |  |  |  |  | print "District: ", $place->district, "\n"; | 
| 91 |  |  |  |  |  |  | print "State   : ", $place->state,    "\n"; | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =cut | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | sub details { | 
| 96 | 3 |  |  | 3 | 1 | 4576 | my ($self, $pin_code) = @_; | 
| 97 |  |  |  |  |  |  |  | 
| 98 | 3 | 100 |  |  |  | 18 | die "ERROR: Missing required param 'pin code'.\n" unless defined $pin_code; | 
| 99 | 2 | 50 |  |  |  | 18 | die "ERROR: Invalid pin code [$pin_code].\n"      unless ($pin_code =~ /^\d{6}$/); | 
| 100 |  |  |  |  |  |  |  | 
| 101 | 0 |  |  |  |  |  | my $url      = sprintf("%s?pincode=%d", $BASE_URL, $pin_code); | 
| 102 | 0 |  |  |  |  |  | my $response = $self->get($url); | 
| 103 | 0 |  |  |  |  |  | my $contents = from_json($response->{'content'}); | 
| 104 |  |  |  |  |  |  |  | 
| 105 | 0 |  |  |  |  |  | return Address::PostCode::India::Place->new($contents->[0]); | 
| 106 |  |  |  |  |  |  | } | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =head1 AUTHOR | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | Mohammad S Anwar, C<<  >> | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | =head1 REPOSITORY | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | L | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =head1 BUGS | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | Please report any bugs or feature requests to C, | 
| 119 |  |  |  |  |  |  | or through the web interface at L. | 
| 120 |  |  |  |  |  |  | I will be notified, and then you'll automatically be notified of progress on your | 
| 121 |  |  |  |  |  |  | bug as I make changes. | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | =head1 SUPPORT | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | perldoc Address::PostCode::India | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | You can also look for information at: | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | =over 4 | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | =item * RT: CPAN's request tracker (report bugs here) | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | L | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | L | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | L | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | =item * Search CPAN | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | L | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | =back | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | Copyright (C) 2014 - 2015 Mohammad S Anwar. | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | This program  is  free software; you can redistribute it and / or modify it under | 
| 156 |  |  |  |  |  |  | the  terms  of the the Artistic License (2.0). You may obtain  a copy of the full | 
| 157 |  |  |  |  |  |  | license at: | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | L | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | Any  use,  modification, and distribution of the Standard or Modified Versions is | 
| 162 |  |  |  |  |  |  | governed by this Artistic License.By using, modifying or distributing the Package, | 
| 163 |  |  |  |  |  |  | you accept this license. Do not use, modify, or distribute the Package, if you do | 
| 164 |  |  |  |  |  |  | not accept this license. | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | If your Modified Version has been derived from a Modified Version made by someone | 
| 167 |  |  |  |  |  |  | other than you,you are nevertheless required to ensure that your Modified Version | 
| 168 |  |  |  |  |  |  | complies with the requirements of this license. | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | This  license  does  not grant you the right to use any trademark,  service mark, | 
| 171 |  |  |  |  |  |  | tradename, or logo of the Copyright Holder. | 
| 172 |  |  |  |  |  |  |  | 
| 173 |  |  |  |  |  |  | This license includes the non-exclusive, worldwide, free-of-charge patent license | 
| 174 |  |  |  |  |  |  | to make,  have made, use,  offer to sell, sell, import and otherwise transfer the | 
| 175 |  |  |  |  |  |  | Package with respect to any patent claims licensable by the Copyright Holder that | 
| 176 |  |  |  |  |  |  | are  necessarily  infringed  by  the  Package. If you institute patent litigation | 
| 177 |  |  |  |  |  |  | (including  a  cross-claim  or  counterclaim) against any party alleging that the | 
| 178 |  |  |  |  |  |  | Package constitutes direct or contributory patent infringement,then this Artistic | 
| 179 |  |  |  |  |  |  | License to you shall terminate on the date that such litigation is filed. | 
| 180 |  |  |  |  |  |  |  | 
| 181 |  |  |  |  |  |  | Disclaimer  of  Warranty:  THE  PACKAGE  IS  PROVIDED BY THE COPYRIGHT HOLDER AND | 
| 182 |  |  |  |  |  |  | CONTRIBUTORS  "AS IS'  AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | 
| 183 |  |  |  |  |  |  | WARRANTIES    OF   MERCHANTABILITY,   FITNESS   FOR   A   PARTICULAR  PURPOSE, OR | 
| 184 |  |  |  |  |  |  | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | 
| 185 |  |  |  |  |  |  | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | 
| 186 |  |  |  |  |  |  | INDIRECT, INCIDENTAL,  OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | 
| 187 |  |  |  |  |  |  | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 188 |  |  |  |  |  |  |  | 
| 189 |  |  |  |  |  |  | =cut | 
| 190 |  |  |  |  |  |  |  | 
| 191 |  |  |  |  |  |  | 1; # End of Address::PostCode::India |