Sha256: 4dd4fb452e111a0a93250dcfc9b8ad71472ab634038971206d0332d8a5accb5c

Contents?: true

Size: 1.5 KB

Versions: 17

Compression:

Stored size: 1.5 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 UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
        end

        private

        attr_reader :object_identifier

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dor-services-client-4.12.0 lib/dor/services/client/embargo.rb
dor-services-client-4.11.0 lib/dor/services/client/embargo.rb
dor-services-client-4.10.0 lib/dor/services/client/embargo.rb
dor-services-client-4.9.0 lib/dor/services/client/embargo.rb
dor-services-client-4.8.0 lib/dor/services/client/embargo.rb
dor-services-client-4.7.0 lib/dor/services/client/embargo.rb
dor-services-client-4.6.0 lib/dor/services/client/embargo.rb
dor-services-client-4.5.0 lib/dor/services/client/embargo.rb
dor-services-client-4.4.0 lib/dor/services/client/embargo.rb
dor-services-client-4.3.0 lib/dor/services/client/embargo.rb
dor-services-client-4.2.0 lib/dor/services/client/embargo.rb
dor-services-client-4.1.0 lib/dor/services/client/embargo.rb
dor-services-client-4.0.0 lib/dor/services/client/embargo.rb
dor-services-client-3.9.2 lib/dor/services/client/embargo.rb
dor-services-client-3.9.1 lib/dor/services/client/embargo.rb
dor-services-client-3.9.0 lib/dor/services/client/embargo.rb
dor-services-client-3.8.0 lib/dor/services/client/embargo.rb