Sha256: e6c29fa3962ea28fdc7580a36beab5da69490dfd58c9420f8454b4b7a8c9532d

Contents?: true

Size: 1.46 KB

Versions: 53

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

module Dor
  module Services
    class Client
      # API calls that are about managing embargo on a repository object
      class Embargo < VersionedService
        # @param object_identifier [String] the pid for the object
        def initialize(connection:, version:, object_identifier:)
          super(connection: connection, version: version)
          @object_identifier = object_identifier
        end

        # @param [String] embargo_date The date to update the embargo to (ISO 8601)
        # @param [String] requesting_user Who is making this change.
        #
        # @example
        #   client.update(embargo_date: '2099-10-20', requesting_user: 'jane')
        #
        # @raise [UnexpectedResponse] on an unsuccessful response from the server
        #
        # @return [NilClass] when the update is successful
        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_exception_based_on_response!(resp, object_identifier)
        end

        private

        attr_reader :object_identifier

        def path
          "#{api_version}/objects/#{object_identifier}/embargo"
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
dor-services-client-6.32.0 lib/dor/services/client/embargo.rb
dor-services-client-6.31.0 lib/dor/services/client/embargo.rb
dor-services-client-6.30.1 lib/dor/services/client/embargo.rb
dor-services-client-6.30.0 lib/dor/services/client/embargo.rb
dor-services-client-6.29.0 lib/dor/services/client/embargo.rb
dor-services-client-6.28.0 lib/dor/services/client/embargo.rb
dor-services-client-6.27.0 lib/dor/services/client/embargo.rb
dor-services-client-6.26.0 lib/dor/services/client/embargo.rb
dor-services-client-6.26.0.beta.1 lib/dor/services/client/embargo.rb
dor-services-client-6.25.0 lib/dor/services/client/embargo.rb
dor-services-client-6.24.0 lib/dor/services/client/embargo.rb
dor-services-client-6.23.0 lib/dor/services/client/embargo.rb
dor-services-client-6.22.0 lib/dor/services/client/embargo.rb
dor-services-client-6.21.0 lib/dor/services/client/embargo.rb
dor-services-client-6.20.0 lib/dor/services/client/embargo.rb
dor-services-client-6.19.2 lib/dor/services/client/embargo.rb
dor-services-client-6.19.1 lib/dor/services/client/embargo.rb
dor-services-client-6.19.0 lib/dor/services/client/embargo.rb
dor-services-client-6.18.0 lib/dor/services/client/embargo.rb
dor-services-client-6.17.0 lib/dor/services/client/embargo.rb