Class: Yelp::Endpoint::Search
- Inherits:
-
Object
- Object
- Yelp::Endpoint::Search
- Defined in:
- lib/yelp/endpoint/search.rb
Constant Summary collapse
- PATH =
'/v2/search'
- BOUNDING_BOX =
[:sw_latitude, :sw_longitude, :ne_latitude, :ne_longitude]
- COORDINATES =
[:latitude, :longitude, :accuracy, :altitude, :altitude_accuracy]
Instance Method Summary collapse
-
#initialize(client) ⇒ Search
constructor
A new instance of Search.
-
#search(location, params = {}, locale = {}) ⇒ Response::Search
Take a search_request and return the formatted/structured response from the API.
-
#search_by_bounding_box(bounding_box, params = {}, locale = {}) ⇒ Response::Search
Search by a bounding box: specify a south west lat/long and a ne lat/long along with regular parameters to make a request to the search endpoint More info at: www.yelp.com/developers/documentation/v2/search_api#searchGBB.
-
#search_by_coordinates(coordinates, params = {}, locale = {}) ⇒ 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.
13 14 15 |
# File 'lib/yelp/endpoint/search.rb', line 13 def initialize(client) @client = client end |
Instance Method Details
#search(location, params = {}, locale = {}) ⇒ Response::Search
Take a search_request and return the formatted/structured response from the API
45 46 47 48 49 50 |
# File 'lib/yelp/endpoint/search.rb', line 45 def search(location, params = {}, locale = {}) params.merge!(locale) params.merge!({location: location}) Response::Search.new(JSON.parse(search_request(params).body)) end |
#search_by_bounding_box(bounding_box, params = {}, locale = {}) ⇒ Response::Search
Search by a bounding box: specify a south west lat/long and a ne lat/long along with regular parameters to make a request to the search endpoint More info at: www.yelp.com/developers/documentation/v2/search_api#searchGBB
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/yelp/endpoint/search.rb', line 87 def search_by_bounding_box(bounding_box, params = {}, locale = {}) raise Error::BoundingBoxNotComplete if BOUNDING_BOX.any? { |corner| bounding_box[corner].nil? } = { bounds: build_bounding_box(bounding_box) } .merge!(params) .merge!(locale) Response::Search.new(JSON.parse(search_request().body)) end |
#search_by_coordinates(coordinates, params = {}, locale = {}) ⇒ 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/v2/search_api#searchGC
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/yelp/endpoint/search.rb', line 133 def search_by_coordinates(coordinates, params = {}, locale = {}) raise Error::MissingLatLng if coordinates[:latitude].nil? || coordinates[:longitude].nil? = { ll: build_coordinates_string(coordinates) } .merge!(params) .merge!(locale) Response::Search.new(JSON.parse(search_request().body)) end |