folio_api_client 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b840ff7acc1495be7cb4dc3895c9a0e372d98df6db09bd45e5a77725e1cc3444
4
- data.tar.gz: 187a19aa42bfe6e1f64e859dfd1b7d71c03db8a0967ab93a7df2318bdc2c4b32
3
+ metadata.gz: c9101df88d1bcae72de9607a5646631b5b4a3ecb2f281f4e81064ea47b1ee9b3
4
+ data.tar.gz: b9e838309973de0b1b66069bf2aa7c6a5c96f32f8a6b8d167a8cb9cc07d87626
5
5
  SHA512:
6
- metadata.gz: 4b1d313a2cf74cd8b28f5d151239136a3fd8c7fe4db9a2bb85c924dd9390ab464e733012fc95d8bc8bf274db6571e2638f66ab0e4fa0633e4e0b5f372184647c
7
- data.tar.gz: 52216d3b49b1b5d5c45c3698eb95eb8350aca7b59846de99f9498524c3e2fe8f202f7a8227a7f53b9f5b6e03da9ad6d33be816e7e87a12412579ecd6c1e445ee
6
+ metadata.gz: 5f087226a449dc37b26445d40f0d99fe752c6f9203123bc0d6aef87f050a5257c0c6b371ee7441905406454933ecb9d37df1c539a21a82f068d6ded468902663
7
+ data.tar.gz: e8d41ca37c67901d6db368509e72f1360bcd509e71a179aa6443defe544d145bcef7a2a56e0f1a40c16dae7ad1d914c0a3e1f36d9d6197470d08479883307e8b
data/README.md CHANGED
@@ -47,6 +47,7 @@ client.delete(path, body, content_type: 'application/json'))
47
47
 
48
48
  client.find_item_record(barcode: 'some-barcode')
49
49
  client.find_location_record(location_id: 'some-location-id')
50
+ client.find_location_record(code: 'some-location-code')
50
51
  client.find_material_type_record(material_type_id: 'some-material-type-id')
51
52
  client.find_holdings_record(holdings_record_id: 'some-holdings-record-id')
52
53
  client.find_instance_record(instance_record_id: 'some-instance-record-id')
@@ -14,10 +14,26 @@ class FolioApiClient
14
14
  item_search_results.first
15
15
  end
16
16
 
17
- def find_location_record(location_id:)
18
- return nil if location_id.nil?
17
+ def find_location_record(location_id: nil, code: nil) # rubocop:disable Metrics/MethodLength
18
+ if location_id
19
+ return self.get("/locations/#{location_id}")
20
+ elsif code
21
+ location_record_search_results = self.get(
22
+ '/locations',
23
+ location_record_query(code: code)
24
+ )['locations']
25
+
26
+ return nil if location_record_search_results.empty?
27
+
28
+ if location_record_search_results.length > 1
29
+ raise FolioApiClient::Exceptions::UnexpectedMultipleRecordsFoundError,
30
+ 'Only expected one location with this code, but found more than one.'
31
+ end
32
+
33
+ return location_record_search_results.first
34
+ end
19
35
 
20
- self.get("/locations/#{location_id}")
36
+ nil
21
37
  rescue Faraday::ResourceNotFound
22
38
  nil
23
39
  end
@@ -89,5 +105,12 @@ class FolioApiClient
89
105
  raise FolioApiClient::Exceptions::MissingQueryFieldError,
90
106
  'Missing query field. Must supply either an instance_record_id or instance_record_hrid.'
91
107
  end
108
+
109
+ def location_record_query(code: nil)
110
+ return { query: "code==#{code}", limit: 2 } if code
111
+
112
+ raise FolioApiClient::Exceptions::MissingQueryFieldError,
113
+ 'Missing query field. Must supply a code.'
114
+ end
92
115
  end
93
116
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioApiClient
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: folio_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric O'Hanlon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-15 00:00:00.000000000 Z
11
+ date: 2025-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday