Sha256: 5d11c34765a9675e03872b9ac643ecd5b7cb976c3f1b6ff4081438977bb56c02

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

module Dor
  module Services
    class Client
      # API calls that are about the DOR workspace
      class Workspace < VersionedService
        # @param object_id [String] the pid for the object
        def initialize(connection:, version:, object_id:)
          super(connection: connection, version: version)
          @object_id = object_id
        end

        # Initializes a new workspace
        # @param source [String] the path to the object
        # @raises [UnexpectedResponse] if the request is unsuccessful.
        # @return nil
        def create(source:)
          resp = connection.post do |req|
            req.url "#{api_version}/objects/#{object_id}/initialize_workspace"
            req.params['source'] = source
          end
          raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" unless resp.success?
        end

        private

        attr_reader :object_id
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dor-services-client-1.1.0 lib/dor/services/client/workspace.rb
dor-services-client-1.0.0 lib/dor/services/client/workspace.rb