Class: GoogleReviews::Reviews
- Inherits:
-
Object
- Object
- GoogleReviews::Reviews
- Defined in:
- lib/google_reviews.rb
Overview
Service to fetch reviews based on place_name or place_id
Class Method Summary collapse
- .fetch_reviews_by_place_id(api_key, place_id) ⇒ Object
- .fetch_reviews_by_place_name(api_key, place_name) ⇒ Object
Class Method Details
.fetch_reviews_by_place_id(api_key, place_id) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/google_reviews.rb', line 30 def self.fetch_reviews_by_place_id(api_key, place_id) url = Utils.request_uri(api_key, place_id: place_id) begin Utils.execute_place_id_request(url) rescue ApiError => e GoogleReviews::Response.new(status: "409", error: e) end end |
.fetch_reviews_by_place_name(api_key, place_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/google_reviews.rb', line 17 def self.fetch_reviews_by_place_name(api_key, place_name) url = Utils.request_uri(api_key, place_name: place_name) begin data = Utils.execute_place_name_request(url) return GoogleReviews::Response.new unless data fetch_reviews_by_place_id(api_key, data.first["place_id"]) rescue ApiError => e GoogleReviews::Response.new(status: "409", error: e) end end |