Class: Dor::Services::Client::Object

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

Overview

API calls that are about a repository object

Instance Method Summary collapse

Constructor Details

#initialize(connection:, version:, object:) ⇒ Object

Returns a new instance of Object.

Parameters:

  • object (String)

    the pid for the object



12
13
14
15
# File 'lib/dor/services/client/object.rb', line 12

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

Instance Method Details

#current_versionString

Get the current_version for a DOR object. This comes from Dor::VersionMetadataDS

Returns:

  • (String)

    the version identifier

Raises:



44
45
46
47
48
49
50
51
# File 'lib/dor/services/client/object.rb', line 44

def current_version
  resp = connection.get do |req|
    req.url "#{object_path}/versions/current"
  end
  raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" unless resp.success?

  resp.body
end

#notify_goobiboolean

Notify the external Goobi system for a new object that was registered in DOR

Returns:

  • (boolean)

    true on success

Raises:



32
33
34
35
36
37
38
39
# File 'lib/dor/services/client/object.rb', line 32

def notify_goobi
  resp = connection.post do |req|
    req.url "#{object_path}/notify_goobi"
  end
  raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" unless resp.success?

  true
end

#publishboolean

Publish a new object

Returns:

  • (boolean)

    true on success

Raises:



20
21
22
23
24
25
26
27
# File 'lib/dor/services/client/object.rb', line 20

def publish
  resp = connection.post do |req|
    req.url "#{api_version}/objects/#{object}/publish"
  end
  raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" unless resp.success?

  true
end