-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
500b2b2
commit fed9fad
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* mc-magento2 Magento Component | ||
* | ||
* @category Ebizmarts | ||
* @package mc-magento2 | ||
* @author Ebizmarts Team <info@ebizmarts.com> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @date: 3/12/18 4:14 PM | ||
* @file: CreateWebhook.php | ||
*/ | ||
|
||
namespace Ebizmarts\MailChimp\Controller\Adminhtml\Ecommerce; | ||
|
||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Exception\ValidatorException; | ||
use Symfony\Component\Config\Definition\Exception\Exception; | ||
|
||
class CreateWebhook extends \Magento\Backend\App\Action | ||
{ | ||
/** | ||
* @var JsonFactory | ||
*/ | ||
protected $resultJsonFactory; | ||
/** | ||
* @var \Ebizmarts\MailChimp\Helper\Data | ||
*/ | ||
protected $helper; | ||
/** | ||
* @var \Magento\Store\Model\StoreManagerInterface | ||
*/ | ||
protected $storeManager; | ||
|
||
/** | ||
* DeleteStore constructor. | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param JsonFactory $resultJsonFactory | ||
* @param \Magento\Store\Model\StoreManagerInterface $storeManagerInterface | ||
* @param \Ebizmarts\MailChimp\Helper\Data $helper | ||
* @param \Magento\Config\Model\ResourceModel\Config $config | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\App\Action\Context $context, | ||
JsonFactory $resultJsonFactory, | ||
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface, | ||
\Ebizmarts\MailChimp\Helper\Data $helper, | ||
\Magento\Config\Model\ResourceModel\Config $config | ||
) | ||
{ | ||
parent::__construct($context); | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->helper = $helper; | ||
$this->storeManager = $storeManagerInterface; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$valid = 1; | ||
$message = ''; | ||
$params = $this->getRequest()->getParams(); | ||
$apiKey = $params['apikey']; | ||
$listId = $params['listId']; | ||
$return = $this->helper->createWebHook($apiKey, $listId); | ||
if(isset($return['message'])) { | ||
$valid = 0; | ||
$message = $return['message']; | ||
} | ||
$resultJson = $this->resultJsonFactory->create(); | ||
|
||
return $resultJson->setData([ | ||
'valid' => (int)$valid, | ||
'message' => $message, | ||
]); | ||
|
||
} | ||
protected function _isAllowed() | ||
{ | ||
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp'); | ||
} | ||
|
||
} |