Skip to content

Commit

Permalink
https://github.com/thehcginstitute-com/m1/issues/590
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed May 2, 2024
1 parent f543a9a commit d30011d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
14 changes: 0 additions & 14 deletions app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ final class Ebizmarts_MailChimp_Model_ProcessWebhook {
* "Refactor `Ebizmarts_MailChimp_Model_ProcessWebhook`": https://github.com/cabinetsbay/site/issues/590
* @used-by Ebizmarts_MailChimp_Model_Cron::deleteWebhookRequests()
* @used-by Ebizmarts_MailChimp_Model_Cron::processWebhookData()
* @used-by Ebizmarts_MailChimp_WebhookController::indexAction()
*/
function __construct() {
$this->_helper = hcg_mc_h();
Expand All @@ -18,19 +17,6 @@ function __construct() {
$this->_interestGroupHandle = Mage::getModel('mailchimp/api_subscribers_InterestGroupHandle');
}

/**
* 2024-05-02 Dmitrii Fediuk https://upwork.com/fl/mage2pro
* "Refactor `Ebizmarts_MailChimp_Model_ProcessWebhook`": https://github.com/cabinetsbay/site/issues/590
* @used-by Ebizmarts_MailChimp_WebhookController::indexAction()
*/
function saveWebhookRequest(array $data):void {
Mage::getModel('mailchimp/webhookrequest')
->setType($data['type'])
->setFiredAt($data['fired_at'])
->setDataRequest($this->_helper->serialize($data['data']))
->save();
}

/**
* Process Webhook request
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
use Ebizmarts_MailChimp_Model_ProcessWebhook as Process;
class Ebizmarts_MailChimp_WebhookController extends Mage_Core_Controller_Front_Action
{
protected $_mailchimpHelper = null;
Expand Down Expand Up @@ -69,8 +68,7 @@ function indexAction()
//Validate "wkey" GET parameter
if ($myKey == $requestKey) {
if ($request->getPost('type')) {
$p = new Process; /** @var Process $p */
$p->saveWebhookRequest($data);
self::saveWebhookRequest($data);
}
# 2024-03-16 Dmitrii Fediuk https://upwork.com/fl/mage2pro
# "«Webhook successfully created» should not be logged as an error my MailChimp":
Expand Down Expand Up @@ -113,4 +111,17 @@ protected function _deleteWebhook($storeId, $listId)
}
}
}

/**
* 2024-05-02 Dmitrii Fediuk https://upwork.com/fl/mage2pro
* "Refactor `Ebizmarts_MailChimp_Model_ProcessWebhook`": https://github.com/cabinetsbay/site/issues/590
* @used-by Ebizmarts_MailChimp_WebhookController::indexAction()
*/
private static function saveWebhookRequest(array $d):void {
Mage::getModel('mailchimp/webhookrequest')
->setType($d['type'])
->setFiredAt($d['fired_at'])
->setDataRequest(hcg_mc_h()->serialize($d['data']))
->save();
}
}
1 change: 1 addition & 0 deletions app/code/local/HCG/MailChimp/lib/h/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
* @used-by Ebizmarts_MailChimp_Model_System_Config_Source_List::makeHelper()
* @used-by Ebizmarts_MailChimp_Model_System_Config_Source_Store::makeHelper()
* @used-by Ebizmarts_MailChimp_Model_System_Config_Source_Userinfo::toOptionArray()
* @used-by Ebizmarts_MailChimp_WebhookController::saveWebhookRequest()
* @used-by HCG\MailChimp\Batch\HandleErrorItem::p()
* @used-by HCG\MailChimp\Observer\AddTabToCustomer::p() (https://github.com/thehcginstitute-com/m1/issues/580)
* @used-by app/design/adminhtml/default/default/template/ebizmarts/mailchimp/customer/tab/mailchimp.phtml
Expand Down

0 comments on commit d30011d

Please sign in to comment.