class Geocoder::Lookup::Pointpin

def results(query)

def results(query)
  # don't look up a loopback or private address, just return the stored result
  return [] if query.internal_ip_address?
  doc = fetch_data(query)
  if doc and doc.is_a?(Hash)
    if !data_contains_error?(doc)
      return [doc]
    elsif doc['error']
      case doc['error']
      when "Invalid IP address"
        raise_error(Geocoder::InvalidRequest) || Geocoder.log(:warn, "Invalid Pointpin request.")
      when "Invalid API key"
        raise_error(Geocoder::InvalidApiKey) || Geocoder.log(:warn, "Invalid Pointpin API key.")
      when "Address not found"
        Geocoder.log(:warn, "Address not found.")
      end
    else
      raise_error(Geocoder::Error) || Geocoder.log(:warn, "Pointpin server error")
    end
  end
  return []
end