Sha256: 811f390a70f230a767ea1e9bff940dc590ccfe2f5343cbff0ba6a558f204d36c

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

require "alma_api/collection"
require "json"
require_relative "../users"

class AlmaApi::Client::Users::Loans
  def initialize(client, user_id, loan_id = nil)
    @client = client
    @loan_id = loan_id
    @user_id = user_id
  end

  def get(options = {})
    (options = options.deep_dup).symbolize_keys!.reverse_merge!({
      user_id_type: :all_unique,
      limit: 10,
      offset: 0,
      order_by: :id,
      direction: :ASC
    })

    # sanitize api quirks
    options[:direction] = options[:direction].to_s.upcase.to_sym

    @client.http(:get, "/v1/users/#{@user_id}/loans", options).try do |_response|
      if _response.status == 200
        AlmaApi::Collection.new(JSON.parse(_response.body), "item_loan")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alma_api-0.1.0 lib/alma_api/client/users/loans.rb