alma 0.5.1 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc037cc120cbf6b68ed5a42c6bfbb15e319f1e6fddea7f66ca93c11be2df5397
4
- data.tar.gz: 3627c391a4512585d23fbd97f126fe3ce7e05801fdc927b5dc0dd0c3351cfe2f
3
+ metadata.gz: e09da26db9596cc2e8a1471efd1f75f6c8e29264860614ae7ca5a3b79567b2c0
4
+ data.tar.gz: 808d2a2f12fa77077e030f8c5b2bb8f072fdbe69f2f775b24be36e7de16fb285
5
5
  SHA512:
6
- metadata.gz: 8d115b3cb161939836de8527c9365619b1399004a12e98ac69fed5a097639fff6c670ac9ddf15e234dd8dcea78665dd6400dfd08891a3b733311757c4e4b94e3
7
- data.tar.gz: 30deded89f0cfaf86844ea872ad883f13a248753838998ab10b3bf46cf24c44533d346b7813bd135c20cf181343da0601207b872eb71f5708552804804a63f74
6
+ metadata.gz: bcbad60834c1231169c93ee6b37fc458085e6deafbc9bb8c9064cc8e9ac0cbccc40edf569d912f22232bbe436f9f4386430011e6c865d250f2b02194cd529cc8
7
+ data.tar.gz: f8a8d01ab65472572fa263a1549c10af53638c83a934501c05faca5310c747873c3c1ba33b4d9c7190f3f752959686d58d7ca572f1c4e42c2d8f1ed4110c685e
@@ -20,22 +20,30 @@ module Alma
20
20
  end
21
21
 
22
22
  def build_holdings_for(bib)
23
+ holdings = []
24
+
23
25
  get_inventory_fields_for(bib).map do |inventory_field|
26
+ h = {}
27
+
24
28
  # Use the mapping for this inventory type
25
29
  subfield_codes = Alma::INVENTORY_SUBFIELD_MAPPING[inventory_field["tag"]]
30
+ h["inventory_type"] = subfield_codes["INVENTORY_TYPE"]
26
31
 
27
32
  inventory_field.
28
33
  # Get all the subfields for this inventory field
29
34
  fetch("subfield", []).
30
35
  # Limit to only subfields codes for which we have a mapping
31
- select { |sf| subfield_codes.key? sf["code"] }.
32
- # Transform the array of subfields into a hash with mapped code as key
33
- reduce(Hash.new) { |acc, subfield|
34
- acc.merge({ "#{subfield_codes[subfield['code']]}" => subfield["content"] })
35
- }.
36
- # Include the inventory type
37
- merge({ "inventory_type" => subfield_codes["INVENTORY_TYPE"] })
36
+ select { |sf| subfield_codes.key? sf["code"] }.each { |f|
37
+ key = subfield_codes[f["code"]]
38
+ if h.key? key
39
+ h[key] << " " + f["content"]
40
+ else
41
+ h[key] = f["content"]
42
+ end
43
+ }
44
+ holdings << h
38
45
  end
46
+ holdings
39
47
  end
40
48
 
41
49
  def get_inventory_fields_for(bib)
data/lib/alma/response.rb CHANGED
@@ -14,7 +14,7 @@ module Alma
14
14
 
15
15
  def initialize(response)
16
16
  @raw_response = response
17
- # We could validate and throw an error here but currently a
17
+ @response = response.parsed_response
18
18
  validate(response)
19
19
  end
20
20
 
@@ -37,9 +37,21 @@ module Alma
37
37
  end
38
38
  end
39
39
 
40
+ def request_id
41
+ @response.fetch("request_id", "")
42
+ end
43
+
44
+ def managed_by_library
45
+ @response.fetch("managed_by_library", "")
46
+ end
47
+
48
+ def managed_by_library_code
49
+ @response.fetch("managed_by_library_code", "")
50
+ end
51
+
40
52
  # Returns an array of errors
41
53
  def errors
42
- @raw_response.parsed_response&.dig("errorList", "error") || []
54
+ @response&.dig("errorList", "error") || []
43
55
  end
44
56
  end
45
57
  end
data/lib/alma/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alma
4
- VERSION = "0.5.1"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jennifer Anton
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-04-29 00:00:00.000000000 Z
13
+ date: 2024-09-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -280,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  - !ruby/object:Gem::Version
281
281
  version: '0'
282
282
  requirements: []
283
- rubygems_version: 3.5.9
283
+ rubygems_version: 3.5.11
284
284
  signing_key:
285
285
  specification_version: 4
286
286
  summary: Client for Ex Libris Alma Web Services