Class: Alma::Location

Inherits:
AlmaRecord show all
Extended by:
ApiDefaults
Defined in:
lib/alma/location.rb

Class Method Summary collapse

Methods included from ApiDefaults

apikey, bibs_base_path, configuration_base_path, headers, items_base_path, region, timeout, users_base_path

Methods inherited from AlmaRecord

#initialize, #method_missing, #post_initialize, #respond_to_missing?, #response

Constructor Details

This class inherits a constructor from Alma::AlmaRecord

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Alma::AlmaRecord

Class Method Details

.all(library_code:, args: {}) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/alma/location.rb', line 7

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

.find(library_code:, location_code:, args: {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/alma/location.rb', line 16

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

.get_body_from(response) ⇒ Object



25
26
27
# File 'lib/alma/location.rb', line 25

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