analyticsToken = $analyticsToken; $this->integrationManager = $integrationManager; $this->config = $config; $this->httpClient = $httpClient; $this->logger = $logger; $this->responseResolver = $responseResolver; } /** * Executes signUp command * * During this call Magento generates or retrieves access token for the integration user * In case successful generation Magento activates user and sends access token to MA * As the response, Magento receives a token to MA * Magento stores this token in System Configuration * * This method returns true in case of success * * @return bool */ public function execute() { $result = false; $integrationToken = $this->integrationManager->generateToken(); if ($integrationToken) { $this->integrationManager->activateIntegration(); $response = $this->httpClient->request( ZendClient::POST, $this->config->getValue($this->signUpUrlPath), [ "token" => $integrationToken->getData('token'), "url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL), ] ); $result = $this->responseResolver->getResult($response); if (!$result) { $this->logger->warning( sprintf( 'Subscription for MBI service has been failed. An error occurred during token exchange: %s.' . ' Content-Type: %s', !empty($response->getBody()) ? $response->getBody() : 'Response body is empty', $response->getHeader('Content-Type') ) ); } } return (bool)$result; } }