Class: Yelp::Fusion::Endpoint::Search
- Inherits:
-
Object
- Object
- Yelp::Fusion::Endpoint::Search
- Defined in:
- lib/yelp/fusion/endpoint/search.rb
Overview
Class to search for businesses
Constant Summary collapse
- PATH =
'/v3/businesses/search'.freeze
Instance Method Summary collapse
-
#initialize(client) ⇒ Search
constructor
A new instance of Search.
-
#search(location, params = {}) ⇒ Response::Search
Take a search_request and return the formatted/structured response from the API.
-
#search_by_coordinates(coordinates, params = {}) ⇒ Response::Search
Search by coordinates: give it a latitude and longitude along with option accuracy, altitude, and altitude_accuracy to search an area.
Constructor Details
#initialize(client) ⇒ Search
Returns a new instance of Search.
32 33 34 |
# File 'lib/yelp/fusion/endpoint/search.rb', line 32 def initialize(client) @client = client end |
Instance Method Details
#search(location, params = {}) ⇒ Response::Search
Take a search_request and return the formatted/structured response from the API
55 56 57 58 59 |
# File 'lib/yelp/fusion/endpoint/search.rb', line 55 def search(location, params = {}) params[:location] = location Responses::Search.new(JSON.parse(search_request(params).body)) end |
#search_by_coordinates(coordinates, params = {}) ⇒ Response::Search
Search by coordinates: give it a latitude and longitude along with option accuracy, altitude, and altitude_accuracy to search an area. More info at: www.yelp.com/developers/documentation/v3/business_search
84 85 86 87 88 89 90 |
# File 'lib/yelp/fusion/endpoint/search.rb', line 84 def search_by_coordinates(coordinates, params = {}) raise Error::MissingLatLng if coordinates[:latitude].nil? || coordinates[:longitude].nil? coordinates.merge!(params) Responses::Search.new(JSON.parse(search_request(coordinates).body)) end |