blob: dc32d4b5aa7da27d986329d097626d68642a2fb6 [file] [log] [blame]
<?php
/*
Example Entity feed for Google Order Redirect. Create build/gen directory for generated proto classes.
Download lastest version of protoc from https://github.com/protocolbuffers/protobuf/releases
Generate proto classes with:
protoc --php_out=./build/gen --proto_path=../proto/ ../proto/*.proto ../proto/google/type/*.proto
*/
require dirname(__FILE__).'/vendor/autoload.php';
use Madden\Ingestion\EntityFeed;
use Madden\Ingestion\Entity;
use Madden\Ingestion\GeoCoordinates;
use Madden\Ingestion\PostalAddress;
function createFeed() {
// Create Entity by using setter methods
$entity = new Entity();
$entity->setEntityId("merchant-1");
$entity->setName("Mo's Dinner");
$entity->setTelephone("+14567891234");
$entity->setUrl("http://moesdinner.com");
$entityLocation = new GeoCoordinates();
$entityLocation->setLatitude(41.525588);
$entityLocation->setLongitude(-90.507067);
$entity->setLocation($entityLocation);
$entityAddress = new PostalAddress();
$entityAddress->setCountry("US");
$entityAddress->setLocality("Mountain View");
$entityAddress->setRegion("CA");
$entityAddress->setPostalCode("94043");
$entityAddress->setStreetAddress("1600 Amphitheatre Pkwy");
$entityLocation->setAddress($entityAddress);
// Add Entity to feed data
$feed = new EntityFeed();
$feed->setData(array($entity));
// Serialize to JSON
return $feed->serializeToJsonString();
}
$feedJSON = createFeed();
echo $feedJSON;