requestBuilder = $requestBuilder; $this->transferFactory = $transferFactory; $this->client = $client; $this->validator = $validator; $this->logger = $logger; } /** * @inheritdoc * * @throws Exception */ public function execute(array $commandSubject): ResultInterface { $transferO = $this->transferFactory->create( $this->requestBuilder->build($commandSubject) ); try { $response = $this->client->placeRequest($transferO); } catch (Exception $e) { $this->logger->critical($e); throw new CommandException(__('There was an error while trying to process the request.')); } $result = $this->validator->validate( array_merge($commandSubject, ['response' => $response]) ); if (!$result->isValid()) { throw new CommandException(__('There was an error while trying to process the request.')); } return new ArrayResult($response); } }