Class: Skala::AlephAdapter::GetUserLoans
- Inherits:
-
Skala::Adapter::GetUserLoans
- Object
- Skala::Adapter::Operation
- Skala::Adapter::GetUserLoans
- Skala::AlephAdapter::GetUserLoans
- Includes:
- parentparent::ResolveUser
- Defined in:
- lib/skala/aleph_adapter/get_user_loans.rb
Instance Attribute Summary
Attributes inherited from Skala::Adapter::Operation
Instance Method Summary collapse
Methods inherited from Skala::Adapter::Operation
Constructor Details
This class inherits a constructor from Skala::Adapter::Operation
Instance Method Details
#call(username, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/skala/aleph_adapter/get_user_loans.rb', line 9 def call(username, = {}) resolved_user_id = resolve_user(username) loans_type = [:type] == :history ? :history : nil = { type: loans_type, view: :full }.compact raw_aleph_response = adapter.restful_api.patron(resolved_user_id).circulationActions.loans.get() if raw_aleph_response.include?("<error>") return nil else self.class::Result.new( loans: Nokogiri::XML(raw_aleph_response).xpath("//loan").map do |_loan| { id: id(_loan), due_date: due_date(_loan), fine: fine(_loan), loan_date: loan_date(_loan), record: { id: ils_record_id(_loan), title: title(_loan) }, renewable: renewable(_loan), returned_date: returned_date(_loan), signature: signature(_loan) } end, source: raw_aleph_response ) end end |