Sha256: 3faacc099732749784d321da48c094c3d029f5a969e23935934cea132699ea9f

Contents?: true

Size: 849 Bytes

Versions: 5

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module Alma
  class Location < AlmaRecord
    extend Alma::ApiDefaults

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

    def self.find(library_code:, location_code:, args: {})
      response = Net.get("#{configuration_base_path}/libraries/#{library_code}/locations/#{location_code}", query: args, headers:, 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

5 entries across 5 versions & 1 rubygems

Version Path
alma-0.6.2 lib/alma/location.rb
alma-0.6.1 lib/alma/location.rb
alma-0.6.0 lib/alma/location.rb
alma-0.5.1 lib/alma/location.rb
alma-0.5.0 lib/alma/location.rb