dor-services-client 15.31.0 → 15.32.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: d248b8f8e52d1f3020aac8e5efc1e078ce1862867bcbd8a0990908bec99883ea
4
- data.tar.gz: 2d12164139fcca79c7ea1ad0d3f83902bb0dbd21f19aa984ae68a8738cc73b41
3
+ metadata.gz: '06370387f51516d2a08d643598cc2e885f783014aa3bcb4f353abd131372470e'
4
+ data.tar.gz: 218e00a0664bb35a8ce93677791f6c5d6c52ffb64e3eb23a88da2713a4e79ee6
5
5
  SHA512:
6
- metadata.gz: 3a6271a344f2d219a06494a36010de260d972acbd4bc6f774b839ccbc962855c4610db16aabffa9ca436664ee0fc5272f04cbf24e031382f6aa4bb5d44254b45
7
- data.tar.gz: f333f58b1431903c83e70ebfad8e3e5a8ac85f07df13739ec2ded1dde04e08dd758c9ce55ae2c7b99a05442c50bae723c04886cf321d93fd93a6352a902f5ea1
6
+ metadata.gz: 37fc5d5a48b56cfa1bab49622d8c63014776f6493252ca7c69d63605296c8b4a60ea4739f0cb9205989a81a6ff37e800b965ba8cf6e35fb9a9f0211719f96ac3
7
+ data.tar.gz: b25369fb1e80f33db2bfc03fb1135f470d882b0af2017b29a3f1342531d5d0c04c0c59f19a8c685519bd89f123b1a9803471204e42f0ad4dd28f6a5339ec9323
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (15.31.0)
4
+ dor-services-client (15.32.0)
5
5
  activesupport (>= 7.0.0)
6
6
  cocina-models (~> 0.113.0)
7
7
  deprecation
data/README.md CHANGED
@@ -108,6 +108,8 @@ object_client.version.current
108
108
  # Status includes whether the object is open, assembling, accessioning, or closeable.
109
109
  # See also objects_client.statuses for getting statuses in batch.
110
110
  object_client.version.status
111
+ # Returns object version as Cocina instance if valid; returns a Hash<cocina_object:, error_message:> if invalid
112
+ object_client.version.find(3)
111
113
 
112
114
  # see dor-services-app openapi.yml for optional params
113
115
  object_client.version.open(description: 'Changed title')
@@ -53,15 +53,21 @@ module Dor
53
53
  @object_identifier = object_identifier
54
54
  end
55
55
 
56
- # @return [Cocina::Models::DROWithMetadata] the object metadata
57
- # @raise [UnexpectedResponse] on an unsuccessful response from the server
56
+ # @return [Cocina::Models::DROWithMetadata, Hash] the object metadata or a hash with
57
+ # invalid metadata and a message about the source of the invalidity
58
+ # @raise [Dor::Services::Client::Error] on an unsuccessful response from the server
58
59
  def find(version)
59
60
  resp = connection.get do |req|
60
61
  req.url "#{base_path}/#{version}"
61
62
  end
62
- raise_exception_based_on_response!(resp) unless resp.success?
63
63
 
64
- build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: false)
64
+ if resp.success?
65
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: false)
66
+ elsif resp.status == 409 # Signals the Cocina is present but invalid
67
+ build_invalid_cocina_from_response(resp)
68
+ else
69
+ raise_exception_based_on_response!(resp) unless resp.success?
70
+ end
65
71
  end
66
72
 
67
73
  # Get the current version for a DOR object. This comes from ObjectVersion table in the DSA
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '15.31.0'
6
+ VERSION = '15.32.0'
7
7
  end
8
8
  end
9
9
  end
@@ -54,6 +54,15 @@ module Dor
54
54
  Cocina::Models.without_metadata(cocina_object).to_json
55
55
  end
56
56
 
57
+ def build_invalid_cocina_from_response(response)
58
+ invalid_cocina_error = JSON.parse(response.body).dig('errors', 0)
59
+
60
+ {
61
+ cocina_object: invalid_cocina_error.dig('meta', 'json'),
62
+ error_message: invalid_cocina_error['message']
63
+ }.with_indifferent_access
64
+ end
65
+
57
66
  def date_from_header(headers, key)
58
67
  headers[key]&.to_datetime
59
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.31.0
4
+ version: 15.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne