Class: BookingReminder::Queue
- Inherits:
-
Trailblazer::Operation
- Object
- Trailblazer::Operation
- BookingReminder::Queue
- Defined in:
- lib/booking_reminder/queue.rb
Overview
This class reminds customer automatically (for defined restaurant) Queue SMS reminder if valid
Instance Attribute Summary collapse
-
#reservation ⇒ Object
Returns the value of attribute reservation.
Instance Method Summary collapse
- #queue_reminder!(options) ⇒ Object
- #send_error_report!(exception, options) ⇒ Object
- #set_reservation!(options) ⇒ Object
- #validate_channel! ⇒ Object
- #validate_restaurants! ⇒ Object
Instance Attribute Details
#reservation ⇒ Object
Returns the value of attribute reservation.
11 12 13 |
# File 'lib/booking_reminder/queue.rb', line 11 def reservation @reservation end |
Instance Method Details
#queue_reminder!(options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/booking_reminder/queue.rb', line 34 def queue_reminder!(, *) return false if reservation.reservation_time - Time.current_time < 90.minutes delayed_time = if (reservation.reservation_time - Time.current_time >= 90.minutes) && (reservation.reservation_time - Time.current_time <= 120.minutes) 60.minutes else 2.hours end in_seconds = ((reservation.reservation_time - delayed_time) - Time.current_time).seconds BookingReminder::SmsReminderWorker.perform_in(in_seconds, reservation.id) ['success'] = true end |
#send_error_report!(exception, options) ⇒ Object
46 47 48 49 50 |
# File 'lib/booking_reminder/queue.rb', line 46 def send_error_report!(exception, ) Rails.logger.error(exception) APMErrorHandler.report('Unable send SMS reminder', exception: exception, options: ) ['success'] = false end |
#set_reservation!(options) ⇒ Object
20 21 22 |
# File 'lib/booking_reminder/queue.rb', line 20 def set_reservation!(, *) self.reservation = ['params'] || [:params] end |
#validate_channel! ⇒ Object
29 30 31 32 |
# File 'lib/booking_reminder/queue.rb', line 29 def validate_channel!(*) return false if ::Channel.manual.include?(reservation.channel) true end |
#validate_restaurants! ⇒ Object
24 25 26 27 |
# File 'lib/booking_reminder/queue.rb', line 24 def validate_restaurants!(*) return true if [685].include?(reservation.restaurant.id) false end |