diff options
Diffstat (limited to 'vendor/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php')
-rw-r--r-- | vendor/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php b/vendor/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php new file mode 100644 index 0000000..8a2aa99 --- /dev/null +++ b/vendor/aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php @@ -0,0 +1,42 @@ +<?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 = JsonBody::getContentType($api); + $this->jsonFormatter = $jsonFormatter ?: new JsonBody($api); + } + + protected function payload(StructureShape $member, array $value, array &$opts) + { + $body = isset($value) ? + ((string) $this->jsonFormatter->build($member, $value)) + : "{}"; + $opts['headers']['Content-Type'] = $this->contentType; + $opts['body'] = $body; + } +} |