Sha256: 6d3b2f51bc7587e9698627d78a0f8690189f3fa2353767f9f1d4ce86c9ae9fe1

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Dor
  module Workflow
    class Client
      # Makes requests relating to versions
      class VersionRoutes
        def initialize(requestor:)
          @requestor = requestor
        end

        # Calls the versionClose endpoint of the workflow service:
        #
        # - completes the versioningWF:submit-version and versioningWF:start-accession steps
        # - initiates accesssionWF
        #
        # @param [String] druid The id of the object to delete the workflow from
        # @param [Boolean] create_accession_wf Option to create accessionWF when closing a version.  Defaults to true
        def close_version(druid:, version:, create_accession_wf: true)
          requestor.request(construct_url(druid, version, create_accession_wf), 'post', '')
          true
        end

        private

        attr_reader :requestor

        def construct_url(druid, version, create_accession_wf)
          url = "objects/#{druid}/versionClose"

          qs_args = []
          qs_args << "version=#{version}" if version
          qs_args << 'create-accession=false' unless create_accession_wf
          url += "?#{qs_args.join('&')}" unless qs_args.empty?
          url
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dor-workflow-client-7.4.0 lib/dor/workflow/client/version_routes.rb