class Geocoder::Lookup::Opencagedata

def results(query)

def results(query)
  return [] unless doc = fetch_data(query)
  # return doc["results"]
  messages = doc['status']['message']
  case doc['status']['code']
  when 400 # Error with input
    raise_error(Geocoder::InvalidRequest, messages) ||
      Geocoder.log(:warn, "Opencagedata Geocoding API error: #{messages}")
  when 403 # Key related error
    raise_error(Geocoder::InvalidApiKey, messages) ||
      Geocoder.log(:warn, "Opencagedata Geocoding API error: #{messages}")
  when 402 # Quata Exceeded
      raise_error(Geocoder::OverQueryLimitError, messages) ||
      Geocoder.log(:warn, "Opencagedata Geocoding API error: #{messages}")
  when 500 # Unknown error
    raise_error(Geocoder::Error, messages) ||
      Geocoder.log(:warn, "Opencagedata Geocoding API error: #{messages}")
  end
  return doc["results"]
end