Class: OpportunityFollowedUpHandler

Inherits:
ApplicationJob show all
Includes:
RailsEventStore::AsyncHandler
Defined in:
app/subscribers/opportunity_followed_up_handler.rb

Overview

Async handler for Events::OpportunityFollowedUp.

Reports a Google Ads conversion when an opportunity moves to the follow_up
state. The conversion_date_time is captured at transition time and embedded
in the event payload so it reflects when the transition actually occurred,
not when this job runs.

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/subscribers/opportunity_followed_up_handler.rb', line 14

def perform(event)
  opportunity = Opportunity.find_by(id: event.data[:opportunity_id])
  return unless opportunity

  conversion_date_time = Time.parse(event.data[:conversion_date_time])
  Invoicing::GoogleConversionReporter.new.send_new_opportunity_conversion(
    opportunity,
    conversion_date_time: conversion_date_time
  )
rescue StandardError => e
  ErrorReporting.error(e)
  raise
end