blob: c2f19eaab182e8a046e0a293858d492220e586ad [file] [log] [blame]
import json
from generated import action_pb2
from google.protobuf.json_format import MessageToDict
#create feed
feed = action_pb2.ActionFeed()
#create action
action = feed.data.add()
action.entity_id = 'merchant-1'
action.link_id = 'merchant-1-takeout-delivery-action'
action.actions.extend([
action_pb2.Action(
food_ordering_info=action_pb2.FoodOrderingInfo(
service_type=action_pb2.FoodOrderingInfo.ServiceType.DELIVERY
)
),
action_pb2.Action(
food_ordering_info=action_pb2.FoodOrderingInfo(
service_type=action_pb2.FoodOrderingInfo.ServiceType.TAKEOUT
)
)
])
action.url = "http://provider.com/merchant-1"
feedJSON = json.dumps(MessageToDict(feed, preserving_proto_field_name=True))
print(feedJSON)