public function __invoke(CommandInterface $command, ResponseInterface $response) { $output = $this->api->getOperation($command->getName())->getOutput(); $result = []; if ($payload = $output['payload']) { $this->extractPayload($payload, $output, $response, $result); } foreach ($output->getMembers() as $name => $member) { switch ($member['location']) { case 'header': $this->extractHeader($name, $member, $response, $result); break; case 'headers': $this->extractHeaders($name, $member, $response, $result); break; case 'statusCode': $this->extractStatus($name, $response, $result); break; } } if (!$payload) { // if no payload was found, then parse the contents of the body $this->payload($response, $output, $result); } return new Result($result); }
public function __invoke(CommandInterface $command, ResponseInterface $response) { $output = $this->api->getOperation($command->getName())->getOutput(); $xml = $response->xml(); if ($this->honorResultWrapper && $output['resultWrapper']) { $xml = $xml->{$output['resultWrapper']}; } return new Result($this->xmlParser->parse($output, $xml)); }
private function hashCommand(ServiceClientInterface $client, CommandInterface $command, EventInterface $event) { return get_class($client) . '::' . $command->getName() . ' (' . spl_object_hash($event) . ')'; }
public function __invoke(CommandInterface $command, ResponseInterface $response) { $operation = $this->api->getOperation($command->getName()); return new Result($this->parser->parse($operation->getOutput(), $response->json())); }
/** * @param CommandInterface $command * * @return RequestInterface */ public function commandToRequestTransformer(CommandInterface $command) { $name = $command->getName(); if (!isset($this->api[$name])) { throw new CommandException('Command not found', $command); } $action = $this->api[$name]; $prefix = ''; if (isset($action['public']) && $command->hasParam('public')) { $prefix = '/public'; } $prefixes = ['system' => '/systems/{system}', 'issuer' => '/issuers/{issuer}', 'program' => '/programs/{program}']; if (isset($action['admin_contexts'])) { $prefix .= implode('', array_intersect_key($prefixes, array_flip($action['admin_contexts']), array_merge($command->toArray(), $this->adminContext))); } $path = GuzzleHttp\uri_template($prefix . $action['path'], array_merge($command->toArray(), $this->adminContext)); $headers = []; $body = null; if ($command->hasParam('body')) { $headers = ['Content-Type' => 'application/json']; $body = GuzzleHttp\json_encode($command['body']); } if ($command->hasParam('query')) { $path .= '?' . Psr7\build_query($command['query']); } return new Psr7\Request($action['method'], $path, $headers, $body); }