Class: Skala::AlephAdapter::GetUser
- Inherits:
-
Skala::Adapter::GetUser
- Object
- Skala::Adapter::Operation
- Skala::Adapter::GetUser
- Skala::AlephAdapter::GetUser
- Defined in:
- lib/skala/aleph_adapter/get_user.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
6 7 8 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.rb', line 6 def call(username, = {}) user_library = [:user_library] || @adapter.default_user_library username = username.upcase # ensure that username/id is always upcased for request/result raw_aleph_result = @adapter.x_services.post( op: :"bor-info", bor_id: username, library: user_library, cash: "B", hold: "P", loans: "P" ) if raw_aleph_result.include?("<error>") return nil else fields = Hash.from_xml(raw_aleph_result) Skala::GetUserResult.new( cash_balance: cash_balance(fields), email_address: fields["bor_info"]["z304"]["z304_email_address"], expiry_date: Date.strptime(fields["bor_info"]["z305"]["z305_expiry_date"], "%d/%m/%Y"), id: username, first_name: fields["bor_info"]["z303"]["z303_name"].split(",").last.strip, last_name: fields["bor_info"]["z303"]["z303_name"].split(",").first.strip, number_of_hold_requests: [fields["bor_info"]["item_h"]].flatten(1).compact.length, number_of_loans: [fields["bor_info"]["item_l"]].flatten(1).compact.length, fields: fields ) end end |