folio_api_client 0.4.0 → 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: b95e817f47b4694776baae831bcad7784810d06e7533577f27f8bcf4ea216b06
4
- data.tar.gz: 63291ad25685d7c4ba71dd2399104b8925241da84eca2483f8bd63b4567b4454
3
+ metadata.gz: c9101df88d1bcae72de9607a5646631b5b4a3ecb2f281f4e81064ea47b1ee9b3
4
+ data.tar.gz: b9e838309973de0b1b66069bf2aa7c6a5c96f32f8a6b8d167a8cb9cc07d87626
5
5
  SHA512:
6
- metadata.gz: '018541167173b30bbf0c938c10465888581fd87d8c64885fd59dfcc3ea4a2305e93d75533f55c752b7eb495ee2b72be7b8514246caffe7bdebbe56b18f5f44ee'
7
- data.tar.gz: 7812af3dbf43c33aa37c490e8a0a084de82842b64bcdc86571c0eb9e713ad293884f7ff03098d26d15acd75bbcb4a73a89d7f2c2d4eee6e1f32eccf1233405bf
6
+ metadata.gz: 5f087226a449dc37b26445d40f0d99fe752c6f9203123bc0d6aef87f050a5257c0c6b371ee7441905406454933ecb9d37df1c539a21a82f068d6ded468902663
7
+ data.tar.gz: e8d41ca37c67901d6db368509e72f1360bcd509e71a179aa6443defe544d145bcef7a2a56e0f1a40c16dae7ad1d914c0a3e1f36d9d6197470d08479883307e8b
data/README.md CHANGED
@@ -47,6 +47,8 @@ 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')
51
+ client.find_material_type_record(material_type_id: 'some-material-type-id')
50
52
  client.find_holdings_record(holdings_record_id: 'some-holdings-record-id')
51
53
  client.find_instance_record(instance_record_id: 'some-instance-record-id')
52
54
  client.find_instance_record(instance_record_hrid: 'some-instance-record-hrid')
@@ -14,8 +14,36 @@ class FolioApiClient
14
14
  item_search_results.first
15
15
  end
16
16
 
17
- def find_location_record(location_id:)
18
- self.get("/locations/#{location_id}")
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
35
+
36
+ nil
37
+ rescue Faraday::ResourceNotFound
38
+ nil
39
+ end
40
+
41
+ def find_material_type_record(material_type_id:)
42
+ return nil if material_type_id.nil?
43
+
44
+ self.get("/material-types/#{material_type_id}")
45
+ rescue Faraday::ResourceNotFound
46
+ nil
19
47
  end
20
48
 
21
49
  def find_loan_type_record(loan_type_id:)
@@ -77,5 +105,12 @@ class FolioApiClient
77
105
  raise FolioApiClient::Exceptions::MissingQueryFieldError,
78
106
  'Missing query field. Must supply either an instance_record_id or instance_record_hrid.'
79
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
80
115
  end
81
116
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioApiClient
4
- VERSION = '0.4.0'
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.0
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-06-06 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