dor-services-client 15.20.0 → 15.22.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: 64a3ed9e1db3912ff1dc3c94e880599fa837c4cb070d27a025f43f79fef2c7e7
4
- data.tar.gz: 8787b1572a98391d202d2185cb2464963b5082994badf9764f51148bbeac6466
3
+ metadata.gz: dbeb9e0e696b60812dcb043f015c6d4921f0a14f2e05102e7444743d8f160da7
4
+ data.tar.gz: e4dec1d4593527d3d3f36fc9c67744d4f33f097d6fcf08e9eb7a9f96945bd261
5
5
  SHA512:
6
- metadata.gz: e466fba4a29711de60526928037c7a7f7dacacd7c5dab6e93a5a521552824e9996e5eb765723048104048e9c74999fd5207ccbb5de75479e35f44a742093d244
7
- data.tar.gz: c00c6df54066eafb49230768c95740c0f2a118d7ce96cac055a6969dd337997a83a967f080a76f7d6133df21baff4627a026f463d2d23cbc6a4667475fe1dbfe
6
+ metadata.gz: 4b2e096727290973a9f699f0449ad040592c0af3c3fc662199f042f438557c82b035f43288c34648a4cf69c0b605cb1be6c943a60e33b2f4b2df834ed470cd5d
7
+ data.tar.gz: 5ae03a7bd42cdcce4a4806ed81d4c3241081d38d0b7b6a8855376b19a1ed0eb57a4e641d768c6840a4b4c6702eaba0687dbf0ac16541001fe54768f8283a4e0e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (15.20.0)
4
+ dor-services-client (15.22.0)
5
5
  activesupport (>= 7.0.0)
6
6
  cocina-models (~> 0.106.0)
7
7
  deprecation
@@ -13,7 +13,7 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (8.0.2.1)
16
+ activesupport (8.0.3)
17
17
  base64
18
18
  benchmark (>= 0.3)
19
19
  bigdecimal
@@ -84,7 +84,7 @@ GEM
84
84
  activesupport (>= 3.0, < 9.0)
85
85
  equivalent-xml (0.6.0)
86
86
  nokogiri (>= 1.4.3)
87
- faraday (2.13.4)
87
+ faraday (2.14.0)
88
88
  faraday-net_http (>= 2.0, < 3.5)
89
89
  json
90
90
  logger
@@ -96,7 +96,7 @@ GEM
96
96
  i18n (1.14.7)
97
97
  concurrent-ruby (~> 1.0)
98
98
  ice_nine (0.11.2)
99
- json (2.13.2)
99
+ json (2.15.0)
100
100
  jsonpath (1.1.5)
101
101
  multi_json
102
102
  language_server-protocol (3.17.0.5)
@@ -139,8 +139,8 @@ GEM
139
139
  rspec-mocks (3.13.5)
140
140
  diff-lcs (>= 1.2.0, < 2.0)
141
141
  rspec-support (~> 3.13.0)
142
- rspec-support (3.13.5)
143
- rubocop (1.80.2)
142
+ rspec-support (3.13.6)
143
+ rubocop (1.81.1)
144
144
  json (~> 2.3)
145
145
  language_server-protocol (~> 3.17.0.2)
146
146
  lint_roller (~> 1.1.0)
@@ -148,10 +148,10 @@ GEM
148
148
  parser (>= 3.3.0.2)
149
149
  rainbow (>= 2.2.2, < 4.0)
150
150
  regexp_parser (>= 2.9.3, < 3.0)
151
- rubocop-ast (>= 1.46.0, < 2.0)
151
+ rubocop-ast (>= 1.47.1, < 2.0)
152
152
  ruby-progressbar (~> 1.7)
153
153
  unicode-display_width (>= 2.4.0, < 4.0)
154
- rubocop-ast (1.46.0)
154
+ rubocop-ast (1.47.1)
155
155
  parser (>= 3.3.7.2)
156
156
  prism (~> 1.4)
157
157
  rubocop-rspec (3.7.0)
@@ -55,7 +55,7 @@ module Dor
55
55
 
56
56
  raise_exception_based_on_response!(resp) unless resp.success?
57
57
 
58
- build_cocina_from_response(resp, validate: validate)
58
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: validate)
59
59
  end
60
60
  # rubocop:enable Metrics/AbcSize
61
61
  # rubocop:enable Metrics/MethodLength
@@ -76,7 +76,7 @@ module Dor
76
76
  end
77
77
  raise_exception_based_on_response!(resp) unless resp.success?
78
78
 
79
- build_cocina_from_response(resp, validate: validate)
79
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: validate)
80
80
  end
81
81
 
82
82
  BASE_ALLOWED_FIELDS = %i[external_identifier cocina_version label version administrative description].freeze
@@ -61,7 +61,7 @@ module Dor
61
61
  end
62
62
  raise_exception_based_on_response!(resp) unless resp.success?
63
63
 
64
- build_cocina_from_response(resp, validate: false)
64
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: false)
65
65
  end
