public function beforeSubscribe($subscriber, $email) { $storeId = $this->_storeManager->getStore()->getId(); $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $email; if (!$isSubscribeOwnEmail) { if ($this->_helper->isMonkeyEnabled($storeId)) { $subscriber->setImportMode(true); $api = $this->_api; if ($this->_helper->isDoubleOptInEnabled($storeId)) { $status = 'pending'; } else { $status = 'subscribed'; } $data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $email, 'email_type' => 'html', 'status' => $status, 'merge_fields' => ['EMAIL' => $email]]; try { $return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data)); if (isset($return->id)) { $subscriber->setMagemonkeyId($return->id); } } catch (\Exception $e) { $this->_helper->log($e->getMessage()); } } } return [$email]; }
public function listDeleteMember($listId, $memberId) { $this->_helper->log('Delete Member with Id: ' . $memberId); $response = $this->callServer('DELETE', 'lists', [0 => $listId, 'members' => $memberId]); $this->_helper->log($response); return $response; }