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

17 lines
351 B
Ruby
Raw Normal View History

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