Class: Alma::Loan

Inherits:
AlmaRecord show all
Extended by:
ApiDefaults
Defined in:
lib/alma/loan.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApiDefaults

apikey, bibs_base_path, headers, region, timeout, users_base_path

Methods inherited from AlmaRecord

#initialize, #method_missing, #post_initialize, #respond_to_missing?, #response

Constructor Details

This class inherits a constructor from Alma::AlmaRecord

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Alma::AlmaRecord

Class Method Details

.where_user(user_id, args = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/alma/loan.rb', line 22

def self.where_user(user_id, args={})
  # Always expand renewable unless you really don't want to
  args[:expand] ||= "renewable"
  # Default to upper limit
  args[:limit] ||= 100
  response = HTTParty.get(
    "#{users_base_path}/#{user_id}/loans",
    query: args,
    headers: headers,
    timeout: timeout
    )
  Alma::LoanSet.new(response, args)
end

Instance Method Details

#overdue?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/alma/loan.rb', line 14

def overdue?
  loan_status == "Overdue"
end

#renewObject



18
19
20
# File 'lib/alma/loan.rb', line 18

def renew
  Alma::User.renew_loan({user_id: user_id, loan_id: loan_id})
end

#renewableObject



10
11
12
# File 'lib/alma/loan.rb', line 10

def renewable
  response.fetch("renewable", false)
end

#renewable?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/alma/loan.rb', line 6

def renewable?
  !!renewable
end