Class: Assistant::TechnicalSupport::CaseEventStream::EventBuilder::CommunicationSerializer

Inherits:
Base
  • Object
show all
Defined in:
app/services/assistant/technical_support/case_event_stream/event_builder/communication_serializer.rb

Constant Summary collapse

SOURCE_TYPE =
'Communication'
GENERIC_FOLLOW_UP_SUBJECT_PATTERN =
/Support Case Ticket Follow-up/i
QUOTED_EMAIL_PATTERN =
/\n{0,2}(?:On .{10,120}wrote:|_{5,}|-----Original Message-----|From:[\s\S]{0,60}Sent:)/m

Constants inherited from Base

Base::RawEvent

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Assistant::TechnicalSupport::CaseEventStream::EventBuilder::Base

Instance Method Details

#call(communication) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/assistant/technical_support/case_event_stream/event_builder/communication_serializer.rb', line 8

def call(communication)
  record_source(SOURCE_TYPE)
  direction = value_for(communication, :direction).to_s.presence
  raw_event = event(
    communication,
    key_prefix: "communication-#{communication.id}",
    source_type: SOURCE_TYPE,
    occurred_at: value_for(communication, :transmit_at) || value_for(communication, :created_at),
    kind: kind_for(communication, direction:),
    actor_role: actor_role_for(direction),
    direction:,
    status: value_for(communication, :state),
    text: communication_text(communication)
  )
  include_source(SOURCE_TYPE)
  raw_event
end