Geo-Coder-GeocodeFarm

 view release on metacpan or  search on metacpan

t/070_reverse_geocode.t  view on Meta::CPAN

                'locality' => 'Anoka',
                'admin_1' => 'Minnesota',
                'country' => 'United States',
                'admin_2' => 'Anoka County'
            },
            'LOCATION_DETAILS' => {
                'timezone_long' => 'UNAVAILABLE',
                'elevation' => 'UNAVAILABLE',
                'timezone_short' => 'America/Menominee'
            },
            'result_number' => 1,
            'accuracy' => 'EXACT_MATCH',
            'BOUNDARIES' => {
                'southwest_longitude' => '-93.4017002802923',
                'northeast_longitude' => '-93.4003513351005',
                'southwest_latitude' => '45.2027761197094',
                'northeast_latitude' => '45.2041251364687'
            },
            'COORDINATES' => {
                'longitude' => '-93.4003513716516',
                'latitude' => '45.2041251738751'
            }
        }
    ],
    'STATISTICS' => {
        'https_ssl' => 'DISABLED, INSECURE'
    },
    'STATUS' => {
        'address_provided' => '530 W Main St Anoka MN 55303 US',
        'access' => 'FREE_USER, ACCESS_GRANTED',
        'status' => 'SUCCESS',
        'result_count' => 1
    },
};

{
    my $result = $geocode->reverse_geocode(latlng => '45.2040305,-93.3995728');

    isa_ok $result, 'HASH';

    cmp_deeply $result, $expected, '$result matches deeply';

    is $ua->{url}, 'http://www.geocode.farm/v3/json/reverse/?lat=45.2040305&lon=-93.3995728', 'url matches';
}

{
    my $result = $geocode->reverse_geocode(lat => 45.2040305, lon => -93.3995728);

    isa_ok $result, 'HASH';

    cmp_deeply $result, $expected, '$result matches deeply';

    is $ua->{url}, 'http://www.geocode.farm/v3/json/reverse/?lat=45.2040305&lon=-93.3995728', 'url matches';
}


package My::Mock;

sub new {
    my ($class) = @_;
    return bless +{} => $class;
}


package LWP::UserAgent;

sub get { }


package HTTP::Response;

sub is_success { }

sub decoded_content { }


package My::Mock::LWP::UserAgent;

use base 'My::Mock', 'LWP::UserAgent';

sub get {
    my ($self, $url) = @_;
    $self->{url} = $url;
    return My::Mock::HTTP::Response->new;
}


package My::Mock::HTTP::Response;

use base 'My::Mock', 'HTTP::Response';

sub is_success {
    return 1;
}

sub decoded_content {
    return << 'END';
{
    "geocoding_results": {
        "LEGAL_COPYRIGHT": {
            "copyright_notice": "Copyright (c) 2015 Geocode.Farm - All Rights Reserved.",
            "copyright_logo": "https:\/\/www.geocode.farm\/images\/logo.png",
            "terms_of_service": "https:\/\/www.geocode.farm\/policies\/terms-of-service\/",
            "privacy_policy": "https:\/\/www.geocode.farm\/policies\/privacy-policy\/"
        },
        "STATUS": {
            "access": "FREE_USER, ACCESS_GRANTED",
            "status": "SUCCESS",
            "address_provided": "530 W Main St Anoka MN 55303 US",
            "result_count": 1
        },
        "ACCOUNT": {
            "ip_address": "1.2.3.4",
            "distribution_license": "NONE, UNLICENSED",
            "usage_limit": "250",
            "used_today": "28",
            "used_total": "28",
            "first_used": "26 Mar 2015"
        },
        "RESULTS": [
            {

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 3.579 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-48ebf85a1963 )