folio_client 0.10.0 → 0.10.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: ad8e1c9733f1bba9dc63d5f8c19edb7f4b40a7c16084c3f434175582d466d70a
4
- data.tar.gz: 32beb6817690d4e95a7ce741fbde1466ccc75b7a13489230b0f1d859af6b7baa
3
+ metadata.gz: 49b7e49d6350ec5da1e3d1b86df567520dbe89c9eed80fb42b8c158c79c3f426
4
+ data.tar.gz: f957345b73f2071fee40ffbe6f6e4f8082468f383bc7848ff9953ac017917c4b
5
5
  SHA512:
6
- metadata.gz: c49e0286404a94fc67bc973b40501885410e5b560e24a922664c2d8e9031766fdfb85af55896cadf21ea8eb91fe85eea6829fa35f7a0645d6a543055c63ef44b
7
- data.tar.gz: 6f1deeee160c8625a5c84c68c57cfb35e3d28d16af0b08c4423478dc8026ebc8a637dcda752b21b814169c49970c0d399511d9c79020ead609470c90ecb150f8
6
+ metadata.gz: c775d4984eab9d5a89d310da0983dbde38824af07498ed4504cb9b9d0614c4a12c3328dde4c59d96aede407672529d39ebabeb227fe01a6b0380de716704f109
7
+ data.tar.gz: bc70a108d1a3d70131db2eed2e20343f5c0462c00a2dab65a1484456dfe7e2e19b4b6d616e628531cf664348c9bf85fc88eda94874cdbc859ae614e2a21bbde6
@@ -0,0 +1,19 @@
1
+ #!/bin/bash --login
2
+
3
+ # This script is called by our weekly dependency update job in Jenkins after updating Ruby and other deps
4
+
5
+ # Switch to Ruby 3.1 for FolioClient (3.0 is default in Jenkinsfile)
6
+ rvm use 3.1.2@folio_client --create &&
7
+ gem install bundler &&
8
+ bundle install --gemfile Gemfile
9
+
10
+ standardrb --fix > folio_client_standard.txt
11
+
12
+ retVal=$?
13
+
14
+ git commit -am "Update to latest standard style guide"
15
+
16
+ if [ $retVal -ne 0 ]; then
17
+ echo "ERROR UPDATING RUBY TO STANDARD STYLE (folio_client)"
18
+ cat folio_client_standard.txt
19
+ fi
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- folio_client (0.10.0)
4
+ folio_client (0.10.1)
5
5
  activesupport (>= 4.2, < 8)
6
6
  dry-monads
7
7
  faraday
@@ -116,6 +116,7 @@ PLATFORMS
116
116
  x86_64-darwin-19
117
117
  x86_64-darwin-20
118
118
  x86_64-darwin-21
119
+ x86_64-darwin-22
119
120
  x86_64-linux
120
121
 
121
122
  DEPENDENCIES
@@ -13,7 +13,8 @@ class FolioClient
13
13
  # get marc bib data from folio given an instance HRID
14
14
  # @param instance_hrid [String] the key to use for MARC lookup
15
15
  # @return [Hash] hash representation of the MARC. should be usable by MARC::Record.new_from_hash (from ruby-marc gem)
16
- # @raises NotFound, MultipleRecordsForIdentifier
16
+ # @raise [ResourceNotFound]
17
+ # @raise [MultipleResourcesFound]
17
18
  def fetch_marc_hash(instance_hrid:)
18
19
  response_hash = client.get("/source-storage/source-records", {instanceHrid: instance_hrid})
19
20
 
@@ -12,10 +12,12 @@ class FolioClient
12
12
  raise ForbiddenError, "The operation requires privileges which the client does not have: #{response.body}"
13
13
  when 404
14
14
  raise ResourceNotFound, "Endpoint not found or resource does not exist: #{response.body}"
15
+ when 409
16
+ raise ConflictError, "Resource cannot be updated: #{response.body}"
15
17
  when 422
16
- raise ValidationError, "There was a validation problem with the request: #{response.body} "
18
+ raise ValidationError, "There was a validation problem with the request: #{response.body}"
17
19
  when 500
