blob: 905c81d7935179ffeb30ed0478b1a65100531e10 [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/entity.proto
See https://protobuf.dev/reference/php/php-generated/ for more details.
*/
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;