Class: Alma::Library

Inherits:
AlmaRecord show all
Extended by:
ApiDefaults
Defined in:
lib/alma/library.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(args: {}) ⇒ Object



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

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

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



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

def self.find(library_code:, args: {})
  response = Net.get("#{configuration_base_path}/libraries/#{library_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/library.rb', line 25

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