Sha256: 78ee9c0e81427afdf4cf3458719d84b5f2d2754d9e1f1b7eb0a6b6f8210a08f2

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 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', URIs.path_escape("#{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

2 entries across 2 versions & 1 rubygems

Version Path
berkeley_library-holdings-1.0.5 lib/berkeley_library/holdings/hathi_trust/record_url_request.rb
berkeley_library-holdings-1.0.4 lib/berkeley_library/holdings/hathi_trust/record_url_request.rb