Class: Alma::ItemRequestOptions

Inherits:
RequestOptions show all
Defined in:
lib/alma/item_request_options.rb

Defined Under Namespace

Classes: ResponseError

Constant Summary

Constants inherited from RequestOptions

RequestOptions::REQUEST_OPTIONS_PERMITTED_ARGS

Instance Attribute Summary

Attributes inherited from RequestOptions

#raw_response, #request_options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RequestOptions

#booking_allowed?, #digitization_allowed?, #ez_borrow_link, #hold_allowed?, #initialize, #loggable, #resource_sharing_broker_allowed?

Methods included from ApiDefaults

#apikey, #bibs_base_path, #configuration_base_path, #headers, #items_base_path, #region, #timeout, #users_base_path

Constructor Details

This class inherits a constructor from Alma::RequestOptions

Class Method Details

.get(mms_id, holding_id = nil, item_pid = nil, options = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/alma/item_request_options.rb', line 8

def self.get(mms_id, holding_id = nil, item_pid = nil, options = {})
  url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items/#{item_pid}/request-options"
  options.select! { |k, _|  REQUEST_OPTIONS_PERMITTED_ARGS.include? k }
  response = Net.get(url, headers:, query: options, timeout:)
  new(response)
end

Instance Method Details

#validate(response) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/alma/item_request_options.rb', line 15

def validate(response)
  if response.code != 200
    message = "Could not get item request options."
    log = loggable.merge(response.parsed_response)
    raise ResponseError.new(message, log)
  end
end