blob: c7677727d04020f9ce73d9e9c930673007fde466 [file] [log] [blame]
import json
from generated import food_service_pb2
from generated import timeofday_pb2
from google.protobuf.json_format import MessageToDict
#create feed
feed = food_service_pb2.FoodServiceFeed()
#create food_service
service_data = feed.data.add()
service_data.service.service_id = 'merchant-1-service-delivery'
service_data.service.service_type = food_service_pb2.FoodOrderingService.ServiceType.DELIVERY
service_data.service.parent_entity_id = 'merchant-1'
service_data.service.lead_time.min_lead_time_duration.seconds = 1200
service_data.service.action_link_id = 'merchant-1-takeout-delivery-action'
#create fee
fee_data = feed.data.add()
fee_data.fee.fee_id = 'merchant-1-fee-delivery'
fee_data.fee.fee_type = food_service_pb2.Fee.FeeType.DELIVERY
fee_data.fee.fixed_amount.currency_code = 'USD'
fee_data.fee.fixed_amount.units = 2
fee_data.fee.service_ids.append('merchant-1-service-delivery')
#create service hours
service_hours_data = feed.data.add()
service_hours_data.service_hours.hours_id = 'merchant-1-advance-hours-delivery'
service_hours_data.service_hours.service_ids.append('merchant-1-service-delivery')
asap_hours = service_hours_data.service_hours.asap_hours.add()
asap_hours.time_windows.MergeFrom(food_service_pb2.TimeOfDayWindow(
time_windows=food_service_pb2.TimeOfDayRange(
open_time=timeofday_pb2.TimeOfDay(
hours=11,
minutes=00
),
close_time=timeofday_pb2.TimeOfDay(
hours=22,
minutes=30
)
)
)
)
asap_hours.lead_time.min_lead_time_duration.seconds = 2400
feedJSON = json.dumps(MessageToDict(feed, preserving_proto_field_name=True))
print(feedJSON)