Class: MenuDataService
- Inherits:
-
Object
- Object
- MenuDataService
- Includes:
- ElasticAPM::SpanHelpers
- Defined in:
- app/services/menu_data_service.rb
Overview
Service class to handle menu data fetching and processing from external API Handles both Ayce and PartyPack menu data formats
CHANGE (2025-09): Time limit attributes (`use_time_limit` / `time_limit_minutes`) are evaluated for all section types, but the exposed output now ONLY includes `:minutes` for UNLIMITED items (Ayce & PartyPack). Limited items (including beverages) never include `:minutes` even if a time limit exists upstream.
Constant Summary collapse
- AYCE_TYPE =
'HhPackage::Package::Ayce'.freeze
- SECTION_TYPE =
'section'.freeze
- MENU_GROUP_SECTION_TYPE =
'menu_group_section'.freeze
- BEVERAGE_SECTION =
'beverage'.freeze
- FOOD_SECTION =
'food'.freeze
Instance Method Summary collapse
-
#call ⇒ Hash?
Fetch and process menu data from external API.
-
#initialize(menu_group_id, package_id, package_type) ⇒ MenuDataService
constructor
A new instance of MenuDataService.
Constructor Details
#initialize(menu_group_id, package_id, package_type) ⇒ MenuDataService
Returns a new instance of MenuDataService.
16 17 18 19 20 |
# File 'app/services/menu_data_service.rb', line 16 def initialize(, package_id, package_type) @menu_group_id = @package_id = package_id @package_type = package_type end |
Instance Method Details
#call ⇒ Hash?
Fetch and process menu data from external API
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/services/menu_data_service.rb', line 24 def call ElasticAPM.with_span('MenuDataService#call', 'ext', subtype: 'http') do response = return nil unless response_valid?(response) result = parse_response(response) return nil unless result_valid?(result) (result) rescue StandardError => e HH_LOGGER.error('Error in MenuDataService#call', { error: e., menu_group_id: @menu_group_id, package_id: @package_id, package_type: @package_type, }) APMErrorHandler.report(e, context: { menu_group_id: @menu_group_id, package_id: @package_id, package_type: @package_type, }) nil end end |