PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / Api / Serializer / RestJsonSerializer.php
transferito / vendor / aws / aws-sdk-php / src / Api / Serializer Last commit date
Ec2ParamBuilder.php 11 months ago JsonBody.php 11 months ago JsonRpcSerializer.php 11 months ago QueryParamBuilder.php 11 months ago QuerySerializer.php 11 months ago RestJsonSerializer.php 11 months ago RestSerializer.php 11 months ago RestXmlSerializer.php 11 months ago XmlBody.php 11 months ago
RestJsonSerializer.php
43 lines
1 <?php
2 namespace Aws\Api\Serializer;
3
4 use Aws\Api\Service;
5 use Aws\Api\StructureShape;
6
7 /**
8 * Serializes requests for the REST-JSON protocol.
9 * @internal
10 */
11 class RestJsonSerializer extends RestSerializer
12 {
13 /** @var JsonBody */
14 private $jsonFormatter;
15
16 /** @var string */
17 private $contentType;
18
19 /**
20 * @param Service $api Service API description
21 * @param string $endpoint Endpoint to connect to
22 * @param JsonBody $jsonFormatter Optional JSON formatter to use
23 */
24 public function __construct(
25 Service $api,
26 $endpoint,
27 JsonBody $jsonFormatter = null
28 ) {
29 parent::__construct($api, $endpoint);
30 $this->contentType = JsonBody::getContentType($api);
31 $this->jsonFormatter = $jsonFormatter ?: new JsonBody($api);
32 }
33
34 protected function payload(StructureShape $member, array $value, array &$opts)
35 {
36 $body = isset($value) ?
37 ((string) $this->jsonFormatter->build($member, $value))
38 : "{}";
39 $opts['headers']['Content-Type'] = $this->contentType;
40 $opts['body'] = $body;
41 }
42 }
43