Class: Netcore::EventWorker
Constant Summary
collapse
- EVENTS =
{
no_show: 'Reservation No Show',
arrived: 'Reservation Arrived',
rejected: 'Reservation Rejected',
cancel_modified: 'Reservation Modified',
cancelled: 'Reservation Canceled',
pending_confirmation: 'Reservation Pending',
pending_arrival: 'Reservation Arrival',
waiting_for_payment: 'Waiting For Payment',
order_being_prepared: 'Reservation Arrival',
transaction_completed: 'Transaction Completed',
point_used: 'Point Used',
cancelled_with_refund: 'Reservation Cancelled with Refund',
}.freeze
- DELAY =
30.seconds
Instance Method Summary
collapse
Methods included from Payload
#fav_payload, #reservation_data_payload, #reward_data_payload, #user_loyalty_payload, #user_properties, #user_properties_for_client
#malaysia_id, #singapore_id, #thailand_id
unlimited_retry
Instance Method Details
#add_fav_restaurant(fav_id, user_id, restaurant_id) ⇒ Object
33
34
35
36
37
38
|
# File 'app/workers/netcore/event_worker.rb', line 33
def add_fav_restaurant(fav_id, user_id, restaurant_id)
fav = Fav.find_by(id: fav_id)
ts = fav.present? ? fav.updated_at.to_i : Time.zone.now.to_i
send_event('Add Favorited Restaurant', fav_payload(fav, user_id, restaurant_id), User.fetch(user_id).email,
timestamp: ts)
end
|
#alert_point_expiration(reward_id) ⇒ Object
78
79
80
|
# File 'app/workers/netcore/event_worker.rb', line 78
def alert_point_expiration(reward_id)
Netcore::LoyaltyWorker.perform_async(:alert_point_expiration, reward_id)
end
|
27
28
29
30
31
|
# File 'app/workers/netcore/event_worker.rb', line 27
def perform(state, *args)
return if AdminSetting.enable_netcore_events.to_s == 'false'
send(state.to_sym, *args)
end
|
#remove_fav_restaurant(fav_id, user_id, restaurant_id) ⇒ Object
40
41
42
43
44
45
|
# File 'app/workers/netcore/event_worker.rb', line 40
def remove_fav_restaurant(fav_id, user_id, restaurant_id)
fav = Fav.find_by(id: fav_id)
ts = fav.present? ? fav.updated_at.to_i : Time.zone.now.to_i
send_event('Remove Favorited Restaurant', fav_payload(fav, user_id, restaurant_id), User.fetch(user_id).email,
timestamp: ts)
end
|
#reservation_event(reservation_id, force_status = nil) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/workers/netcore/event_worker.rb', line 48
def reservation_event(reservation_id, force_status = nil)
reservation = Reservation.fetch(reservation_id)
return unless reservation.package?
return if reservation.skip_sending_netcore_event?
status = force_status || reservation.status_as_symbol
payload = reservation_data_payload(reservation, event: status)
event_status = EVENTS[status.to_sym]
return if status.to_sym == :transaction_completed && invalid_booking(reservation)
if event_status
return send_event(event_status, payload, reservation.email,
timestamp: reservation.updated_at.utc.iso8601)
end
HH_LOGGER.warn(
'Unknown status', {
id: reservation_id,
status: status,
force_status: force_status,
}
)
end
|
#send_custom_event(name, data, identity) ⇒ Object
74
75
76
|
# File 'app/workers/netcore/event_worker.rb', line 74
def send_custom_event(name, data, identity)
send_event(name, data, identity)
end
|