Skip to content

Commit

Permalink
Merge pull request #91 from mlibrary/loans-api-optional
Browse files Browse the repository at this point in the history
fix: handles not being able to contact Alma
  • Loading branch information
bertrama authored Jul 6, 2022
2 parents 48bfb4b + 396b731 commit d6552f1
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 d6552f1

Please sign in to comment.