Class: Webhook::V3

Inherits:
Integration
  • Object
show all
Defined in:
app/models/pager_tree/integrations/webhook/v3.rb

Constant Summary collapse

OPTIONS =
[
  {key: :token, type: :string, default: nil},
  {key: :capture_additional_data, type: :boolean, default: false}
]

Instance Method Summary collapse

Instance Method Details

#adapter_actionObject



34
35
36
37
38
39
40
41
42
43
# File 'app/models/pager_tree/integrations/webhook/v3.rb', line 34

def adapter_action
  case _adapter_incoming_request_params.dig("event_type").to_s.downcase.strip
  when "create"
    :create
  when "resolve"
    :resolve
  else
    :other
  end
end

#adapter_incoming_can_defer?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/pager_tree/integrations/webhook/v3.rb', line 26

def adapter_incoming_can_defer?
  true
end

#adapter_process_createObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/pager_tree/integrations/webhook/v3.rb', line 45

def adapter_process_create
  Alert.new(
    title: _title,
    description: _description,
    urgency: _urgency,
    thirdparty_id: adapter_thirdparty_id,
    dedup_keys: _dedup_keys,
    incident: _incident,
    incident_severity: _incident_severity,
    incident_message: _incident_message,
    tags: _tags,
    meta: _meta,
    additional_data: _additional_datums
  )
end

#adapter_should_block_incoming?(request) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/pager_tree/integrations/webhook/v3.rb', line 14

def adapter_should_block_incoming?(request)
  self.option_token.present? && (request.headers["pagertree-token"] != self.option_token)
end

#adapter_supports_incoming?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/pager_tree/integrations/webhook/v3.rb', line 18

def adapter_supports_incoming?
  true
end

#adapter_supports_outgoing?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/pager_tree/integrations/webhook/v3.rb', line 22

def adapter_supports_outgoing?
  false
end

#adapter_thirdparty_idObject



30
31
32
# File 'app/models/pager_tree/integrations/webhook/v3.rb', line 30

def adapter_thirdparty_id
  _adapter_incoming_request_params.dig("id")
end