class Geocoder::Lookup::PostcodeAnywhereUk
def name
def name 'PostcodeAnywhereUk' end
def query_url(query)
def query_url(query) format('%s://%s?%s', protocol, BASE_URL_GEOCODE_V2_00, url_query_string(query)) 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