|  | /** | 
|  | Example Action feed for Google Order Redirect. | 
|  | **/ | 
|  |  | 
|  | package com.example.order_redirect; | 
|  |  | 
|  | import com.google.protobuf.InvalidProtocolBufferException; | 
|  | import com.google.protobuf.util.JsonFormat; | 
|  | import com.google.madden.ingestion.ActionFeed; | 
|  | import com.google.madden.ingestion.Action; | 
|  | import com.google.madden.ingestion.ActionDetail; | 
|  | import com.google.madden.ingestion.FoodOrderingInfo; | 
|  |  | 
|  |  | 
|  | public class ActionFeedExample { | 
|  |  | 
|  | public static void main(String[] args) throws InvalidProtocolBufferException { | 
|  | ActionFeedExample feed = new ActionFeedExample(); | 
|  | String feedJSON = feed.createActionFeed(); | 
|  | System.out.println(feedJSON); | 
|  | } | 
|  |  | 
|  | public String createActionFeed() throws InvalidProtocolBufferException { | 
|  |  | 
|  | // Create ActionFeed | 
|  | ActionFeed.Builder actionFeed = ActionFeed.newBuilder(); | 
|  |  | 
|  | // Create ActionDetail using one link for both takeout and delivery | 
|  | ActionDetail actionDetailDeliveryTakeout = ActionDetail.newBuilder() | 
|  | .setEntityId("merchant-1") | 
|  | .setLinkId("merchant-1-takeout-delivery-action") | 
|  | .setUrl("http://provider.com/merchant-1") | 
|  | .addActions( | 
|  | Action.newBuilder().setFoodOrderingInfo( | 
|  | FoodOrderingInfo.newBuilder().setServiceType( | 
|  | FoodOrderingInfo.ServiceType.DELIVERY | 
|  | ) | 
|  | ) | 
|  | ) | 
|  | .addActions( | 
|  | Action.newBuilder().setFoodOrderingInfo( | 
|  | FoodOrderingInfo.newBuilder().setServiceType( | 
|  | FoodOrderingInfo.ServiceType.TAKEOUT | 
|  | ) | 
|  | ) | 
|  | ).build(); | 
|  |  | 
|  | // Add to feed data | 
|  | actionFeed.addData(actionDetailDeliveryTakeout); | 
|  |  | 
|  | // Create ActionDetail using a separate link for delivery | 
|  | ActionDetail actionDetailDelivery = ActionDetail.newBuilder() | 
|  | .setEntityId("merchant-2") | 
|  | .setLinkId("merchant-2-delivery-action") | 
|  | .setUrl("http://provider.com/merchant-2/delivery") | 
|  | .addActions( | 
|  | Action.newBuilder().setFoodOrderingInfo( | 
|  | FoodOrderingInfo.newBuilder().setServiceType( | 
|  | FoodOrderingInfo.ServiceType.DELIVERY | 
|  | ) | 
|  | ) | 
|  | ).build(); | 
|  |  | 
|  | // Add to feed data | 
|  | actionFeed.addData(actionDetailDelivery); | 
|  |  | 
|  | // Serialize feed to JSON string | 
|  | return JsonFormat.printer() | 
|  | .omittingInsignificantWhitespace() | 
|  | .preservingProtoFieldNames() | 
|  | .print(actionFeed); | 
|  | } | 
|  |  | 
|  | } |