Class: Assistant::TechnicalSupport::CaseReplayPreparation

Inherits:
Object
  • Object
show all
Defined in:
app/services/assistant/technical_support/case_replay_preparation.rb

Overview

Validates a case, builds its complete evidence stream, and extracts a safe
replay episode before any Sunny conversation is created.

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(support_case:, account:, analyzer:, event_stream_builder:) ⇒ CaseReplayPreparation

Returns a new instance of CaseReplayPreparation.



24
25
26
27
28
29
# File 'app/services/assistant/technical_support/case_replay_preparation.rb', line 24

def initialize(support_case:, account:, analyzer:, event_stream_builder:)
  @support_case = support_case
  @account = 
  @analyzer = analyzer
  @event_stream_builder = event_stream_builder
end

Class Method Details

.call(**attributes) ⇒ Result

Returns preparation outcome.

Parameters:

  • attributes (Hash)

    constructor keywords forwarded to #initialize

Options Hash (**attributes):

  • support_case (SupportCase)

    case being replayed

  • account (Account)

    replaying account

  • analyzer (Object)

    episode analyzer

  • event_stream_builder (Object)

    builds the case evidence stream

Returns:

  • (Result)

    preparation outcome



19
20
21
# File 'app/services/assistant/technical_support/case_replay_preparation.rb', line 19

def call(**attributes)
  new(**attributes).call
end

Instance Method Details

#callObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/services/assistant/technical_support/case_replay_preparation.rb', line 31

def call
  validation_error = source_error
  return Result.new(error: validation_error) if validation_error

  stream = event_stream_builder.call(support_case)
  evidence_error = stream_error(stream)
  return Result.new(stream:, error: evidence_error) if evidence_error

  extraction = analyzer.extract(events: stream.events, coverage: stream.coverage)
  return Result.new(stream:, events: stream.events, error: ineligible_error(extraction)) if extraction.ineligible?

  episode_result = Assistant::TechnicalSupport::CaseReplayEpisodeBuilder.call(
    payload: extraction.data,
    events: stream.events
  )
  Result.new(
    stream:,
    events: stream.events,
    episode: episode_result.episode,
    error: episode_result.error
  )
end