mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-20 05:13:42 -07:00
spaces.php
This commit is contained in:
parent
7755490b81
commit
eefa32741e
845 changed files with 50409 additions and 0 deletions
69
aws/Aws/Api/Serializer/JsonRpcSerializer.php
Normal file
69
aws/Aws/Api/Serializer/JsonRpcSerializer.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
namespace Aws\Api\Serializer;
|
||||
|
||||
use Aws\Api\Service;
|
||||
use Aws\CommandInterface;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Prepares a JSON-RPC request for transfer.
|
||||
* @internal
|
||||
*/
|
||||
class JsonRpcSerializer
|
||||
{
|
||||
/** @var JsonBody */
|
||||
private $jsonFormatter;
|
||||
|
||||
/** @var string */
|
||||
private $endpoint;
|
||||
|
||||
/** @var Service */
|
||||
private $api;
|
||||
|
||||
/** @var string */
|
||||
private $contentType;
|
||||
|
||||
/**
|
||||
* @param Service $api Service description
|
||||
* @param string $endpoint Endpoint to connect to
|
||||
* @param JsonBody $jsonFormatter Optional JSON formatter to use
|
||||
*/
|
||||
public function __construct(
|
||||
Service $api,
|
||||
$endpoint,
|
||||
JsonBody $jsonFormatter = null
|
||||
) {
|
||||
$this->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
|
||||
*
|
||||
* @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()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue