Class: SdrClient::Deposit::CreateResource
- Inherits:
-
Object
- Object
- SdrClient::Deposit::CreateResource
- Defined in:
- lib/sdr_client/deposit/create_resource.rb
Overview
Creates a resource (metadata) in SDR
Constant Summary collapse
- DRO_PATH =
'/v1/resources'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(accession:, metadata:, logger:, connection:) ⇒ CreateResource
constructor
A new instance of CreateResource.
-
#run ⇒ String
Job id for the background job result.
Constructor Details
#initialize(accession:, metadata:, logger:, connection:) ⇒ CreateResource
Returns a new instance of CreateResource.
16 17 18 19 20 21 |
# File 'lib/sdr_client/deposit/create_resource.rb', line 16 def initialize(accession:, metadata:, logger:, connection:) @accession = accession @metadata = @logger = logger @connection = connection end |
Class Method Details
.run(accession:, metadata:, logger:, connection:) ⇒ Object
9 10 11 |
# File 'lib/sdr_client/deposit/create_resource.rb', line 9 def self.run(accession:, metadata:, logger:, connection:) new(accession: accession, metadata: , logger: logger, connection: connection).run end |
Instance Method Details
#run ⇒ String
Returns job id for the background job result.
25 26 27 28 29 30 31 32 |
# File 'lib/sdr_client/deposit/create_resource.rb', line 25 def run response = UnexpectedResponse.call(response) unless response.status == 201 logger.info("Response from server: #{response.body}") JSON.parse(response.body)['jobId'] end |