Class: UptimeRobot::V3

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

Constant Summary collapse

OPTIONS =
[]

Instance Method Summary collapse

Instance Method Details

#adapter_actionObject



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

def adapter_action
  case adapter_incoming_request_params.dig("alertTypeFriendlyName").to_s.downcase
  when "down"
    :create
  when "up"
    :resolve
  else
    :other
  end
end

#adapter_incoming_can_defer?Boolean

Returns:

  • (Boolean)


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

def adapter_incoming_can_defer?
  true
end

#adapter_process_createObject



48
49
50
51
52
53
54
55
56
# File 'app/models/pager_tree/integrations/uptime_robot/v3.rb', line 48

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

#adapter_supports_incoming?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/models/pager_tree/integrations/uptime_robot/v3.rb', line 9

def adapter_supports_incoming?
  true
end

#adapter_supports_outgoing?Boolean

Returns:

  • (Boolean)


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

def adapter_supports_outgoing?
  false
end

#adapter_thirdparty_idObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/pager_tree/integrations/uptime_robot/v3.rb', line 21

def adapter_thirdparty_id
  monitor_id = adapter_incoming_request_params.dig("monitorID")

  # LEGACY: We offerred the ability to aggregate for one of our customers
  # we did this through a groupSeconds parameter. Technically, with our new aggregration
  # this shouldn't be here, but to support our legacy customers it is.
  group_seconds = adapter_incoming_request_params.dig("groupSeconds").to_i

  return monitor_id unless group_seconds > 0

  alert_datetime = Time.at(adapter_incoming_request_params.dig("alertDateTime").to_i)

  # return the rounded off time as the id (as so to group them together by id)
  _round_off(alert_datetime, group_seconds.seconds).to_i
end