0.0
No commit activity in last 3 years
No release in over 3 years
Gem that lets user find a brazilian address with the given zip_code.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
>= 0
~> 10.0

Runtime

 Project Readme

BrZipCode

This gem helps you to find an address based on a brazilian zip code. For that, 5 webservices are used:

The webservices are searched in order. If one is not available, the next is tested until one is available or none.

Installation

Add this line to your application's Gemfile:

gem 'br_zip_code'

And then execute:

$ bundle

Or install it yourself as:

$ gem install br_zip_code

Usage

BrZipCode.get("22451090")   #=> {:street=>"Rua Duque Estrada", :state=>"RJ", :city=>"Rio de Janeiro", :district=>"Gávea"}
BrZipCode.get("22.451-090") #=> {:street=>"Rua Duque Estrada", :state=>"RJ", :city=>"Rio de Janeiro", :district=>"Gávea"}
BrZipCode.get("22451-090")  #=> {:street=>"Rua Duque Estrada", :state=>"RJ", :city=>"Rio de Janeiro", :district=>"Gávea"}

BrZipCode.get("12345678")   #=> nil
BrZipCode.get("1234567")    #=> nil

Basic JSON API

The route /zip_code/:zip_code.json (/zip_code/22441090.json, for example) is accessible. Pass the zip_code and get the response, so you can create AJAX function to autocomplete addresses.

So, http://localhost:3000/zip_code/22441090.json will return:

{
  "success":true,
  "zip_code_info":
  {
    "street_type":"Rua",
    "street":"Rua General Venâncio Flores",
    "state":"RJ",
    "city":"Rio de Janeiro",
    "neighborhood":"Leblon"
  }
}

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/br_zip_code/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request