Sha256: 388de3ded7d0c3a31e0d49f813f4ecf30cfb0dcb1f1c597fdd9d3a5685fb2909

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

require "nokogiri"
require "skala/adapter/delete_user_hold_request"
require_relative "../aleph_adapter"
require_relative "./resolve_user"

class Skala::AlephAdapter::DeleteUserHoldRequest < Skala::Adapter::DeleteUserHoldRequest
  include parent::ResolveUser

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skala-1.1.0 lib/skala/aleph_adapter/delete_user_hold_request.rb