public function __invoke(CommandTransaction $trans)
 {
     $command = $trans->command;
     $name = $command->getName();
     $operation = $this->api->getOperation($name);
     return $trans->client->createRequest($operation['http']['method'], $this->endpoint, ['headers' => ['X-Amz-Target' => $this->api->getMetadata('targetPrefix') . '.' . $name, 'Content-Type' => $this->contentType], 'body' => $this->jsonFormatter->build($operation->getInput(), $command->toArray()), 'config' => ['command' => $command]]);
 }
Example #2
0
 /**
  * Create a pre-signed URL for Polly operation `SynthesizeSpeech`
  *
  * @param array $args parameters array for `SynthesizeSpeech`
  *                    More information @see Aws\Polly\PollyClient::SynthesizeSpeech
  *
  * @return string
  */
 public function createSynthesizeSpeechPreSignedUrl(array $args)
 {
     $uri = new Uri($this->getEndpoint());
     $uri = $uri->withPath('/v1/speech');
     // Formatting parameters follows rest-json protocol
     $this->formatter = $this->formatter ?: new JsonBody($this->getApi());
     $queryArray = json_decode($this->formatter->build($this->getApi()->getOperation('SynthesizeSpeech')->getInput(), $args), true);
     // Mocking a 'GET' request in pre-signing the Url
     $query = Psr7\build_query($queryArray);
     $uri = $uri->withQuery($query);
     $request = new Request('GET', $uri);
     $request = $request->withBody(Psr7\stream_for(''));
     $signer = new SignatureV4('polly', $this->getRegion());
     return (string) $signer->presign($request, $this->getCredentials()->wait(), '+15 minutes')->getUri();
 }
 protected function payload(RequestInterface $request, StructureShape $member, array $value)
 {
     $request->setHeader('Content-Type', $this->contentType);
     $request->setBody(Stream::factory($this->jsonFormatter->build($member, $value)));
 }
 protected function payload(StructureShape $member, array $value, array &$opts)
 {
     $opts['headers']['Content-Type'] = $this->contentType;
     $opts['body'] = (string) $this->jsonFormatter->build($member, $value);
 }
 /**
  * When invoked with an AWS command, returns a serialization array
  * containing "method", "uri", "headers", and "body" key value pairs.
  *
  * @param CommandInterface $command
  *
  * @return RequestInterface
  */
 public function __invoke(CommandInterface $command)
 {
     $name = $command->getName();
     $operation = $this->api->getOperation($name);
     return new Request($operation['http']['method'], $this->endpoint, ['X-Amz-Target' => $this->api->getMetadata('targetPrefix') . '.' . $name, 'Content-Type' => $this->contentType], $this->jsonFormatter->build($operation->getInput(), $command->toArray()));
 }