Skip to content

Commit

Permalink
fix: handles not being able to contact Alma
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Jul 1, 2022
1 parent fe02374 commit 396b731
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions local-gems/spectrum-json/lib/spectrum/entities/alma_holdings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ def initialize(alma:, solr:)
end
def self.for(bib_record:, client: AlmaRestClient.client)
if bib_record.physical_holdings?
response = client.get_all(url: "/bibs/#{bib_record.mms_id}/loans", record_key: "item_loan")
if response.code == 200
begin
response = client.get_all(url: "/bibs/#{bib_record.mms_id}/loans", record_key: "item_loan")
raise ::StandardError.new("problem with contacting alma") if response.code != 200
Spectrum::Entities::AlmaHoldings.new(alma: response.parsed_response, solr: bib_record)
else
#TBD ERROR
rescue => e
Logger.new($stdout).error "Cant'contact Alma: #{e}"
Spectrum::Entities::AlmaHoldings.new(alma: { "item_loan" => [] }, solr: bib_record)
end
else
Spectrum::Entities::AlmaHoldings::Empty.new
Expand Down

0 comments on commit 396b731

Please sign in to comment.