Class: Freshdesk::V3

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

Constant Summary collapse

FD_TICKET_STATUS =
{
  open: 2,
  pending: 3,
  resolved: 4,
  closed: 5
}
FD_TICKET_PRIORITY =
{
  low: 1,
  medium: 2,
  high: 3,
  urgent: 4
}
OPTIONS =
[]

Instance Method Summary collapse

Instance Method Details

#adapter_actionObject



39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/pager_tree/integrations/freshdesk/v3.rb', line 39

def adapter_action
  status = _freshdesk_webhook.dig("ticket_status")
  status_i = status&.to_i
  if status_i == FD_TICKET_STATUS[:open] || status == "Open" || status_i == FD_TICKET_STATUS[:pending] || status == "Pending"
    :create
  elsif status_i == FD_TICKET_STATUS[:resolved] || status == "Resolved" || status_i == FD_TICKET_STATUS[:closed] || status == "Closed"
    :resolve
  else
    :other
  end
end

#adapter_incoming_can_defer?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/pager_tree/integrations/freshdesk/v3.rb', line 31

def adapter_incoming_can_defer?
  true
end

#adapter_process_createObject



51
52
53
54
55
56
57
58
59
60
# File 'app/models/pager_tree/integrations/freshdesk/v3.rb', line 51

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

#adapter_supports_incoming?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/pager_tree/integrations/freshdesk/v3.rb', line 23

def adapter_supports_incoming?
  true
end

#adapter_supports_outgoing?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/pager_tree/integrations/freshdesk/v3.rb', line 27

def adapter_supports_outgoing?
  false
end

#adapter_thirdparty_idObject



35
36
37
# File 'app/models/pager_tree/integrations/freshdesk/v3.rb', line 35

def adapter_thirdparty_id
  _freshdesk_webhook.dig("ticket_id")
end