/** * @return Esendex_Sms_Model_Api_Api */ public function getEsendexApi() { if (!$this->esendexApi) { $this->esendexApi = Esendex_Sms_Model_Api_Factory::getInstance(); } return $this->esendexApi; }
/** * @param Varien_Event_Observer $observer */ public function refreshAccountCache(Varien_Event_Observer $observer) { if ($this->helper()->hasNotFilledInAccountDetails()) { return false; } //event listener will trigger re-cache try { $account = Esendex_Sms_Model_Api_Factory::getAccount(false); } catch (HttpException $e) { } }
/** * If there was an error getting the account * return false * * @return bool|Account */ public function getAccount() { if (!$this->account) { try { $this->account = Esendex_Sms_Model_Api_Factory::getAccount(); } catch (\Esendex\Http\HttpException $e) { $this->account = false; } } return $this->account; }
/** * @return array|bool */ public function getNotifications() { if ($this->helper()->hasNotFilledInAccountDetails()) { return array(); } try { $account = Esendex_Sms_Model_Api_Factory::getAccount(); } catch (\Esendex\Http\HttpException $e) { //account not authorised $notifications[] = $this->getInvalidAuthNotification(); return $notifications; } if (null === $account) { return array($this->getAccountExpiredOrIncorrectDetailsNotification(Mage::getStoreConfig('esendex_sms/sms/account_reference'))); } $notifications = array(); if ($this->accountExpiryLooming($account)) { $notifications[] = $this->getExpiryNotification($account); } if ($this->hasWarnLimit() && $this->remainingMessagesBelowThreshold($account)) { $notifications[] = $this->helper()->__('Your Esendex account %1$s has %2$d messages left', $account->reference(), $account->messagesRemaining()); } return $notifications; }
/** * @return \Esendex\Model\Account */ public function getEsendexAccount() { return Esendex_Sms_Model_Api_Factory::getAccount(); }