lib/ezid/client.rb in ezid-client-0.12.0 vs lib/ezid/client.rb in ezid-client-0.13.0
- old
+ new
@@ -40,16 +40,17 @@
def version
"ezid-client #{VERSION} (EZID API Version #{API_VERSION})"
end
end
- attr_reader :user, :password, :host, :port, :use_ssl
+ attr_reader :user, :password, :host, :port, :use_ssl, :timeout
def initialize(opts = {})
@host = opts[:host] || config.host
@port = (opts[:port] || config.port).to_i
@use_ssl = opts[:use_ssl] || config.use_ssl
+ @timeout = (opts[:timeout] || config.timeout).to_i
@user = opts[:user] || config.user
@password = opts[:password] || config.password
if block_given?
login
yield self
@@ -167,10 +168,18 @@
# @return [Ezid::StatusResponse] the status response
def server_status(*subsystems)
execute ServerStatusRequest, *subsystems
end
+ # Submit a batch download request
+ # @see http://ezid.cdlib.org/doc/apidoc.html#batch-download
+ # @param format [String] format of results - one of "anvl", "csv", "xml"
+ # @param params [Hash] optional request parameters
+ def batch_download(params={})
+ execute BatchDownloadRequest, params
+ end
+
# The Net::HTTP object used to connect to EZID
# @return [Net::HTTP] the connection
def connection
@connection ||= build_connection
end
@@ -182,9 +191,10 @@
end
def build_connection
conn = Net::HTTP.new(host, port)
conn.use_ssl = use_ssl?
+ conn.read_timeout = timeout
conn
end
def handle_response(response, request_name)
log_level = response.error? ? Logger::ERROR : Logger::INFO