iachat/enterprise/app/services/captain/lifecycle/event_resolver.rb
Rodribm10 4a88f7f517 feat(lifecycle): add EventResolver service
Pure function mapping reservation events to timestamps; used by Scheduler (T9) to compute fire_at.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 01:31:47 -03:00

25 lines
721 B
Ruby

# frozen_string_literal: true
class Captain::Lifecycle::EventResolver
UNSUPPORTED_IN_MVP = %w[checkin.detected checkout.detected].freeze
def self.resolve(reservation, event_name)
return nil if UNSUPPORTED_IN_MVP.include?(event_name)
case event_name
when 'reservation.confirmed'
reservation.updated_at
when 'checkin.scheduled_at'
reservation.check_in_at
when 'checkout.scheduled_at'
reservation.check_out_at
when 'reservation.cancelled'
reservation.updated_at if reservation.status.to_s == 'cancelled'
when 'reservation.no_show'
reservation.check_in_at&.+(1.hour)
else
raise ArgumentError, "unknown event: #{event_name.inspect}"
end
end
end