class Libis::Services::Alma::SruService
Public Class Methods
new(url = 'https://eu.alma.exlibrisgroup.com/view/sru')
click to toggle source
# File lib/libis/services/alma/sru_service.rb, line 13 def initialize(url = 'https://eu.alma.exlibrisgroup.com/view/sru') configure(url) end
Public Instance Methods
search(field, value, library = '32KUL_LIBIS_NETWORK')
click to toggle source
# File lib/libis/services/alma/sru_service.rb, line 17 def search(field, value, library = '32KUL_LIBIS_NETWORK') result = get library, version: '1.2', operation: 'searchRetrieve', recordSchema: 'marcxml', query: "#{field}=#{value}" if result.is_a?(Libis::Tools::XmlDocument) unless result['//diag:diagnostic'].blank? raise Libis::Services::ServiceError, "#{result['/searchRetrieveResponse/diag:diagnostic/diag:message']}" end return result.document.xpath('//marc:record', 'marc' => 'http://www.loc.gov/MARC21/slim').map do |record| Libis::Tools::XmlDocument.parse(record.to_s) end end raise Libis::Services::ServiceError, "#{result[:error_type]} - #{result[:error_name]}" if result[:error_type] raise Libis::Services::ServiceError, "Unexpected reply: '#{result.to_s}' (#{result.class})" end
Protected Instance Methods
result_parser(response)
click to toggle source
# File lib/libis/services/alma/sru_service.rb, line 40 def result_parser(response) Libis::Tools::XmlDocument.parse(response) rescue response end