public function after(GuzzleCommandInterface $command, RequestInterface $request, Operation $operation, array $context) { $additional = $operation->getAdditionalParameters(); if ($additional && $additional->getLocation() == $this->locationName) { foreach ($command->toArray() as $key => $value) { if (!$operation->hasParam($key)) { $request->setHeader($key, $additional->filter($value)); } } } }
public function after(GuzzleCommandInterface $command, RequestInterface $request, Operation $operation, array $context) { $additional = $operation->getAdditionalParameters(); if ($additional && $additional->getLocation() == $this->locationName) { foreach ($command->toArray() as $key => $value) { if (!$operation->hasParam($key)) { $query = $request->getQuery(); $query[$key] = $this->prepareValue($value, $additional); } } } }
public function after(GuzzleCommandInterface $command, RequestInterface $request, Operation $operation, array $context) { $additional = $operation->getAdditionalParameters(); if ($additional && $additional->getLocation() == $this->locationName) { $body = $request->getBody(); if (!$body instanceof PostBodyInterface) { throw new \RuntimeException('Must be a POST body interface'); } foreach ($command->toArray() as $key => $value) { if (!$operation->hasParam($key)) { $body->setField($key, $this->prepareValue($value, $additional)); } } } }
public function after(GuzzleCommandInterface $command, RequestInterface $request, Operation $operation, array $context) { $data = $this->jsonData; $this->jsonData = null; // Add additional parameters to the JSON document $additional = $operation->getAdditionalParameters(); if ($additional && $additional->getLocation() == $this->locationName) { foreach ($command->toArray() as $key => $value) { if (!$operation->hasParam($key)) { $data[$key] = $this->prepareValue($value, $additional); } } } // Don't overwrite the Content-Type if one is set if ($this->jsonContentType && !$request->hasHeader('Content-Type')) { $request->setHeader('Content-Type', $this->jsonContentType); } $request->setBody(Stream::factory(json_encode($data))); }