class GdsApi::LocationsApi

def coordinates_for_postcode(postcode)

Returns:
  • (Hash) - The average coordinates (two fields, "latitude" and "longitude") for a specific postcode

Parameters:
  • postcode (String, nil) -- The postcode for which the coordinates are requested
def coordinates_for_postcode(postcode)
  response = get_json("#{endpoint}/v1/locations?postcode=#{postcode}")
  { "latitude" => response["average_latitude"], "longitude" => response["average_longitude"] } unless response["results"].nil?
end

def local_custodian_code_for_postcode(postcode)

Returns:
  • (Array) - All local custodian codes for a specific postcode

Parameters:
  • postcode (String, nil) -- The postcode for which the custodian codes are requested
def local_custodian_code_for_postcode(postcode)
  response = get_json("#{endpoint}/v1/locations?postcode=#{postcode}")
  return [] if response["results"].nil?
  response["results"].map { |r| r["local_custodian_code"] }.uniq
end