Sha256: 95c3782e35d82a7801e04339fb2022630ea0b007df9c2b739244032f76117dfb

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

module Alma
  class Loan < AlmaRecord
    extend Alma::ApiDefaults


    def renewable?
      !!renewable
    end

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

    def overdue?
      loan_status == "Overdue"
    end

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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alma-0.3.1 lib/alma/loan.rb