Class: SdrClient::Deposit::UpdateResource

Inherits:
Object
  • Object
show all
Defined in:
lib/sdr_client/deposit/update_resource.rb

Overview

Updates a resource (metadata) in SDR

Constant Summary collapse

DRO_PATH =
'/v1/resources/%<id>s'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata:, logger:, connection:) ⇒ UpdateResource

Returns a new instance of UpdateResource.

Parameters:

  • metadata (Cocina::Models::DRO)
  • the (Hash<Symbol,String>)

    result of the metadata call



15
16
17
18
19
# File 'lib/sdr_client/deposit/update_resource.rb', line 15

def initialize(metadata:, logger:, connection:)
  @metadata = 
  @logger = logger
  @connection = connection
end

Class Method Details

.run(metadata:, logger:, connection:) ⇒ Object



9
10
11
# File 'lib/sdr_client/deposit/update_resource.rb', line 9

def self.run(metadata:, logger:, connection:)
  new(metadata: , logger: logger, connection: connection).run
end

Instance Method Details

#runString

Returns job id for the background job result.

Parameters:

  • the (Hash<Symbol,String>)

    result of the metadata call

Returns:

  • (String)

    job id for the background job result



23
24
25
26
27
28
29
30
# File 'lib/sdr_client/deposit/update_resource.rb', line 23

def run
  response = 
  UnexpectedResponse.call(response) unless response.status == 202

  logger.info("Response from server: #{response.body}")

  JSON.parse(response.body)['jobId']
end