Class: VendorsService::GoogleReserve::ServiceFeedsService
- Inherits:
-
BaseOperationService
- Object
- BaseOperationService
- VendorsService::GoogleReserve::ServiceFeedsService
- Includes:
- ElasticAPM::SpanHelpers, Concerns::FeedUploader
- Defined in:
- app/services/vendors_service/google_reserve/service_feeds_service.rb
Overview
VendorsService::GoogleReserve::ServiceFeedsService generates restaurant service feeds for Google Reserve (RWG) E2E Integration
This service creates a JSON feed containing restaurant service information and uploads it to Google's SFTP server. The service feed includes comprehensive restaurant data required for Google Reserve integration.
Process Overview
-
Fetch active restaurants with Google Reserve E2E integration enabled
-
Build service data for each restaurant including localized names and rules
-
Generate and upload feed file using centralized FeedUploader workflow
-
Upload the file to Google's SFTP server via secure connection
Service Feed Structure
The generated JSON follows Google's service feed specification: {
"metadata": {
"processing_instruction": "PROCESS_AS_COMPLETE",
"shard_number": 0,
"total_shards": 1,
"nonce": <timestamp>,
"generation_timestamp": <timestamp>
},
"service": [
{
"merchant_id": "restaurant-<id>",
"service_id": "dining-<id>",
"localized_service_name": { "value": "Reservation", "localized_value": [...] },
"localized_description": { "value": "Dining", "localized_value": [...] },
"type": "SERVICE_TYPE_DINING_RESERVATION",
"uri_template": { "uri_template": "..." },
"rules": { "min_advance_booking": ..., "min_advance_online_canceling": ... }
}
]
}
Restaurant Eligibility
Only restaurants that meet ALL criteria are included:
-
Active and not expired
-
Have latitude/longitude coordinates
-
Have active Google Reserve integration (e2e: true, agreement_status: active)
-
Have associated Google Reserve packages
Error Handling
-
Individual restaurant processing errors are logged but don't stop the entire job
-
Comprehensive APM error reporting for debugging
-
SFTP upload failures are reported with context information
Dependencies
-
Flipper feature flag: :google_reserve_e2e must be enabled
-
FeedUploader concern for centralized file generation and upload
-
SftpService for Google SFTP uploads
-
Restaurant service data and booking rules
Constant Summary collapse
- WEB_V2_HOST_URL =
Base URL for restaurant booking pages
Figaro.env.WEB_V2_HOST_URL!
Instance Attribute Summary
Attributes inherited from BaseOperationService
Instance Method Summary collapse
-
#generate_and_upload_feed ⇒ Boolean
Main entry point for the service feed generation process.
-
#initialize ⇒ ServiceFeedsService
constructor
A new instance of ServiceFeedsService.
Methods inherited from BaseOperationService
Constructor Details
#initialize ⇒ ServiceFeedsService
Returns a new instance of ServiceFeedsService.
65 66 67 68 69 70 71 |
# File 'app/services/vendors_service/google_reserve/service_feeds_service.rb', line 65 def initialize super() BUSINESS_LOGGER.set_business_context({ vendor_name: ApiVendorV1::Constants::GOOGLE_RESERVE_VENDOR_NAME, feed_type: 'service_feeds', }) end |
Instance Method Details
#generate_and_upload_feed ⇒ Boolean
Main entry point for the service feed generation process
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/services/vendors_service/google_reserve/service_feeds_service.rb', line 77 def generate_and_upload_feed return false unless Flipper.enabled?(:google_reserve_e2e) BUSINESS_LOGGER.info("#{self.class}: Starting Google Reserve service feeds generation") restaurants = eligible_restaurants_query BUSINESS_LOGGER.info("#{self.class}: Found restaurants for Google Reserve feed", { count: restaurants.count }) data = [] restaurants.find_each do |restaurant| data << build_data(restaurant.decorate) end json_data = build_to_json(data) generate_and_upload_feed_file(json_data, :service_feed) BUSINESS_LOGGER.info("#{self.class}: Successfully generated Google Reserve service feed") true rescue StandardError => e APMErrorHandler.report('Failed to generate Google Reserve service feed', exception: e) raise e end |