Sha256: 9c8c2c68bcf34ed31c6e35e3af2d90ecb3f5dcafc7fd8b473176020bd852211d

Contents?: true

Size: 948 Bytes

Versions: 7

Compression:

Stored size: 948 Bytes

Contents

module Goodreads
  module Books
    # Search for books
    #
    # query   - Text to match against book title, author, and ISBN fields.
    # options - Optional search parameters
    #
    # options[:page] - Which page to returns (default: 1)
    # options[:field] - Search field. One of: title, author, or genre (default is all)
    #
    def search_books(query, params = {})
      params[:q] = query.to_s.strip
      data = request("/search/index", params)
      Hashie::Mash.new(data["search"])
    end

    # Get book details by Goodreads book ID
    #
    def book(id)
      Hashie::Mash.new(request("/book/show", id: id)["book"])
    end

    # Get book details by book ISBN
    #
    def book_by_isbn(isbn)
      Hashie::Mash.new(request("/book/isbn", isbn: isbn)["book"])
    end

    # Get book details by book title
    #
    def book_by_title(title)
      Hashie::Mash.new(request("/book/title", title: title)["book"])
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
goodreads-0.9.0 lib/goodreads/client/books.rb
goodreads-0.8.0 lib/goodreads/client/books.rb
goodreads-0.7.0 lib/goodreads/client/books.rb
goodreads-0.6.2 lib/goodreads/client/books.rb
goodreads-0.6.1 lib/goodreads/client/books.rb
goodreads-0.6.0 lib/goodreads/client/books.rb
goodreads-0.5.0 lib/goodreads/client/books.rb