18
- raise ServiceUnavailable, "The remote server returned an internal server error."
20
+ raise ServiceUnavailable, "The remote server returned an internal server error: #{response.body}"
19
21
  else
20
22
  raise StandardError, "Unexpected response: #{response.status} #{response.body}"
21
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FolioClient
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.1"
5
5
  end
data/lib/folio_client.rb CHANGED
@@ -35,6 +35,9 @@ class FolioClient
35
35
  # Error raised when the Folio API returns a 422 Unprocessable Entity
36
36
  class ValidationError < Error; end
37
37
 
38
+ # Error raised when the Folio API returns a 409 Conflict
39
+ class ConflictError < Error; end
40
+
38
41
  DEFAULT_HEADERS = {
39
42
  accept: "application/json, text/plain",
40
43
  content_type: "application/json"
@@ -44,15 +47,15 @@ class FolioClient
44
47
  # @param url [String] the folio API URL
45
48
  # @param login_params [Hash] the folio client login params (username:, password:)
46
49
  # @param okapi_headers [Hash] the okapi specific headers to add (X-Okapi-Tenant:, User-Agent:)
47
- def configure(url:, login_params:, okapi_headers:)
48
- instance.config = OpenStruct.new(url: url, login_params: login_params, okapi_headers: okapi_headers, token: nil)
50
+ def configure(url:, login_params:, okapi_headers:, timeout: default_timeout)
51
+ instance.config = OpenStruct.new(url: url, login_params: login_params, okapi_headers: okapi_headers, token: nil, timeout: timeout)
49
52
 
50
53
  instance.config.token = Authenticator.token(login_params, connection)
51
54
 
52
55
  self
53
56
  end
54
57
 
55
- delegate :config, :connection, :get, :post, :put, to: :instance
58
+ delegate :config, :connection, :get, :post, :put, :default_timeout, to: :instance
56
59
  delegate :fetch_hrid, :fetch_external_id, :fetch_instance_info, :fetch_marc_hash, :has_instance_status?, :data_import, :edit_marc_json,
57
60
  :organizations, :organization_interfaces, :interface_details, to: :instance
58
61
  end
@@ -61,7 +64,7 @@ class FolioClient
61
64
 
62
65
  # Send an authenticated get request
63
66
  # @param path [String] the path to the Folio API request
64
- # @param request [Hash] params to get to the API
67
+ # @param params [Hash] params to get to the API
65
68
  def get(path, params = {})
66
69
  response = TokenWrapper.refresh(config, connection) do
67
70
  connection.get(path, params, {"x-okapi-token": config.token})
@@ -120,7 +123,8 @@ class FolioClient
120
123
  def connection
121
124
  @connection ||= Faraday.new(
122
125
  url: config.url,
123
- headers: DEFAULT_HEADERS.merge(config.okapi_headers || {})
126
+ headers: DEFAULT_HEADERS.merge(config.okapi_headers || {}),
127
+ request: {timeout: config.timeout}
124
128
  )
125
129
  end
126
130
 
@@ -192,4 +196,8 @@ class FolioClient
192
196
  .new(self)
193
197
  .fetch_interface_details(...)
194
198
  end
199
+
200
+ def default_timeout
201
+ 120
202
+ end
195
203
  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.10.0
4
+ version: 0.10.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-03-28 00:00:00.000000000 Z
11
+ date: 2023-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -177,6 +177,7 @@ executables: []
177
177
  extensions: []
178
178
  extra_rdoc_files: []
179
179
  files:
180
+ - ".autoupdate/postupdate"
180
181
  - ".rspec"
181
182
  - ".rubocop.yml"
182
183
  - ".rubocop/custom.yml"
@@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
221
  - !ruby/object:Gem::Version
221
222
  version: '0'
222
223
  requirements: []
223
- rubygems_version: 3.4.5
224
+ rubygems_version: 3.3.3
224
225
  signing_key:
225
226
  specification_version: 4
226
227
  summary: Interface for interacting with the Folio ILS API.