Exemplo n.º 1
0
 private function extractPayload($payload, StructureShape $output, ResponseInterface $response, array &$result)
 {
     $member = $output->getMember($payload);
     if ($member instanceof StructureShape) {
         // Structure members parse top-level data into a specific key.
         $result[$payload] = [];
         $this->payload($response, $member, $result[$payload]);
     } else {
         // Streaming data is just the stream from the response body.
         $result[$payload] = $response->getBody();
     }
 }
 protected function format_structure(StructureShape $shape, array $value, $prefix, &$query)
 {
     if ($prefix) {
         $prefix .= '.';
     }
     foreach ($value as $k => $v) {
         if ($shape->hasMember($k)) {
             $member = $shape->getMember($k);
             $this->format($member, $v, $prefix . $this->queryName($member, $k), $query);
         }
     }
 }
 private function applyPayload(StructureShape $input, $name, array $args, array &$opts)
 {
     if (!isset($args[$name])) {
         return;
     }
     $m = $input->getMember($name);
     if ($m['streaming'] || ($m['type'] == 'string' || $m['type'] == 'blob')) {
         // Streaming bodies or payloads that are strings are
         // always just a stream of data.
         $opts['body'] = Psr7\stream_for($args[$name]);
         return;
     }
     $this->payload($m, $args[$name], $opts);
 }
Exemplo n.º 4
0
 private function getStructureMembers(StructureShape $shape, array $value)
 {
     $members = [];
     foreach ($value as $k => $v) {
         if ($v !== null && $shape->hasMember($k)) {
             $definition = ['member' => $shape->getMember($k), 'value' => $v];
             if ($definition['member']['xmlAttribute']) {
                 // array_unshift_associative
                 $members = [$k => $definition] + $members;
             } else {
                 $members[$k] = $definition;
             }
         }
     }
     return $members;
 }
Exemplo n.º 5
0
 private function check_structure(StructureShape $shape, $value)
 {
     if (!$this->checkAssociativeArray($value)) {
         return;
     }
     if ($shape['required']) {
         foreach ($shape['required'] as $req) {
             if (!isset($value[$req])) {
                 $this->path[] = $req;
                 $this->addError('is missing and is a required parameter');
                 array_pop($this->path);
             }
         }
     }
     foreach ($value as $name => $v) {
         if ($shape->hasMember($name)) {
             $this->path[] = $name;
             $this->dispatch($shape->getMember($name), isset($value[$name]) ? $value[$name] : null);
             array_pop($this->path);
         }
     }
 }
Exemplo n.º 6
0
 private function applyPayload(RequestInterface $request, StructureShape $input, $name, array $args)
 {
     if (!isset($args[$name])) {
         return;
     }
     $m = $input->getMember($name);
     if ($m['streaming'] || ($m['type'] == 'string' || $m['type'] == 'blob')) {
         // Streaming bodies or payloads that are strings are
         // always just a stream of data.
         $request->setBody(Stream::factory($args[$name]));
     } else {
         $this->payload($request, $m, $args[$name]);
     }
 }