blob: 83558d214e8115a91e4d510ad9b97257c5ed89a3 [file] [log] [blame]
<?php
/*
Example Action feed for Google Order Redirect.
*/
require dirname(__FILE__).'/vendor/autoload.php';
use Madden\Ingestion\ActionFeed;
use Madden\Ingestion\ActionDetail;
use Madden\Ingestion\Action;
use Madden\Ingestion\FoodOrderingInfo;
use Madden\Ingestion\FoodOrderingInfo\ServiceType;
function createFeed() {
// Create ActionDetail by passing the fields to the constructor
$actions = array(
// Example using one link for both takeout and delivery
new ActionDetail([
'entity_id' => 'merchant-1',
'link_id' => 'merchant-1-takeout-delivery-action',
'actions' => array(
new Action([
'food_ordering_info' => new FoodOrderingInfo([
'service_type' => ServiceType::DELIVERY
])
]),
new Action([
'food_ordering_info' => new FoodOrderingInfo([
'service_type' => ServiceType::TAKEOUT
])
])
),
'url' => 'http://provider.com/merchant-1'
]),
// Example using a separate link for delivery
new ActionDetail([
'entity_id' => 'merchant-2',
'link_id' => 'merchant-2-delivery-action',
'actions' => array(
new Action([
'food_ordering_info' => new FoodOrderingInfo([
'service_type' => ServiceType::DELIVERY
])
])
),
'url' => 'http://provider.com/merchant-2/delivery'
])
);
// Add ActionDetail array to feed data
$feed = new ActionFeed();
$feed->setData($actions);
// Serialize to JSON
return $feed->serializeToJsonString();
}
$feedJSON = createFeed();
echo $feedJSON;