Sha256: 37cbf1a512ec5588f514c7156f1c314748bf9011cbb2a8dbddc4d71d14a07af7

Contents?: true

Size: 805 Bytes

Versions: 3

Compression:

Stored size: 805 Bytes

Contents

# frozen_string_literal: true

module Alma
  class Library < AlmaRecord
    extend Alma::ApiDefaults

    def self.all(args: {})
      response = HTTParty.get("#{configuration_base_path}/libraries", query: args, headers: headers, timeout: timeout)
      if response.code == 200
        LibrarySet.new(response)
      else
        raise StandardError, get_body_from(response)
      end
    end

    def self.find(library_code:, args: {})
      response = HTTParty.get("#{configuration_base_path}/libraries/#{library_code}", query: args, headers: headers, timeout: timeout)
      if response.code == 200
        AlmaRecord.new(response)
      else
        raise StandardError, get_body_from(response)
      end
    end

    def self.get_body_from(response)
      JSON.parse(response.body)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alma-0.4.0 lib/alma/library.rb
alma-0.3.3 lib/alma/library.rb
alma-0.3.2 lib/alma/library.rb