lib/alma/bib.rb in alma-0.3.1 vs lib/alma/bib.rb in alma-0.3.2
- old
+ new
@@ -1,32 +1,34 @@
+# frozen_string_literal: true
+
module Alma
class Bib
extend Alma::ApiDefaults
extend Forwardable
-
+
def self.find(ids, args)
get_bibs(ids, args)
end
- def self.get_bibs(ids, args={})
+ def self.get_bibs(ids, args = {})
response = HTTParty.get(
- self.bibs_base_path,
- query: {mms_id: ids_from_array(ids) }.merge(args),
+ self.bibs_base_path,
+ query: { mms_id: ids_from_array(ids) }.merge(args),
headers: headers,
timeout: timeout
)
if response.code == 200
Alma::BibSet.new(get_body_from(response))
else
raise StandardError, get_body_from(response)
- end
+ end
end
- def self.get_availability(ids, args={})
- args.merge!({expand: 'p_avail,e_avail,d_avail'})
+ def self.get_availability(ids, args = {})
+ args.merge!({ expand: "p_avail,e_avail,d_avail" })
bibs = get_bibs(ids, args)
Alma::AvailabilityResponse.new(bibs)
end
@@ -37,33 +39,33 @@
# The User object can respond directly to Hash like access of attributes
def_delegators :response, :[], :[]=, :has_key?, :keys, :to_json, :each
def initialize(response_body)
@response = response_body
- @id = @response['mms_id'].to_s
+ @id = @response["mms_id"].to_s
end
# The raw MARCXML record, converted to a Hash
def record
- @record ||= XmlSimple.xml_in(response['anies'].first)
+ @record ||= XmlSimple.xml_in(response["anies"].first)
end
private
- def bibs_base_path
- self.class.bibs_base_path
- end
+ def bibs_base_path
+ self.class.bibs_base_path
+ end
- def headers
- self.class.headers
- end
+ def headers
+ self.class.headers
+ end
- def self.get_body_from(response)
- JSON.parse(response.body)
- end
+ def self.get_body_from(response)
+ JSON.parse(response.body)
+ end
- def self.ids_from_array(ids)
- ids.map(&:to_s).map(&:strip).join(',')
- end
+ def self.ids_from_array(ids)
+ ids.map(&:to_s).map(&:strip).join(",")
+ end
end
end