endpoint = $endpoint; $this->api = $api; $this->jsonFormatter = $jsonFormatter ?: new JsonBody($this->api); $this->contentType = JsonBody::getContentType($api); } /** * When invoked with an AWS command, returns a serialization array * containing "method", "uri", "headers", and "body" key value pairs. * * @param CommandInterface $command Command to serialize into a request. * @param $endpointProvider Provider used for dynamic endpoint resolution. * @param $clientArgs Client arguments used for dynamic endpoint resolution. * * @return RequestInterface */ public function __invoke( CommandInterface $command, $endpointProvider = null, $clientArgs = null ) { $operationName = $command->getName(); $operation = $this->api->getOperation($operationName); $commandArgs = $command->toArray(); $headers = [ 'X-Amz-Target' => $this->api->getMetadata('targetPrefix') . '.' . $operationName, 'Content-Type' => $this->contentType ]; if ($endpointProvider instanceof EndpointProviderV2) { $this->setRequestOptions( $endpointProvider, $command, $operation, $commandArgs, $clientArgs, $headers ); } return new Request( $operation['http']['method'], $this->endpoint, $headers, $this->jsonFormatter->build( $operation->getInput(), $commandArgs ) ); } }