Module: NotificationWorkers::ReservationModules::PushNotification

Included in:
NotificationWorkers::Reservation
Defined in:
app/workers/notification_workers/reservation_modules/push_notification.rb

Overview

typed: ignore frozen_string_literal: true

Instance Method Summary collapse

Instance Method Details

#push_notification_booking_cancelled(rules) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/workers/notification_workers/reservation_modules/push_notification.rb', line 53

def push_notification_booking_cancelled(rules)
  # Send to user
  if allow_send_notif_to_user?(receivers: rules[:receiver])
    report["#{__callee__}_to_user"] = safe_call do
      push_to_user.publish_event(:reservation_cancelled, object_id: reservation.id)
    end
  end

  # Send to owner
  if rules[:receiver].include?('owner')
    report["#{__callee__}_to_owner"] = safe_call do
      push_to_staff.publish_event(:reservation_cancelled, object_id: reservation.id)
    end
  end
end

#push_notification_booking_confirmed(rules) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/workers/notification_workers/reservation_modules/push_notification.rb', line 21

def push_notification_booking_confirmed(rules)
  # Send to user
  if allow_send_notif_to_user?(receivers: rules[:receiver])
    report["#{__callee__}_to_user"] = safe_call do
      push_to_user.publish_event(:reservation_created, object_id: reservation.id)
    end
  end

  # Send to owner
  if rules[:receiver].include?('owner')
    report["#{__callee__}_to_owner"] = safe_call do
      push_to_staff.publish_event(:reservation_created, object_id: reservation.id)
    end
  end
end

#push_notification_booking_created(rules) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/workers/notification_workers/reservation_modules/push_notification.rb', line 5

def push_notification_booking_created(rules)
  # Send to user
  if allow_send_notif_to_user?(receivers: rules[:receiver])
    report["#{__callee__}_to_user"] = safe_call do
      push_to_user.publish_event(:reservation_created, object_id: reservation.id)
    end
  end

  # Send to owner
  if rules[:receiver].include?('owner')
    report["#{__callee__}_to_owner"] = safe_call do
      push_to_staff.publish_event(:reservation_created, object_id: reservation.id)
    end
  end
end

#push_notification_booking_modified(rules) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/workers/notification_workers/reservation_modules/push_notification.rb', line 37

def push_notification_booking_modified(rules)
  # Send to user
  if allow_send_notif_to_user?(receivers: rules[:receiver])
    report["#{__callee__}_to_user"] = safe_call do
      push_to_user.publish_event(:reservation_modified, object_id: reservation.id)
    end
  end

  # Send to owner
  if rules[:receiver].include?('owner')
    report["#{__callee__}_to_owner"] = safe_call do
      push_to_staff.publish_event(:reservation_modified, object_id: reservation.id)
    end
  end
end