Class: Books

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/kbapibooks.rb

Class Method Summary collapse

Class Method Details

.list_books(author, api_key) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/kbapibooks.rb', line 8

def self.list_books(author, api_key)
  format_author = author.gsub(' ', '+') if author.match(/\s/)
  url = "https://www.googleapis.com/books/v1/volumes?q=inauthor:#{format_author}&key=#{api_key}"
  puts 'VERSION 0.5.0'
  response = HTTParty.get(url)
  puts "RESPONSE CODE  #{response.code}"
  response.parsed_response
end