preservation-client 5.2.0 → 6.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 264c8e3e6d57fc3e422ec89120ee8e65d3c949328b91e45d7ac619d0ee3acc6a
4
- data.tar.gz: c98d4b2d5fb782808c53812b2858d65bc90b26a606a423227ff83849b5f6dca6
3
+ metadata.gz: 1f564cb04f2c454690324230f40e8876d752f7eb405e1dcde3671d9cd573556e
4
+ data.tar.gz: f86ce941a43ca660099a67424b21450b1b83e34be79033e4dac3d99eef41c5b3
5
5
  SHA512:
6
- metadata.gz: 3ea57d957febb7da750c62784e3af22213e3ae40200edb75acfc98f5eb5a9be8b03261a333cbd775a14eeb53580b8380d0d7c94828b99dd5f7b3644e3e918d67
7
- data.tar.gz: 935c2ac4854dc91813242402fc51d6b88e00e31b70ca94a11feaf51c5acea90655bf434730afa7cca11e651f0c7fb180a6eb155fbb33adf2846859f90a5d6bc1
6
+ metadata.gz: b30b8db76ff51c9c1bda3c574da09e4acf294b1151b234addb1c3da66c0bbf7ba034bc11160d02b50766ededd6927bcb4945d6de759fd2e10d274fd7bdffedc3
7
+ data.tar.gz: 54ef26cec8442266b9f2b0ffb7dabd0f7df0c10b1eb18f7c05819e9b52cbda741990db9271a650b2fb6f505b66a43de736d20175289714e1cefec669822f3458
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby-rails: sul-dlss/ruby-rails@3.1.2
3
+ ruby-rails: sul-dlss/ruby-rails@3.2.0
4
4
  workflows:
5
5
  build:
6
6
  jobs:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- preservation-client (5.2.0)
4
+ preservation-client (6.0.0)
5
5
  activesupport (>= 4.2, < 8)
6
6
  faraday (~> 2.0)
7
7
  moab-versioning (>= 5.0.0, < 7)
@@ -36,14 +36,14 @@ GEM
36
36
  json (2.6.3)
37
37
  method_source (1.0.0)
38
38
  minitest (5.17.0)
39
- moab-versioning (6.0.0)
39
+ moab-versioning (6.1.0)
40
40
  druid-tools (>= 1.0.0)
41
41
  json
42
42
  nokogiri
43
43
  nokogiri-happymapper
44
- nokogiri (1.14.0-x86_64-darwin)
44
+ nokogiri (1.14.1-x86_64-darwin)
45
45
  racc (~> 1.4)
46
- nokogiri (1.14.0-x86_64-linux)
46
+ nokogiri (1.14.1-x86_64-linux)
47
47
  racc (~> 1.4)
48
48
  nokogiri-happymapper (0.9.0)
49
49
  nokogiri (~> 1.5)
@@ -66,7 +66,7 @@ GEM
66
66
  rspec-core (~> 3.12.0)
67
67
  rspec-expectations (~> 3.12.0)
68
68
  rspec-mocks (~> 3.12.0)
69
- rspec-core (3.12.0)
69
+ rspec-core (3.12.1)
70
70
  rspec-support (~> 3.12.0)
71
71
  rspec-expectations (3.12.2)
72
72
  diff-lcs (>= 1.2.0, < 2.0)
@@ -113,6 +113,7 @@ GEM
113
113
 
114
114
  PLATFORMS
115
115
  x86_64-darwin-19
116
+ x86_64-darwin-20
116
117
  x86_64-linux
117
118
 
118
119
  DEPENDENCIES
@@ -23,18 +23,9 @@ module Preservation
23
23
  private
24
24
 
25
25
  def request(druid:, version:, http_args:)
26
- result = if version == 1
27
- connection.post "/#{api_version}/catalog", http_args
28
- else
29
- connection.patch "/#{api_version}/catalog/#{druid}", http_args
30
- end
31
- unless result.success?
32
- raise UnexpectedResponseError, "response was not successful. Received status #{result.status}"
33
- end
26
+ return post('catalog', http_args) if version == 1
34
27
 
35
- true
36
- rescue Faraday::Error => e
37
- raise UnexpectedResponseError, e
28
+ patch("catalog/#{druid}", http_args)
38
29
  end
39
30
  end
40
31
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Preservation
4
4
  class Client
5
- VERSION = '5.2.0'
5
+ VERSION = '6.0.0'
6
6
  end
7
7
  end
@@ -95,8 +95,19 @@ module Preservation
95
95
  rescue Faraday::Error => e
96
96
  errmsg = "Preservation::Client.#{caller_locations.first.label} " \
97
97
  "got #{e.response[:status]} from Preservation at #{req_url}: #{e.response[:body]}"
98
- exception_class = e.response[:status] == 423 ? LockedError : UnexpectedResponseError
99
- raise exception_class, errmsg
98
+ raise http_exception_class(e.response[:status]), errmsg
99
+ end
100
+
101
+ # @param status_code [Integer] the HTTP status code to translate to an exception class
102
+ def http_exception_class(status_code)
103
+ case status_code
104
+ when 423
105
+ LockedError
106
+ when 409
107
+ ConflictError
108
+ else
109
+ UnexpectedResponseError
110
+ end
100
111
  end
101
112
  end
102
113
  end
@@ -23,6 +23,9 @@ module Preservation
23
23
  # Error raised when server returns 423 Locked
24
24
  class LockedError < Error; end
25
25
 
26
+ # Error raised when server returns 409 Conflict
27
+ class ConflictError < Error; end
28
+
26
29
  # Error raised when server returns an unexpected response
27
30
  # e.g., 4xx or 5xx status not otherwise handled
28
31
  class UnexpectedResponseError < Error; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: preservation-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-01 00:00:00.000000000 Z
11
+ date: 2023-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -240,7 +240,7 @@ metadata:
240
240
  homepage_uri: https://github.com/sul-dlss/preservation-client
241
241
  source_code_uri: https://github.com/sul-dlss/preservation-client.
242
242
  rubygems_mfa_required: 'true'
243
- post_install_message:
243
+ post_install_message:
244
244
  rdoc_options: []
245
245
  require_paths:
246
246
  - lib
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  requirements: []
258
258
  rubygems_version: 3.2.32
259
- signing_key:
259
+ signing_key:
260
260
  specification_version: 4
261
261
  summary: A thin client for getting info from SDR preservation.
262
262
  test_files: []