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 dd09e20 commit a85c7c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class Ebizmarts_MailChimp_Model_Api_Subscribers_MailchimpTags {
* https://github.com/cabinetsbay/site/issues/589
* @used-by Ebizmarts_MailChimp_Model_Api_Customers::_buildMailchimpTags()
* @used-by Ebizmarts_MailChimp_Model_Api_Subscribers::_buildMailchimpTags()
* @used-by Ebizmarts_MailChimp_Model_ProcessWebhook::__construct()
* @used-by Ebizmarts_MailChimp_Model_ProcessWebhook::processWebhookData()
*/
function __construct() {
$this->setMailChimpHelper();
Expand Down Expand Up @@ -114,8 +114,7 @@ function getStoreId() {return $this->_storeId;}
function getSubscriber():Sub {return $this->_subscriber;}

/**
* @used-by Ebizmarts_MailChimp_Model_ProcessWebhook::_profile()
* @used-by Ebizmarts_MailChimp_Model_ProcessWebhook::_subscribe()
* @used-by Ebizmarts_MailChimp_Model_ProcessWebhook::processWebhookData()
* @param $data
* @param bool $subscribe
* @throws Mage_Core_Exception
Expand Down
32 changes: 6 additions & 26 deletions app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
# "Refactor `Ebizmarts_MailChimp_Model_ProcessWebhook`": https://github.com/cabinetsbay/site/issues/590
use Ebizmarts_MailChimp_Model_Api_Subscribers_MailchimpTags as Tags;
final class Ebizmarts_MailChimp_Model_ProcessWebhook {
/**
* 2024-05-02 Dmitrii Fediuk https://upwork.com/fl/mage2pro
* "Refactor `Ebizmarts_MailChimp_Model_ProcessWebhook`": https://github.com/cabinetsbay/site/issues/590
* @used-by Aoe_Scheduler_Model_Observer::dispatch() (app/code/community/Ebizmarts/MailChimp/etc/config.xml)
*/
function __construct() {
$this->_tags = new Tags;
}

/**
* 2024-05-02 Dmitrii Fediuk https://upwork.com/fl/mage2pro
* "Refactor `Ebizmarts_MailChimp_Model_ProcessWebhook`": https://github.com/cabinetsbay/site/issues/590
Expand Down Expand Up @@ -41,9 +32,14 @@ function processWebhookData():void {

if ($data) {
switch ($webhookRequest->getType()) {
case 'profile':
$tags = new Tags;
$tags->processMergeFields($data);
break;
case 'subscribe':
try {
$this->getMailchimpTagsModel()->processMergeFields($data, true);
$tags = new Tags;
$tags->processMergeFields($data, true);
} catch (Exception $e) {
Mage::logException($e);
}
Expand All @@ -56,9 +52,6 @@ function processWebhookData():void {
break;
case 'upemail':
$this->_updateEmail($data);
break;
case 'profile':
$this->getMailchimpTagsModel()->processMergeFields($data);
}
}

Expand Down Expand Up @@ -86,14 +79,6 @@ private function _clean(array $data):void {
}
}

/**
* 2024-05-02 Dmitrii Fediuk https://upwork.com/fl/mage2pro
* "Refactor `Ebizmarts_MailChimp_Model_ProcessWebhook`": https://github.com/cabinetsbay/site/issues/590
* @used-by self::_profile()
* @used-by self::_subscribe()
*/
private function getMailchimpTagsModel():Tags {return $this->_tags;}

/**
* @param $webhookRequest
*/
Expand Down Expand Up @@ -169,11 +154,6 @@ private function _unsubscribe(array $data):void {

const BATCH_LIMIT = 200;

/**
* @var Ebizmarts_MailChimp_Model_Api_Subscribers_MailchimpTags
*/
private $_tags;

/**
* Webhooks request url path
*
Expand Down

0 comments on commit a85c7c8

Please sign in to comment.