From 6a14e443b539e566e527c828c7c55b60adc76278 Mon Sep 17 00:00:00 2001
From: Rob Murray <robmurray17@gmail.com>
Date: Fri, 30 May 2014 14:39:37 +0100
Subject: [PATCH] Add some PostcodeAnywhere API documentation to lookup and
 result impl

---
 lib/geocoder/lookups/postcode_anywhere_uk.rb | 8 +++++---
 lib/geocoder/results/postcode_anywhere_uk.rb | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/geocoder/lookups/postcode_anywhere_uk.rb b/lib/geocoder/lookups/postcode_anywhere_uk.rb
index 40b425c5..be8fe93d 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 abf13f71..3f51fbba 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
-- 
GitLab