class Celsius::Primo::SoapApi::Searcher::SearchBrief
Public Class Methods
new(searcher_url)
click to toggle source
# File lib/celsius/primo/soap_api/searcher/search_brief.rb, line 10 def initialize(searcher_url) @searcher_url = searcher_url end
Public Instance Methods
call(search_request, options = {})
click to toggle source
# File lib/celsius/primo/soap_api/searcher/search_brief.rb, line 14 def call(search_request, options = {}) options = deep_stringify(options) raw_response = begin Timeout::timeout(options["timeout"]) do HTTPI.post(httpi_request(search_request, options)).body end rescue Timeout::Error raise Timeout::Error, "Primo search request aborted! The server has not responded within #{options["timeout"]} seconds!" end SearchResultTransformation.new( search_request: search_request ).apply(to: raw_response) end
Private Instance Methods
deep_stringify(obj)
click to toggle source
# File lib/celsius/primo/soap_api/searcher/search_brief.rb, line 34 def deep_stringify(obj) JSON.parse(JSON.dump(obj), symbolize_names: false) end
httpi_request(search_request, options)
click to toggle source
# File lib/celsius/primo/soap_api/searcher/search_brief.rb, line 38 def httpi_request(search_request, options) HTTPI::Request.new({ url: @searcher_url, headers: { "Content-Type" => "application/xml", # necessary since new soap endpoint (else -> premature end of file error) "SOAPAction" => "searchBrief" }, body: soap_request_body(search_request, options) }) end
soap_request_body(search_request, options)
click to toggle source
# File lib/celsius/primo/soap_api/searcher/search_brief.rb, line 49 def soap_request_body(search_request, options) SearchRequestTransformation.new( languages: options["languages"], locations: options["locations"], institution: options["institution"] ).apply(to: search_request) end