66
66
 
67
67
  # Get the current version for a DOR object. This comes from ObjectVersion table in the DSA
@@ -93,7 +93,7 @@ module Dor
93
93
 
94
94
  raise_exception_based_on_response!(resp) unless resp.success?
95
95
 
96
- build_cocina_from_response(resp)
96
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers)
97
97
  end
98
98
 
99
99
  # Close current version for an object
@@ -13,7 +13,7 @@ module Dor
13
13
  # @param [string] user_name the sunetid of the user registering the object
14
14
  # @param [boolean] validate validate the response object
15
15
  # @return [Cocina::Models::DROWithMetadata,Cocina::Models::CollectionWithMetadata,Cocina::Models::AdminPolicyWithMetadata] the returned model
16
- def register(params:, assign_doi: false, validate: false, user_name: nil)
16
+ def register(params:, assign_doi: false, validate: false, user_name: nil) # rubocop:disable Metrics/AbcSize
17
17
  resp = connection.post do |req|
18
18
  req.url objects_path
19
19
  req.params = { assign_doi: assign_doi, user_name: user_name }.compact
@@ -25,7 +25,7 @@ module Dor
25
25
 
26
26
  raise_exception_based_on_response!(resp) unless resp.success?
27
27
 
28
- build_cocina_from_response(resp, validate: validate)
28
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: validate)
29
29
  end
30
30
 
31
31
  # Find an object by source ID
@@ -40,7 +40,26 @@ module Dor
40
40
  end
41
41
  raise_exception_based_on_response!(resp) unless resp.success?
42
42
 
43
- build_cocina_from_response(resp, validate: validate)
43
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: validate)
44
+ end
45
+
46
+ # Find objects by a list of druids
47
+ # @raise [UnexpectedResponse] when the response is not successful.
48
+ # @return [Array<Cocina::Models::DROWithMetadata,Cocina::Models::CollectionWithMetadata,,Cocina::Models::AdminPolicyWithMetadata>] the returned objects
49
+ def find_all(druids:, validate: false) # rubocop:disable Metrics/AbcSize
50
+ return [] if druids.empty?
51
+
52
+ resp = connection.post do |req|
53
+ req.url "#{objects_path}/find_all"
54
+ req.headers['Content-Type'] = 'application/json'
55
+ req.body = { 'externalIdentifiers' => druids }.to_json
56
+ end
57
+ raise_exception_based_on_response!(resp) unless resp.success?
58
+
59
+ JSON.parse(resp.body).map do |item|
60
+ # The ETag header is used as the lock parameter when instantiating a cocina model with metadata
61
+ build_cocina_from_response(item, headers: { 'ETag' => item['lock'] }, validate: validate)
62
+ end
44
63
  end
45
64
 
46
65
  # Retrieves the version statuses for a batch of objects
@@ -44,7 +44,7 @@ module Dor
44
44
  end
45
45
  raise_exception_based_on_response!(resp) unless resp.success?
46
46
 
47
- build_cocina_from_response(resp, validate: false)
47
+ build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: false)
48
48
  end
49
49
 
50
50
  # @return [Hash] the solr document for the user version
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '15.20.0'
6
+ VERSION = '15.22.0'
7
7
  end
8
8
  end
9
9
  end
@@ -41,18 +41,20 @@ module Dor
41
41
  errors: data.fetch('errors', []))
42
42
  end
43
43
 
44
- def build_cocina_from_response(response, validate: false)
45
- cocina_object = Cocina::Models.build(JSON.parse(response.body), validate: validate)
46
- Cocina::Models.with_metadata(cocina_object, response.headers['ETag'], created: date_from_header(response, 'X-Created-At'),
47
- modified: date_from_header(response, 'Last-Modified'))
44
+ def build_cocina_from_response(item, headers: nil, validate: false)
45
+ cocina_object = Cocina::Models.build(item, validate: validate)
46
+ return Cocina::Models.without_metadata(cocina_object) unless headers.present?
47
+
48
+ Cocina::Models.with_metadata(cocina_object, headers['ETag'], created: date_from_header(headers, 'X-Created-At'),
49
+ modified: date_from_header(headers, 'Last-Modified'))
48
50
  end
49
51
 
50
52
  def build_json_from_cocina(cocina_object)
51
53
  Cocina::Models.without_metadata(cocina_object).to_json
52
54
  end
53
55
 
54
- def date_from_header(response, key)
55
- response.headers[key]&.to_datetime
56
+ def date_from_header(headers, key)
57
+ headers[key]&.to_datetime
56
58
  end
57
59
  end
58
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.20.0
4
+ version: 15.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  - Michael Giarlo
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-19 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -292,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
292
  - !ruby/object:Gem::Version
293
293
  version: '0'
294
294
  requirements: []
295
- rubygems_version: 3.6.2
295
+ rubygems_version: 3.7.1
296
296
  specification_version: 4
297
297
  summary: A client for dor-services-app
298
298
  test_files: []