Class: Ragoon::Services::Workflow

Inherits:
Ragoon::Services show all
Defined in:
lib/ragoon/services/workflow.rb

Overview

Constant Summary

Constants inherited from Ragoon::Services

SERVICE_LOCATIONS

Instance Attribute Summary

Attributes inherited from Ragoon::Services

#action_type, #client

Instance Method Summary collapse

Methods inherited from Ragoon::Services

#endpoint, #garoon_endpoint, #initialize, start_and_end

Constructor Details

This class inherits a constructor from Ragoon::Services

Instance Method Details

#workflow_get_received_application_versions(id_versions = [], start_date:, end_date: nil) ⇒ Object

recieved



104
105
106
107
108
109
110
# File 'lib/ragoon/services/workflow.rb', line 104

def workflow_get_received_application_versions(id_versions = [], start_date:, end_date: nil)
  get_application_versions(
    'WorkflowGetReceivedApplicationVersions',
    start_date, end_date,
    id_versions
  )
end

#workflow_get_received_applications_by_id(ids) ⇒ Object



112
113
114
# File 'lib/ragoon/services/workflow.rb', line 112

def workflow_get_received_applications_by_id(ids)
  get_applications_by_id('WorkflowGetReceivedApplicationsById', ids)
end

#workflow_get_requests(request_form_id:, **options) ⇒ Object

for admin only



11
12
13
14
15
16
17
18
19
20
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/ragoon/services/workflow.rb', line 11

def workflow_get_requests(request_form_id:, **options)
  action_name = 'WorkflowGetRequests'

  options[:request_form_id] = request_form_id
  [ :start_request_date, :end_request_date,
    :start_approval_date, :end_approval_date ].each do |key|
    options[key] = to_datetime_str(options[key]) if options.has_key?(key)
  end

  body_node = Ragoon::XML.create_node(action_name)
  parameter_node = Ragoon::XML.create_node('parameters')
  body_node.add_child(parameter_node)

  manage_parameter_node = Ragoon::XML.create_node(
    'manage_request_parmeter', options)
  parameter_node.add_child(manage_parameter_node)

  client.request(action_name, body_node)

  client.result_set.xpath('//manage_item_detail').map do |item|
    {
      id: item[:pid],
      number: item[:number],
      priority: item[:priority],
      subject: item[:subject],
      status: item[:status],
      applicant: item[:applicant], # user_id
      last_approver: item[:last_approver],
      request_date: parse_time(item[:request_date]),
    }
  end
ensure
  client.reset
end

#workflow_get_requests_by_id(ids) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ragoon/services/workflow.rb', line 46

def workflow_get_requests_by_id(ids)
  action_name = 'WorkflowGetRequestById'

  body_node = Ragoon::XML.create_node(action_name)
  parameter_node = Ragoon::XML.create_node('parameters')
  body_node.add_child(parameter_node)

  ids.each do |id|
    request_id_node = Ragoon::XML.create_node('request_id')
    request_id_node.content = id
    parameter_node.add_child(request_id_node)
  end

  client.request(action_name, body_node)

  client.result_set.xpath('//application').map do |app|
    parse_application(app)
  end
ensure
  client.reset
end

#workflow_get_sent_application_versions(id_versions = [], start_date:, end_date: nil) ⇒ Object

sent



88
89
90
91
92
93
94
# File 'lib/ragoon/services/workflow.rb', line 88

def workflow_get_sent_application_versions(id_versions = [], start_date:, end_date: nil)
  get_application_versions(
    'WorkflowGetSentApplicationVersions',
    start_date, end_date,
    id_versions
  )
end

#workflow_get_sent_applications_by_id(ids) ⇒ Object



96
97
98
# File 'lib/ragoon/services/workflow.rb', line 96

def workflow_get_sent_applications_by_id(ids)
  get_applications_by_id('WorkflowGetSentApplicationsById', ids)
end

#workflow_get_unprocessed_application_versions(id_versions = []) ⇒ Object

unprocessed



72
73
74
75
76
77
78
# File 'lib/ragoon/services/workflow.rb', line 72

def workflow_get_unprocessed_application_versions(id_versions = [])
  get_application_versions(
    'WorkflowGetUnprocessedApplicationVersions',
    nil, nil,
    id_versions
  )
end

#workflow_get_unprocessed_applications_by_id(ids) ⇒ Object



80
81
82
# File 'lib/ragoon/services/workflow.rb', line 80

def workflow_get_unprocessed_applications_by_id(ids)
  get_applications_by_id('WorkflowGetUnprocessedApplicationsById', ids)
end