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 = {}) ⇒ BurstStruct::Burst
Take a search_request and return the formatted/structured response from the API.
-
#search_by_bounding_box(bounding_box, params = {}, locale = {}) ⇒ BurstStruct::Burst
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 = {}) ⇒ BurstStruct::Burst
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.
11 12 13 |
# File 'lib/yelp/endpoint/search.rb', line 11 def initialize(client) @client = client end |
Instance Method Details
#search(location, params = {}, locale = {}) ⇒ BurstStruct::Burst
Take a search_request and return the formatted/structured response from the API
43 44 45 46 47 48 |
# File 'lib/yelp/endpoint/search.rb', line 43 def search(location, params = {}, locale = {}) params.merge!(locale) params.merge!({location: location}) BurstStruct::Burst.new(JSON.parse(search_request(params).body)) end |
#search_by_bounding_box(bounding_box, params = {}, locale = {}) ⇒ BurstStruct::Burst
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
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/yelp/endpoint/search.rb', line 85 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) BurstStruct::Burst.new(JSON.parse(search_request().body)) end |
#search_by_coordinates(coordinates, params = {}, locale = {}) ⇒ BurstStruct::Burst
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
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/yelp/endpoint/search.rb', line 131 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) BurstStruct::Burst.new(JSON.parse(search_request().body)) end |