demarches-normaliennes/lib/carto/bano/driver.rb

23 lines
445 B
Ruby
Raw Normal View History

2015-08-10 11:05:06 +02:00
module Carto
module Bano
# input : string (address)
# output : json
class Driver
def initialize(address, limit = 1)
2015-08-10 11:05:06 +02:00
@address = address
@limit = limit
2015-08-10 11:05:06 +02:00
end
def call
RestClient.get api_url, params: { q: @address, limit: @limit }
rescue RestClient::ServiceUnavailable
nil
2015-08-10 11:05:06 +02:00
end
def api_url
'http://api-adresse.data.gouv.fr/search'
end
end
end
end