dor-services-client 4.0.0 → 4.1.0

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: 5bc4758395797b8e5b89c28b1db1587628728e0983e1f85f2985875b80b1f907
4
- data.tar.gz: f6e2af51ab5b85c9b5295779f2bb8cf3466deed3016bf9fd281f17657e414919
3
+ metadata.gz: ce0f327c126168128a603bb0c50b455922a6542e61a186c141851d5b2f11cf7c
4
+ data.tar.gz: 060ce3ba245a689a518ec8be58a9666c0b45d61b31d01f7577fcba22738c89aa
5
5
  SHA512:
6
- metadata.gz: ada4de8d9117375cda2225b2491a57f96c599fd44a77273e2c04c85e1b9a75acdbc82e0da641cb7e1cba16f1ee8b4b0e8e3fdf26eb325c1dff2b02b06d9773f5
7
- data.tar.gz: 14b7d08e789e16c122631b18989786e2e2a44a78f010ce8d943694001786f475a9120bb1341d6f2c4cc6f432ae9d261881a436ad4cd5db90f1f7d3209d98a534
6
+ metadata.gz: a9e5a35b526047c84571bb35238cc1743daabfd1a4fb6315d45c21efb9066ea22c29c28a5e3f1a4e879c1b01f44c6cb7c866b124b0b8013bbc80a3b688f7b125
7
+ data.tar.gz: f69c66c22201e36ecee91ed7ad64267d23fdc2413d2a39b879d433f189088af9ddf77d6288be3027ec91116d5c5030068738b39e2571cc711b402354ba480c8e
data/README.md CHANGED
@@ -51,24 +51,30 @@ Note that the client may **not** be used without first having been configured, a
51
51
  Dor::Services:Client provides a number of methods to simplify connecting to the RESTful HTTP API of dor-services-app. In this section we list all of the available methods, reflecting how much of the API the client covers. For details see the [API docs](https://www.rubydoc.info/github/sul-dlss/dor-services-client/master/Dor/Services/Client)
52
52
 
53
53
  ```ruby
54
- # For performing operations on one or more objects
54
+ # Perform operations on one or more objects
55
55
  objects_client = Dor::Services::Client.objects
56
56
 
57
- # For registering a non-existent object
57
+ # Register a non-existent object
58
58
  objects_client.register(params: {})
59
59
 
60
- # For interacting with virtual objects
60
+ # Interact with virtual objects
61
61
  virtual_objects_client = Dor::Services::Client.virtual_objects
62
62
 
63
63
  # Create a batch of virtual objects
64
64
  virtual_objects_client.create(virtual_objects: [{ parent_id: '', child_ids: [''] }])
65
65
 
66
- # For getting background job results
66
+ # Retrieve background job results
67
67
  background_jobs_client = Dor::Services::Client.background_job_results
68
68
 
69
69
  # Show results of background job
70
70
  background_jobs_client.show(job_id: 123)
71
71
 
72
+ # Perform MARCXML operations
73
+ marcxml_client = Dor::Services::Client.marcxml
74
+
75
+ # Retrieve a catkey for a given barcode
76
+ marcxml_client.catkey(barcode: 'foobarcode')
77
+
72
78
  # For performing operations on a known, registered object
73
79
  object_client = Dor::Services::Client.object(object_identifier)
74
80
 
@@ -66,6 +66,11 @@ module Dor
66
66
  @background_job_results ||= BackgroundJobResults.new(connection: connection, version: DEFAULT_VERSION)
67
67
  end
68
68
 
69
+ # @return [Dor::Services::Client::Marcxml] an instance of the `Client::Marcxml` class
70
+ def marcxml
71
+ @marcxml ||= Marcxml.new(connection: connection, version: DEFAULT_VERSION)
72
+ end
73
+
69
74
  class << self
70
75
  # @param [String] url the base url of the endpoint the client should connect to (required)
71
76
  # @param [String] token a bearer token for HTTP authentication (required)
@@ -79,7 +84,7 @@ module Dor
79
84
  self
80
85
  end
81
86
 
82
- delegate :objects, :object, :virtual_objects, :background_job_results, to: :instance
87
+ delegate :background_job_results, :marcxml, :objects, :object, :virtual_objects, to: :instance
83
88
  end
84
89
 
85
90
  attr_writer :url, :token, :connection
@@ -22,13 +22,6 @@ module Dor
22
22
 
23
23
  raise_exception_based_on_response!(resp)
24
24
  end
25
-
26
- private
27
-
28
- def raise_exception_based_on_response!(response)
29
- raise (response.status == 404 ? NotFoundResponse : UnexpectedResponse),
30
- ResponseErrorFormatter.format(response: response)
31
- end
32
25
  end
33
26
  end
34
27
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dor
4
+ module Services
5
+ class Client
6
+ # API calls around MARCXML-based operations from dor-services-app
7
+ class Marcxml < VersionedService
8
+ # Get a catkey corresponding to a barcode
9
+ # @param barcode [String] required string representing a barcode
10
+ # @raise [NotFoundResponse] when the response is a 404 (object not found)
11
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
12
+ # @return [String] result of background job
13
+ def catkey(barcode:)
14
+ resp = connection.get do |req|
15
+ req.url "#{api_version}/catalog/catkey"
16
+ req.params['barcode'] = barcode
17
+ end
18
+
19
+ return resp.body if resp.success? && resp.body.present?
20
+ raise NotFoundResponse if resp.success? && resp.body.blank?
21
+
22
+ raise_exception_based_on_response!(resp)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -150,11 +150,6 @@ module Dor
150
150
  def object_path
151
151
  "#{api_version}/objects/#{object_identifier}"
152
152
  end
153
-
154
- def raise_exception_based_on_response!(response)
155
- raise (response.status == 404 ? NotFoundResponse : UnexpectedResponse),
156
- ResponseErrorFormatter.format(response: response)
157
- end
158
153
  end
159
154
  end
160
155
  end
@@ -85,11 +85,6 @@ module Dor
85
85
  "#{api_version}/objects/#{object_identifier}"
86
86
  end
87
87
 
88
- def raise_exception_based_on_response!(response)
89
- raise (response.status == 404 ? NotFoundResponse : UnexpectedResponse),
90
- ResponseErrorFormatter.format(response: response)
91
- end
92
-
93
88
  # Make request to server to open a new version
94
89
  # @param params [Hash] optional params (see dor-services-app)
95
90
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '4.0.0'
6
+ VERSION = '4.1.0'
7
7
  end
8
8
  end
9
9
  end
@@ -18,6 +18,11 @@ module Dor
18
18
  private
19
19
 
20
20
  attr_reader :connection, :api_version
21
+
22
+ def raise_exception_based_on_response!(response)
23
+ raise (response.status == 404 ? NotFoundResponse : UnexpectedResponse),
24
+ ResponseErrorFormatter.format(response: response)
25
+ end
21
26
  end
22
27
  end
23
28
  end
@@ -21,13 +21,6 @@ module Dor
21
21
 
22
22
  raise_exception_based_on_response!(resp)
23
23
  end
24
-
25
- private
26
-
27
- def raise_exception_based_on_response!(response)
28
- raise (response.status == 404 ? NotFoundResponse : UnexpectedResponse),
29
- ResponseErrorFormatter.format(response: response)
30
- end
31
24
  end
32
25
  end
33
26
  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: 4.0.0
4
+ version: 4.1.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-01-07 00:00:00.000000000 Z
12
+ date: 2020-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -213,6 +213,7 @@ files:
213
213
  - lib/dor/services/client/embargo.rb
214
214
  - lib/dor/services/client/error_faraday_middleware.rb
215
215
  - lib/dor/services/client/files.rb
216
+ - lib/dor/services/client/marcxml.rb
216
217
  - lib/dor/services/client/metadata.rb
217
218
  - lib/dor/services/client/object.rb
218
219
  - lib/dor/services/client/object_version.rb
@@ -241,7 +242,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
242
  - !ruby/object:Gem::Version
242
243
  version: '0'
243
244
  requirements: []
244
- rubygems_version: 3.0.3
245
+ rubyforge_project:
246
+ rubygems_version: 2.7.8
245
247
  signing_key:
246
248
  specification_version: 4
247
249
  summary: A client for dor-services-app