zipcode_locator <img src=“https://badge.fury.io/rb/zipcode_locator.svg” alt=“Gem Version” /> <img src=“https://travis-ci.org/anildias/zipcode_locator.svg?branch=master” alt=“Build Status” /> ¶ ↑
Get Zipcodes and Location info by using ZipCode APIS.
Usage¶ ↑
To use this gem, first you need to register your application at Zipcode API visit www.zipcodeapi.com/Register, give your application name and email, then obtain an apikey which can be used to communicate with zipcode apis.
$ apikey = "xxxxxxxx"
then,
$ gem install zipcode_locator
initialize zipcode_locator object with this apikey
$ @object = ZipcodeLocator.new(apikey)
Zipcode Locator methods¶ ↑
zipcode_locator supports different units and reposnse formats, To get repsonse in particular format with a particulat unit, you can pass these as an optional parameter
optional parameter includes unit and format for the request. unit can be any of these availble units
unit : 'km', 'mile', 'degree', and 'radians' and format : 'json', 'xml', and 'csv' $ options = { :unit => "km", :format => "json" }
Zipcode Distance¶ ↑
$ zipcode1 = 10001 $ zipcode2 = 10005 $ @object.distance_between_zipcodes(zipcode1, zipcode2, options)
Zipcodes By Radius¶ ↑
$ zipcode = 10001 $ radius = 5 $ @object.get_zipcodes_by_radius(zipcode, radius, options)
Find close Zipcodes¶ ↑
$ zipcodes = "10001, 10005"
or
$ zipcodes = [10001, 10005] $ distance = 5 $ @object.find_close_zipcodes(zipcodes, distance, options)
Zipcode to Location info¶ ↑
$ zipcode = 10005 $ @object.zipcode_location_info(zipcode, options)
Multi Zipcodes to Location info¶ ↑
$ zipcodes = "10001, 10005"
or
$ zipcodes = [10001, 10005] $ @object.multi_zipcodes_location_info(zipcodes, options)
Location to Zipcodes¶ ↑
$ city = "Brooklyn" $ state = "NY" $ @object.get_zipcodes_by_locations(city, state, options)
Run Tests¶ ↑
$ rake test
Contributing to zipcode_locator¶ ↑
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.
-
Fork the project.
-
Start a feature/bugfix branch.
-
Commit and push until you are happy with your contribution.
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright¶ ↑
Copyright © 2016 anildias. See LICENSE.txt for further details.