Class: Assistant::TechnicalSupport::CaseEventStream::EventBuilder::CommerceSerializer

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

Constant Summary

Constants inherited from Base

Base::RawEvent

Instance Method Summary collapse

Constructor Details

#initialize(source_type:, **attributes) ⇒ CommerceSerializer

Returns a new instance of CommerceSerializer.

Parameters:

  • source_type (String)

    commerce source type label (e.g. 'Order', 'Quote')

  • attributes (Hash)

    base serializer wiring, forwarded to super

Options Hash (**attributes):

  • graph (Object)

    evidence graph

  • redactor (Proc)

    text redactor

  • on_record (Proc)

    record-coverage callback

  • on_unavailable (Proc)

    unavailable-source callback

  • next_sequence (Proc)

    sequence generator



11
12
13
14
# File 'app/services/assistant/technical_support/case_event_stream/event_builder/commerce_serializer.rb', line 11

def initialize(source_type:, **attributes)
  @source_type = source_type
  super(**attributes)
end

Instance Method Details

#call(record) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/services/assistant/technical_support/case_event_stream/event_builder/commerce_serializer.rb', line 16

def call(record)
  record_source(source_type)
  raw_event = event(
    record,
    key_prefix: "#{source_type.underscore.dasherize}-#{record.id}",
    source_type:,
    occurred_at: value_for(record, :created_at) || value_for(support_case, :created_at),
    kind: 'product_context',
    actor_role: 'system',
    status: value_for(record, :state),
    text: commerce_text(record)
  )
  include_source(source_type)
  raw_event
end