Class: Providers::Citysearch::Api
- Defined in:
- lib/providers/citysearch/api.rb
Constant Summary collapse
- LOCALHOST_IP =
"127.0.0.1"
Instance Method Summary collapse
- #find_business_by_id(citysearch_id) ⇒ Object
- #find_business_by_name(name, business_type, city_state) ⇒ Object
- #find_reviews_for_business(citysearch_id) ⇒ Object
-
#initialize(options) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(options) ⇒ Api
Returns a new instance of Api.
7 8 9 10 |
# File 'lib/providers/citysearch/api.rb', line 7 def initialize() @key = [:publisher_key] @ip = [:client_ip] || LOCALHOST_IP end |
Instance Method Details
#find_business_by_id(citysearch_id) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/providers/citysearch/api.rb', line 18 def find_business_by_id(citysearch_id) request_url = business_url(citysearch_id) json_results = HTTParty.get(request_url) json = json_results["locations"] || [] return json if json.empty? Providers::Citysearch::Business.build_business(json.first) end |
#find_business_by_name(name, business_type, city_state) ⇒ Object
12 13 14 15 16 |
# File 'lib/providers/citysearch/api.rb', line 12 def find_business_by_name(name, business_type, city_state) request_url = business_search_url(name, business_type, city_state) json_results = HTTParty.get(request_url) parse_business_results(json_results) end |
#find_reviews_for_business(citysearch_id) ⇒ Object
27 28 29 30 31 |
# File 'lib/providers/citysearch/api.rb', line 27 def find_reviews_for_business(citysearch_id) request_url = reviews_url(citysearch_id) json_results = HTTParty.get(request_url) parse_reviews_results(json_results) end |