analyticsToken = $analyticsToken; $this->otpRequest = $otpRequest; $this->config = $config; $this->flagManager = $flagManager; } /** * Provide URL on resource with reports. * * @return string * @throws SubscriptionUpdateException */ public function getUrl() { if ($this->flagManager->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)) { throw new SubscriptionUpdateException(__( 'Your Base URL has been changed and your reports are being updated. ' . 'Advanced Reporting will be available once this change has been processed. Please try again later.' )); } $url = $this->config->getValue($this->urlReportConfigPath); if ($this->analyticsToken->isTokenExist()) { $otp = $this->otpRequest->call(); if ($otp) { $query = http_build_query(['otp' => $otp], '', '&'); $url .= '?' . $query; } } return $url; } }