Class: Api::Admin::RestaurantsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Api::Admin::RestaurantsController
- Defined in:
- app/controllers/api/admin/restaurants_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
#identity_cache_memoization, #set_app_language
Methods included from LogrageCustomLogger
Instance Method Details
#create ⇒ Object
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 |
# File 'app/controllers/api/admin/restaurants_controller.rb', line 5 def create HH_LOGGER.info('Restaurant API creation started', { params: restaurant_params.inspect }) begin HH_LOGGER.info('Calling restaurant creation service') result = RestaurantService::CreateFromApi.new(params: restaurant_params).execute! HH_LOGGER.info('Restaurant creation service completed', { success: result.success?, message: result. }) if result.success? render_success( data: serialize_restaurant_response(result), message: 'Restaurant created successfully', status: :created, ) else render_error( message: result. || 'Failed to create restaurant', errors: result.errors || [], status: :unprocessable_entity, ) end rescue ActionController::ParameterMissing => e HH_LOGGER.error('Restaurant API parameter missing', { error: e., params: params }) render_error( message: e., errors: [], status: :bad_request, ) rescue StandardError => e HH_LOGGER.error('Restaurant API unexpected error', { error: e.class.name, message: e., backtrace: e.backtrace.first(10), }) render_error( message: "Something went wrong during restaurant creation: #{e.}", errors: [], status: :internal_server_error, ) end end |