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 a2986a3 commit 2ea3113
Showing 1 changed file with 51 additions and 56 deletions.
107 changes: 51 additions & 56 deletions app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,62 @@ function processWebhookData():void {
}
}

/**
* Add "Cleaned Emails" notification to Adminnotification Inbox <cleaned>
*
* @param array $data
* @return void
*/
private function _clean(array $data):void {
//Delete subscriber from Magento
$helper = hcg_mc_h();
$s = $helper->loadListSubscriber($data['list_id'], $data['email']);

if ($s && $s->getId()) {
try {
$s->delete();
} catch (Exception $e) {
Mage::logException($e);
}
}
}

/**
* 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;}

/**
* 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::processWebhookData()
* @throws Mage_Core_Exception
*/
private function _profile(array $d):void {$this->getMailchimpTagsModel()->processMergeFields($d);}

/**
* @param $webhookRequest
*/
private function _saveProcessedWebhook($webhookRequest):void {$webhookRequest->setProcessed(1)->save();}

/**
* Subscribe email to Magento list, store aware
*
* @param array $data
* @return void
*/
private function _subscribe(array $data):void {
try {
$subscribe = true;
$this->getMailchimpTagsModel()->processMergeFields($data, $subscribe);
} catch (Exception $e) {
Mage::logException($e);
}
}

/**
* Update customer email <upemail>
*
Expand Down Expand Up @@ -95,26 +146,6 @@ private function _updateEmail(array $data):void {
}
}

/**
* Add "Cleaned Emails" notification to Adminnotification Inbox <cleaned>
*
* @param array $data
* @return void
*/
private function _clean(array $data):void {
//Delete subscriber from Magento
$helper = hcg_mc_h();
$s = $helper->loadListSubscriber($data['list_id'], $data['email']);

if ($s && $s->getId()) {
try {
$s->delete();
} catch (Exception $e) {
Mage::logException($e);
}
}
}

/**
* Unsubscribe or delete email from Magento list, store aware
*
Expand Down Expand Up @@ -155,42 +186,6 @@ private function _unsubscribe(array $data):void {
}
}

private function _getStoreId()
{
return Mage::app()->getStore()->getId();
}

/**
* 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::processWebhookData()
* @throws Mage_Core_Exception
*/
private function _profile(array $d):void {$this->getMailchimpTagsModel()->processMergeFields($d);}

/**
* Subscribe email to Magento list, store aware
*
* @param array $data
* @return void
*/
private function _subscribe(array $data):void {
try {
$subscribe = true;
$this->getMailchimpTagsModel()->processMergeFields($data, $subscribe);
} catch (Exception $e) {
Mage::logException($e);
}
}

/**
* 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;}

const BATCH_LIMIT = 200;

/**
Expand Down

0 comments on commit 2ea3113

Please sign in to comment.