Sha256: a7eea13797c02611c032206e33076b476a077f30b5281644428bebe4a62c7ad4

Contents?: true

Size: 802 Bytes

Versions: 3

Compression:

Stored size: 802 Bytes

Contents

require 'berkeley_library/holdings/hathi_trust/record_url_request_base'

module BerkeleyLibrary
  module Holdings
    module HathiTrust
      class RecordUrlRequest
        include RecordUrlRequestBase

        attr_reader :oclc_number

        def initialize(oclc_number)
          @oclc_number = OCLCNumber.ensure_oclc_number!(oclc_number)
        end

        def execute
          response_body = URIs.get(uri, log: false)
          record_url_from(response_body, oclc_number)
        end

        def uri
          @uri ||= URIs.append(volumes_base_uri, 'oclc', "#{oclc_number}.json")
        end

        private

        def record_url_from(json_str, oclc_number)
          json_obj = JSON.parse(json_str)
          find_record_url(json_obj, oclc_number)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
berkeley_library-holdings-1.0.3 lib/berkeley_library/holdings/hathi_trust/record_url_request.rb
berkeley_library-holdings-1.0.2 lib/berkeley_library/holdings/hathi_trust/record_url_request.rb
berkeley_library-holdings-1.0.1 lib/berkeley_library/holdings/hathi_trust/record_url_request.rb