2018-10-15 16:33:42 +02:00
|
|
|
module ApiAdresse
|
|
|
|
# input : string (address)
|
|
|
|
# output : json
|
|
|
|
class Driver
|
|
|
|
def initialize(address, limit = 1)
|
|
|
|
@address = address
|
|
|
|
@limit = limit
|
|
|
|
end
|
|
|
|
|
|
|
|
def call
|
2018-10-15 16:38:17 +02:00
|
|
|
search_url = [API_ADRESSE_URL, "search"].join("/")
|
|
|
|
|
|
|
|
RestClient.get(search_url, params: { q: @address, limit: @limit })
|
2018-10-15 16:33:42 +02:00
|
|
|
rescue RestClient::ServiceUnavailable
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|