Пример #1
0
 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');
     }
 }
Пример #2
0
 protected function executeRequest(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
 {
     // parse body
     $parser = $this->templateFactory->newTextParser();
     $body = $parser->parse($request, $context, $configuration->get('body'));
     // build request
     $method = $configuration->get('method') ?: 'POST';
     $headers = $this->parserHeaders($configuration->get('headers'));
     $request = new Request(new Url($configuration->get('url')), $method, $headers, $body);
     return $this->http->request($request);
 }