public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context) { $response = $this->executeRequest($request, $configuration, $context); if ($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) { return $this->response->build(200, [], ['success' => true, 'message' => 'Request successful']); } else { return $this->response->build(500, [], ['success' => false, 'message' => 'Request failed']); } }
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context) { // parse json $parser = $this->templateFactory->newTextParser(); $response = $parser->parse($request, $context, $configuration->get('response')); if (!empty($response)) { $statusCode = $configuration->get('statusCode') ?: 200; return $this->response->build($statusCode, [], Json::decode($response, false)); } else { throw new ConfigurationException('No response defined'); } }