dor-services-client 4.9.0 → 4.10.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: c7cbcc8c0942079ad92c72c56a5e50f5eec40874aca88b9c5d71afda95410332
4
- data.tar.gz: 04710fd23832ce6a1de24c9b067afc392ce383c2e5a6628ce6d5de3a24953c2b
3
+ metadata.gz: 2318b72fea424890cea6809d9015250bb1efa68bc748ddf6aad0524ac9023df3
4
+ data.tar.gz: 7c1ec4bc41177fdbf97318bd338f46c6e8d084ed658036a17c75344c3b7654cb
5
5
  SHA512:
6
- metadata.gz: 01d80a9bfaab329fada884588ac4ccd09403c928f2742afafe7e3928ade0e3ae40a0156afe74b42c8b05f43452e2db882ceaad4db43921e3e91563914e500dfe
7
- data.tar.gz: 3aa18d9ad738413341fcd57ebc1a48ecc55842cdb8bc58b656fa24b0eaf6bd7f2015d9f5b8c4d074e16cc187da1d36fa141a350722225d5a8759f90938ccbcea
6
+ metadata.gz: 1bdf07a56ae7d348fa2e2682605d09865a449ff561b427d772d919a51cd39023f5289d88637ca683d4b37fd6dc780b4975bfff0220236aec172e5de91516113a
7
+ data.tar.gz: 9e2fe89165c72007d00bd018466557ddb9236dc51edc8f4c8efd5b141e09e3eeddc56ca46c60faeef8feb5ef32cd5cadb2482056433e6b4bb42ddc5ae6d68612
data/README.md CHANGED
@@ -73,7 +73,13 @@ background_jobs_client.show(job_id: 123)
73
73
  marcxml_client = Dor::Services::Client.marcxml
74
74
 
75
75
  # Retrieve a catkey for a given barcode
76
- marcxml_client.catkey(barcode: 'foobarcode')
76
+ marcxml_client.catkey(barcode: '123456789')
77
+
78
+ # Retrieve MARCXML for a given barcode
79
+ marcxml_client.marcxml(barcode: '123456789')
80
+
81
+ # Retrieve MARCXML for a given catkey
82
+ marcxml_client.marcxml(catkey: '987654321')
77
83
 
78
84
  # For performing operations on a known, registered object
79
85
  object_client = Dor::Services::Client.object(object_identifier)
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'cocina-models', '~> 0.15.0'
27
27
  spec.add_dependency 'faraday', '~> 0.15'
28
28
  spec.add_dependency 'moab-versioning', '~> 4.0'
29
- spec.add_dependency 'nokogiri', '~> 1.8'
30
29
  spec.add_dependency 'zeitwerk', '~> 2.1'
31
30
 
32
31
  spec.add_development_dependency 'bundler'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'nokogiri'
4
+
3
5
  module Dor
4
6
  module Services
5
7
  class Client
@@ -9,7 +11,7 @@ module Dor
9
11
  # @param barcode [String] required string representing a barcode
10
12
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
11
13
  # @raise [UnexpectedResponse] on an unsuccessful response from the server
12
- # @return [String] result of background job
14
+ # @return [String] catkey
13
15
  def catkey(barcode:)
14
16
  resp = connection.get do |req|
15
17
  req.url "#{api_version}/catalog/catkey"
@@ -21,6 +23,41 @@ module Dor
21
23
 
22
24
  raise_exception_based_on_response!(resp)
23
25
  end
26
+
27
+ # Gets MARCXML corresponding to a barcode or catkey
28
+ # @param barcode [String] required string representing a barcode
29
+ # @param catkey [String] required string representing a catkey
30
+ # @raise [NotFoundResponse] when the response is a 500 with "Record not found in Symphony"
31
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
32
+ # @return [String] MARCXML
33
+ def marcxml(barcode: nil, catkey: nil)
34
+ check_args(barcode, catkey)
35
+
36
+ resp = connection.get do |req|
37
+ req.url "#{api_version}/catalog/marcxml"
38
+ req.params['barcode'] = barcode unless barcode.nil?
39
+ req.params['catkey'] = catkey unless catkey.nil?
40
+ end
41
+
42
+ raise_exception_based_on_marcxml_response!(resp)
43
+
44
+ resp.body
45
+ end
46
+
47
+ private
48
+
49
+ def check_args(barcode, catkey)
50
+ raise ArgumentError, 'Barcode or catkey must be provided' if barcode.nil? && catkey.nil?
51
+ raise ArgumentError, 'Both barcode and catkey may not be provided' if !barcode.nil? && !catkey.nil?
52
+ 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
24
61
  end
25
62
  end
26
63
  end
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '4.9.0'
6
+ VERSION = '4.10.0'
7
7
  end
8
8
  end
9
9
  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.9.0
4
+ version: 4.10.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-05 00:00:00.000000000 Z
12
+ date: 2020-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -73,20 +73,6 @@ dependencies:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '4.0'
76
- - !ruby/object:Gem::Dependency
77
- name: nokogiri
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.8'
83
- type: :runtime
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.8'
90
76
  - !ruby/object:Gem::Dependency
91
77
  name: zeitwerk
92
78
  requirement: !ruby/object:Gem::Requirement
@@ -243,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
229
  - !ruby/object:Gem::Version
244
230
  version: '0'
245
231
  requirements: []
246
- rubygems_version: 3.0.6
232
+ rubygems_version: 3.1.2
247
233
  signing_key:
248
234
  specification_version: 4
249
235
  summary: A client for dor-services-app