Skip to content
Snippets Groups Projects
Commit 6a14e443 authored by Rob Murray's avatar Rob Murray
Browse files

Add some PostcodeAnywhere API documentation to lookup and result impl

parent c439bdf4
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,10 @@ require 'geocoder/results/postcode_anywhere_uk' ...@@ -3,8 +3,10 @@ require 'geocoder/results/postcode_anywhere_uk'
module Geocoder::Lookup module Geocoder::Lookup
class PostcodeAnywhereUk < Base 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' 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 def name
'PostcodeAnywhereUk' 'PostcodeAnywhereUk'
...@@ -30,9 +32,9 @@ module Geocoder::Lookup ...@@ -30,9 +32,9 @@ module Geocoder::Lookup
def raise_exception_for_response(response) def raise_exception_for_response(response)
case response['Error'] 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']) 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']) raise_error(Geocoder::InvalidApiKey, response['Cause']) || warn(response['Cause'])
else # anything else just raise general error with the api cause else # anything else just raise general error with the api cause
raise_error(Geocoder::Error, response['Cause']) || warn(response['Cause']) raise_error(Geocoder::Error, response['Cause']) || warn(response['Cause'])
......
...@@ -25,6 +25,8 @@ module Geocoder::Result ...@@ -25,6 +25,8 @@ module Geocoder::Result
city.strip city.strip
end end
# This is a UK only API; all results are UK specific and
# so ommitted from API response.
def country def country
'United Kingdom' 'United Kingdom'
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment