Class: Dor::Workflow::Client::VersionRoutes

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/workflow/client/version_routes.rb

Overview

Makes requests relating to versions

Instance Method Summary collapse

Constructor Details

#initialize(requestor:) ⇒ VersionRoutes

Returns a new instance of VersionRoutes.



8
9
10
# File 'lib/dor/workflow/client/version_routes.rb', line 8

def initialize(requestor:)
  @requestor = requestor
end

Instance Method Details

#close_version(*args) ⇒ Object

Calls the versionClose endpoint of the workflow service:

  • completes the versioningWF:submit-version and versioningWF:start-accession steps
  • initiates accesssionWF

rubocop:disable Metrics/MethodLength

Parameters:

  • repo (String)

    The repository the object resides in. This parameter is deprecated

  • druid (String)

    The id of the object to delete the workflow from

  • create_accession_wf (Boolean)

    Option to create accessionWF when closing a version. Defaults to true



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dor/workflow/client/version_routes.rb', line 21

def close_version(*args)
  case args.size
  when 3
    Deprecation.warn(self, 'you provided 3 args, but close_version now takes kwargs')
    (repo, druid, create_accession_wf) = args
  when 2
    Deprecation.warn(self, 'you provided 2 args, but close_version now takes kwargs')
    (repo, druid) = args
    create_accession_wf = true
  when 1
    opts = args.first
    repo = opts[:repo]
    druid = opts[:druid]
    version = opts[:version]
    create_accession_wf = opts.key?(:create_accession_wf) ? opts[:create_accession_wf] : true
  else
    raise ArgumentError, 'wrong number of arguments, must be 1-3'
  end

  Deprecation.warn(self, 'passing the repo parameter to close_version is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo

  requestor.request(construct_url(druid, version, create_accession_wf), 'post', '')
  true
end