folio_api_client 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +8 -2
- data/lib/folio_api_client/exceptions.rb +1 -0
- data/lib/folio_api_client/finders.rb +38 -0
- data/lib/folio_api_client/version.rb +1 -1
- data/lib/folio_api_client.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1529c6d23ad243ce9503b24965a0afc4db6abd28a6cea7aae1000b42b5a19b0
|
4
|
+
data.tar.gz: 8da619e1c7614fe9bf46951af5ee6c086467ec90869d0f32ba9803584b65487a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6196344ec464f39dfdd0b44dbd269f3b949a630c7a41d449961a73091f494ad1d49edff1eb39d2f79b4d36ee0b9f6456257cb2ca645a4d8d1a4c8f0b3c50cd0
|
7
|
+
data.tar.gz: 064356b0fe0d418128ae36d101005229d3eb766f89a62456a6b024bedb5a9d748e42335177918985c34a2bef7ed4a0168c54f38b6bea58a5fd2ed3b0508e86f4
|
data/README.md
CHANGED
@@ -4,9 +4,15 @@ A Ruby interface for making requests to the FOLIO ILS API (https://folio.org), i
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
```bash
|
8
|
+
bundle add folio_api_client
|
9
|
+
```
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, you can install the gem by running:
|
8
12
|
|
9
|
-
|
13
|
+
```bash
|
14
|
+
gem install folio_api_client
|
15
|
+
```
|
10
16
|
|
11
17
|
## Usage
|
12
18
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class FolioApiClient
|
4
|
+
module Finders
|
5
|
+
def find_item_record(barcode:)
|
6
|
+
item_search_results = self.get('/item-storage/items', { query: "barcode==#{barcode}", limit: 2 })['items']
|
7
|
+
return nil if item_search_results.empty?
|
8
|
+
|
9
|
+
if item_search_results.length > 1
|
10
|
+
raise FolioApiClient::Exceptions::UnexpectedMultipleRecordsFoundError,
|
11
|
+
'Only expected one item with this barcode, but found more than one.'
|
12
|
+
end
|
13
|
+
|
14
|
+
item_record_id = item_search_results.first['id']
|
15
|
+
self.get("/item-storage/items/#{item_record_id}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_location_record(location_id:)
|
19
|
+
self.get("/locations/#{location_id}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def find_holdings_record(holdings_record_id:)
|
23
|
+
self.get("/holdings-storage/holdings/#{holdings_record_id}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def find_instance_record(instance_record_id:)
|
27
|
+
self.get("/instance-storage/instances/#{instance_record_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_marc_record(instance_record_id:)
|
31
|
+
source_record_search_results = self.get('/source-storage/source-records', { instanceId: instance_record_id })
|
32
|
+
return nil if source_record_search_results['totalRecords'].zero?
|
33
|
+
|
34
|
+
bib_record_marc_hash = source_record_search_results['sourceRecords'].first['parsedRecord']['content']
|
35
|
+
MARC::Record.new_from_hash(bib_record_marc_hash)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/folio_api_client.rb
CHANGED
@@ -5,9 +5,12 @@ loader = Zeitwerk::Loader.for_gem
|
|
5
5
|
loader.setup # ready!
|
6
6
|
|
7
7
|
require 'faraday'
|
8
|
+
require 'marc'
|
8
9
|
|
9
10
|
# A client used for making http requests (get/post/etc.) to the FOLIO ILS REST API.
|
10
11
|
class FolioApiClient
|
12
|
+
include Finders
|
13
|
+
|
11
14
|
attr_reader :config
|
12
15
|
|
13
16
|
def initialize(config)
|
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
|
+
version: 0.2.0
|
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-04-
|
11
|
+
date: 2025-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/folio_api_client.rb
|
69
69
|
- lib/folio_api_client/configuration.rb
|
70
70
|
- lib/folio_api_client/exceptions.rb
|
71
|
+
- lib/folio_api_client/finders.rb
|
71
72
|
- lib/folio_api_client/version.rb
|
72
73
|
homepage: https://www.github.com/cul/folio_api_client
|
73
74
|
licenses: []
|