Class: MarkReservationArrivedService
- Inherits:
-
BaseOperationService
- Object
- BaseOperationService
- MarkReservationArrivedService
- Includes:
- DefaultErrorContainer, Modules::Reservations::RewardPoints
- Defined in:
- app/services/mark_reservation_arrived_service.rb
Instance Attribute Summary collapse
-
#reservation ⇒ Object
Returns the value of attribute reservation.
Attributes inherited from BaseOperationService
Instance Method Summary collapse
- #execute ⇒ Object
- #execute! ⇒ Object
-
#initialize(reservation_id) ⇒ MarkReservationArrivedService
constructor
A new instance of MarkReservationArrivedService.
Methods included from DefaultErrorContainer
#error, #error_message_simple, #merge_errors
Methods inherited from BaseOperationService
Constructor Details
#initialize(reservation_id) ⇒ MarkReservationArrivedService
Returns a new instance of MarkReservationArrivedService.
11 12 13 |
# File 'app/services/mark_reservation_arrived_service.rb', line 11 def initialize(reservation_id) self.reservation = Reservation.find(reservation_id) end |
Instance Attribute Details
#reservation ⇒ Object
Returns the value of attribute reservation.
9 10 11 |
# File 'app/services/mark_reservation_arrived_service.rb', line 9 def reservation @reservation end |
Instance Method Details
#execute ⇒ Object
79 80 81 82 83 84 |
# File 'app/services/mark_reservation_arrived_service.rb', line 79 def execute execute! rescue StandardError => e errors.add(:base, e.) false end |
#execute! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 73 74 75 76 77 |
# File 'app/services/mark_reservation_arrived_service.rb', line 15 def execute! result = false ActiveRecord::Base.transaction do reservation.lock! validate_for_tablecheck validate_for_seven_rooms validate_for_weeloy validate_for_bistrochat reservation.mark_voucher_as_active! reservation.mark_as_arrived! reservation.save validate: false # Use priority sync for arrival status - fast but non-blocking reservation.trigger_priority_sync BUSINESS_LOGGER.set_business_context({ reservation_id: reservation.id }) if reservation.aoa_reservation.present? && reservation.aoa_channel? BUSINESS_LOGGER.info("#{self.class}: Aoa::WebhookWorker called from execute! method with status: #{:arrived}") Aoa::WebhookWorker.default_perform_async(reservation.id, :arrived) elsif reservation.by_marketplace? vendor_name = reservation.vendor_reservation.oauth_application.name status = ApiVendorV1::Constants::CONFIRM case vendor_name when ApiVendorV1::Constants::OPEN_RICE_VENDOR_NAME BUSINESS_LOGGER.info( "#{self.class}: Vendors::OpenRice::WebhookWorker called from execute! method with status: #{status}", status: status ) Vendors::OpenRice::WebhookWorker.perform_async(reservation.id.to_s, reservation.vendor_reservation.id.to_s, status) when ApiVendorV1::Constants::TAG_THAI_VENDOR_NAME BUSINESS_LOGGER.info( "#{self.class}: Vendors::TagThai::WebhookWorkerr called from execute! method with status: #{status}", status: status ) Vendors::TagThai::WebhookWorker.perform_async(reservation.id, status) when ApiVendorV1::Constants::GOOGLE_RESERVE_VENDOR_NAME # no need to handle this action for google reserve else APMErrorHandler.report("Invalid vendor name: #{vendor_name}") end end if reservation.user_id.blank? result = true return result end if reservation.id.blank? APMErrorHandler.report('Nil reservation id detected before enqueuing reward workers') else LoyaltyPrograms::TierQualificationWorker.perform_async(reservation.id) end result = true end result end |