Class: OlaMaps::Client
- Inherits:
-
Object
- Object
- OlaMaps::Client
- Defined in:
- lib/ola_maps/client.rb
Constant Summary collapse
- BASE_URL =
'https://api.olamaps.io'
Instance Method Summary collapse
- #autocomplete(input, origin: nil, location: nil, radius: nil, strictbounds: nil) ⇒ Object
- #geocode(address, bounds: nil, language: 'English') ⇒ Object
-
#initialize(api_key: nil, client_id: nil, client_secret: nil) ⇒ Client
constructor
A new instance of Client.
- #reverse_geocode(latlng) ⇒ Object
Constructor Details
#initialize(api_key: nil, client_id: nil, client_secret: nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/ola_maps/client.rb', line 9 def initialize(api_key: nil, client_id: nil, client_secret: nil) @api_key = api_key @client_id = client_id @client_secret = client_secret end |
Instance Method Details
#autocomplete(input, origin: nil, location: nil, radius: nil, strictbounds: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/ola_maps/client.rb', line 15 def autocomplete(input, origin: nil, location: nil, radius: nil, strictbounds: nil) query = { input: input, api_key: @api_key } query[:origin] = origin if origin query[:location] = location if location query[:radius] = radius if radius query[:strictbounds] = strictbounds if strictbounds get('/places/v1/autocomplete', query) end |
#geocode(address, bounds: nil, language: 'English') ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ola_maps/client.rb', line 25 def geocode(address, bounds: nil, language: 'English') query = { address: address, api_key: @api_key } query[:bounds] = bounds if bounds query[:language] = language get('/places/v1/geocode', query) end |
#reverse_geocode(latlng) ⇒ Object
33 34 35 36 37 |
# File 'lib/ola_maps/client.rb', line 33 def reverse_geocode(latlng) query = { latlng: latlng, api_key: @api_key } get('/places/v1/reverse-geocode', query) end |