folio_client 0.8.0 → 0.9.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/Gemfile.lock +8 -8
- data/README.md +2 -2
- data/lib/folio_client/holdings.rb +2 -1
- data/lib/folio_client/inventory.rb +12 -9
- data/lib/folio_client/job_status.rb +1 -1
- data/lib/folio_client/source_storage.rb +1 -0
- data/lib/folio_client/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f400cbad25cc1f7a7a4af985a510c597af5dea7b18cf636d5e6cb8196b4ef059
|
4
|
+
data.tar.gz: 26d9485bebd8780fafe498b15827575703316c229ed8c35e361aee3246ee70fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 472ca9f6c928aa3353b8f928cce63030329e62a7c26655700aaaef6c835e777f58d0771c8b58d8bfd50ee59a7c2c1724063246884ab529556b7cd92ee2065dfd
|
7
|
+
data.tar.gz: 2add95c0f3492db0c80f1770c40576d7bbac019a31674a9b0124a47706b065e1b02e67735519dddc2cf4f832216d453ddb3126906a4c89f4d4eac1f59c70fd6d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
folio_client (0.
|
4
|
+
folio_client (0.9.0)
|
5
5
|
activesupport (>= 4.2, < 8)
|
6
6
|
dry-monads
|
7
7
|
faraday
|
@@ -11,7 +11,7 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
activesupport (7.0.4.
|
14
|
+
activesupport (7.0.4.3)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
16
|
i18n (>= 1.6, < 2)
|
17
17
|
minitest (>= 5.1)
|
@@ -67,21 +67,21 @@ GEM
|
|
67
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
68
|
rspec-support (~> 3.12.0)
|
69
69
|
rspec-support (3.12.0)
|
70
|
-
rubocop (1.
|
70
|
+
rubocop (1.48.1)
|
71
71
|
json (~> 2.3)
|
72
72
|
parallel (~> 1.10)
|
73
73
|
parser (>= 3.2.0.0)
|
74
74
|
rainbow (>= 2.2.2, < 4.0)
|
75
75
|
regexp_parser (>= 1.8, < 3.0)
|
76
76
|
rexml (>= 3.2.5, < 4.0)
|
77
|
-
rubocop-ast (>= 1.
|
77
|
+
rubocop-ast (>= 1.26.0, < 2.0)
|
78
78
|
ruby-progressbar (~> 1.7)
|
79
79
|
unicode-display_width (>= 2.4.0, < 3.0)
|
80
80
|
rubocop-ast (1.27.0)
|
81
81
|
parser (>= 3.2.1.0)
|
82
82
|
rubocop-capybara (2.17.1)
|
83
83
|
rubocop (~> 1.41)
|
84
|
-
rubocop-performance (1.
|
84
|
+
rubocop-performance (1.16.0)
|
85
85
|
rubocop (>= 1.7.0, < 2.0)
|
86
86
|
rubocop-ast (>= 0.4.0)
|
87
87
|
rubocop-rspec (2.19.0)
|
@@ -96,10 +96,10 @@ GEM
|
|
96
96
|
simplecov_json_formatter (~> 0.1)
|
97
97
|
simplecov-html (0.12.3)
|
98
98
|
simplecov_json_formatter (0.1.4)
|
99
|
-
standard (1.
|
99
|
+
standard (1.25.2)
|
100
100
|
language_server-protocol (~> 3.17.0.2)
|
101
|
-
rubocop (= 1.
|
102
|
-
rubocop-performance (= 1.
|
101
|
+
rubocop (= 1.48.1)
|
102
|
+
rubocop-performance (= 1.16.0)
|
103
103
|
tzinfo (2.0.6)
|
104
104
|
concurrent-ruby (~> 1.0)
|
105
105
|
unf (0.1.4)
|
data/README.md
CHANGED
@@ -65,13 +65,13 @@ client.fetch_hrid(barcode: "12345")
|
|
65
65
|
=> "a7927874"
|
66
66
|
|
67
67
|
# Request a MARC record given an instance hrid
|
68
|
-
# returns a hash if found; raises FolioClient::
|
68
|
+
# returns a hash if found; raises FolioClient::ResourceNotFound if instance_hrid not found
|
69
69
|
client.fetch_marc_hash(instance_hrid: "a7927874")
|
70
70
|
=> {"fields"=>
|
71
71
|
[{"003"=>"FOLIO"}....]
|
72
72
|
}
|
73
73
|
|
74
|
-
# Import a MARC record
|
74
|
+
# Import a MARC record into FOLIO
|
75
75
|
data_importer = client.data_import(marc: my_marc, job_profile_id: '4ba4f4ab', job_profile_name: 'ETDs')
|
76
76
|
# If called too quickly, might get Failure(:not_found)
|
77
77
|
data_importer.status
|
@@ -6,12 +6,13 @@ class FolioClient
|
|
6
6
|
attr_accessor :client, :instance_id
|
7
7
|
|
8
8
|
# @param client [FolioClient] the configured client
|
9
|
-
# @param instance_id [String] the UUID of the instance to which the holdings
|
9
|
+
# @param instance_id [String] the UUID of the instance to which the holdings record belongs
|
10
10
|
def initialize(client, instance_id:)
|
11
11
|
@client = client
|
12
12
|
@instance_id = instance_id
|
13
13
|
end
|
14
14
|
|
15
|
+
# create a holdings record for the instance
|
15
16
|
# @param permanent_location_id [String] the UUID of the permanent location
|
16
17
|
# @param holdings_type_id [String] the UUID of the holdings type
|
17
18
|
def create(holdings_type_id:, permanent_location_id:)
|
@@ -10,8 +10,9 @@ class FolioClient
|
|
10
10
|
@client = client
|
11
11
|
end
|
12
12
|
|
13
|
-
#
|
14
|
-
# @
|
13
|
+
# get instance HRID from barcode
|
14
|
+
# @param barcode [String] barcode
|
15
|
+
# @return [String,nil] instance HRID if present, otherwise nil.
|
15
16
|
def fetch_hrid(barcode:)
|
16
17
|
# find the instance UUID for this barcode
|
17
18
|
instance = client.get("/search/instances", {query: "items.barcode==#{barcode}"})
|
@@ -24,8 +25,9 @@ class FolioClient
|
|
24
25
|
result.dig("hrid")
|
25
26
|
end
|
26
27
|
|
27
|
-
#
|
28
|
-
# @
|
28
|
+
# get instance external ID from HRID
|
29
|
+
# @param hrid [String] instance HRID
|
30
|
+
# @return [String,nil] instance external ID if present, otherwise nil.
|
29
31
|
# @raise [ResourceNotFound, MultipleResourcesFound] if search does not return exactly 1 result
|
30
32
|
def fetch_external_id(hrid:)
|
31
33
|
instance_response = client.get("/search/instances", {query: "hrid==#{hrid}"})
|
@@ -36,11 +38,11 @@ class FolioClient
|
|
36
38
|
instance_response.dig("instances", 0, "id")
|
37
39
|
end
|
38
40
|
|
39
|
-
# Retrieve basic information about a record. Example usage: get the external ID and _version for update using
|
41
|
+
# Retrieve basic information about a instance record. Example usage: get the external ID and _version for update using
|
40
42
|
# optimistic locking when the HRID is available: `fetch_instance_info(hrid: 'a1234').slice('id', '_version')`
|
41
43
|
# (or vice versa if the external ID is available).
|
42
|
-
# @param external_id [String] an external ID for
|
43
|
-
# @param hrid [String] an HRID for
|
44
|
+
# @param external_id [String] an external ID for the desired instance record
|
45
|
+
# @param hrid [String] an instance HRID for the desired instance record
|
44
46
|
# @return [Hash] information about the record.
|
45
47
|
# @raise [ArgumentError] if the caller does not provide exactly one of external_id or hrid
|
46
48
|
def fetch_instance_info(external_id: nil, hrid: nil)
|
@@ -51,9 +53,10 @@ class FolioClient
|
|
51
53
|
client.get("/inventory/instances/#{external_id}")
|
52
54
|
end
|
53
55
|
|
54
|
-
# @param hrid [String]
|
56
|
+
# @param hrid [String] instance HRID
|
55
57
|
# @param status_id [String] uuid for an instance status code
|
56
|
-
# @
|
58
|
+
# @return true if instance status matches the uuid param, false otherwise
|
59
|
+
# @raise [ResourceNotFound] if search by instance HRID returns 0 results
|
57
60
|
def has_instance_status?(hrid:, status_id:)
|
58
61
|
# get the instance record and its statusId
|
59
62
|
instance = client.get("/inventory/instances", {query: "hrid==#{hrid}"})
|
@@ -87,7 +87,7 @@ class FolioClient
|
|
87
87
|
def check_not_found(result, index)
|
88
88
|
return unless result.failure? && result.failure == :not_found && index > 2
|
89
89
|
|
90
|
-
raise ResourceNotFound, "Job not found"
|
90
|
+
raise ResourceNotFound, "Job #{job_execution_id} not found after #{index} retries"
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -10,6 +10,7 @@ class FolioClient
|
|
10
10
|
@client = client
|
11
11
|
end
|
12
12
|
|
13
|
+
# get marc bib data from folio given an instance HRID
|
13
14
|
# @param instance_hrid [String] the key to use for MARC lookup
|
14
15
|
# @return [Hash] hash representation of the MARC. should be usable by MARC::Record.new_from_hash (from ruby-marc gem)
|
15
16
|
# @raises NotFound, MultipleRecordsForIdentifier
|
data/lib/folio_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: folio_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -206,7 +206,7 @@ metadata:
|
|
206
206
|
source_code_uri: https://github.com/sul-dlss/folio_client
|
207
207
|
changelog_uri: https://github.com/sul-dlss/folio_client/releases
|
208
208
|
rubygems_mfa_required: 'true'
|
209
|
-
post_install_message:
|
209
|
+
post_install_message:
|
210
210
|
rdoc_options: []
|
211
211
|
require_paths:
|
212
212
|
- lib
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
224
224
|
rubygems_version: 3.3.7
|
225
|
-
signing_key:
|
225
|
+
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Interface for interacting with the Folio ILS API.
|
228
228
|
test_files: []
|