Class: GdsApi::LocationsApi
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#coordinates_for_postcode(postcode) ⇒ Hash
Get the average coordinates for a postcode.
-
#local_custodian_code_for_postcode(postcode) ⇒ Array
Get a list of local custodian codes for a postcode.
Methods inherited from Base
#client, #create_client, #get_list, #initialize, #url_for_slug
Constructor Details
This class inherits a constructor from GdsApi::Base
Instance Method Details
#coordinates_for_postcode(postcode) ⇒ Hash
Get the average coordinates for a postcode
23 24 25 26 27 |
# File 'lib/gds_api/locations_api.rb', line 23 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 |
#local_custodian_code_for_postcode(postcode) ⇒ Array
Get a list of local custodian codes for a postcode
10 11 12 13 14 15 16 |
# File 'lib/gds_api/locations_api.rb', line 10 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 |