adding the isbn_search client
parent
f8be3938f6
commit
7fac0781f3
@ -0,0 +1,26 @@
|
||||
module Internal
|
||||
module IsbnSearch
|
||||
class Client
|
||||
def initialize
|
||||
@port = ENV.fetch('ISBN_SEARCH_PORT', 3001)
|
||||
@host = ENV.fetch('ISBN_SEARCH_HOST', '0.0.0.0')
|
||||
@path = 'isbn/'
|
||||
end
|
||||
|
||||
def get(isbn)
|
||||
response = Excon.get(url_for(isbn))
|
||||
if response.status == 200
|
||||
JSON.parse(response.body)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def url_for(isbn)
|
||||
"http://#{@host}:#{@port}/#{@path}/#{isbn}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue