Class: SchedulerBookingLeadProcessor

Inherits:
Object
  • Object
show all
Defined in:
app/services/scheduler_booking_lead_processor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(booking) ⇒ SchedulerBookingLeadProcessor

Returns a new instance of SchedulerBookingLeadProcessor.



15
16
17
# File 'app/services/scheduler_booking_lead_processor.rb', line 15

def initialize(booking)
  @booking = booking
end

Instance Attribute Details

#bookingObject (readonly)

Returns the value of attribute booking.



4
5
6
# File 'app/services/scheduler_booking_lead_processor.rb', line 4

def booking
  @booking
end

Class Method Details

.customer_for_sales_rep_invite(booking) ⇒ Object

Existing customer matched by guest email/phone (same rules as #process), or nil.
Used to invite the customer's primary sales rep on calendar events before party_id is set.



8
9
10
11
12
13
# File 'app/services/scheduler_booking_lead_processor.rb', line 8

def self.customer_for_sales_rep_invite(booking)
  party = new(booking).send(:find_existing_party)
  return unless party

  party.is_a?(Customer) ? party : party.try(:customer)
end

Instance Method Details

#processObject



19
20
21
22
23
24
25
26
# File 'app/services/scheduler_booking_lead_processor.rb', line 19

def process
  party = find_existing_party || create_lead_qualify_customer
  return unless party

  activity = create_booking_activity(party)
  booking.update_columns(party_id: party.customer_id || party.id) if activity&.persisted?
  activity
end