folio_client 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/folio_client/inventory.rb +2 -2
- data/lib/folio_client/source_storage.rb +2 -2
- data/lib/folio_client/token_wrapper.rb +1 -1
- data/lib/folio_client/unexpected_response.rb +0 -18
- data/lib/folio_client/version.rb +1 -1
- data/lib/folio_client.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba0a7a402a239866f9e2e3aaeae1a7a3fa4f113a97aa5fac4b5f8a54037fb734
|
4
|
+
data.tar.gz: 4184b99c342fe2d9d01ab7763f2fc8407f93f70a8370e44552e1a639ac1753fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a1a19fbfe4e6dfe76e30ba00fe22873cfcd96f7df5241db8118d5ed8d7b16812e03bed56653418bf6883acf1447dd8fc93364d3adf5703fac31468fcbc83055
|
7
|
+
data.tar.gz: f1b8d6af99291e0d4a2c12a2fb7831cef7ba7587c6f979c5ae764b77c665860b6115fee27cd0f18cbabfc3a553385d64728297c07ce3999478f094fa143d9035
|
data/Gemfile.lock
CHANGED
@@ -26,11 +26,11 @@ class FolioClient
|
|
26
26
|
|
27
27
|
# @param hrid [String] folio instance HRID
|
28
28
|
# @param status_id [String] uuid for an instance status code
|
29
|
-
# @raise [
|
29
|
+
# @raise [ResourceNotFound] if search by hrid returns 0 results
|
30
30
|
def has_instance_status?(hrid:, status_id:)
|
31
31
|
# get the instance record and its statusId
|
32
32
|
instance = client.get("/inventory/instances", {query: "hrid==#{hrid}"})
|
33
|
-
raise
|
33
|
+
raise ResourceNotFound, "No matching instance found for #{hrid}" if instance["totalRecords"] == 0
|
34
34
|
|
35
35
|
instance_status_id = instance.dig("instances", 0, "statusId")
|
36
36
|
|
@@ -17,8 +17,8 @@ class FolioClient
|
|
17
17
|
response_hash = client.get("/source-storage/source-records", {instanceHrid: instance_hrid})
|
18
18
|
|
19
19
|
record_count = response_hash["totalRecords"]
|
20
|
-
raise
|
21
|
-
raise
|
20
|
+
raise ResourceNotFound, "No records found for #{instance_hrid}" if record_count.zero?
|
21
|
+
raise MultipleResourcesFound, "Expected 1 record for #{instance_hrid}, but found #{record_count}" if record_count > 1
|
22
22
|
|
23
23
|
response_hash["sourceRecords"].first["parsedRecord"]["content"]
|
24
24
|
end
|
@@ -3,24 +3,6 @@
|
|
3
3
|
class FolioClient
|
4
4
|
# Handles unexpected responses when communicating with Folio
|
5
5
|
class UnexpectedResponse
|
6
|
-
# Base class for all FolioClient errors
|
7
|
-
class FolioClientError < StandardError; end
|
8
|
-
|
9
|
-
# Error raised by the Folio Auth API returns a 422 Unauthorized
|
10
|
-
class UnauthorizedError < FolioClientError; end
|
11
|
-
|
12
|
-
# Error raised when the Folio API returns a 404 NotFound, or returns 0 results when one was expected
|
13
|
-
class ResourceNotFound < FolioClientError; end
|
14
|
-
|
15
|
-
# Error raised when e.g. exactly one result was expected, but more than one was returned
|
16
|
-
class MultipleResourcesFound < FolioClientError; end
|
17
|
-
|
18
|
-
# Error raised when the Folio API returns a 403 Forbidden
|
19
|
-
class ForbiddenError < FolioClientError; end
|
20
|
-
|
21
|
-
# Error raised when the Folio API returns a 500
|
22
|
-
class ServiceUnavailable < FolioClientError; end
|
23
|
-
|
24
6
|
# @param [Faraday::Response] response
|
25
7
|
def self.call(response)
|
26
8
|
case response.status
|
data/lib/folio_client/version.rb
CHANGED
data/lib/folio_client.rb
CHANGED
@@ -13,6 +13,24 @@ Zeitwerk::Loader.for_gem.setup
|
|
13
13
|
class FolioClient
|
14
14
|
include Singleton
|
15
15
|
|
16
|
+
# Base class for all FolioClient errors
|
17
|
+
class Error < StandardError; end
|
18
|
+
|
19
|
+
# Error raised by the Folio Auth API returns a 422 Unauthorized
|
20
|
+
class UnauthorizedError < Error; end
|
21
|
+
|
22
|
+
# Error raised when the Folio API returns a 404 NotFound, or returns 0 results when one was expected
|
23
|
+
class ResourceNotFound < Error; end
|
24
|
+
|
25
|
+
# Error raised when e.g. exactly one result was expected, but more than one was returned
|
26
|
+
class MultipleResourcesFound < Error; end
|
27
|
+
|
28
|
+
# Error raised when the Folio API returns a 403 Forbidden
|
29
|
+
class ForbiddenError < Error; end
|
30
|
+
|
31
|
+
# Error raised when the Folio API returns a 500
|
32
|
+
class ServiceUnavailable < Error; end
|
33
|
+
|
16
34
|
DEFAULT_HEADERS = {
|
17
35
|
accept: "application/json, text/plain",
|
18
36
|
content_type: "application/json"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: folio_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
189
|
- !ruby/object:Gem::Version
|
190
190
|
version: '0'
|
191
191
|
requirements: []
|
192
|
-
rubygems_version: 3.3.
|
192
|
+
rubygems_version: 3.3.7
|
193
193
|
signing_key:
|
194
194
|
specification_version: 4
|
195
195
|
summary: Interface for interacting with the Folio ILS API.
|