Class: Nestoria::Api
- Inherits:
-
Object
- Object
- Nestoria::Api
- Defined in:
- lib/nestoria/api.rb
Constant Summary collapse
- API_VERSION =
1.21
- LOCATION_KEYS =
Valid search parameters - See www.nestoria.co.uk/help/api-search-listings for key/value details
[ :place_name, :south_west, :north_east, :centre_point, :radius ]
- SEARCH_KEYS =
[ :guid, :listing_type, :property_type, :price_min, :price_max, :bedroom_min, :bedroom_max, :room_min, :room_max, :bathroom_min, :bathroom_max, :size_min, :size_max, :keywords, :keywords_exclude, :has_photo, :updated_min, :number_of_results, :page, :sort ] + LOCATION_KEYS
Instance Method Summary collapse
-
#echo(params = {:foo => "bar"}) ⇒ Object
Test URL request, returns whatever params you put in.
-
#initialize(country) ⇒ Api
constructor
A new instance of Api.
-
#keywords ⇒ Object
List of keywords that can be used in search - See www.nestoria.co.uk/help/api-keywords.
-
#metadata(params) ⇒ Object
Average house price for an area - See www.nestoria.co.uk/help/api-metadata.
-
#search(params) ⇒ Object
Search nestoria property listings - See www.nestoria.co.uk/help/api-search-listings.
Constructor Details
#initialize(country) ⇒ Api
Returns a new instance of Api.
30 31 32 |
# File 'lib/nestoria/api.rb', line 30 def initialize(country) @country = country end |
Instance Method Details
#echo(params = {:foo => "bar"}) ⇒ Object
Test URL request, returns whatever params you put in
73 74 75 |
# File 'lib/nestoria/api.rb', line 73 def echo(params = {:foo => "bar"}) request :echo, params end |
#keywords ⇒ Object
List of keywords that can be used in search - See www.nestoria.co.uk/help/api-keywords
53 54 55 56 57 58 59 60 |
# File 'lib/nestoria/api.rb', line 53 def keywords response = request :keywords keywords = Hash.new response["labels"].each do |label| keywords[label["keyword"]] = label["content"] end keywords end |
#metadata(params) ⇒ Object
Average house price for an area - See www.nestoria.co.uk/help/api-metadata
63 64 65 66 67 68 69 70 |
# File 'lib/nestoria/api.rb', line 63 def (params) invalid_keys = params.keys - LOCATION_KEYS raise InvalidRequest.new "Invalid keys: #{invalid_keys.join(", ")}" unless invalid_keys.empty? process_location! params request :metadata, params end |
#search(params) ⇒ Object
Search nestoria property listings - See www.nestoria.co.uk/help/api-search-listings
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nestoria/api.rb', line 35 def search(params) invalid_keys = params.keys - SEARCH_KEYS raise InvalidRequest.new "Invalid keys: #{invalid_keys.join(", ")}" unless invalid_keys.empty? # Convert arrays into CSVs [:keywords, :keywords_exclude].each do |key| params[key] = params[key].join(",") unless params[key].nil? end # Convert any Time/DateTime objects to UNIX time integers params[:updated_min] = params[:updated_min].to_i unless params[:updated_min].nil? process_location! params request :search_listings, params end |