<?php

use FiloBlu\Esb\Api\Data\ConsumerInterface;
use FiloBlu\Esb\Api\Data\MessageInterface;
use FiloBlu\Esb\Api\Data\MessageInterfaceFactory;
use FiloBlu\Refilo\Model\Consumer\NewsletterConsumer;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\State;
use Magento\Framework\DataObject;
use FiloBlu\Refilo\Model\NewsletterManagement;

require __DIR__ . '/../../../../../app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$obj = $bootstrap->getObjectManager();
$state = $obj->get(State::class);
$state->setAreaCode('adminhtml');
$objectManager = ObjectManager::getInstance();

//$data = json_decode('{}', true);

$data = [
    'form_type' => 'newsletter',
    'fields' => []
];

///////////////////////////////////////////////////////////////////////////////
///
///
//////////////////////////////////////////////////////////////////////////////

$payload = new DataObject(['data' => $data]);

/** @var  MessageInterface $message */
/** @var  ConsumerInterface $formConsumer */
$formConsumer = $objectManager->get(NewsletterConsumer::class);


///////////////////////////////////////////////////////////////////////////////
///
/// Dispatch
///
//////////////////////////////////////////////////////////////////////////////

$formConsumer->consume($message);
