Class: Api::Vendor::V1::TemporaryReservationsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Api::Vendor::V1::TemporaryReservationsController
- Defined in:
- app/controllers/api/vendor/v1/temporary_reservations_controller.rb
Constant Summary
Constants inherited from BaseController
BaseController::CACHE_NAMESPACE
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Methods included from LogrageCustomLogger
Methods included from ResponseCacheConcern
Instance Method Details
#create ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 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 |
# File 'app/controllers/api/vendor/v1/temporary_reservations_controller.rb', line 3 def create VendorLogger.log_event(:request, params[:route], payload: params) params.require(:reservation) params.require(:packages) %i[restaurant_id date start_time adult kids].each do |key| params[:reservation].require(key) end params[:packages].each do |pkg| %i[id quantity].each { |k| pkg.fetch(k) } end permitted_params = params.permit( reservation: %i[restaurant_id date start_time adult kids channel], packages: %i[id quantity], ) permitted_params[:reservation][:channel] = find_vendor_channel&.channel_id service = ReservationService::InitFactory.build(permitted_params) result = service.create_temporary if result.success? reservation_id = result.data.id BUSINESS_LOGGER.set_business_context({ reservation_id: reservation_id }) data = { tmp_reservation_id: reservation_id, expired_at: service.expiry_time, } else data = {} = result.errors..to_sentence end response = { success: result.success?, data: data, message: , } VendorLogger.log_event(:response, params[:route], payload: response) render json: response end |