2015-08-10 11:05:06 +02:00
|
|
|
module Carto
|
|
|
|
module Bano
|
|
|
|
# input : string (address)
|
|
|
|
# output : json
|
|
|
|
class Driver
|
2016-06-09 12:08:18 +02:00
|
|
|
def initialize(address, limit = 1)
|
2015-08-10 11:05:06 +02:00
|
|
|
@address = address
|
2016-06-09 12:08:18 +02:00
|
|
|
@limit = limit
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def call
|
2016-06-09 12:08:18 +02:00
|
|
|
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
|