{"id":18892404,"url":"https://github.com/marcelobarreto/autocomplete_zipcode","last_synced_at":"2025-07-06T14:40:20.336Z","repository":{"id":20309074,"uuid":"89416963","full_name":"marcelobarreto/autocomplete_zipcode","owner":"marcelobarreto","description":"\"Automagically\" fills an address form through zipcode (Brazil only)","archived":false,"fork":false,"pushed_at":"2023-01-23T09:00:55.000Z","size":145,"stargazers_count":19,"open_issues_count":16,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-08T18:42:38.485Z","etag":null,"topics":["brazil","cep","javascript","rails","ruby","simpleform","zipcode"],"latest_commit_sha":null,"homepage":"http://autocompletezipcode.herokuapp.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcelobarreto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":"FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"marcelobarreto"}},"created_at":"2017-04-25T23:46:35.000Z","updated_at":"2023-03-27T14:03:19.000Z","dependencies_parsed_at":"2023-02-12T21:45:25.764Z","dependency_job_id":null,"html_url":"https://github.com/marcelobarreto/autocomplete_zipcode","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelobarreto%2Fautocomplete_zipcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelobarreto%2Fautocomplete_zipcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelobarreto%2Fautocomplete_zipcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelobarreto%2Fautocomplete_zipcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcelobarreto","download_url":"https://codeload.github.com/marcelobarreto/autocomplete_zipcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223651389,"owners_count":17179919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brazil","cep","javascript","rails","ruby","simpleform","zipcode"],"created_at":"2024-11-08T08:02:05.311Z","updated_at":"2024-11-08T08:03:06.784Z","avatar_url":"https://github.com/marcelobarreto.png","language":"Ruby","readme":"# AutocompleteZipcode\n\nThis gem was built to \"automagically\" fills an address form, for Rails version \u003e= 3.1.\n\n## Status\n\n[![Build Status](https://api.travis-ci.com/marcelobarreto/autocomplete_zipcode.svg?branch=master)](https://travis-ci.com/marcelobarreto/autocomplete_zipcode)\n[![Maintainability](https://api.codeclimate.com/v1/badges/37008f3eeaaf2ea47122/maintainability)](https://codeclimate.com/github/marcelobarreto/autocomplete_zipcode/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/37008f3eeaaf2ea47122/test_coverage)](https://codeclimate.com/github/marcelobarreto/autocomplete_zipcode/test_coverage)\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)\n[![RubyGems](http://img.shields.io/gem/dt/autocomplete_zipcode.svg?style=flat)](http://rubygems.org/gems/autocomplete_zipcode)\n\n## Try it\n\n[Online](http://autocompletezipcode.herokuapp.com)\n\n## Installation\n\nAdd the following gems to your application's Gemfile:\n\n```ruby\ngem 'autocomplete_zipcode'\n```\n\nAnd then execute:\n\n```bash\nbundle install\n```\n\n## Simple Usage\n\nIn app/assets/javascripts/application.js, you should add as follows:\n\n```js\n// app/assets/javascripts/application.js\n//= require ...\n//= require turbolinks\n//= require jquery\n//= require autocomplete_zipcode\n\n$(document).on('ready', () =\u003e {\n  AutocompleteZipcode.mount();\n});\n```\n\n## Basic Example\n\n```erb\n\u003c%= simple_form_for :example do |f| %\u003e\n  ...\n  \u003c%= f.input :zipcode, as: :zipcode %\u003e\n  \u003c%= f.input :street, as: :street %\u003e\n  \u003c%= f.input :neighborhood, as: :neighborhood %\u003e\n  \u003c%= f.input :city, as: :city %\u003e\n  \u003c%= f.input :state, as: :state %\u003e\n  ...\n\u003c% end %\u003e\n```\n\nIf you are not using simple_form, then simply add the `data-provider=\"zipcode\"` and the other fields name to the input field yourself.\n\n```erb\n\u003c%= form_for :example do |f| %\u003e\n  ...\n  \u003c%= f.text_field :zipcode, data: { autocomplete_zipcode_provider: :zipcode } %\u003e\n  \u003c%= f.text_field :street, data: { autocomplete_zipcode_provider: :street }  %\u003e\n  ...\n\u003c% end %\u003e\n```\n\n## Handle invalid zipcodes\n\nSimply add an event listener callback to `zipcode.error`, for example:\n\n```js\n// app/assets/javascripts/application.js\n\ndocument.addEventListener('zipcode.error', () =\u003e {\n  alert('Invalid zipcode!!!')\n});\n```\n\n## Advanced Usage\n\n```js\n// app/assets/javascripts/application.js\n//= require ...\n//= require turbolinks\n//= require jquery\n//= require autocomplete_zipcode\n\n$(document).on('ready', () =\u003e {\n  AutocompleteZipcode.mount({\n    onSuccess: (containerEl, zipcodeEl) =\u003e {\n      console.log(containerEl, zipcodeEl);\n    },\n    onFail: (containerEl, zipcodeEl) =\u003e {\n      console.log(containerEl, zipcodeEl);\n    },\n  });\n\n  document.addEventListener('zipcode.success', () =\u003e {\n    console.log('zipcode fetched successfully');\n  });\n\n  document.addEventListener('zipcode.error', () =\u003e {\n    console.log('zipcode fetch failed');\n  });\n});\n```\n\n## Sample projects\n\nFor an online example, take a look at [this repository](https://github.com/marcelobarreto/autocomplete_zipcode_example).\nYou can also see it working on the dummy application (`spec/dummy`)\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","funding_links":["https://patreon.com/marcelobarreto"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcelobarreto%2Fautocomplete_zipcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcelobarreto%2Fautocomplete_zipcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcelobarreto%2Fautocomplete_zipcode/lists"}