Method: RelatonIsbn::OpenLibrary#request_api
- Defined in:
- lib/relaton_isbn/open_library.rb
#request_api(isbn) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/relaton_isbn/open_library.rb', line 30 def request_api(isbn) uri = URI "#{ENDPOINT}#{isbn}.json" response = Net::HTTP.get_response uri return unless response.is_a? Net::HTTPSuccess data = JSON.parse response.body return unless data["records"]&.any? data["records"].first.last end |