Class: CustomWebhook::V3

Inherits:
Integration
  • Object
show all
Extended by:
PagerTree::Integrations::Env
Defined in:
app/models/pager_tree/integrations/custom_webhook/v3.rb

Constant Summary collapse

OPTIONS =
[
  {key: :custom_definition, type: :string, default: nil}
]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.custom_webhook_v3_service_urlObject



15
16
17
18
# File 'app/models/pager_tree/integrations/custom_webhook/v3.rb', line 15

def self.custom_webhook_v3_service_url
  ::PagerTree::Integrations.integration_custom_webhook_v3_service_url.presence ||
    find_value_by_name("integration_custom_webhook_v3", "service_url")
end

Instance Method Details

#adapter_actionObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/pager_tree/integrations/custom_webhook/v3.rb', line 36

def adapter_action
  case custom_response_result.dig("type")&.downcase
  when "create"
    :create
  when "acknowledge"
    :acknowledge
  when "resolve"
    :resolve
  else
    :other
  end
end

#adapter_incoming_can_defer?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/pager_tree/integrations/custom_webhook/v3.rb', line 28

def adapter_incoming_can_defer?
  true
end

#adapter_process_createObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/pager_tree/integrations/custom_webhook/v3.rb', line 49

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_supports_incoming?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/pager_tree/integrations/custom_webhook/v3.rb', line 20

def adapter_supports_incoming?
  true
end

#adapter_supports_outgoing?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/models/pager_tree/integrations/custom_webhook/v3.rb', line 24

def adapter_supports_outgoing?
  false
end

#adapter_thirdparty_idObject



32
33
34
# File 'app/models/pager_tree/integrations/custom_webhook/v3.rb', line 32

def adapter_thirdparty_id
  custom_response_result.dig("thirdparty_id")
end

#custom_response_processed_log_dataObject



65
66
67
# File 'app/models/pager_tree/integrations/custom_webhook/v3.rb', line 65

def custom_response_processed_log_data
  _custom_response_processed_log_data || {}
end