Module: Pipedream::Dsl::Pipeline::Approve

Included in:
Pipedream::Dsl::Pipeline
Defined in:
lib/pipedream/dsl/pipeline/approve.rb

Instance Method Summary collapse

Instance Method Details

#approve(props) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pipedream/dsl/pipeline/approve.rb', line 3

def approve(props)
  default = {
    name: "approve",
    action_type_id: {
      category: "Approval",
      owner: "AWS",
      provider: "Manual",
      version: "1",
    },
    run_order: @run_order,
    configuration: {  # required: will be set
      notification_arn: {ref: "SnsTopic"}, # defaults to generated SNS topic
    },
  }

  # Normalize special options. Simple approach of setting the default
  case props
  when String, Symbol
    default[:configuration][:custom_data] = props
    props = {}
  when Hash
    default[:configuration][:notification_arn] = props.delete(:notification_arn) if props.key?(:notification_arn)
    default[:configuration][:custom_data] = props.delete(:custom_data) if props.key?(:custom_data)
  else
    raise "Invalid props type: #{props.class}"
  end

  options = default.merge(props)
  action(options)
end