Class: Dor::Services::Client::Marcxml
- Inherits:
-
VersionedService
- Object
- VersionedService
- Dor::Services::Client::Marcxml
- Defined in:
- lib/dor/services/client/marcxml.rb
Overview
API calls around MARCXML-based operations from dor-services-app
Instance Method Summary collapse
-
#catkey(barcode:) ⇒ String
Get a catkey corresponding to a barcode.
-
#marcxml(barcode: nil, catkey: nil) ⇒ String
Gets MARCXML corresponding to a barcode or catkey.
Methods inherited from VersionedService
Constructor Details
This class inherits a constructor from Dor::Services::Client::VersionedService
Instance Method Details
#catkey(barcode:) ⇒ String
Get a catkey corresponding to a barcode
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dor/services/client/marcxml.rb', line 15 def catkey(barcode:) resp = connection.get do |req| req.url "#{api_version}/catalog/catkey" req.params['barcode'] = end return resp.body if resp.success? && resp.body.present? # This method needs its own exception handling logic due to how the endpoint service (SearchWorks) operates raise NotFoundResponse, ResponseErrorFormatter.format(response: resp) if resp.success? && resp.body.blank? raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) end |
#marcxml(barcode: nil, catkey: nil) ⇒ String
Gets MARCXML corresponding to a barcode or catkey
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dor/services/client/marcxml.rb', line 35 def marcxml(barcode: nil, catkey: nil) check_args(, catkey) resp = connection.get do |req| req.url "#{api_version}/catalog/marcxml" req.params['barcode'] = unless .nil? req.params['catkey'] = catkey unless catkey.nil? end # This method needs its own exception handling logic due to how the endpoint service (Symphony) operates # # DOR Services App does not respond with a 404 when no match in Symphony. # Rather, it responds with a 500 containing "Record not found in Symphony" in the body. raise NotFoundResponse, ResponseErrorFormatter.format(response: resp) if !resp.success? && resp.body.match?(/Record not found in Symphony/) raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success? resp.body end |