diff --git a/lib/geocoder/lookups/postcode_anywhere_uk.rb b/lib/geocoder/lookups/postcode_anywhere_uk.rb index 40b425c567290647c9d123e54de5999ee296d401..be8fe93df265ca2339ef723513eef9e3520e9a15 100644 --- a/lib/geocoder/lookups/postcode_anywhere_uk.rb +++ b/lib/geocoder/lookups/postcode_anywhere_uk.rb @@ -3,8 +3,10 @@ require 'geocoder/results/postcode_anywhere_uk' module Geocoder::Lookup class PostcodeAnywhereUk < Base - + # API documentation: http://www.postcodeanywhere.co.uk/Support/WebService/Geocoding/UK/Geocode/2/ BASE_URL_GEOCODE_V2_00 = 'services.postcodeanywhere.co.uk/Geocoding/UK/Geocode/v2.00/json.ws' + DAILY_LIMIT_EXEEDED_ERROR_CODES = ['8', '17'] # api docs say these two codes are the same error + INVALID_API_KEY_ERROR_CODE = '2' def name 'PostcodeAnywhereUk' @@ -30,9 +32,9 @@ module Geocoder::Lookup def raise_exception_for_response(response) case response['Error'] - when '8', '17' # api docs say these two codes are the same error + when *DAILY_LIMIT_EXEEDED_ERROR_CODES raise_error(Geocoder::OverQueryLimitError, response['Cause']) || warn(response['Cause']) - when '2' + when INVALID_API_KEY_ERROR_CODE raise_error(Geocoder::InvalidApiKey, response['Cause']) || warn(response['Cause']) else # anything else just raise general error with the api cause raise_error(Geocoder::Error, response['Cause']) || warn(response['Cause']) diff --git a/lib/geocoder/results/postcode_anywhere_uk.rb b/lib/geocoder/results/postcode_anywhere_uk.rb index abf13f7193918356dea542a611062372c1ced453..3f51fbba6247aa11f3b5e705612a1c5dc34bafb0 100644 --- a/lib/geocoder/results/postcode_anywhere_uk.rb +++ b/lib/geocoder/results/postcode_anywhere_uk.rb @@ -25,6 +25,8 @@ module Geocoder::Result city.strip end + # This is a UK only API; all results are UK specific and + # so ommitted from API response. def country 'United Kingdom' end