public function visit(GuzzleCommandInterface $command, ResponseInterface $response, Parameter $param, &$result, array $context = array()) { // Retrieving a single header by name $name = $param->getName(); if ($header = $response->getHeader($param->getWireName())) { $result[$name] = $param->filter($header); } }
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, array $context) { $body = $request->getBody(); if (!$body instanceof PostBodyInterface) { throw new \RuntimeException('Must be a POST body interface'); } $body->setField($param->getWireName(), $this->prepareValue($command[$param->getName()], $param)); }
public function visit(GuzzleCommandInterface $command, RequestInterface $request, Parameter $param, array $context) { $body = $request->getBody(); if (!$body instanceof PostBodyInterface) { throw new \RuntimeException('Must be a POST body interface'); } $value = $param->filter($command[$param->getName()]); if (!$value instanceof PostFileInterface) { $value = new PostFile($param->getWireName(), $value); } $body->addFile($value); }
public function visit(GuzzleCommandInterface $command, ResponseInterface $response, Parameter $param, &$result, array $context = array()) { $sentAs = $param->getWireName(); $ns = null; if (strstr($sentAs, ':')) { list($ns, $sentAs) = explode(':', $sentAs); } // Process the primary property if (count($this->xml->children($ns, true)->{$sentAs})) { $result[$param->getName()] = $this->recursiveProcess($param, $this->xml->children($ns, true)->{$sentAs}); } }
public function visit(CommandInterface $command, ResponseInterface $response, Parameter $param, &$result, array $context = []) { $name = $param->getName(); $key = $param->getWireName(); // Check if the result should be treated as a list if ($param->getType() == 'array') { // Treat as javascript array if ($name) { // name provided, store it under a key in the array $result[$name] = $this->recurse($param, $this->json[$name]); } else { // top-level `array` or an empty name $result = array_merge($result, $this->recurse($param, $this->json)); } } elseif (isset($this->json[$key])) { $result[$name] = $this->recurse($param, $this->json[$key]); } }
/** * Recursively build the XML body * * @param \XMLWriter $writer XML to modify * @param Parameter $param API Parameter * @param mixed $value Value to add */ protected function addXml(\XMLWriter $writer, Parameter $param, $value) { $value = $param->filter($value); $type = $param->getType(); $name = $param->getWireName(); $prefix = null; $namespace = $param->getData('xmlNamespace'); if (false !== strpos($name, ':')) { list($prefix, $name) = explode(':', $name, 2); } if ($type == 'object' || $type == 'array') { if (!$param->getData('xmlFlattened')) { if ($namespace) { $writer->startElementNS(null, $name, $namespace); } else { $writer->startElement($name); } } if ($param->getType() == 'array') { $this->addXmlArray($writer, $param, $value); } elseif ($param->getType() == 'object') { $this->addXmlObject($writer, $param, $value); } if (!$param->getData('xmlFlattened')) { $writer->endElement(); } return; } if ($param->getData('xmlAttribute')) { $this->writeAttribute($writer, $prefix, $name, $namespace, $value); } else { $this->writeElement($writer, $prefix, $name, $namespace, $value); } }
public function visit(GuzzleCommandInterface $command, RequestInterface $request, Parameter $param, array $context) { $query = $request->getQuery(); $query[$param->getWireName()] = $this->prepareValue($command[$param->getName()], $param); }
public function testHasKeyMethod() { $p = new Parameter(['name' => 'foo', 'sentAs' => 'bar']); $this->assertEquals('bar', $p->getWireName()); }
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, array $context) { $value = $command[$param->getName()]; $request->setHeader($param->getWireName(), $param->filter($value)); }
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, array $context) { $this->jsonData[$param->getWireName()] = $this->prepareValue($command[$param->getName()], $param); }