Class: Dor::Services::Client::Metadata

Inherits:
VersionedService show all
Defined in:
lib/dor/services/client/metadata.rb

Overview

API calls that are about retrieving metadata

Instance Method Summary collapse

Constructor Details

#initialize(connection:, version:, object_identifier:) ⇒ Metadata

Returns a new instance of Metadata.

Parameters:

  • object_identifier (String)

    the pid for the object



9
10
11
12
# File 'lib/dor/services/client/metadata.rb', line 9

def initialize(connection:, version:, object_identifier:)
  super(connection: connection, version: version)
  @object_identifier = object_identifier
end

Instance Method Details

#descriptiveString, NilClass

Returns The descriptive metadata XML representation of the object or nil if response is 404.

Returns:

  • (String, NilClass)

    The descriptive metadata XML representation of the object or nil if response is 404

Raises:



28
29
30
31
32
33
34
35
36
# File 'lib/dor/services/client/metadata.rb', line 28

def descriptive
  resp = connection.get do |req|
    req.url "#{base_path}/descriptive"
  end
  return resp.body if resp.success?
  return if resp.status == 404

  raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
end

#dublin_coreString, NilClass

Returns The Dublin Core XML representation of the object or nil if response is 404.

Returns:

  • (String, NilClass)

    The Dublin Core XML representation of the object or nil if response is 404

Raises:



16
17
18
19
20
21
22
23
24
# File 'lib/dor/services/client/metadata.rb', line 16

def dublin_core
  resp = connection.get do |req|
    req.url "#{base_path}/dublin_core"
  end
  return resp.body if resp.success?
  return if resp.status == 404

  raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
end