Class: Api::Vendor::V1::Klook::AvailabilitiesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- Api::Vendor::V1::Klook::AvailabilitiesController
- Includes:
- Concerns::ErrorResponses
- Defined in:
- app/controllers/api/vendor/v1/klook/availabilities_controller.rb
Constant Summary
Constants inherited from BaseController
BaseController::CACHE_NAMESPACE
Instance Attribute Summary collapse
-
#availability_params ⇒ Object
readonly
Returns the value of attribute availability_params.
-
#restaurant ⇒ Object
readonly
Returns the value of attribute restaurant.
-
#restaurant_package ⇒ Object
readonly
Returns the value of attribute restaurant_package.
Attributes inherited from BaseController
Instance Method Summary collapse
Methods inherited from BaseController
Methods included from ResponseCacheConcern
Methods included from EncryptableHelper
#decrypt, #encrypt, #generate_signature
Methods inherited from ApplicationController
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
Methods included from LogrageCustomLogger
Methods included from ControllerHelpers
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Attribute Details
#availability_params ⇒ Object (readonly)
Returns the value of attribute availability_params.
5 6 7 |
# File 'app/controllers/api/vendor/v1/klook/availabilities_controller.rb', line 5 def availability_params @availability_params end |
#restaurant ⇒ Object (readonly)
Returns the value of attribute restaurant.
5 6 7 |
# File 'app/controllers/api/vendor/v1/klook/availabilities_controller.rb', line 5 def restaurant @restaurant end |
#restaurant_package ⇒ Object (readonly)
Returns the value of attribute restaurant_package.
5 6 7 |
# File 'app/controllers/api/vendor/v1/klook/availabilities_controller.rb', line 5 def restaurant_package @restaurant_package end |
Instance Method Details
#calendar ⇒ Object
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 |
# File 'app/controllers/api/vendor/v1/klook/availabilities_controller.rb', line 7 def calendar set_calendar_params! set_restaurant! set_restaurant_package! BUSINESS_LOGGER.set_business_context({ restaurant_id: restaurant.id }) availability_service = VendorsService::Klook::AvailabilityService.new( restaurant, restaurant_package, availability_params ) availability_data = availability_service.calendar_dates_availability_data data = OpenStruct.new( restaurant_package: restaurant_package, units: availability_params[:units], availability_data: availability_data, method_name: :calendar, ) serialized_data = Api::Vendor::V1::Klook::AvailabilitySerializer.new(data) render json: serialized_data, status: :ok rescue ProductValidationError render_error(error: ApiVendorV1::Constants::KLOOK_INVALID_PRODUCT_ID_ERROR, error_message: ApiVendorV1::Constants::KLOOK_INVALID_PRODUCT_ID_ERROR_MESSAGE, method: :calendar) rescue OptionValidationError render_error(error: ApiVendorV1::Constants::KLOOK_INVALID_OPTION_ID_ERROR, error_message: ApiVendorV1::Constants::KLOOK_INVALID_OPTION_ID_ERROR_MESSAGE, method: :calendar) rescue ActionController::ParameterMissing => e render_error(error: ApiVendorV1::Constants::KLOOK_BAD_REQUEST_ERROR, error_message: "Missing parameter: #{e.param}", method: :calendar) rescue StandardError => e render_error(error: ApiVendorV1::Constants::KLOOK_UNPROCESSABLE_ENTITY_ERROR, error_message: e., method: :calendar) end |
#check ⇒ Object
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 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/api/vendor/v1/klook/availabilities_controller.rb', line 45 def check set_check_params! set_restaurant! set_restaurant_package! BUSINESS_LOGGER.set_business_context({ restaurant_id: restaurant.id }) availability_service = VendorsService::Klook::AvailabilityService.new( restaurant, restaurant_package, availability_params ) availability_data = availability_service.check_start_times_availability_data = data = OpenStruct.new( restaurant_package: restaurant_package, units: availability_params[:units], availability_data: availability_data, max_units: [:max_units], utc_cutoff_minutes: [:utc_cutoff_minutes], method_name: :check, ) serialized_data = Api::Vendor::V1::Klook::AvailabilitySerializer.new(data) render json: serialized_data, status: :ok rescue ProductValidationError render_error(error: ApiVendorV1::Constants::KLOOK_INVALID_PRODUCT_ID_ERROR, error_message: ApiVendorV1::Constants::KLOOK_INVALID_PRODUCT_ID_ERROR_MESSAGE, method: :check) rescue OptionValidationError render_error(error: ApiVendorV1::Constants::KLOOK_INVALID_OPTION_ID_ERROR, error_message: ApiVendorV1::Constants::KLOOK_INVALID_OPTION_ID_ERROR_MESSAGE, method: :check) rescue ActionController::ParameterMissing => e render_error(error: ApiVendorV1::Constants::KLOOK_BAD_REQUEST_ERROR, error_message: "Missing parameter: #{e.param}", method: :check) rescue StandardError => e render_error(error: ApiVendorV1::Constants::KLOOK_UNPROCESSABLE_ENTITY_ERROR, error_message: e., method: :check) end |