Socket
Book a DemoInstallSign in
Socket

google_reviews

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google_reviews

1.1.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

Google Reviews Gem

The Google Reviews gem is a Ruby library that provides a service to fetch reviews from Google based on a place name or place ID. It utilizes the Google Places API to retrieve the reviews and provides a convenient interface for accessing the review data.

Installation

Add this line to your Gemfile:

gem 'google_reviews'

And then execute:

$ bundle install

Or install it directly:

$ gem install google_reviews

Usage

To fetch reviews based on a place name or place ID, you can use the GoogleReviews::Reviews class provided by the gem. Here's an example of how to use it:

require 'google_reviews'

api_key = 'YOUR_API_KEY'
place_id = 'PLACE_ID'

reviews = GoogleReviews::Reviews.fetch_reviews_by_place_id(api_key, place_id)

reviews.each do |review|
  puts "Author: #{review[:author_name]}"
  puts "Rating: #{review[:rating]}"
  puts "Review Text: #{review[:text]}"
  puts "---"
end

Make sure to replace YOUR_API_KEY with your actual Google Places API key.

Error Handling

The gem provides custom error classes that you can handle to deal with specific error scenarios. Here are the error classes available:

  • GoogleReviews::ApiError: Represents general API-related errors.
  • GoogleReviews::InvalidApiKeyError: Indicates an invalid API key error.
  • GoogleReviews::InvalidPlaceIdError: Indicates an invalid place ID error. You can rescue and handle these errors to provide appropriate error handling in your application.

Configuration

The gem doesn't require any additional configuration. However, it's recommended to configure the locale for translations. By default, the gem uses English (:en) as the locale. If you want to use a different locale, you can modify the lib/google_reviews/translations.rb file.

Submitting a Pull Request

Fork the official repository. Create a topic branch. Implement your feature or bug fix. Add, commit, and push your changes. Submit a pull request.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 14 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.