2018-10-15 17:35:44 +02:00
|
|
|
class ApiAdresse::API
|
2018-10-15 18:23:32 +02:00
|
|
|
def self.call(address, limit = 1)
|
2018-10-15 17:35:44 +02:00
|
|
|
search_url = [API_ADRESSE_URL, "search"].join("/")
|
|
|
|
|
2019-04-23 14:31:01 +02:00
|
|
|
RestClient::Request.execute(method: :get,
|
|
|
|
url: search_url,
|
|
|
|
timeout: 5,
|
|
|
|
headers: { params: { q: address, limit: limit } })
|
2018-10-15 17:35:44 +02:00
|
|
|
rescue RestClient::ServiceUnavailable
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|