blob: 905c81d7935179ffeb30ed0478b1a65100531e10 [file] [log] [blame]
Ryan Conigliaro5f455a72024-01-03 18:01:34 +00001<?php
2/*
Ryan Conigliaroa69c69f2024-01-03 18:18:58 +00003Example Entity feed for Google Order Redirect. Create build/gen directory for generated proto classes.
4Download lastest version of protoc from https://github.com/protocolbuffers/protobuf/releases
5Generate proto classes with:
Ryan Conigliaro63775b02024-01-03 21:16:31 +00006 protoc --php_out=./build/gen --proto_path=../proto/ ../proto/entity.proto
7
8See https://protobuf.dev/reference/php/php-generated/ for more details.
Ryan Conigliaro5f455a72024-01-03 18:01:34 +00009*/
10
11require dirname(__FILE__).'/vendor/autoload.php';
12
13use Madden\Ingestion\EntityFeed;
14use Madden\Ingestion\Entity;
15use Madden\Ingestion\GeoCoordinates;
16use Madden\Ingestion\PostalAddress;
17
18
19function createFeed() {
20 // Create Entity by using setter methods
21 $entity = new Entity();
22 $entity->setEntityId("merchant-1");
23 $entity->setName("Mo's Dinner");
24 $entity->setTelephone("+14567891234");
25 $entity->setUrl("http://moesdinner.com");
26 $entityLocation = new GeoCoordinates();
27 $entityLocation->setLatitude(41.525588);
28 $entityLocation->setLongitude(-90.507067);
29 $entity->setLocation($entityLocation);
30 $entityAddress = new PostalAddress();
31 $entityAddress->setCountry("US");
32 $entityAddress->setLocality("Mountain View");
33 $entityAddress->setRegion("CA");
34 $entityAddress->setPostalCode("94043");
35 $entityAddress->setStreetAddress("1600 Amphitheatre Pkwy");
36 $entityLocation->setAddress($entityAddress);
37
Ryan Conigliaro45b53362024-01-03 18:04:21 +000038 // Add Entity to feed data
Ryan Conigliaro5f455a72024-01-03 18:01:34 +000039 $feed = new EntityFeed();
40 $feed->setData(array($entity));
41
Ryan Conigliaro45b53362024-01-03 18:04:21 +000042 // Serialize to JSON
Ryan Conigliaro5f455a72024-01-03 18:01:34 +000043 return $feed->serializeToJsonString();
44}
45
46$feedJSON = createFeed();
47echo $feedJSON;
48