lib/alma/bib_item.rb in alma-0.2.8 vs lib/alma/bib_item.rb in alma-0.3.1

- old
+ new

@@ -1,8 +1,9 @@ require 'alma/bib_item_set' module Alma class BibItem + extend Alma::ApiDefaults extend Forwardable attr_reader :item def_delegators :item, :[], :has_key?, :keys, :to_json @@ -13,12 +14,12 @@ def self.find(mms_id, options={}) holding_id = options.delete(:holding_id) || "ALL" options.select! {|k,_| PERMITTED_ARGS.include? k } url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items" - response = HTTParty.get(url, headers: headers, query: options) - BibItemSet.new(response) + response = HTTParty.get(url, headers: headers, query: options, timeout: timeout) + BibItemSet.new(response, options.merge({mms_id: mms_id, holding_id: holding_id})) end def initialize(item) @item = item end @@ -49,11 +50,10 @@ def location_name in_temp_location? ? temp_location_name : holding_location_name end - def holding_library item_data.dig("library", "value") end def holding_library_name @@ -91,17 +91,15 @@ def has_temp_call_number? !temp_call_number.empty? end def call_number - if has_temp_call_number? - holding_data.fetch("temp_call_number") - elsif has_alt_call_number? - alt_call_number - else - holding_data.fetch("call_number","") - end + if has_temp_call_number? + holding_data.fetch("temp_call_number") + else + holding_data.fetch("call_number","") + end end def has_alt_call_number? !alt_call_number.empty? end @@ -147,28 +145,7 @@ end def public_note item_data.fetch("public_note", "") end - - private - - def self.region - Alma.configuration.region - end - - def self.bibs_base_path - "#{region}/almaws/v1/bibs" - end - - def self.headers - { "Authorization": "apikey #{apikey}", - "Accept": "application/json", - "Content-Type": "application/json" } - end - - def self.apikey - Alma.configuration.apikey - end end - end