folio_client 0.6.0 → 0.6.1

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: 3e45342fc554ea5de7c33e31a2bc41fd1b550cf1d60a52edd47b18f2c861846e
4
- data.tar.gz: 13b0ddc4db0c2f73c31b2db26c48c9295ffa836e1e5e491b3308382d61021e72
3
+ metadata.gz: db6b3bd02eac883e93ca7a24725f1c3d4f1ef48b34a3aa6e9326070e1903f600
4
+ data.tar.gz: e2592286592f8fe064b326373dc3f8ca3123a7fa775fedcb23f00da97dc58638
5
5
  SHA512:
6
- metadata.gz: 5087d3b4a53111f8d442756e4ef4d7d5213c4232650fb46216c48aa877ea12c4bf5a2686ac90cbc575be3c1b7b271079357a00dd25a96f6cd7fc32a2738741f8
7
- data.tar.gz: 1094cccbea7e0d3cfc5f0b602c78b1b1b85aa2374cd1f264dcdf569c3b7bd907153f5f9342ddc5ccc7a3a45e68e5462060f5c4452cbc1c2c5a87fd6f4bd903d8
6
+ metadata.gz: 7ee03f5f2ae933bab57d6a3c6b2be09d7933b98f51ea66c07ffb09e821c4a5c9a08564125c01cd0858a4347465f8e588314b25bc26296851e61e593f8e1c42bd
7
+ data.tar.gz: '0170689c2a3d9bd2547b976cd43b7258cc3dd6c51a5a8caba9ba62774d3425e62f624024c155d3b728a7dea8df30bce23ee7f111f628c5c1649c8327891e1cc9'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- folio_client (0.6.0)
4
+ folio_client (0.6.1)
5
5
  activesupport (>= 4.2, < 8)
6
6
  faraday
7
7
  zeitwerk
@@ -4,7 +4,7 @@ class FolioClient
4
4
  # Wraps API operations to request new access token if expired
5
5
  class TokenWrapper
6
6
  def self.refresh(config, connection)
7
- yield
7
+ yield.tap { |response| UnexpectedResponse.call(response) unless response.success? }
8
8
  rescue UnauthorizedError
9
9
  config.token = Authenticator.token(config.login_params, connection)
10
10
  yield
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioClient
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
data/lib/folio_client.rb CHANGED
@@ -58,7 +58,9 @@ class FolioClient
58
58
  # @param path [String] the path to the Folio API request
59
59
  # @param request [Hash] params to get to the API
60
60
  def get(path, params = {})
61
- response = connection.get(path, params, {"x-okapi-token": config.token})
61
+ response = TokenWrapper.refresh(config, connection) do
62
+ connection.get(path, params, {"x-okapi-token": config.token})
63
+ end
62
64
 
63
65
  UnexpectedResponse.call(response) unless response.success?
64
66
 
@@ -69,7 +71,9 @@ class FolioClient
69
71
  # @param path [String] the path to the Folio API request
70
72
  # @param request [json] request body to post to the API
71
73
  def post(path, request = nil)
72
- response = connection.post(path, request, {"x-okapi-token": config.token})
74
+ response = TokenWrapper.refresh(config, connection) do
75
+ connection.post(path, request, {"x-okapi-token": config.token})
76
+ end
73
77
 
74
78
  UnexpectedResponse.call(response) unless response.success?
75
79
 
@@ -85,25 +89,18 @@ class FolioClient
85
89
  end
86
90
 
87
91
  # Public methods available on the FolioClient below
88
- # Wrap methods in `TokenWrapper` to ensure a new token is fetched automatically if expired
89
92
  def fetch_hrid(...)
90
- TokenWrapper.refresh(config, connection) do
91
- inventory = Inventory.new(self)
92
- inventory.fetch_hrid(...)
93
- end
93
+ inventory = Inventory.new(self)
94
+ inventory.fetch_hrid(...)
94
95
  end
95
96
 
96
97
  def fetch_marc_hash(...)
97
- TokenWrapper.refresh(config, connection) do
98
- source_storage = SourceStorage.new(self)
99
- source_storage.fetch_marc_hash(...)
100
- end
98
+ source_storage = SourceStorage.new(self)
99
+ source_storage.fetch_marc_hash(...)
101
100
  end
102
101
 
103
102
  def has_instance_status?(...)
104
- TokenWrapper.refresh(config, connection) do
105
- inventory = Inventory.new(self)
106
- inventory.has_instance_status?(...)
107
- end
103
+ inventory = Inventory.new(self)
104
+ inventory.has_instance_status?(...)
108
105
  end
109
106
  end
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-28 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -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.4.5
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.