Module: HomeAway::API::Domain::Search

Included in:
Client
Defined in:
lib/homeaway/api/domain/search.rb

Instance Method Summary collapse

Instance Method Details

#search(opts = {}) ⇒ HomeAway::API::Paginator

Search for listings

analogous to calling a GET on API url /public/search

Headers:

  • Authenticated: required: By specifying a Client object in the method signature, all incoming requests MUST have a valid current OAuth authenticated client

  • X-HomeAway-DisplayLocale: required: If a locale is not specified in a query param, it will be searched for in the X-HomeAway-DisplayLocale Header. If it is not supplied in either area the default locale of the user will be selected if it exists. Otherwise the Accept-Language Header will be used.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :q (String)

    The query to search for listings with, for example ‘austin sleeps 6’

  • :min_bedrooms (Integer)

    Minimum number of bedrooms to search (optional)

  • :min_sleeps (Integer)

    Minimum number of sleeps to search (optional)

  • :availability_start (String)

    Date formatted as yyyy-MM-dd to indicate the earliest available date (lower bound) in the search (optional)

  • :max_sleeps (Integer)

    Maximum number of sleeps to search (optional)

  • :availability_end (String)

    Date formatted as yyyy-MM-dd to indicate the latest available date (upper bound) in the search (optional)

  • :min_bathrooms (Integer)

    Minimum number of bathrooms to search (optional)

  • :center_point_latitude (Float)

    Uses a proximity search to limit results to listings located within a max distance from a specific location, must be sent with centerPointLongitude and distanceInKm

  • :refine (String)

    Refine the search with the given comma delimited refinements (optional comes from a search refinement)

  • :sort (String)

    Sort the results <field:asc|desc> where field is one of (availabilityUpdated, bathrooms, bedrooms, prices, travelerReviewCount, averageRating) (optional)

  • :upper_right_longitude (Float)

    Adds a geographical bounding box constraint to the search. Only listings located within this bounding box will be returned in the results, must be sent with lowerLeftLongitude, upperRightLatitude and upperRightLongitude

  • :distance_in_km (Float)

    Uses a proximity search to limit results to listings located within a max distance from a specific location, must be sent with centerPointLatitude and centerPointLongitude

  • :upper_right_latitude (Float)

    Adds a geographical bounding box constraint to the search. Only listings located within this bounding box will be returned in the results, must be sent with lowerLeftLongitude, upperRightLatitude and upperRightLongitude

  • :max_bedrooms (Integer)

    Maximum number of bedrooms to search (optional)

  • :max_bathrooms (Integer)

    Maximum number of bathrooms to search (optional)

  • :center_point_longitude (Float)

    Uses a proximity search to limit results to listings located within a max distance from a specific location, must be sent with centerPointLatitude and distanceInKm

  • :min_price (Float)

    Minimum price to search (optional)

  • :lower_left_latitude (Float)

    Adds a geographical bounding box constraint to the search. Only listings located within this bounding box will be returned in the results, must be sent with lowerLeftLongitude, upperRightLatitude and upperRightLongitude

  • :lower_left_longitude (Float)

    Adds a geographical bounding box constraint to the search. Only listings located within this bounding box will be returned in the results, must be sent with lowerLeftLongitude, upperRightLatitude and upperRightLongitude

  • :max_price (Float)

    Maximum price to search (optional)

  • :image_size (String)

    Size of the image to return the URL for (optional) must be one of: SMALL, MEDIUM, LARGE

  • :page (Integer)

    The page of the result set

  • :page_size (Integer)

    The size of a page of results

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/homeaway/api/domain/search.rb', line 53

def search(opts={})
  encoded_opts = opts.merge(opts) do |_, v|
    if v.is_a? ::String
      HomeAway::API::Util::Validators.uri_encoded(v)
    else
      v
    end
  end
  params = {
      'locale' => 'en',
      'page' => 1,
      'pageSize' => @configuration.page_size
  }.merge(HomeAway::API::Util::Validators.query_keys(encoded_opts))
  params['availabilityStart'] = HomeAway::API::Util::Validators.date(params['availabilityStart']) if params.has_key?('availabilityStart')
  params['availabilityEnd'] = HomeAway::API::Util::Validators.date(params['availabilityEnd']) if params.has_key?('availabilityEnd')
  hashie = get '/public/search', params
  HomeAway::API::Paginator.new(self, hashie, @configuration.auto_pagination)
end