class BookFinder::Client

Constants

BASE_URI

Public Class Methods

new() click to toggle source

this will only make requests to the public variation of the google books api

# File lib/bookfinder/client.rb, line 9
def initialize
end

Public Instance Methods

books(name) click to toggle source
# File lib/bookfinder/client.rb, line 12
def books(name)
  response = http_get(
    endpoint: "volumes?q=",
    query: name.sub(" ","")
  )

  response.map { |book| BookFinder::Book.new(book["volumeInfo"]) }
end

Private Instance Methods

http_get(endpoint:, query:) click to toggle source
# File lib/bookfinder/client.rb, line 23
def http_get(endpoint:, query:)
  self.class.get(BASE_URI + endpoint + query).parsed_response["items"]
end