Sha256: c3033d5ff8a1ad690f512b1e70b172e49af37f35f7c595643b768b895f722525

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

module Alma
  class  Bib < AlmaRecord
    extend Alma::Api

    attr_accessor :id, :record

    def post_initialize
      @id = response['mms_id'].to_s
      @record = response.fetch('record', {})
    end

    class << self

      def get_availability(ids, args={})
        args.merge!({expand: 'p_avail,e_avail,d_avail'})
        bibs = get_bibs(ids, args)

        return bibs if bibs.has_error?
        Alma::AvailabilityResponse.new(bibs)
      end

      def find(ids, args)
        get_bibs(ids, args)
      end

      def get_bibs(ids, args={})
        args[:mms_id] = ids_from_array(ids)
        params = query_merge(args)
        response = resources.almaws_v1_bibs.get(params)

        Alma::BibSet.new(response)
      end

      private

      def ids_from_array(ids)
        ids.map(&:to_s).map(&:strip).join(',')
      end

      def set_wadl_filename
        'bib.wadl'
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alma-0.2.4 lib/alma/bib.rb
alma-0.2.3 lib/alma/bib.rb