| /* |
| Example Action feed for Google Order Redirect. |
| */ |
| |
| import { |
| ActionFeed, ActionDetail, FoodOrderingInfo_ServiceType |
| } from './generated/action'; |
| |
| function createFeed() : string { |
| // Create ActionDetail using one link for both delivery and takeout |
| const actionDetailCombined: ActionDetail = { |
| entity_id: 'merchant-1', |
| link_id: 'merchant-1-takeout-delivery-action', |
| actions: [ |
| { |
| food_ordering_info: { |
| service_type: FoodOrderingInfo_ServiceType.DELIVERY |
| } |
| }, |
| { |
| food_ordering_info: { |
| service_type: FoodOrderingInfo_ServiceType.TAKEOUT |
| } |
| } |
| ], |
| url: 'http://provider.com/merchant-1' |
| }; |
| |
| // Create ActionDetail using a separate link for delivery |
| const actionDetailDelivery: ActionDetail = { |
| entity_id: 'merchant-2', |
| link_id: 'merchant-2-delivery-action', |
| actions: [ |
| { |
| food_ordering_info: { |
| service_type: FoodOrderingInfo_ServiceType.DELIVERY |
| } |
| } |
| ], |
| url: 'http://provider.com/merchant-2/delivery' |
| }; |
| |
| // Add ActionDetail to feed data array |
| const feed: ActionFeed = { |
| data:[actionDetailCombined, actionDetailDelivery] |
| }; |
| |
| // Serialize feed to JSON |
| return JSON.stringify(feed); |
| } |
| |
| const feedJSON = createFeed(); |
| console.log(feedJSON); |