class Geocoder::Lookup::PostcodeAnywhereUk

def base_query_url(query)

def base_query_url(query)
  "#{protocol}://services.postcodeanywhere.co.uk/Geocoding/UK/Geocode/v2.00/json.ws?"
end

def name

def name
  'PostcodeAnywhereUk'
end

def query_url_params(query)

def query_url_params(query)
  {
    :location => query.sanitized_text,
    :key => configuration.api_key
  }.merge(super)
end

def raise_exception_for_response(response)

def raise_exception_for_response(response)
  case response['Error']
  when *DAILY_LIMIT_EXEEDED_ERROR_CODES
    raise_error(Geocoder::OverQueryLimitError, response['Cause']) || Geocoder.log(:warn, response['Cause'])
  when INVALID_API_KEY_ERROR_CODE
    raise_error(Geocoder::InvalidApiKey, response['Cause']) || Geocoder.log(:warn, response['Cause'])
  else # anything else just raise general error with the api cause
    raise_error(Geocoder::Error, response['Cause']) || Geocoder.log(:warn, response['Cause'])
  end
end

def required_api_key_parts

def required_api_key_parts
  %w(key)
end

def results(query)

def results(query)
  response = fetch_data(query)
  return [] if response.nil? || !response.is_a?(Array) || response.empty?
  raise_exception_for_response(response[0]) if response[0]['Error']
  response
end