Class: Honeybadger::V3

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

Constant Summary collapse

OPTIONS =
[
  # only used if they set this up as a "webhook" from honeybadger, the native PT integration doesn't have the token option
  {key: :token, type: :string, default: nil}
]

Instance Method Summary collapse

Instance Method Details

#adapter_actionObject



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

def adapter_action
  event = adapter_incoming_request_params.dig("event").to_s.downcase
  case event
  when "occurred", "down", "check_in_missing"
    :create
  when "resolved", "up", "check_in_reporting"
    :resolve
  else
    :other
  end
end

#adapter_incoming_can_defer?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/models/pager_tree/integrations/honeybadger/v3.rb', line 25

def adapter_incoming_can_defer?
  true
end

#adapter_process_createObject



45
46
47
48
49
50
51
52
53
# File 'app/models/pager_tree/integrations/honeybadger/v3.rb', line 45

def adapter_process_create
  Alert.new(
    title: _title,
    thirdparty_id: adapter_thirdparty_id,
    dedup_keys: [],
    additional_data: _additional_datums,
    tags: _tags
  )
end

#adapter_should_block_incoming?(request) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/pager_tree/integrations/honeybadger/v3.rb', line 13

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

#adapter_supports_incoming?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/pager_tree/integrations/honeybadger/v3.rb', line 17

def adapter_supports_incoming?
  true
end

#adapter_supports_outgoing?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/models/pager_tree/integrations/honeybadger/v3.rb', line 21

def adapter_supports_outgoing?
  false
end

#adapter_thirdparty_idObject



29
30
31
# File 'app/models/pager_tree/integrations/honeybadger/v3.rb', line 29

def adapter_thirdparty_id
  adapter_incoming_request_params.dig("fault", "url") || adapter_incoming_request_params.dig("outage", "details_url") || adapter_incoming_request_params.dig("check_in", "details_url")
end