demarches-normaliennes/app/lib/api_adresse/api.rb

10 lines
241 B
Ruby
Raw Normal View History

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("/")
2018-10-15 18:23:32 +02:00
RestClient.get(search_url, params: { q: address, limit: limit })
2018-10-15 17:35:44 +02:00
rescue RestClient::ServiceUnavailable
nil
end
end