Module: GoogleBooks::API
- Includes:
- HTTParty
- Defined in:
- lib/google_books/api.rb,
lib/google_books/api/book.rb,
lib/google_books/api/response.rb
Overview
A simple wrapper around the Google Books API
Defined Under Namespace
Class Attribute Summary collapse
-
.parameters ⇒ Object
The search parameters.
Class Method Summary collapse
-
.search(query, opts = {}) ⇒ Object
Queries the Google Books API.
Class Attribute Details
.parameters ⇒ Object
The search parameters.
8 9 10 |
# File 'lib/google_books/api.rb', line 8 def parameters @parameters end |
Class Method Details
.search(query, opts = {}) ⇒ Object
Queries the Google Books API. Takes a query string and an optional options hash.
The options hash respects the following members:
-
‘:page`, which specifies the page.
-
‘:count`, which specifies the number of results per page.
-
‘:api_key`, your [API key](code.google.com/apis/books/docs/v1/using.html#auth) for making requests against the Google Books API.
20 21 22 23 24 25 26 27 28 |
# File 'lib/google_books/api.rb', line 20 def search(query, opts ={}) self.parameters = { 'q' => query } parameters['startIndex'] = opts[:page] if opts[:page] parameters['maxResults'] = opts[:count] if opts[:count] parameters['key'] = opts[:api_key] if opts[:api_key] result = get(url.to_s) Response.new result end |