Class: Skala::AlephAdapter::DeleteUserHoldRequest

Inherits:
Skala::Adapter::DeleteUserHoldRequest show all
Includes:
parentparent::ResolveUser
Defined in:
lib/skala/aleph_adapter/delete_user_hold_request.rb

Instance Attribute Summary

Attributes inherited from Skala::Adapter::Operation

#adapter

Instance Method Summary collapse

Methods inherited from Skala::Adapter::Operation

#initialize

Constructor Details

This class inherits a constructor from Skala::Adapter::Operation

Instance Method Details

#call(username, hold_request_id, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/skala/aleph_adapter/delete_user_hold_request.rb', line 9

def call(username, hold_request_id, options = {})
  document_base = options[:document_base] || adapter.default_document_base
  record_id = "#{document_base}#{record_id}"
  resolved_user_id = resolve_user(username)

  raw_aleph_response = @adapter.restful_api.patron(resolved_user_id).circulationActions.requests.holds(hold_request_id).delete
  reply_code = Nokogiri::XML(raw_aleph_response).at_xpath("//reply-code").try(:content).try(:to_i)

  if reply_code == 0
    adapter.class::DeleteUserHoldRequest::Result.new(
      source: raw_aleph_response
    )
  else
    if reply_code == 8
      raise self.class::HoldRequestMissingError
    else
      raise adapter.class::RequestFailedError
    end
  end
end