Crystal wrapper around the Google Places API
Add this to your application's shard.yml
:
dependencies:
google-places:
github: liepaja/google-places
require "google-places"
Default options
#GooglePlaces::Api::Client.new(api_key : String, @format = Formats::Json, tls = true)
client = GooglePlaces::Api::Client.new("AIzaSyAdutrZU_b83yb4Otn-6yuJ79QvFR9anIM") # Xml currently not supported
response = client.autocomplete("Riga")
response.status # Ok
response.predictions[0].description # Riga, Latvia
Custom options
client = GooglePlaces::Api::Client.new("AIzaSyAdutrZU_b83yb4Otn-6yuJ79QvFR9anIM")
response = client.autocomplete("Riga", {"types" => "(cities)", "language" => "nl"})
response.status # Ok
response.predictions[0].description # Riga, Letland
OpenSSL workaround
# Some users face OpenSSL issues, in this case tls can be made insecure
client = GooglePlaces::Api::Client.new("AIzaSyAdutrZU_b83yb4Otn-6yuJ79QvFR9anIM", GooglePlaces::Formats::Json, tls = false)
- Expand api
- Write tests
- Solve OpenSSL issues
- Fork it ( https://github.com/liepaja/google-places/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- liepaja Ernests Elksnis - creator, maintainer