This gem provides a simple way to validate and format Brazilian postal codes (CEP).
$ gem install brazil-cep
Or add this line to your application's Gemfile:
gem 'brazil-cep'
address = Brazil::Cep.fetch('01311-200')
address.street # => "Avenida Paulista"
address.neighborhood # => "Bela Vista"
address = Brazil::Cep.fetch('01311-200', provider: :postmon)
address.street # => "Avenida Paulista"
address.neighborhood # => "Bela Vista"
module Brazil
module Cep
module Adapters
class MyProvider < Base
provider base_url: 'https://api.myprovider.com/address/{{cep}}'
private
def transformation!
address_params = {
street: response[:street],
neighborhood: response[:neighborhood],
...
}
Brazil::Cep::Address.new(**address_params)
end
end
end
end
Bug reports and pull requests are welcome on GitHub at https://github.com/dvinciguerra/brazil-cep. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
Everyone interacting in the Brazil::Cep project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Created by Daniel Vinciguerra and available as open source under the terms of the MIT License.