Class: Workers::Reservations::RatingReservationWorker

Inherits:
ApplicationWorker show all
Defined in:
app/workers/workers/reservations/rating_reservation_worker.rb

Overview

Ask customer to give a rating to restaurant system sends sms and email to customer

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Attribute Details

#restaurantObject (readonly)

Returns the value of attribute restaurant.



9
10
11
# File 'app/workers/workers/reservations/rating_reservation_worker.rb', line 9

def restaurant
  @restaurant
end

Instance Method Details

#ask_rating_by_email(reservation) ⇒ Object



28
29
30
# File 'app/workers/workers/reservations/rating_reservation_worker.rb', line 28

def ask_rating_by_email(reservation)
  UserMailer.rating_reservation(reservation.id).deliver_later!
end

#ask_rating_by_sms(reservation) ⇒ Object



32
33
34
35
36
37
38
# File 'app/workers/workers/reservations/rating_reservation_worker.rb', line 32

def ask_rating_by_sms(reservation)
  NotificationService::Sms.new(
    phones: reservation.phone,
    reservation: reservation,
    default_locale: :en,
  ).send_review_msg_to_user
end

#perform(reservation_id) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/workers/workers/reservations/rating_reservation_worker.rb', line 13

def perform(reservation_id)
  reservation = Reservation.fetch(reservation_id)
  return unless reservation.active?
  return if reservation.no_show?
  return unless reservation.ack?
  return if reservation.review.present? && reservation.review.persisted?
  return if reservation&.booking_channel&.skip_send_notifications?(actor: 'user')

  @restaurant = reservation.restaurant
  ask_rating_by_email(reservation)
  return unless restaurant.any_offers?

  ask_rating_by_sms(reservation)
end