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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2421b3de04e4754677703bb1012074d586cbce87bd90fe8b3341212ebeffae7
4
- data.tar.gz: 54b49208c11498964a494c5c57c0c97ca3a47d71fddef9766ccf1ef4e0c404a2
3
+ metadata.gz: ba0a7a402a239866f9e2e3aaeae1a7a3fa4f113a97aa5fac4b5f8a54037fb734
4
+ data.tar.gz: 4184b99c342fe2d9d01ab7763f2fc8407f93f70a8370e44552e1a639ac1753fb
5
5
  SHA512:
6
- metadata.gz: 6fa88a92dcf548e03d69978c3600cadb33324106871ec1fcd86652e83af86aa14ed2bb3d60725cc74e6fd7291a8e4056b090d71061c04c24425d25a86310e158
7
- data.tar.gz: 2094388e4e9c87abf1f09bdee68a05341358365940db25cde91e411e1f929ff1059a481089bde26c5b44398be824eb2300f1480d55ca431a07004fcbef26e0b6
6
+ metadata.gz: 9a1a19fbfe4e6dfe76e30ba00fe22873cfcd96f7df5241db8118d5ed8d7b16812e03bed56653418bf6883acf1447dd8fc93364d3adf5703fac31468fcbc83055
7
+ data.tar.gz: f1b8d6af99291e0d4a2c12a2fb7831cef7ba7587c6f979c5ae764b77c665860b6115fee27cd0f18cbabfc3a553385d64728297c07ce3999478f094fa143d9035
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- folio_client (0.4.0)
4
+ folio_client (0.5.0)
5
5
  activesupport (>= 4.2, < 8)
6
6
  faraday
7
7
  zeitwerk
@@ -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 [FolioClient::UnexpectedResponse::ResourceNotFound] if search by hrid returns 0 results
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 FolioClient::UnexpectedResponse::ResourceNotFound, "No matching instance found for #{hrid}" if instance["totalRecords"] == 0
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 FolioClient::UnexpectedResponse::ResourceNotFound, "No records found for #{instance_hrid}" if record_count.zero?
21
- raise FolioClient::UnexpectedResponse::MultipleResourcesFound, "Expected 1 record for #{instance_hrid}, but found #{record_count}" if record_count > 1
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
@@ -5,7 +5,7 @@ class FolioClient
5
5
  class TokenWrapper
6
6
  def self.refresh(config, connection)
7
7
  yield
8
- rescue UnexpectedResponse::UnauthorizedError
8
+ rescue UnauthorizedError
9
9
  config.token = Authenticator.token(config.login_params, connection)
10
10
  yield
11
11
  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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioClient
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
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.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.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.