Class: Agents::CreateBookingForOwner
- Inherits:
-
CreateBase
- Object
- Base
- CreateBase
- Agents::CreateBookingForOwner
- Includes:
- DefaultErrorContainer
- Defined in:
- app/my_lib/agents/create_booking_for_owner.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#audit_comment, #errors, #executor, #force_update, #owner, #reservation, #reservation_params, #restaurant, #user, #vendor_booking_id
Instance Method Summary collapse
- #after_initialize ⇒ Object
-
#initialize(params_or_obj = nil) ⇒ CreateBookingForOwner
constructor
A new instance of CreateBookingForOwner.
- #make_booking! ⇒ Object
Methods included from DefaultErrorContainer
#error, #error_message_simple, #merge_errors
Methods inherited from CreateBase
#execute, #execute!, #make_booking, #notification_sent?
Methods inherited from Base
#error_message, #hotline, #inventory_available?, #save_reservation!, #status=
Methods included from SharedJobs
#give_campaign_reward, #send_rating_email
Constructor Details
#initialize(params_or_obj = nil) ⇒ CreateBookingForOwner
Returns a new instance of CreateBookingForOwner.
10 11 12 13 |
# File 'app/my_lib/agents/create_booking_for_owner.rb', line 10 def initialize(params_or_obj = nil) super(params_or_obj) @reservation.channel = @reservation.restaurant.any_offers? ? Channel.manual_package.channel_id : Channel.manual.first if @reservation.channel.blank? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Agents::Base
Instance Method Details
#after_initialize ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/my_lib/agents/create_booking_for_owner.rb', line 15 def after_initialize reservation.audit_comment = 'Create by owner' reservation.ack = true reservation.active = true reservation.is_valid_reservation = true reservation.no_show = false reservation.created_by = :owner end |
#make_booking! ⇒ Object
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 78 |
# File 'app/my_lib/agents/create_booking_for_owner.rb', line 24 def make_booking! validate_owner_parameters! result = true reservation.transaction do save_reservation! sneaky: true, validate: false reservation.run_callbacks :create reservation.trigger_creation_sync # if restaurant has inventory_tablecheck then create reservation for [TableCheck] # or restaurant has inventory_seven_rooms then create reservation for [SevenRooms] if reservation.restaurant.inventory_tablecheck? create_tc_reservation_result = create_tablecheck_reservation(reservation) unless create_tc_reservation_result.success? result = false raise InvalidReservation, Tablecheck::ErrorMessages.('owner', create_tc_reservation_result.) end elsif reservation.restaurant.inventory_seven_rooms? create_sr_reservation_result = create_seven_rooms_reservation(reservation) unless create_sr_reservation_result.success? result = false raise InvalidReservation, SevenRooms::ErrorMessages.('owner', create_sr_reservation_result.) end elsif reservation.restaurant.inventory_weeloy? create_weeloy_reservation_result = create_weeloy_reservation(reservation) unless create_weeloy_reservation_result.success? result = false raise InvalidReservation, Weeloy::ErrorMessages.('owner', create_weeloy_reservation_result.) end elsif reservation.restaurant.inventory_bistrochat? create_bc_reservation_result = create_bistrochat_reservation(reservation) unless create_bc_reservation_result.success? result = false raise InvalidReservation, Bistrochat::ErrorMessages.('owner', create_bc_reservation_result.) end elsif reservation.restaurant. = (reservation) unless .success? result = false raise InvalidReservation, MyMenu::ErrorMessages.('owner', .) end end add_event_to_calendar send_notification Netcore::EventWorker.perform_in(Netcore::EventWorker::DELAY, :reservation_event, reservation.id) end result end |