Class: Assistant::TechnicalSupport::CaseEventStream::EventBuilder::CallRecordSerializer

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

Constant Summary collapse

SOURCE_TYPE =
'CallRecord'
TERMINAL_EMPTY_STATES =
%w[no_audio too_short].freeze

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(call_record) ⇒ Object



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

def call(call_record)
  record_source(SOURCE_TYPE)
  transcript = clean_text(raw_attribute(call_record, :transcript))
  state = value_for(call_record, :transcription_state).to_s
  report_unavailable(call_record, transcript:, state:)
  raw_event = event(
    call_record,
    key_prefix: "call-record-#{call_record.id}",
    source_type: SOURCE_TYPE,
    occurred_at: value_for(call_record, :created_at),
    kind: 'call',
    actor_role: 'customer_and_staff',
    direction: value_for(call_record, :call_direction),
    status: value_for(call_record, :call_outcome),
    text: call_text(call_record, transcript:, state:)
  )
  include_source(SOURCE_TYPE)
  raw_event
end