Class: Dor::Services::Client::Embargo

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

Overview

API calls that are about managing embargo on a repository object

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Embargo.

Parameters:

  • object_identifier (String)

    the pid for the object



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

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

Instance Method Details

#update(embargo_date:, requesting_user:) ⇒ NilClass

Returns when the update is successful.

Examples:

client.update(embargo_date: '2099-10-20', requesting_user: 'jane')

Parameters:

  • embargo_date (String)

    The date to update the embargo to (ISO 8601)

  • requesting_user (String)

    Who is making this change.

Returns:

  • (NilClass)

    when the update is successful

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dor/services/client/embargo.rb', line 23

def update(embargo_date:, requesting_user:)
  resp = connection.patch do |req|
    req.url path
    req.headers['Content-Type'] = 'application/json'
    req.body = {
      embargo_date: embargo_date,
      requesting_user: requesting_user
    }.to_json
  end
  return if resp.success?

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