* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PsAccounts\Service; use PrestaShop\Module\PsAccounts\Adapter\Link; use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository; /** * Class PsAccountsService */ class PsAccountsService { /** * @var Link */ protected $link; /** * @var ConfigurationRepository */ private $configuration; /** * @var \Ps_accounts */ private $module; /** * @var ShopTokenService */ private $shopTokenService; /** * PsAccountsService constructor. * * @param \Ps_accounts $module * @param ShopTokenService $shopTokenService * @param ConfigurationRepository $configuration * @param Link $link */ public function __construct( \Ps_accounts $module, ShopTokenService $shopTokenService, ConfigurationRepository $configuration, Link $link ) { $this->configuration = $configuration; $this->shopTokenService = $shopTokenService; $this->module = $module; $this->link = $link; } /** * @return string */ public function getSuperAdminEmail() { return (new \Employee(1))->email; } /** * @return string | false */ public function getShopUuidV4() { return $this->configuration->getShopUuid(); } /** * Get the user firebase token. * * @return string * * @throws \Exception */ public function getOrRefreshToken() { return $this->shopTokenService->getOrRefreshToken(); } /** * @return string|null */ public function getRefreshToken() { return $this->shopTokenService->getRefreshToken(); } /** * @return string|null */ public function getToken() { return $this->shopTokenService->getToken(); } /** * @return bool */ public function isEmailValidated() { return $this->configuration->firebaseEmailIsVerified(); } /** * @return string|null */ public function getEmail() { return $this->configuration->getFirebaseEmail(); } /** * @return bool * * @throws \Exception */ public function isAccountLinked() { /** @var ShopLinkAccountService $shopLinkAccountService */ $shopLinkAccountService = $this->module->getService(ShopLinkAccountService::class); return $shopLinkAccountService->isAccountLinked(); } /** * Generate ajax admin link with token * available via PsAccountsPresenter into page dom, * ex : * let url = window.contextPsAccounts.adminAjaxLink + '&action=unlinkShop' * * @return string * * @throws \PrestaShopException */ public function getAdminAjaxUrl() { // Tools::getAdminTokenLite('AdminAjaxPsAccounts')); return $this->link->getAdminLink('AdminAjaxPsAccounts', true, [], ['ajax' => 1]); } }