public function testReturnsErrorsShapeArray() { $o = new Operation(['errors' => [['shape' => 'a'], ['shape' => 'b']]], new ShapeMap(['a' => ['type' => 'structure'], 'b' => ['type' => 'list']])); $e = $o->getErrors(); $this->assertInternalType('array', $e); $this->assertInstanceOf('Vws\\Api\\Shape', $e[0]); $this->assertInstanceOf('Vws\\Api\\Shape', $e[1]); $this->assertEquals('structure', $e[0]->getType()); $this->assertEquals('list', $e[1]->getType()); }
/** * Builds the URI template for a REST based request. * * @param Operation $operation * @param array $args * * @return array */ private function buildEndpoint(Operation $operation, array $args) { $varspecs = []; if ($operation->getInput()->getType() !== 'list') { // Create an associative array of varspecs used in expansions foreach ($operation->getInput()->getMembers() as $name => $member) { if ($member['location'] == 'uri') { $varspecs[$member['locationName'] ?: $name] = isset($args[$name]) ? $args[$name] : null; } } } // Expand path place holders using Amazon's slightly different URI // template syntax. return $this->endpoint->combine(preg_replace_callback('/\\{([^\\}]+)\\}/', function (array $matches) use($varspecs) { $isGreedy = substr($matches[1], -1, 1) == '+'; $k = $isGreedy ? substr($matches[1], 0, -1) : $matches[1]; if (!isset($varspecs[$k])) { return ''; } elseif ($isGreedy) { return str_replace('%2F', '/', rawurlencode($varspecs[$k])); } else { return rawurlencode($varspecs[$k]); } }, $operation['http']['requestUri'])); }