Sha256: 9fdf3f09d11a8b340b2125ea5a017246b23d87b92ceb9c8c3e0f682f382e5330
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true class FolioClient # Lookup records in Folio Source Storage class SourceStorage attr_accessor :client # @param client [FolioClient] the configured client def initialize(client) @client = client end # get marc bib data from folio given an instance HRID # @param instance_hrid [String] the key to use for MARC lookup # @return [Hash] hash representation of the MARC. should be usable by MARC::Record.new_from_hash (from ruby-marc gem) # @raises NotFound, MultipleRecordsForIdentifier def fetch_marc_hash(instance_hrid:) response_hash = client.get("/source-storage/source-records", {instanceHrid: instance_hrid}) record_count = response_hash["totalRecords"] raise ResourceNotFound, "No records found for #{instance_hrid}" if record_count.zero? raise MultipleResourcesFound, "Expected 1 record for #{instance_hrid}, but found #{record_count}" if record_count > 1 response_hash["sourceRecords"].first["parsedRecord"]["content"] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
folio_client-0.10.0 | lib/folio_client/source_storage.rb |
folio_client-0.9.0 | lib/folio_client/source_storage.rb |