Sha256: c04cafa3f3e673a054bf58585a69cd27324171bb92d0c758496786a1bcf0bfa4
Contents?: true
Size: 1.33 KB
Versions: 13
Compression:
Stored size: 1.33 KB
Contents
# coding: utf-8 require 'libis-tools' require 'libis/services/service_error' require 'libis/services/rest_client' module Libis module Services module Alma class SruService include ::Libis::Services::RestClient def initialize(url = 'https://eu.alma.exlibrisgroup.com/view/sru') configure(url) end 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.xpath('//record').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 def result_parser(response) Libis::Tools::XmlDocument.parse(response) rescue response end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems