dor-services-client 4.12.0 → 4.13.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: 78cb3df1e3d97be3b57b992d7059683524baa1e55deedcc8e5e46ee2a6918a2b
4
- data.tar.gz: 7a76faaefd3472f4b3c5151903e664a776a9decdcef97a2c3c59588779afad2f
3
+ metadata.gz: df42df85af44b22aa3cc0e5ae6ca8516b3aed6ebc4ab35f661f48380cc4daecf
4
+ data.tar.gz: d02b757c73b9875c60cb2f5edcd37e1d97fb1e30920d4119bf3eb6eaac5dd507
5
5
  SHA512:
6
- metadata.gz: e3c57d81c115e47088341f60aa23d35a63576231b925a03857c6fba965ee7ee1e30e993a56f6615ffd9834a36d94166b2a471f7c5a71a50202b16b2ff1020a4a
7
- data.tar.gz: f45e7147388edd1eeac604eb02a1899aa4215f79e6396c3815b9ed902c517731189ac3968868ac19a510b89c979fb3a972eeaf77be3d8f1ea53ce2f9a6b610ab
6
+ metadata.gz: ea9d7a9ffa4bead67be72b12a9cc8432a88466b32e859a99be4c90a5d66cc9a103eaa2baa1bb7e21c42d68eb23072ae2b3c8be0e047e85da66ab33f83fbcbbc6
7
+ data.tar.gz: eece297309acdb8979391c1f3d462c979a4d7c1d04f8888b32b9b39d332b979f39113bbdef425f55d5dfb81bb20d229b6e342a42c4e67a3234db0c4a11df44c3
data/.rubocop_todo.yml CHANGED
@@ -1,19 +1,24 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-09-03 08:11:02 -0500 using RuboCop version 0.61.1.
3
+ # on 2020-02-13 15:40:30 -0800 using RuboCop version 0.61.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 2
10
+ Metrics/AbcSize:
11
+ Exclude:
12
+ - 'lib/dor/services/client/marcxml.rb'
13
+
14
+ # Offense count: 1
10
15
  Style/Documentation:
11
16
  Exclude:
12
17
  - 'spec/**/*'
13
18
  - 'test/**/*'
14
19
  - 'lib/dor/services/client.rb'
15
20
 
16
- # Offense count: 151
21
+ # Offense count: 256
17
22
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
18
23
  # URISchemes: http, https
19
24
  Metrics/LineLength:
data/README.md CHANGED
@@ -132,11 +132,12 @@ object_client.collections
132
132
  object_client.files.retrieve(filename: filename_string)
133
133
  object_client.files.list
134
134
 
135
- # Set and list an object's release tags
135
+ # Create and list release tags for an object
136
136
  object_client.release_tags.create(release: release, what: what, to: to, who: who)
137
137
  object_client.release_tags.list
138
138
 
139
- # Get the events for the object
139
+ # Create and list events for an object
140
+ object_client.events.create(type: type, data: data)
140
141
  object_client.events.list
141
142
 
142
143
  # Create, remove, and reset workspaces
@@ -23,7 +23,7 @@ module Dor
23
23
 
24
24
  return response_to_models(resp) if resp.success?
25
25
 
26
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp)
26
+ raise_exception_based_on_response!(resp, object_identifier)
27
27
  end
28
28
 
29
29
  private
@@ -31,7 +31,7 @@ module Dor
31
31
  end
32
32
  return if resp.success?
33
33
 
34
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
34
+ raise_exception_based_on_response!(resp, object_identifier)
35
35
  end
36
36
 
37
37
  private
@@ -15,7 +15,24 @@ module Dor
15
15
  @object_identifier = object_identifier
16
16
  end
17
17
 
18
- # @return [Array<Events>] The events for an object
18
+ # @param type [String] a type for the event, e.g., publish, shelve
19
+ # @param data [Hash] an unstructured hash of event data
20
+ # @return [Boolean] true if successful
21
+ # @raise [NotFoundResponse] when the response is a 404 (object not found)
22
+ # @raise [UnexpectedResponse] if the request is unsuccessful.
23
+ def create(type:, data:)
24
+ resp = connection.post do |req|
25
+ req.url "#{api_version}/objects/#{object_identifier}/events"
26
+ req.headers['Content-Type'] = 'application/json'
27
+ req.body = { event_type: type, data: data }.to_json
28
+ end
29
+
30
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
31
+
32
+ true
33
+ end
34
+
35
+ # @return [Array<Event>,NilClass] The events for an object or nil if 404
19
36
  # @raise [UnexpectedResponse] on an unsuccessful response from the server
20
37
  def list
21
38
  resp = connection.get do |req|
@@ -24,7 +41,7 @@ module Dor
24
41
  return response_to_models(resp) if resp.success?
25
42
  return if resp.status == 404
26
43
 
27
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
44
+ raise_exception_based_on_response!(resp, object_identifier)
28
45
  end
29
46
 
30
47
  private
@@ -19,9 +19,11 @@ module Dor
19
19
  end
20
20
 
21
21
  return resp.body if resp.success? && resp.body.present?
22
- raise NotFoundResponse if resp.success? && resp.body.blank?
23
22
 
24
- raise_exception_based_on_response!(resp)
23
+ # This method needs its own exception handling logic due to how the endpoint service (SearchWorks) operates
24
+ raise NotFoundResponse, ResponseErrorFormatter.format(response: resp) if resp.success? && resp.body.blank?
25
+
26
+ raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp)
25
27
  end
26
28
 
27
29
  # Gets MARCXML corresponding to a barcode or catkey
@@ -39,7 +41,12 @@ module Dor
39
41
  req.params['catkey'] = catkey unless catkey.nil?
40
42
  end
41
43
 
42
- raise_exception_based_on_marcxml_response!(resp)
44
+ # This method needs its own exception handling logic due to how the endpoint service (Symphony) operates
45
+ #
46
+ # DOR Services App does not respond with a 404 when no match in Symphony.
47
+ # Rather, it responds with a 500 containing "Record not found in Symphony" in the body.
48
+ raise NotFoundResponse, ResponseErrorFormatter.format(response: resp) if !resp.success? && resp.body.match?(/Record not found in Symphony/)
49
+ raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success?
43
50
 
44
51
  resp.body
45
52
  end
@@ -50,14 +57,6 @@ module Dor
50
57
  raise ArgumentError, 'Barcode or catkey must be provided' if barcode.nil? && catkey.nil?
51
58
  raise ArgumentError, 'Both barcode and catkey may not be provided' if !barcode.nil? && !catkey.nil?
52
59
  end
53
-
54
- def raise_exception_based_on_marcxml_response!(resp)
55
- # DOR Services App does not respond with a 404 when no match in Symphony.
56
- # Rather, it responds with a 500 containing "Record not found in Symphony" in the body.
57
- raise NotFoundResponse if !resp.success? && resp.body.match?(/Record not found in Symphony/)
58
-
59
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success?
60
- end
61
60
  end
62
61
  end
63
62
  end
@@ -31,7 +31,7 @@ module Dor
31
31
  end
32
32
  return if resp.success?
33
33
 
34
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
34
+ raise_exception_based_on_response!(resp, object_identifier)
35
35
  end
36
36
 
37
37
  # @return [String, NilClass] The Dublin Core XML representation of the object or nil if response is 404
@@ -43,7 +43,7 @@ module Dor
43
43
  return resp.body if resp.success?
44
44
  return if resp.status == 404
45
45
 
46
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
46
+ raise_exception_based_on_response!(resp, object_identifier)
47
47
  end
48
48
 
49
49
  # @return [String, NilClass] The descriptive metadata XML representation of the object or nil if response is 404
@@ -55,7 +55,7 @@ module Dor
55
55
  return resp.body if resp.success?
56
56
  return if resp.status == 404
57
57
 
58
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
58
+ raise_exception_based_on_response!(resp, object_identifier)
59
59
  end
60
60
 
61
61
  private
@@ -40,7 +40,7 @@ module Dor
40
40
  end
41
41
  return resp.body if resp.success?
42
42
 
43
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp)
43
+ raise_exception_based_on_response!(resp)
44
44
  end
45
45
  end
46
46
  end
@@ -16,8 +16,9 @@ module Dor
16
16
  # @param what [String]
17
17
  # @param to [String]
18
18
  # @param who [String]
19
- # @raise [UnexpectedResponse] if the request is unsuccessful.
20
19
  # @return [Boolean] true if successful
20
+ # @raise [NotFoundResponse] when the response is a 404 (object not found)
21
+ # @raise [UnexpectedResponse] if the request is unsuccessful.
21
22
  # rubocop:disable Metrics/MethodLength
22
23
  def create(release:, what:, to:, who:)
23
24
  params = {
@@ -31,13 +32,14 @@ module Dor
31
32
  req.headers['Content-Type'] = 'application/json'
32
33
  req.body = params.to_json
33
34
  end
34
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success?
35
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
35
36
 
36
37
  true
37
38
  end
38
39
  # rubocop:enable Metrics/MethodLength
39
40
 
40
41
  # List new release tags for the object
42
+ # @raise [NotFoundResponse] when the response is a 404 (object not found)
41
43
  # @raise [UnexpectedResponse] if the request is unsuccessful.
42
44
  # @return [Hash] (see Dor::ReleaseTags::IdentityMetadata.released_for)
43
45
  def list
@@ -45,9 +47,9 @@ module Dor
45
47
  req.url "#{api_version}/objects/#{object_identifier}/release_tags"
46
48
  end
47
49
 
48
- return JSON.parse(resp.body) if resp.success?
50
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
49
51
 
50
- raise_exception_based_on_response!(resp)
52
+ JSON.parse(resp.body)
51
53
  end
52
54
 
53
55
  private
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '4.12.0'
6
+ VERSION = '4.13.0'
7
7
  end
8
8
  end
9
9
  end
@@ -19,9 +19,9 @@ module Dor
19
19
 
20
20
  attr_reader :connection, :api_version
21
21
 
22
- def raise_exception_based_on_response!(response)
22
+ def raise_exception_based_on_response!(response, object_identifier = nil)
23
23
  raise (response.status == 404 ? NotFoundResponse : UnexpectedResponse),
24
- ResponseErrorFormatter.format(response: response)
24
+ ResponseErrorFormatter.format(response: response, object_identifier: object_identifier)
25
25
  end
26
26
  end
27
27
  end
@@ -20,7 +20,7 @@ module Dor
20
20
  req.url workspace_path
21
21
  req.params['source'] = source
22
22
  end
23
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success?
23
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
24
24
  end
25
25
 
26
26
  # Cleans up a workspace
@@ -30,7 +30,7 @@ module Dor
30
30
  resp = connection.delete do |req|
31
31
  req.url workspace_path
32
32
  end
33
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success?
33
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
34
34
  end
35
35
 
36
36
  # After an object has been copied to preservation the workspace can be
@@ -41,7 +41,7 @@ module Dor
41
41
  resp = connection.post do |req|
42
42
  req.url "#{workspace_path}/reset"
43
43
  end
44
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success?
44
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
45
45
  end
46
46
 
47
47
  private
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: 4.12.0
4
+ version: 4.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-02-13 00:00:00.000000000 Z
12
+ date: 2020-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  - !ruby/object:Gem::Version
244
244
  version: '0'
245
245
  requirements: []
246
- rubygems_version: 3.1.2
246
+ rubygems_version: 3.0.6
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: A client for dor-services-app