mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-07-06 04:51:32 -07:00
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
39 lines
1 KiB
PHP
39 lines
1 KiB
PHP
<?php
|
|
namespace Aws\Api\Serializer;
|
|
|
|
use Aws\Api\Service;
|
|
use Aws\Api\StructureShape;
|
|
|
|
/**
|
|
* Serializes requests for the REST-JSON protocol.
|
|
* @internal
|
|
*/
|
|
class RestJsonSerializer extends RestSerializer
|
|
{
|
|
/** @var JsonBody */
|
|
private $jsonFormatter;
|
|
|
|
/** @var string */
|
|
private $contentType;
|
|
|
|
/**
|
|
* @param Service $api Service API 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
|
|
) {
|
|
parent::__construct($api, $endpoint);
|
|
$this->contentType = 'application/json';
|
|
$this->jsonFormatter = $jsonFormatter ?: new JsonBody($api);
|
|
}
|
|
|
|
protected function payload(StructureShape $member, array $value, array &$opts)
|
|
{
|
|
$opts['headers']['Content-Type'] = $this->contentType;
|
|
$opts['body'] = (string) $this->jsonFormatter->build($member, $value);
|
|
}
|
|
}
|