blob: 085b4b3abda7e94e44fa5f41589c7db99e7e0057 [file] [log] [blame]
/**
Example Entity 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.EntityFeed;
import com.google.madden.ingestion.Entity;
import com.google.madden.ingestion.PostalAddress;
import com.google.madden.ingestion.GeoCoordinates;
public class EntityFeedExample {
public static void main(String[] args) throws InvalidProtocolBufferException {
EntityFeedExample feed = new EntityFeedExample();
String feedJSON = feed.createEntityFeed();
System.out.println(feedJSON);
}
public String createEntityFeed() throws InvalidProtocolBufferException {
// Create Entity
Entity entity = Entity.newBuilder()
.setEntityId("merchant-1")
.setName("Mo's Dinner")
.setTelephone("+14567891234")
.setUrl("http://moesdinner.com")
.setLocation(
GeoCoordinates.newBuilder()
.setLatitude(41.525588)
.setLongitude(-90.507067)
.setAddress(
PostalAddress.newBuilder()
.setCountry("US")
.setLocality("Mountain View")
.setRegion("CA")
.setPostalCode("94043")
.setStreetAddress("1600 Amphitheatre Pkwy")
.build()
)
).build();
// Add to feed data
EntityFeed entityFeed = EntityFeed.newBuilder().addData(entity).build();
// Serialize feed to JSON string
return JsonFormat.printer()
.omittingInsignificantWhitespace()
.preservingProtoFieldNames()
.print(entityFeed);
}
}