Class: Skala::AlephAdapter::GetUserInterLibraryLoans

Inherits:
Skala::Adapter::GetUserInterLibraryLoans show all
Includes:
parentparent::ResolveUser
Defined in:
lib/skala/aleph_adapter/get_user_inter_library_loans.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, 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
# File 'lib/skala/aleph_adapter/get_user_inter_library_loans.rb', line 9

def call(username, options = {})
  resolved_user_id = resolve_user(username)
  raw_aleph_response = adapter.restful_api.patron(resolved_user_id).circulationActions.requests.ill.get(view: :brief)

  if raw_aleph_response.include?("<error>")
    return nil
  else
    self.class::Result.new(
      inter_library_loans: Nokogiri::XML(raw_aleph_response).xpath("//ill-request").map do |_ill_request|
        {
          id: id(_ill_request),
          due_date: due_date(_ill_request),
          record: {
            creator: creator(_ill_request),
            id: record_id(_ill_request),
            title: title(_ill_request),
            year_of_publication: year_of_publication(_ill_request)
          },
          renewable: renewable(_ill_request)
        }
      end,
      source: raw_aleph_response
    )
  end
end